当前位置: 首页>>代码示例>>C#>>正文


C# ProgressBar.Invoke方法代码示例

本文整理汇总了C#中System.Windows.Forms.ProgressBar.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressBar.Invoke方法的具体用法?C# ProgressBar.Invoke怎么用?C# ProgressBar.Invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ProgressBar的用法示例。


在下文中一共展示了ProgressBar.Invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartDownload

        public void StartDownload(ProgressBar pb, String url, String name)
        {

           

            Thread t = new Thread(() =>
            {
                WebClient webClient = new WebClient();
                webClient.Headers["User-Agent"] = "Mozilla/5.0";
                webClient.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs args)
                {                   
                    double percentage = (double.Parse(args.BytesReceived.ToString()) /double.Parse(args.TotalBytesToReceive.ToString())) * 100;
                    Debug.Print(percentage.ToString());
                    pb.Invoke((MethodInvoker) delegate
                    {
                        pb.Value = (int)Math.Truncate(percentage);
                    });

                };


                webClient.DownloadFile(new Uri(url), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord\\temp\\" + name);

            });

            t.Start();
        }
开发者ID:ayydriel,项目名称:BetterDiscordApp,代码行数:27,代码来源:Utils.cs

示例2: ProgressStream

        public ProgressStream(Stream fs, ProgressBar progressBar)
        {
            this.fs=fs;
            //	this.readnotifycount=readnotifycount;
            this.progressBar=progressBar;
            this.fileLength=fs.Length;
            this.readnotifycount=fileLength/fileLengthDivider/numNotifications;

            progressBar.Invoke(new EventHandler(SetMaximumPosition));
        }
开发者ID:Earth2Me,项目名称:WinMD5,代码行数:10,代码来源:ProgressStream.cs

示例3: bmp_create

        public static Bitmap bmp_create(Bitmap BMP, int num_filtr, ProgressBar progressBar1, ProgressThread pr)
        {
            BMPFilters flr = new BMPFilters();
            byte[, ,] rs;
            rs = MatrixPixelReader.matrix(BMP);
            Bitmap BMP1 = new Bitmap(BMP.Width, BMP.Height);
            Color colorBMP1;//переменная, которая будет задавать цвет
            double red1 = 0, blue1 = 0, green1 = 0;
            byte red = 0, blue = 0, green = 0;
            flr.choose_filtr(num_filtr);

            if (flr.filtr.black)
            {
                for (int j = 0; j < BMP.Width; j++) BMP1.SetPixel(j, 0, Color.Black);
            }
            else
            {
                for (int j = 0; j < BMP.Width; j++) BMP1.SetPixel(j, 0, BMP.GetPixel(j, 0));
            }

            for (int i = 1; i < BMP.Height - 1; i++)
            {
                progressBar1.Invoke(pr.MyDelegate);
                if (flr.filtr.black) BMP1.SetPixel(0, i, Color.Black);
                for (int j = 1; j < BMP.Width - 1; j++)
                {
                    for (int p = 0; p < 3; p++)
                        for (int p1 = 0; p1 < 3; p1++)
                        {
                            red1 += flr.filtr.fl[p, p1] * rs[0, i + p - 1, j + p1 - 1];
                            green1 += flr.filtr.fl[p, p1] * rs[1, i + p - 1, j + p1 - 1];
                            blue1 += flr.filtr.fl[p, p1] * rs[2, i + p - 1, j + p1 - 1];
                        }
                    blue = (byte)(flr.filtr.bl ? (blue1 / flr.filtr.div) > 255 ? 255 : (blue1 / flr.filtr.div) < 0 ? 0 : (blue1 / flr.filtr.div) : blue1);
                    red = (byte)(flr.filtr.bl ? (red1 / flr.filtr.div) > 255 ? 255 : (red1 / flr.filtr.div) < 0 ? 0 : (red1 / flr.filtr.div) : red1);
                    green = (byte)(flr.filtr.bl ? (green1 / flr.filtr.div) > 255 ? 255 : (green1 / flr.filtr.div) < 0 ? 0 : (green1 / flr.filtr.div) : green1);
                    colorBMP1 = Color.FromArgb((int)red, (int)green, (int)blue);
                    BMP1.SetPixel(j, i, colorBMP1);
                    red1 = blue1 = green1 = 0;
                }
                if (flr.filtr.black) BMP1.SetPixel(BMP.Width - 1, i, Color.Black);
            }
            if (flr.filtr.black)
            {
                for (int j = 0; j < BMP.Width; j++) BMP1.SetPixel(j, BMP.Height - 1, Color.Black);
            }
            else
            {
                for (int j = 0; j < BMP.Width; j++) BMP1.SetPixel(j, BMP.Height - 1, Color.White);
            }
            return BMP1;
        }
