本文整理匯總了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();
}
示例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));
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例6: SetForeColor
public static void SetForeColor(ProgressBar progressBar, Color color)
{
MethodInvoker miSetForeColor = delegate
{
progressBar.ForeColor = color;
};
if (progressBar.InvokeRequired)
{
progressBar.Invoke(miSetForeColor);
}
else
{
miSetForeColor();
}
}
示例7: SetStep
public static void SetStep(ProgressBar progressBar, int step)
{
MethodInvoker miSetStep = delegate
{
progressBar.Step = step;
};
if (progressBar.InvokeRequired)
{
progressBar.Invoke(miSetStep);
}
else
{
miSetStep();
}
}
示例8: PerformStep
public static void PerformStep(ProgressBar progressBar)
{
MethodInvoker miPerformStep = delegate
{
progressBar.PerformStep();
};
if (progressBar.InvokeRequired)
{
progressBar.Invoke(miPerformStep);
}
else
{
miPerformStep();
}
}
示例9: SetMinimum
public static void SetMinimum(ProgressBar progressBar, int minimum)
{
MethodInvoker miSetMinimum = delegate
{
progressBar.Maximum = minimum;
};
if (progressBar.InvokeRequired)
{
progressBar.Invoke(miSetMinimum);
}
else
{
miSetMinimum();
}
}
示例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
}
}
示例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 });
}
}
示例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);
}
}
示例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;
}
}
}
示例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();
}
}
示例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();
}
}