本文整理匯總了C#中System.Windows.Forms.PictureBox.Invoke方法的典型用法代碼示例。如果您正苦於以下問題:C# PictureBox.Invoke方法的具體用法?C# PictureBox.Invoke怎麽用?C# PictureBox.Invoke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.PictureBox
的用法示例。
在下文中一共展示了PictureBox.Invoke方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DisplayPicture
public void DisplayPicture(Bitmap img, PictureBox picBox)
{
picBox.Invoke(new EventHandler(delegate
{
picBox.Image = img;
}));
}
示例2: setPicture
public void setPicture(PictureBox box, Image pic)
{
if (box.InvokeRequired)
{
try { box.Invoke(new PictureBoxDelegate(setPicture), new Object[] { box, pic }); }
catch { }
}
else
box.Image = pic;
}
示例3: UpdateImage
public static void UpdateImage(PictureBox i_PictoreBox, Image i_Image)
{
if (i_PictoreBox.InvokeRequired)
{
i_PictoreBox.Invoke(new Action<PictureBox, Image>(UpdateImage), i_PictoreBox, i_Image);
}
else
{
i_PictoreBox.Image = i_Image;
}
}
示例4: MoveDog
private void MoveDog(PictureBox pcb)
{
while (!((pcb.Location.X) >= (pcbPistaCorrida.Width - pcb.Width)))
{
int distance = MyRandom.Next(4);
Point p = pcb.Location;
p.X += distance;
pcb.Invoke(() => pcb.Location = p);
pcbPistaCorrida.Invoke(() => pcbPistaCorrida.Refresh());
Thread.Sleep(30);
}
TheWinnerDog(pcb);
}
示例5: updatePictureBox
private void updatePictureBox(PictureBox pic, Image value)
{
if (pic.InvokeRequired)
{ pic.Invoke(new picDelegate(updatePictureBox), new object[] { pic, value }); }
else
{
pic.BackgroundImage = value;
}
}
示例6: setPictureBox
private void setPictureBox(PictureBox control, bool visible)
{
if (control.InvokeRequired)
{
control.Invoke(new MethodInvoker(delegate
{
control.Visible = visible;
}));
}
else
{
control.Visible = visible;
}
}
示例7: SetImage
// set Image
private void SetImage(PictureBox pic, string text)
{
if (pic.InvokeRequired)
{
pic.Invoke(new MethodInvoker(delegate { SetImage(pic, text); }));
return;
}
pic.Image = Image.FromFile(text);
}
示例8: setImage
private void setImage(PictureBox pcx, Bitmap map)
{
if (pcx.InvokeRequired)
{
pcx.Invoke(new setImageHandler(setImage), pcx, map);
}
else
{
pcx.Image = map;
}
}
示例9: SetPictureBoxImage
public static void SetPictureBoxImage(PictureBox control, Image image)
{
if (control.InvokeRequired)
control.Invoke(new SetPictureBoxImageDelegate(SetPictureBoxImage), new object[] { control, image });
else
control.Image = image;
}
示例10: reload
//Load ban do
public void reload(PictureBox pic)
{
pic.Invoke(new EventHandler(delegate
{
try
{
Database myDatabase = new Database();
Bitmap image = new Bitmap(path);
gr.DrawImage(image, 0, 0);
XmlNodeList node = (myDatabase.xml).GetElementsByTagName("node");
foreach (XmlNode nodechild in node)
{
string mac = nodechild.Attributes["mac"].Value;
if (mac == "00" || mac[0] == 'B')
{
DrawActor(mac);
}
else
{
DrawSensor(mac);
}
}
XmlNodeList val = (myDatabase.xml).GetElementsByTagName("val");
foreach (XmlNode valchild in val)
{
int id = Int32.Parse(valchild.Attributes["id"].Value);
DrawVan(id);
}
// pictureBox.Image = bit;
//pictureBox.Refresh();
pic.Image = bit;
}
catch
{
//DisplayData("Khong the load anh", tb);
}
}));
}
示例11: updatePictureBox
private void updatePictureBox(PictureBox p, ref System.Drawing.Bitmap bmp)
{
if (p.IsDisposed == false)
{
if (p.InvokeRequired)
{
try
{
p.Invoke(new updatePictureBoxCallback(updatePictureBox), p, bmp);
}
catch (Exception ex) { }
}
else
{
p.Image = bmp;
p.Refresh();
}
}
}
示例12: Render
public void Render(Bitmap img, Dictionary<int, List<int>> xDic, int xLength, int yLength, PictureBox pictureBox1, PictureBox pictureBox2, string shapeName)
{
try
{
var g = default(Graphics);
var g2 = default(Graphics);
//var imageSq = new List<MosaicTile>();
var newImg = new Bitmap(xLength * tileSize.Width, yLength * tileSize.Height);
var pb2Img = new Bitmap(xLength * tileSize.Width, yLength * tileSize.Height);
//var saveImg = new Bitmap(colorMap.GetLength(0) * tileSize.Width, colorMap.GetLength(1) * tileSize.Height);
//var file = Graphics.FromImage(saveImg);
var rand = new Random();
pictureBox1.Invoke(new MethodInvoker(() =>
{
pictureBox1.Image = newImg;
pictureBox2.Image = pb2Img;
g = Graphics.FromImage(pictureBox1.Image);
g2 = Graphics.FromImage(pictureBox2.Image);
}));
var b = new SolidBrush(Color.Black);
g.FillRectangle(b, 0, 0, img.Width, img.Height);
g2.FillRectangle(b, 0, 0, img.Width, img.Height);
//file.FillRectangle(b, 0, 0, img.Width, img.Height);
Rectangle destRect, srcRect;
foreach (var xItem in xDic)
{
foreach (var yItem in xItem.Value)
{
int x = xItem.Key;
int y = yItem;
string[] files = Directory.GetFiles(ConfigurationSettings.AppSettings["DownloadImagesFolderPath"])
.Where(file => !file.ToLower().Contains("processed"))
.ToArray();
string path = string.Empty;
if (files.Length > 0)
{
path = files[0];
}
else
{
var processedList = Directory.GetFiles(ConfigurationSettings.AppSettings["DownloadImagesFolderPath"])
.Where(file => file.ToLower().Contains("processed")).ToArray();
path = processedList[rand.Next(processedList.Length)];
}
using (Image source = Image.FromFile(path))
{
//imageSq.Add(new MosaicTile()
//{
// X = x,
// Y = y,
// Image = path
//});
srcRect = new Rectangle(0, 0, source.Width, source.Height);
for (int i = 1; i < 15; )
{
pictureBox2.Invoke(new MethodInvoker(() =>
{
pictureBox2.Image = PictureBoxZoom(source, new Size(i, i));
int xloc = ((x * tileSize.Width));
int yloc = ((y * tileSize.Width));
if (xloc < 0)
xloc = 0;
if (yloc < 0)
yloc = 0;
pictureBox2.Location = new Point(xloc, yloc);
pictureBox2.Refresh();
}));
Thread.Sleep(400 / i);
i += i;
}
destRect = new Rectangle(x * tileSize.Width, y * tileSize.Height, tileSize.Width, tileSize.Height);
g.DrawImage(source, destRect, srcRect, GraphicsUnit.Pixel);
//file.DrawImage(source, destRect, srcRect, GraphicsUnit.Pixel);
pictureBox1.Invoke(new MethodInvoker(() =>
{
pictureBox1.Refresh();
}));
}
if (files.Length > 0)
{
//File.Delete(path);
//.........這裏部分代碼省略.........
示例13: UpdatePbOriginalImage
private void UpdatePbOriginalImage(PictureBox pb, Image img)
{
if (pb.InvokeRequired)
{
// This is a worker thread so delegate the task.
pb.Invoke(new UpdatePbOriginalImageDelegate(this.UpdatePbOriginalImage), pb, img);
}
else
{
// This is the UI thread so perform the task.
pbOriginal.Image = img;
}
}
示例14: updatePictureBox
private void updatePictureBox(Bitmap x, PictureBox l)
{
if (l.InvokeRequired)
{
// this is worker thread
updatePictureBoxDelegate del = new updatePictureBoxDelegate(updatePictureBox);
l.Invoke(del, new object[] { x, l });
}
else
{
// this is UI thread
l.Image = x;
}
}
示例15: show
/// <summary>
/// This method demonstrates a pattern for making thread-safe
/// calls on a Windows Forms control.
///
/// If the calling thread is different from the thread that
/// created the UserControl object's, this method creates a
/// SetLocationCallback and calls itself asynchronously using the
/// Invoke method.
///
/// If the calling thread is the same as the thread that created
/// the UserControl object's, the Location property is set directly.
/// </summary>
/// <param name="obj">The UserControl object's</param>
/// <param name="newLocation">Move object to this location</param>
public void show(PictureBox obj, Point newLocation)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different, it returns true.
try
{
#region Set Location in Safely
if (obj.InvokeRequired)
{
SetLocationCallback d = new SetLocationCallback(show);
obj.Invoke(d, new object[] { obj, newLocation });
}
else
{
// if:
// original location = newLocation = (50, 50)
// obj.Size = (70, 70)
// ----------------------------
// Virtual location in form
// (15,15)._______
// |(50,50)|
// 70| .---|---. Original location in form
// | | | |
// |___|___| |
// | |
// ._______.
// <--->
// 35
//
// create virtual location from original location:
obj.Location = new Point(newLocation.X - (obj.Size.Width / 2),
newLocation.Y - (obj.Size.Height / 2));
}
#endregion
}
catch { }
}