/[AnywhereTS-MSSQL]/trunk/TSAdminTool/frmConfigMode.cs
ViewVC logotype

Annotation of /trunk/TSAdminTool/frmConfigMode.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (hide annotations) (download)
Wed Jul 11 14:19:13 2012 UTC (8 years ago) by william
File size: 7163 byte(s)
imported from https://anywherets.svn.sourceforge.net/svnroot/anywherets/trunk/
Revision: 1
Author: beartown
Date: 3:10:40 AM, Monday, June 21, 2010
Message:
First upload. Still todo in order to get a fully working product: Replace Thinstation images with vanilla Thinstation, modify ImageDesigntimeConfig.cs, ImageRuntimeConfig.cs in order to support the Thinstation image
1 william 4 using System;
2     using System.Collections.Generic;
3     using System.ComponentModel;
4     using System.Data;
5     using System.Drawing;
6     using System.Text;
7     using System.Windows.Forms;
8     using System.IO;
9    
10     namespace AnywhereTS
11     {
12     public partial class frmConfigMode : Form
13     {
14     DatabaseSupport dataSupport;
15    
16     public frmConfigMode()
17     {
18     InitializeComponent();
19     }
20    
21     private void Mode_Load(object sender, EventArgs e)
22     {
23     this.Cursor = Cursors.WaitCursor;
24     if (ATSGlobals.configured == 0)
25     { // ATS not configured yet
26     radManagedMode.Checked = true;
27     txtDatabasePath.Text = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\AnywhereTS";
28     txtDestinationDir.Text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\AnywhereTS";
29     }
30     else
31     { // ATS already configured
32     txtDatabasePath.Text = ProSupport.strDatabasePath;
33     txtDestinationDir.Text = ProSupport.strDestDir;
34     txtDatabasePath.Enabled = false;
35     btnBrowseDatabase.Enabled = false;
36     // Update radio buttons
37     if (ATSGlobals.managedMode == 1)
38     // We are running in managed mode
39     radManagedMode.Checked = true;
40    
41     else if (ATSGlobals.managedMode == 2)
42     { // We are running in unmanaged mode
43     radUnmanagedMode.Checked = true;
44     }
45     }
46    
47     this.Cursor = Cursors.Default;
48    
49     }
50    
51    
52     private void btnOK_Click(object sender, EventArgs e)
53     {
54     if (radManagedMode.Checked)
55     { // Managed mode is selected
56     // Validate database directory
57     if (txtDatabasePath.Text.Trim().Length == 0)
58     {
59     MessageBox.Show("You must specifiy a directory for the AnywhereTS database.");
60     txtDatabasePath.Focus();
61     return;
62     }
63     this.Cursor = Cursors.WaitCursor;
64    
65     // Create Datbase directory
66     try
67     {
68     Directory.CreateDirectory(txtDatabasePath.Text.Trim());
69     }
70     catch (Exception ex)
71     {
72     this.Cursor = Cursors.Default;
73     MessageBox.Show("Could not create directory '" + txtDatabasePath.Text.Trim() + "'. Error: " + ex.Message);
74     return;
75     }
76    
77     // Save the database directory to registry
78     ProSupport.strDatabasePath = txtDatabasePath.Text.Trim();
79     ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseDir, ProSupport.strDatabasePath);
80    
81     // Set up database
82     dataSupport = new DatabaseSupport();
83     dataSupport.SetupDatabase(); // Creates updates the database if necessary
84    
85     ATSGlobals.managedMode = 1; // We are running in Managed Mode
86     }
87     else if (radUnmanagedMode.Checked)
88     { // Unmanaged mode is selected
89     // Validate database dest dir
90     if (txtDestinationDir.Text.Trim().Length == 0)
91     {
92     MessageBox.Show("You must specifiy a destination directory for the AnywhereTS boot image files.");
93     txtDestinationDir.Focus();
94     return;
95     }
96    
97     // Create Dest directory
98     try
99     {
100     Directory.CreateDirectory(txtDestinationDir.Text.Trim());
101     }
102     catch (Exception ex)
103     {
104     this.Cursor = Cursors.Default;
105     MessageBox.Show("Could not create directory '" + txtDestinationDir.Text.Trim() + "'. Error: " + ex.Message);
106     return;
107     }
108    
109     ATSGlobals.managedMode = 2; // We are running in unmanaged mode
110     // No services should be run in unmanaged mode
111     ATSGlobals.dhcpConfig = 1; // Other DHCP
112     ATSGlobals.tftpConfig = 1; // Other TFTP
113     ProSupport.strDestDir = txtDestinationDir.Text.Trim();
114    
115     }
116     else
117     {
118     throw new Exception("Error: Unknown mode (84377)");
119     }
120     // Save the database directory to registry
121     ProSupport.strDatabasePath = txtDatabasePath.Text.Trim();
122     ATSGlobals.SetATSRegValue(ProSupport.strRegDatabaseDir, ProSupport.strDatabasePath);
123    
124     // Save mode
125     ATSGlobals.SetATSRegValue(ATSGlobals.strRegManagedMode, ATSGlobals.managedMode);
126    
127     // Save destination directory
128     ATSGlobals.SetATSRegValue(ProSupport.strRegDestDir, ProSupport.strDestDir);
129    
130     // Terminate window
131     this.Cursor = Cursors.Default;
132     DialogResult = DialogResult.OK;
133     }
134    
135     private void btnBrowseDatabase_Click(object sender, EventArgs e)
136     {
137     // Show the FolderBrowserDialog.
138     DialogResult result = folderBrowserDialog.ShowDialog();
139     if (result == DialogResult.OK)
140     {
141     txtDatabasePath.Text = folderBrowserDialog.SelectedPath;
142     }
143     }
144    
145     private void radManagedMode_CheckedChanged(object sender, EventArgs e)
146     {
147     UpdateControls();
148     }
149    
150     private void radUnmanagedMode_CheckedChanged(object sender, EventArgs e)
151     {
152     UpdateControls();
153     }
154    
155     private void UpdateControls()
156     {
157     if (radManagedMode.Checked)
158     { // Managed mode
159     lblDatabasePath.Enabled = true;
160     txtDatabasePath.Enabled = true;
161     btnBrowseDatabase.Enabled = true;
162     lblDestinationDir.Enabled = false;
163     txtDestinationDir.Enabled = false;
164     btnBrowseDestinationDir.Enabled = false;
165     btnOK.Text = "Next >";
166     }
167     else
168     { // Unmanaged mode
169     lblDatabasePath.Enabled = false;
170     txtDatabasePath.Enabled = false;
171     btnBrowseDatabase.Enabled = false;
172     lblDestinationDir.Enabled = true;
173     txtDestinationDir.Enabled = true;
174     btnBrowseDestinationDir.Enabled = true;
175     btnOK.Text = "Finish";
176     }
177    
178     }
179    
180     private void btnBrowseDestinationDir_Click(object sender, EventArgs e)
181     {
182     // Show the FolderBrowserDialog.
183     DialogResult result = folderBrowserDialog.ShowDialog();
184     if (result == DialogResult.OK)
185     {
186     txtDestinationDir.Text = folderBrowserDialog.SelectedPath;
187     }
188     }
189    
190     }
191     }

  ViewVC Help
Powered by ViewVC 1.1.22