Subversion Repositories Code-Repo

Rev

Rev 46 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
46 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 DriveLogger_LabelPrompt_Form : Form
13
    {
14
        // Default values to return on query
15
        public string driveOwner = "Unknown";
16
        public string driveDock = "Unspecified";
17
        // RadioButton list for holding list of docks as specified in settings.xml
18
        private List<RadioButton> rdoBtnList= new List<RadioButton>();
19
 
20
        public DriveLogger_LabelPrompt_Form()
21
        {
22
            InitializeComponent();
23
            this.KeyPreview = true;
24
            this.btn_Ok.Enabled = false;
25
            // Location markers for the next radiobutton plcaement
26
            int nextXLocation = 6, nextYLocation = 19;
27
            // Sets groupbox and window size depending on number of radiobuttons
28
            this.groupBox_Dock.Size = new Size(118, 19 + (Settings_Form.driveLoggerDockLabels.Count) * 23);
29
            this.Size = new Size(148, 126 + (Settings_Form.driveLoggerDockLabels.Count) * 23);
30
            // Adds a radiobutton for each dock
31
            foreach (string str in Settings_Form.driveLoggerDockLabels)
32
            {
33
                RadioButton newRdoBtn = new RadioButton();
34
                newRdoBtn.Name = "rdo_" + str;
35
                newRdoBtn.TabStop = true;
36
                newRdoBtn.AutoSize = true;
37
                newRdoBtn.Text = str;
38
                newRdoBtn.Location = new Point(nextXLocation, nextYLocation);
39
                nextYLocation += 23;
40
                // Adds the radiobutton to the groupbox and rdoBtnList
41
                groupBox_Dock.Controls.Add(newRdoBtn);
42
                rdoBtnList.Add(newRdoBtn);
43
            }
44
            this.txt_Owner.TextChanged += new EventHandler(txt_Owner_TextChanged);
45
        }
46
        void txt_Owner_TextChanged(object sender, EventArgs e)
47
        {
48
            // Enables the Ok button if text is entered
49
            if (txt_Owner.TextLength > 0)
50
                this.btn_Ok.Enabled = true;
51
            else
52
                this.btn_Ok.Enabled = false;
53
        }
54
        private void btn_Ok_Click(object sender, EventArgs e)
55
        {
56
            // Updates variables and closes form
57
            driveOwner = txt_Owner.Text;
58
            foreach (RadioButton btn in rdoBtnList)
59
            {
60
                if (btn.Checked)
61
                    driveDock = btn.Text;
62
            }
63
            this.Close();
64
        }
65
    }
66
}