Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
9 Kevin 1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Linq;
7
using System.Text;
8
using System.Windows.Forms;
9
 
10
namespace SWAT_Office_App
11
{
12
    public partial class Reimage_USB_Drive_Progress_Form : Form
13
    {
14
 
15
        private static Reimage_USB_Drive_Progress_Form _Reimage_USB_Drive_Progress_Form = null;
16
        // Singleton instance
17
        public static Reimage_USB_Drive_Progress_Form Reimage_USB_Drive_Progress_Form_Instance
18
        {
19
            set
20
            {
21
                _Reimage_USB_Drive_Progress_Form = value;
22
            }
23
            get
24
            {
25
                if (_Reimage_USB_Drive_Progress_Form == null)
26
                    _Reimage_USB_Drive_Progress_Form = new Reimage_USB_Drive_Progress_Form();
27
                return _Reimage_USB_Drive_Progress_Form;
28
            }
29
        }
30
        public Reimage_USB_Drive_Progress_Form()
31
        {
32
            InitializeComponent();
33
            btn_Cancel.Text = "Cancel";
34
            this.updateStatus("Beginning the Reimaging of USB Drives");
35
        }
36
        private void btn_Cancel_Click(object sender, EventArgs e)
37
        {
38
            Reimage_USB_Drives.bwThread.CancelAsync();
39
            foreach (BackgroundWorker bw in Reimage_USB_Drives.backgroundWorkerList)
40
                bw.CancelAsync();
41
            btn_Cancel.Text = "Cancellation Pending";
42
        }
43
        delegate void updateStatus_(string parameter);
44
        public void updateStatus(string status)
45
        {
46
            try
47
            {
48
                if (!InvokeRequired)
49
                {
50
                    lbl_Status.Text = status;
51
                }
52
                else
53
                    Invoke(new updateStatus_(updateStatus), new object[] { status });
54
            }
55
            catch (Exception e)
56
            {
57
                MessageBox.Show(e.ToString());
58
            }
59
        }
60
        delegate void closeForm_();
61
        public void closeForm()
62
        {
63
            try
64
            {
65
                if (!InvokeRequired)
66
                {
67
                    this.Close();
68
                }
69
                else
70
                    Invoke(new closeForm_(closeForm), new object[] { });
71
            }
72
            catch (Exception e)
73
            {
74
                MessageBox.Show(e.ToString());
75
            }
76
        }
77
    }
78
}