BioGTK  6.7.0
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images. Including whole slide, pyramidal, and series.
Loading...
Searching...
No Matches
Progress.cs
1using AForge;
2using Gdk;
3using Gtk;
4using sun.tools.tree;
5using System;
6using System.Collections.Generic;
7using System.IO;
8using System.Linq;
9using System.Text;
10using System.Threading.Tasks;
11
12namespace BioGTK
13{
14
15 public class Progress : Gtk.Dialog
16 {
17 #region Properties
18 private Builder _builder;
19
20 /* A property that is used to update the progress bar. */
21 public double ProgressValue
22 {
23 get
24 {
25 return progressBar.Fraction;
26 }
27 set
28 {
29 // update progress bar on main UI thread
30 Application.Invoke(delegate
31 {
32 if(value <= 1)
33 progressBar.Fraction = value;
34 else
35 progressBar.Fraction = value / 100;
36 });
37 }
38 }
39 public double ProgressPercentValue
40 {
41 get
42 {
43 return progressBar.Fraction * 100;
44 }
45 set
46 {
47 Application.Invoke(delegate
48 {
49 double percent = Math.Max(0, Math.Min(100, value));
50 progressBar.Fraction = percent / 100;
51 });
52 }
53 }
54 /* A property that is used to update the progress bar. */
55 public string Text
56 {
57 get { return progLabel.Text; }
58 set
59 {
60 // update progress bar on main UI thread
61 Application.Invoke(delegate
62 {
63 progLabel.Text = value;
64 });
65 }
66 }
67 /* A property that is used to update the progress bar. */
68 public string Status
69 {
70 get { return statusLabel.Text; }
71 set
72 {
73 // update progress bar on main UI thread
74 Application.Invoke(delegate
75 {
76 statusLabel.Text = value;
77 });
78 }
79 }
80#pragma warning disable 649
81
82 [Builder.Object]
83 private ProgressBar progressBar;
84 [Builder.Object]
85 private Label progLabel;
86 [Builder.Object]
87 private Label statusLabel;
88#pragma warning restore 649
89
90 #endregion
91
92 #region Constructors / Destructors
93
94
95 public static Progress Create(string title, string status, string state)
96 {
97 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/Progress.glade", FileMode.Open));
98 return new Progress(builder, builder.GetObject("progress").Handle, title, status, state);
99 }
100
101
102 /* The constructor for the class. */
103 protected Progress(Builder builder, IntPtr handle, string title, string status, string state) : base(handle)
104 {
105 _builder = builder;
106 builder.Autoconnect(this);
107 this.Title = title;
108 this.statusLabel.Text = status;
109 this.progLabel.Text = state;
110 App.ApplyStyles(this);
111 }
112
113 #endregion
114
115 }
116}
Definition ML.cs:17