當前位置: 首頁>>代碼示例>>C#>>正文


C# PictureBox.Invoke方法代碼示例

本文整理匯總了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;
     }));
 }
開發者ID:ThuTrangK57,項目名稱:sigateWsan,代碼行數:7,代碼來源:ShowData.cs

示例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;
 }
開發者ID:DutchSoldier,項目名稱:FHSICT,代碼行數:10,代碼來源:Form1.cs

示例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;
     }
 }
開發者ID:rajeshwarn,項目名稱:dp_ex4,代碼行數:11,代碼來源:Utils.cs

示例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);
        }
開發者ID:luisflv,項目名稱:SistemasDistribuidos,代碼行數:16,代碼來源:Form1.cs

示例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;
     }
 }
開發者ID:keithloughnane,項目名稱:Omnipresent,代碼行數:9,代碼來源:Client.cs

示例6: setPictureBox

 private void setPictureBox(PictureBox control, bool visible)
 {
     if (control.InvokeRequired)
     {
         control.Invoke(new MethodInvoker(delegate
         {
             control.Visible = visible;
         }));
     }
     else
     {
         control.Visible = visible;
     }
 }
開發者ID:oofdui,項目名稱:ContactCheckup-MassConvert,代碼行數:14,代碼來源:frmConvertPayorByRegisterDate.cs

示例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);
 }
開發者ID:nhatkycon,項目名稱:bxvinh,代碼行數:10,代碼來源:Form1.cs

示例8: setImage

 private void setImage(PictureBox pcx, Bitmap map)
 {
     if (pcx.InvokeRequired)
     {
         pcx.Invoke(new setImageHandler(setImage), pcx, map);
     }
     else
     {
         pcx.Image = map;
     }
 }
開發者ID:fanjunwei,項目名稱:My12306ForDotNet,代碼行數:11,代碼來源:Form1.cs

示例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;
 }
開發者ID:CustomerFX,項目名稱:SalesLogixGitExtensions,代碼行數:7,代碼來源:ControlHelper.cs

示例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);
         }
     }));
 }
開發者ID:WSAN-Lab411,項目名稱:Embedded_Computer_Gateway,代碼行數:39,代碼來源:libDraw.cs

示例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();
         }
     }
 }
開發者ID:daiiniel,項目名稱:ThermoCamApp,代碼行數:19,代碼來源:CamControl.cs

示例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);
//.........這裏部分代碼省略.........
開發者ID:piyushkp,項目名稱:MosaicPhotoViewer,代碼行數:101,代碼來源:ImageProcessing.cs

示例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;
     }
 }
開發者ID:7ASecond-Net,項目名稱:Imogen,代碼行數:13,代碼來源:FrmProfileImage.cs

示例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;
     }
 }
開發者ID:tyrelsouza-archive,項目名稱:TorchTester2,代碼行數:14,代碼來源:startForm.cs

示例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 { }
 }
開發者ID:Behzadkhosravifar,項目名稱:FoxRabbit,代碼行數:52,代碼來源:MainForm.cs


注:本文中的System.Windows.Forms.PictureBox.Invoke方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。