开发者ID:ALEXSSS,项目名称:store_of_my_project1,代码行数:52,代码来源:BMPCreate.cs

示例4: webclient_UploadProgressChanged

 private void webclient_UploadProgressChanged(object sender, long maxsize, long Downloaded, ProgressBar progress)
 {
     if(progress.InvokeRequired)
     {
         progress.Invoke(cssv, new object[] { sender, maxsize, Downloaded, progress });
     }
     else
     {
         float per = ((float)Downloaded / maxsize) * 100;
         progress.Value = (int)per;
         progress.Controls[0].Text = string.Format("{0}%", (int)per);
     }
 }
开发者ID:leejongseok,项目名称:TeamProject,代码行数:13,代码来源:main.cs

示例5: webclient_DownloadFileCompleted

 private void webclient_DownloadFileCompleted(object sender, ProgressBar progress)
 {
     if(progress.InvokeRequired)
     {
         progress.Invoke(cscp, new object[] { sender, progress });
     }
     else
     {
         MessageBox.Show("다운 완료");
         int index = downflowPanel.Controls.IndexOf(progress);
         downflowPanel.Controls.RemoveAt(index);
         down.Stop();
     }
 }
开发者ID:leejongseok,项目名称:TeamProject,代码行数:14,代码来源:main.cs

