BioImager  5.0.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
Progress.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Diagnostics;
6using System.Drawing;
7using System.Linq;
8using System.Text;
9using System.Threading.Tasks;
10using System.Windows.Forms;
11
12namespace BioImager
13{
14 public partial class Progress : Form
15 {
16 Stopwatch watch = new Stopwatch();
17 public Progress(string file, string status)
18 {
19 InitializeComponent();
20 watch.Start();
21 statusLabel.Text = status;
22 fileLabel.Text = file;
23 timer.Start();
24 }
25 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
26 public string Status
27 {
28 get { return statusLabel.Text; }
29 set
30 {
31 // Use Invoke to update the label on the UI thread
32 if (statusLabel.InvokeRequired)
33 {
34 statusLabel.Invoke(() => statusLabel.Text = value);
35 }
36 else
37 {
38 statusLabel.Text = value;
39 }
40 }
41 }
42 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
43 public float ProgressValue
44 {
45 get { return progressBar.Value; }
46 set
47 {
48 if (progressBar.InvokeRequired)
49 {
50 if (progressBar.Maximum < value)
51 {
52 progressBar.Invoke(() => progressBar.Value = (int)(value / 100));
53 }
54 else
55 progressBar.Invoke(() => progressBar.Value = (int)value);
56 return;
57 }
58 if (progressBar.Maximum < value)
59 progressBar.Value = (int)(value * 100);
60 else
61 progressBar.Value = (int)(value);
62 }
63 }
64
65 public void UpdateProgress(int p)
66 {
67 progressBar.Value = p;
68 }
69 public void UpdateProgressF(float p)
70 {
71 if (p * 100 > progressBar.Maximum)
72 return;
73 progressBar.Value = (int)(p * 100);
74 }
75
76 private void timer_Tick(object sender, EventArgs e)
77 {
78 timeLabel.Text = watch.Elapsed.Seconds + "." + watch.Elapsed.Milliseconds + "s";
79 }
80 }
81}
void UpdateProgressF(float p)
Definition Progress.cs:69
void UpdateProgress(int p)
Definition Progress.cs:65
Progress(string file, string status)
Definition Progress.cs:17