本文整理汇总了C#中System.Windows.Forms.PictureBox.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# PictureBox.Dispose方法的具体用法?C# PictureBox.Dispose怎么用?C# PictureBox.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.PictureBox
的用法示例。
在下文中一共展示了PictureBox.Dispose方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Set
public static void Set(string fpath)
{
string sfiletype = fpath.Substring(fpath.LastIndexOf(".")+1,(fpath.Length-fpath.LastIndexOf(".")-1)).ToLower();
if (sfiletype == "bmp")
{
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, fpath, 1); //调用,filename为图片地址,最后一个参数需要为1,0的话在重启后就变回原来的了
}
else
{
string bmp_path = Application.StartupPath + @"\wallpaper.bmp";
FileInfo file_info = new FileInfo(bmp_path);
if (file_info.Exists)
{
file_info.Delete();
PictureBox picutrebox = new PictureBox();
picutrebox.Image = Image.FromFile(fpath);
picutrebox.Image.Save(bmp_path, ImageFormat.Bmp);
picutrebox.Image.Dispose();
picutrebox.Dispose();
}
else
{
PictureBox picutrebox = new PictureBox();
picutrebox.Image = Image.FromFile(fpath);
picutrebox.Image.Save(bmp_path, ImageFormat.Bmp);
picutrebox.Image.Dispose();
picutrebox.Dispose();
}
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, bmp_path, 1);
}
}
示例2: BoxDelete
public void BoxDelete()
{
if (pbl.Count > 0)
{
pbox = (PictureBox)pbl[pbl.Count - 1];
pbox.Select();
pbl.Remove(pbox);
pbname.Remove(pbox.Name);
pbox.Dispose();
}
}
示例3: fanpage_init
private async void fanpage_init()
{
if (SE.pages.Count > 0) return;
PictureBox loading = new PictureBox();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoadingForm));
loading.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
loading.Size = new System.Drawing.Size(172, 107);
loading.Location = new Point(89, 0);
panelFanpageComment.Controls.Add(loading);
await SE.getPages();
panelFanpageComment.Controls.Remove(loading);
loading.Dispose();
// logical :]]
if (SE.pages.Count > 0)
{
int top_pos = 0;
cbFanpage.Items.Clear();
panelFanpageComment.Controls.Clear();
foreach (string page_title in SE.pages.Keys)
{
CheckBox cb = new CheckBox();
panelFanpageComment.Controls.Add(cb);
cb.Location = new Point(10, top_pos);
cb.Size = new System.Drawing.Size(300, 20);
cb.Checked = true;
cb.Text = page_title;
top_pos += 20;
cbFanpage.Items.Add(page_title);
}
cbFanpage.SelectedIndex = 0;
cbFanpage.Enabled = true;
}
else
{
CheckBox cb = new CheckBox();
panelFanpageComment.Controls.Add(cb);
cb.Location = new Point(10, 0);
cb.Size = new System.Drawing.Size(300, 20);
cb.Text = "Bạn chưa thích Fanpage nào cả!";
cb.Enabled = false;
cbFanpage.Items.Add("Bạn chưa thích Fanpage nào cả!");
cbFanpage.SelectedIndex = 0;
cbFanpage.Enabled = false;
}
}
示例4: Flor
public void Flor(int x, int pos)
{
PictureBox flower = new PictureBox();
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(
delegate()
{
flower.BackgroundImage = global::SimulacionAbejasHilos.Properties.Resources.Flower;
flower.BackColor = System.Drawing.Color.Transparent;
flower.Location = new System.Drawing.Point(x, 309);
flower.Size = new System.Drawing.Size(72, 100);
flower.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.Controls.Add(flower);
}
));
}
else
{
flower.BackgroundImage = global::SimulacionAbejasHilos.Properties.Resources.Flower;
flower.BackColor = System.Drawing.Color.Transparent;
flower.Location = new System.Drawing.Point(x, 309);
flower.Size = new System.Drawing.Size(72, 100);
flower.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.Controls.Add(flower);
}
Thread.Sleep(5000);
vec[pos] = 0;
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(
delegate()
{
flower.BackgroundImage = global::SimulacionAbejasHilos.Properties.Resources.Marchita;
flower.Location = new System.Drawing.Point(x, 316);
}
));
}
else
{
flower.BackgroundImage = global::SimulacionAbejasHilos.Properties.Resources.Marchita;
flower.Location = new System.Drawing.Point(x, 316);
}
Thread.Sleep(1000);
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(
delegate()
{
flower.Dispose();
}
));
}
else
{
flower.Dispose();
}
}
示例5: addSprite
/// <summary>
/// Adds a sprite to the component.
/// </summary>
/// <param name="index">The of the sprite.</param>
/// <param name="spriteImage">The image to use for the sprite.</param>
/// <param name="x">The X position of the sprite.</param>
/// <param name="y">The Y position of the sprite.</param>
public void addSprite(int index, Image spriteImage, int x, int y)
{
// A temporary picture box is created, and then
// it's various properties (such as the image, the size, etc.)
// are set, and then it is added to the list of picture boxes.
// Future implementation will include a way to set the various sprites
// to specific indexes, to make retrieving them easier.
// A temporary PictureBox to add.
PictureBox pic = new PictureBox();
// Set the image.
pic.Image = spriteImage;
// Set the width of the image.
pic.Width = spriteImage.Width;
// Set the height of the image.
pic.Height = spriteImage.Height;
// Set the location.
pic.Location = new Point(x, y);
// Add the PictureBox to the list of sprites.
if (sprites.ContainsKey(index))
{
sprites[index] = pic;
}
else
{
sprites.Add(index, pic);
}
// Dipose of the PictureBox.
pic.Dispose();
}
示例6:
private void cancelbutton_click
(object sender, EventArgs e, WebClient client,PictureBox cancelbutton,
ProgressBar progressbar,string filename,TextBox episode = null)
{
const string message = "确定取消下载么?";
const string caption = "取消下载";
if (cancelbutton.Name.StartsWith("batch"))
{
client.CancelAsync();
client.Dispose(); //without it, deleting file would fail.
batchpanel.Controls.Remove(episode);
batchpanel.Controls.Remove(cancelbutton);
batchpanel.Controls.Remove(progressbar);
cancelbutton.Dispose();
progressbar.Dispose();
episode.Dispose();
File.Delete(filename);
}
else
{
var result = System.Windows.Forms.MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
client.CancelAsync();
client.Dispose();
infopanel.Controls.Remove(cancelbutton);
infopanel.Controls.Remove(progressbar);
cancelbutton.Dispose();
progressbar.Dispose();
File.Delete(filename);
}
}
}
示例7: createImg
private static bool createImg(String strType, String strImg)
{
if (strImg == null || strImg.Equals("null") || strImg.Length == 0) //如果null或空,直接返回
return true;
WebRequest request = HttpWebRequest.Create(GlobalVariables.StrServerUrl + "/servlet/FileDownload?strFileType=" + strType + "&strFileName=" + strImg);
Stream stream = request.GetResponse().GetResponseStream();
byte[] bytes = new byte[2048];
int i;
if (strType.Equals("template"))
{
strType = "download";
}
if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + strType + "\\" + strImg))
File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + strType + "\\" + strImg);
FileStream fs = new FileStream(System.Windows.Forms.Application.StartupPath + "\\" + strType + "\\" + strImg, FileMode.CreateNew);
while ((i = stream.Read(bytes, 0, 2048)) > 0)
{
fs.Write(bytes, 0, i);
}
stream.Close();
fs.Close();
if (!strImg.ToLower().EndsWith("wmv"))
{
//测试图像文件是否受损
PictureBox pb = new PictureBox();
FileStream pFileStream = new FileStream(System.Windows.Forms.Application.StartupPath + "\\" + strType + "\\" + strImg, FileMode.Open, FileAccess.Read);
try
{
pb.Image = new Bitmap(Image.FromStream(pFileStream), 760, 407);
pFileStream.Close();
return true;
}
catch (Exception e)
{
StreamWriter sw = File.AppendText(System.Windows.Forms.Application.StartupPath + "\\error.log");
sw.WriteLine("[File]" + strType + " " + strImg);
sw.Close();
ErrorLog.log(e);
pFileStream.Close();
File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + strType + "\\" + strImg);
return false;
}
finally
{
pb.Dispose();
pb = null;
}
}
return true;
}
示例8: button3_Click
private void button3_Click(object sender, EventArgs e)
{
for (int i = 0; i < pbl.Count; i++)
{
pbox = (PictureBox)this.pbl[i];
pbox.Dispose();
}
pbl.Clear();
pbname.Clear();
}
示例9: OnReceive
//.........这里部分代码省略.........
sfxPlayer.Initialize(wr);
if (!mute)
sfxPlayer.Play();
for (int x = 0; x <= 64; x++)
{
testimonyPB.Location = new Point(256 - (4 * x), 3);
//icon.Location = new Point(256 + 6 - (2 * x), 3 + 5);
//name.Location = new Point(256 + 91 - (2 * x), 3 + 8);
//note.Location = new Point(256 + 92 - (2 * x), 3 + 26);
//desc.Location = new Point(256 + 9 - (2 * x), 3 + 81);
icon.Refresh();
name.Refresh();
note.Refresh();
desc.Refresh();
}
System.Threading.Thread.Sleep(3000);
for (int x = 0; x <= 64; x++)
{
testimonyPB.Location = new Point(0 - (4 * x), 3);
//icon.Location = new Point(6 - (2 * x), 3 + 5);
//name.Location = new Point(91 - (2 * x), 3 + 8);
//note.Location = new Point(92 - (2 * x), 3 + 26);
//desc.Location = new Point(9 - (2 * x), 3 + 81);
icon.Refresh();
name.Refresh();
note.Refresh();
desc.Refresh();
}
testimonyPB.Image = null;
name.Dispose();
icon.Dispose();
desc.Dispose();
note.Dispose();
}
else
{
Data msgReceived = new Data(byteData);
//Accordingly process the message received
switch (msgReceived.cmdCommand)
{
case Command.Login:
break;
case Command.Logout:
break;
case Command.ChangeMusic:
if (msgReceived.strMessage != null && msgReceived.strMessage != "" & msgReceived.strName != null)
{
appendTxtLogSafe("<<<" + msgReceived.strName + " changed the music to " + msgReceived.strMessage + ">>>\r\n");
musicReader = new DmoMp3Decoder("base/sounds/music/" + msgReceived.strMessage);
if (musicPlayer.PlaybackState != PlaybackState.Stopped)
musicPlayer.Stop();
musicPlayer.Initialize(musicReader);
if (!mute)
musicPlayer.Play();
}
break;
case Command.ChangeHealth:
示例10: ExtractIcon
public static void ExtractIcon()
{
if (Form1.Instance.checkmainicon.Checked & File.Exists("icon.exe"))
{
if (Form1.Instance.checkIconM2.Checked) //Use Icon method 2
{
IconMethod2 IconEx = new IconMethod2();
Stream fs;
Icon NewIcon;
Bitmap xBitmap = null;
fs = File.OpenWrite("icon.ico");
if (Form1.Instance.checkmainicon.Checked)
{
xBitmap = IconEx.ExtractIcon(Form1.Instance.TextHostFile.Text);
}
else if (Form1.Instance.textIconPath.Text.EndsWith(".exe".ToLower()))
{
xBitmap = IconEx.ExtractIcon(Form1.Instance.textIconPath.Text);
}
IntPtr Hicon = xBitmap.GetHicon();
NewIcon = System.Drawing.Icon.FromHandle(Hicon);
NewIcon.Save(fs);
fs.Close();
xBitmap.Dispose();
NewIcon.Dispose();
}
else if (Form1.Instance.checkIconM1.Checked) //Use Icon method 1
{
string origfile = null;
if (Form1.Instance.checkmainicon.Checked)
{
origfile = (Form1.Instance.TextHostFile.Text);
}
else if (Form1.Instance.textIconPath.Text.EndsWith(".exe".ToLower()))
{
origfile = (Form1.Instance.textIconPath.Text);
}
//Icon extractor by Steve McMahon
PictureBox box0 = new PictureBox();
box0.Image = Icon.ExtractAssociatedIcon(origfile).ToBitmap();
Bitmap MyBMP0 = new Bitmap(box0.Image);
PictureBox box = new PictureBox();
box.Image = MyBMP0;
Bitmap MyBMP = new Bitmap(32, 32, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Icon MyIcon = Icon.FromHandle(MyBMP.GetHicon());
Stream st = new System.IO.FileStream("icon.ico", FileMode.Create);
BinaryWriter wr = new System.IO.BinaryWriter(st);
MyIcon.Save(st);
wr.Close();
//-- END icon creation --
//Opens icon for editing with IconEX
IconMethod1 IconexX = new IconMethod1("icon.ico");
//Removes original icon image that we created above
IconexX.Items.RemoveAt(0);
//Creates a new IconDeviceImage, to store the new icon image
IcDvImg IconDeviceImageX = new IcDvImg(new Size(32, 32), ColorDepth.Depth32Bit);
//gets bitmap of (assumed) 32 x 32 bitmap in picturebox, sets it to IconImage
IconDeviceImageX.IconImage = new Bitmap(box.Image);
//adds icondevicimage to the icon file
IconexX.Items.Add(IconDeviceImageX);
//saves icon
IconexX.Save("icon.ico");
box0.Dispose();
MyBMP0.Dispose();
MyIcon.Dispose();
MyBMP.Dispose();
st.Dispose();
box.Dispose();
IconexX.Dispose();
IconDeviceImageX.Dispose();
}
}
}
示例11: DeleteWaypoint
private void DeleteWaypoint(PictureBox wpPic)
{
if (map.HasWaypoint(wpPic.Location))
{
Waypoint wp = map.GetWaypoint(wpPic.Location);
if (!String.IsNullOrEmpty(wp.Name) || !String.IsNullOrEmpty(wp.Notes))
if (MessageBox.Show("This waypoint has notes. Are you sure you want to delete it?", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) != DialogResult.OK)
return;
map.RemoveWaypoint(wpPic.Location);
}
wpPic.Dispose();
AutoSave();
}
示例12: DeleteStamp
private void DeleteStamp(PictureBox stamp)
{
if (btnNoIsland.Checked || btnStamp.Checked)
{
map.RemoveStamp(stamp.Location);
stamp.Dispose();
AutoSave();
}
}
示例13: button4_Click
private void button4_Click(object sender, EventArgs e)
{
if (pictureBox1.Image != null)
pictureBox1.Image.Dispose();
PictureBox pic = new PictureBox();
pic.Width = 800;
pic.Height = 1024;
_pdfDoc.FitToWidth(pic.Handle);
pic.Height = _pdfDoc.PageHeight;
_pdfDoc.RenderPage(pic.Handle);
/*Added since 1.0.6.2*/
_pdfDoc.CurrentX = 0;
_pdfDoc.CurrentY = 0;
_pdfDoc.ClientBounds = new Rectangle(0, 0, _pdfDoc.PageWidth, _pdfDoc.PageHeight);
_backbuffer = new Bitmap(_pdfDoc.PageWidth, _pdfDoc.PageHeight);
using (Graphics g = Graphics.FromImage(_backbuffer))
{
/*New thread safe method*/
_pdfDoc.DrawPageHDC(g.GetHdc());
g.ReleaseHdc();
}
pic.Dispose();
pictureBox1.Image = _backbuffer;
}