示例6: SetForeColor

        public static void SetForeColor(ProgressBar progressBar, Color color)
        {
            MethodInvoker miSetForeColor = delegate
            {
                progressBar.ForeColor = color;
            };

            if (progressBar.InvokeRequired)
            {
                progressBar.Invoke(miSetForeColor);
            }
            else
            {
                miSetForeColor();
            }
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:16,代码来源:ProgressBarDelegates.cs

示例7: SetStep

        public static void SetStep(ProgressBar progressBar, int step)
        {
            MethodInvoker miSetStep = delegate
            {
                progressBar.Step = step;
            };

            if (progressBar.InvokeRequired)
            {
                progressBar.Invoke(miSetStep);
            }
            else
            {
                miSetStep();
            }
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:16,代码来源:ProgressBarDelegates.cs

示例8: PerformStep

        public static void PerformStep(ProgressBar progressBar)
        {
            MethodInvoker miPerformStep = delegate
            {
                progressBar.PerformStep();
            };

            if (progressBar.InvokeRequired)
            {
                progressBar.Invoke(miPerformStep);
            }
            else
            {
                miPerformStep();
            }
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:16,代码来源:ProgressBarDelegates.cs

示例9: SetMinimum

        public static void SetMinimum(ProgressBar progressBar, int minimum)
        {
            MethodInvoker miSetMinimum = delegate
            {
                progressBar.Maximum = minimum;
            };

            if (progressBar.InvokeRequired)
            {
                progressBar.Invoke(miSetMinimum);
            }
            else
            {
                miSetMinimum();
            }
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:16,代码来源:ProgressBarDelegates.cs

示例10: UpdateProgressBar

        public static void UpdateProgressBar(ProgressBar prg, int value)
        {
            try
            {
                if (prg.InvokeRequired)
                {
                    UpdateProgressBarCallback d = UpdateProgressBar;
                    prg.Invoke(d, prg, value);
                    return;
                }

                prg.Value = value;
            }
            catch
            {
                // This catch is simply here to avoid the OCCASIONAL crash of the application when closing it by pressing the stop button in visual studio while it is running tasks
            }
        }
开发者ID:Xcesius,项目名称:PixelMagic-OpenSource,代码行数:18,代码来源:Threads.cs

示例11: SetFullProgressLevel

 private void SetFullProgressLevel(ProgressBar progressBar, Label progressLabel, int current, int max, int min)
 {
     if (!progressBar.InvokeRequired)
     {
     progressBar.Maximum = max;
     progressBar.Minimum = min;
     if (current > max)
         current = max;
     progressBar.Value = current;
         progressLabel.Text = !((current == min) || (current == 0))
                                  ? string.Format("{0:%}", (current)/(max - min))
                                  : "0%";
     }
     else
     {
         if ((progressBar.IsDisposed || progressLabel.IsDisposed))
             return;
         var d = new SetFullProgressLevelCallback(SetFullProgressLevel);
         progressBar.Invoke(d, new object[] { progressBar, progressLabel, current, max, min });
     }
 }
开发者ID:Corprus,项目名称:unilogviewer,代码行数:21,代码来源:UICommon.cs

示例12: DecodeImages

 public static void DecodeImages(String path, ProgressBar progressBar)
 {
     DirectoryInfo dir = new DirectoryInfo(path);
     IEnumerable<FileInfo> files;
     IEnumerable<DirectoryInfo> dirs;
     files = dir.EnumerateFiles().Where(f => extensions.Contains(f.Extension));
     dirs = dir.EnumerateDirectories();
     foreach (FileInfo f in files)
     {
         //JpegBitmapEncoder encoder = new JpegBitmapEncoder();
         //FileStream stream = new FileStream(@"" + f.FullName, FileMode.Open, FileAccess.Write);
         //encoder.Save(stream); //throw NotSupportedException
         progressBar.Invoke(new Action<double>(i =>
         {
             progressBar.Value += Convert.ToInt32(step);
         }), step);
     }
     foreach (DirectoryInfo d in dirs)
     {
         DecodeImages(d.FullName, progressBar);
     }
 }
开发者ID:ByAgenT,项目名称:JPEGCompressor,代码行数:22,代码来源:FileHelper.cs

示例13: UpdateProgressBar

        public static void UpdateProgressBar(ProgressBar progressBar, int max, int value)
        {
            if (progressBar.InvokeRequired)
            {
                updateProgressBarDelegate del = new updateProgressBarDelegate(UpdateProgressBar);
                progressBar.Invoke(del, new object[] { progressBar, max, value });
            }
            else
            {
                if ((max == 0) && (value == 0))
                {
                    progressBar.Visible = false;

                }
                else
                {
                    if (max != 0)
                        progressBar.Maximum = max;

                    progressBar.Value = value;
                }
            }
        }
开发者ID:riguelbf,项目名称:portalSureg,代码行数:23,代码来源:CrossThread.cs

示例14: up_StreamCompleteCallback

 void up_StreamCompleteCallback(object sender, ProgressBar progress)
 {
     if(progress.InvokeRequired)
     {
         progress.Invoke(uscp, new object[] { sender, progress });
     }
     else
     {
         MessageBox.Show("업로드 완료");
         int index = uploadflowpanel.Controls.IndexOf(progress);
         uploadflowpanel.Controls.RemoveAt(index);
         up.Stop();
     }
 }
开发者ID:leejongseok,项目名称:TeamProject,代码行数:14,代码来源:main.cs

示例15: down_StreamCompleteCallback

        void down_StreamCompleteCallback(object sender, ProgressBar progress)
        {
            if (progress.InvokeRequired)
                progress.Invoke(SDC, new object[] { sender, progress });
            else
            {
                MessageBox.Show("다운 완료");
                int index = downflowPanel.Controls.IndexOf(progress);
                downflowPanel.Controls.RemoveAt(index);
                down.Stop();
            }

        }
开发者ID:leejongseok,项目名称:TeamProject,代码行数:13,代码来源:main.cs


注:本文中的System.Windows.Forms.ProgressBar.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。