ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/AnywhereTS-MSSQL/trunk/CSDLL/frmClientMiscellany.cs
Revision: 4
Committed: Wed Jul 11 14:19:13 2012 UTC (10 years, 10 months ago) by william
File size: 12198 byte(s)
Log Message:
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

File Contents

# Content
1 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
9 namespace AnywhereTS
10 {
11 public partial class frmClientMiscellany : Form
12 {
13 public frmClientMiscellany()
14 {
15 InitializeComponent();
16 }
17
18 public ATSImage currentImage = null; // The current client configuration. Will be set by caller.
19 public bool isPro = false; // The current program version. Will be set by caller.
20
21 private void frmClientMiscellany_Load(object sender, EventArgs e)
22 {
23
24 // Initate controls from current configuration
25
26 // Initate controls on misc tab
27 currentImage.RuntimeConfig.NumLock = true;
28 currentImage.RuntimeConfig.MiscRedirectCom1 = false;
29 currentImage.RuntimeConfig.MiscRedirectCom2 = false;
30 currentImage.RuntimeConfig.UsbDrive = ATSImageRuntimeConfig.ATSUsbDrive.None;
31 currentImage.RuntimeConfig.ServerPort = -1;
32
33 chkMiscDailyreboot.Checked = currentImage.RuntimeConfig.DailyReboot;
34 chkMiscReconnect.Checked = !currentImage.RuntimeConfig.ReconnectPrompt;
35 chkMiscMousefix.Checked = currentImage.RuntimeConfig.MiscMousefix;
36 chkMiscFlippedFix.Checked = currentImage.RuntimeConfig.MiscFlippedFix;
37 chkMiscNoaccel.Checked = currentImage.RuntimeConfig.MiscNoAcceleration;
38 chkMiscNumLock.Checked = currentImage.RuntimeConfig.NumLock;
39
40 // Initiate keyboard combo
41 cboKeyboard.Items.AddRange(ATSKeyboard.keyboardDescription); // Load keyboard descriptions
42 cboKeyboard.SelectedIndex = ATSKeyboard.KeyboardCodeToIndex(currentImage.RuntimeConfig.KeyboardMap);
43 // Initiate timezone combo
44 cboTimezone.Items.AddRange(ATSTimeZone.timeZoneCode); // Load timezones
45 cboTimezone.SelectedIndex = ATSTimeZone.TimeZoneCodeToIndex(currentImage.RuntimeConfig.TimeZone);
46
47 // Initiate RDP controls
48 chkMiscFloppyRedirect.Checked = currentImage.RuntimeConfig.RedirectFloppy;
49 chkMiscCDredirect.Checked = currentImage.RuntimeConfig.RedirectCD;
50 chkMiscCOM1.Checked = currentImage.RuntimeConfig.MiscRedirectCom1;
51 chkMiscCOM2.Checked = currentImage.RuntimeConfig.MiscRedirectCom2;
52 chkUsbMemory.Checked = currentImage.RuntimeConfig.UsbDrive == ATSImageRuntimeConfig.ATSUsbDrive.One;
53
54 // Initialise server port
55 if (currentImage.RuntimeConfig.ServerPort == -1)
56 {
57 txtServerPort.Text = "";
58 }
59 else
60 {
61 txtServerPort.Text = currentImage.RuntimeConfig.ServerPort.ToString();
62 }
63
64
65 if (currentImage.DesigntimeConfig.OnlyUseRDP)
66 {
67 // Remove ICA tab
68 tabClientProperties.TabPages.Remove(tabClientProperties.TabPages["tabIca"]);
69 }
70 else
71 {
72 // Initiate ICA controls
73 chkIcaCompression.Checked = currentImage.RuntimeConfig.ICACompression;
74 if (currentImage.RuntimeConfig.IcaAudioQuality == ATSImageRuntimeConfig.ATSIcaAudioQuality.Low)
75 tbrIcaAudioQuality.Value = 1;
76 else if (currentImage.RuntimeConfig.IcaAudioQuality == ATSImageRuntimeConfig.ATSIcaAudioQuality.Medium)
77 tbrIcaAudioQuality.Value = 2;
78 else if (currentImage.RuntimeConfig.IcaAudioQuality == ATSImageRuntimeConfig.ATSIcaAudioQuality.High)
79 tbrIcaAudioQuality.Value = 3;
80 else
81 throw new Exception("Error: Unhandled audio quality (66432)");
82
83 if (currentImage.RuntimeConfig.ICAProtocol == ATSImageRuntimeConfig.ATSIcaProtocol.ATSUDP)
84 radIcaProtocolUDP.Checked = true;
85 else if (currentImage.RuntimeConfig.ICAProtocol == ATSImageRuntimeConfig.ATSIcaProtocol.ATSHTTPOnTCP)
86 radIcaProtocolHTTP.Checked = true;
87 else
88 throw new Exception("Error: Unhandlced ICA protocol (60032)");
89
90 int i = cboIcaEncryption.FindStringExact(currentImage.RuntimeConfig.ICAEncryption);
91 if (i != -1) // Check if the item was found in the combobox.
92 {
93 cboIcaEncryption.SelectedIndex = i;
94 }
95 else
96 throw new Exception("Error: Unhandlced ICA encryption(60033)");
97 }
98
99 // Initate the Network Boot tab
100 if (currentImage.DesigntimeConfig.BootPackage == 0)
101 {
102 radEtherboot.Checked = true;
103 }
104 else
105 {
106 radPxelinux.Checked = true;
107 }
108
109 }
110
111 private void btnOk_Click(object sender, EventArgs e)
112 {
113 // Update current configuration from controls
114 // Update from Misc tab
115 currentImage.RuntimeConfig.NumLock = chkMiscNumLock.Checked;
116 currentImage.RuntimeConfig.DailyReboot = chkMiscDailyreboot.Checked;
117 currentImage.RuntimeConfig.ReconnectPrompt = !chkMiscReconnect.Checked;
118 currentImage.RuntimeConfig.MiscMousefix = chkMiscMousefix.Checked;
119 currentImage.RuntimeConfig.MiscFlippedFix = chkMiscFlippedFix.Checked;
120 currentImage.RuntimeConfig.MiscNoAcceleration = chkMiscNoaccel.Checked;
121 currentImage.RuntimeConfig.TimeZone = cboTimezone.Items[cboTimezone.SelectedIndex].ToString();
122 currentImage.RuntimeConfig.KeyboardMap = ATSKeyboard.keyboardCode[cboKeyboard.SelectedIndex];
123
124 // If RDP tab exists (removed if in ICA mode)
125 if (tabClientProperties.TabPages.ContainsKey("tabRdp"))
126 {
127 // Save RDP controls
128 currentImage.RuntimeConfig.MiscRedirectCom1 = chkMiscCOM1.Checked;
129 currentImage.RuntimeConfig.MiscRedirectCom2 = chkMiscCOM2.Checked;
130 currentImage.RuntimeConfig.RedirectFloppy = chkMiscFloppyRedirect.Checked;
131 currentImage.RuntimeConfig.RedirectCD = chkMiscCDredirect.Checked;
132
133 if (chkUsbMemory.Checked)
134 {
135 currentImage.RuntimeConfig.UsbDrive = ATSImageRuntimeConfig.ATSUsbDrive.One;
136 }
137 else
138 {
139 currentImage.RuntimeConfig.UsbDrive = ATSImageRuntimeConfig.ATSUsbDrive.None;
140 }
141
142 // Validate and convert server port
143 if (txtServerPort.Text.Trim().Length == 0)
144 { // No server port specified
145 currentImage.RuntimeConfig.ServerPort = -1;
146 }
147 else
148 { // The user has specified a server port
149 try
150 {
151 currentImage.RuntimeConfig.ServerPort = Int32.Parse(txtServerPort.Text.Trim());
152 }
153 catch (Exception)
154 {
155 tabClientProperties.SelectTab("TabRdp");
156 MessageBox.Show("Invalid server port!");
157 txtServerPort.Focus();
158 txtServerPort.SelectAll();
159 return;
160 }
161 if (currentImage.RuntimeConfig.ServerPort < 0 || currentImage.RuntimeConfig.ServerPort > 65535)
162 { // Value to high or to low
163 tabClientProperties.SelectTab("TabRdp");
164 MessageBox.Show("Invalid server port!");
165 txtServerPort.Focus();
166 txtServerPort.SelectAll();
167 return;
168 }
169 }
170 }
171
172 // If ICA tab exists (removed if in RDP mode)
173 if (tabClientProperties.TabPages.ContainsKey("tabIca"))
174 {
175 currentImage.RuntimeConfig.ICACompression = chkIcaCompression.Checked;
176 currentImage.RuntimeConfig.ICAEncryption = cboIcaEncryption.Items[cboIcaEncryption.SelectedIndex].ToString();
177 if (radIcaProtocolUDP.Checked)
178 currentImage.RuntimeConfig.ICAProtocol = ATSImageRuntimeConfig.ATSIcaProtocol.ATSUDP;
179 else
180 currentImage.RuntimeConfig.ICAProtocol = ATSImageRuntimeConfig.ATSIcaProtocol.ATSHTTPOnTCP;
181
182 if (tbrIcaAudioQuality.Value == 1)
183 currentImage.RuntimeConfig.IcaAudioQuality = ATSImageRuntimeConfig.ATSIcaAudioQuality.Low;
184 else if (tbrIcaAudioQuality.Value == 2)
185 currentImage.RuntimeConfig.IcaAudioQuality = ATSImageRuntimeConfig.ATSIcaAudioQuality.Medium;
186 else
187 currentImage.RuntimeConfig.IcaAudioQuality = ATSImageRuntimeConfig.ATSIcaAudioQuality.High;
188 }
189
190 // Save Network Boot tab
191 if (radEtherboot.Checked)
192 {
193 currentImage.DesigntimeConfig.BootPackage = 0;
194 }
195 else
196 {
197 currentImage.DesigntimeConfig.BootPackage = 1;
198 }
199
200 DialogResult = DialogResult.OK;
201 }
202
203
204 // Display context sensitive ATS help, depending on mode (default properties or normal properties) and selected tab
205 private void ShowAtsHelp()
206 {
207 string helpKeyword = "";
208 switch (tabClientProperties.SelectedTab.Name)
209 {
210 case "tabRdp":
211 helpKeyword = "advancedclientoptionsrdp.htm";
212 break;
213 case "tabIca":
214 helpKeyword = "advancedclientoptionsica.htm";
215 break;
216 case "tabMisc":
217 helpKeyword = "advancedclientoptionsmisc.htm";
218 break;
219 case "tabBoot":
220 helpKeyword = "advancedclientoptionsnetworkboot.htm";
221 break;
222 default:
223 throw new Exception("Error: Invalid tab (63320): " + tabClientProperties.SelectedTab.Name);
224 }
225 Help.ShowHelp(this, ATSGlobals.strHelpFilePath, HelpNavigator.Topic, helpKeyword);
226 }
227
228
229 private void frmClientMiscellany_HelpRequested(object sender, HelpEventArgs hlpevent)
230 {
231 hlpevent.Handled = true;
232 }
233
234 private void frmClientMiscellany_KeyDown(object sender, KeyEventArgs e)
235 {
236 if (e.KeyCode == Keys.F1)
237 { // F1 pressed, show ATS help
238 ShowAtsHelp();
239 }
240 }
241
242 private void chkMiscNumLock_CheckedChanged(object sender, EventArgs e)
243 {
244 ProControl((CheckBox)sender, currentImage);
245 }
246
247 private void ProControl(CheckBox proCheckbox, ATSImage currentImage)
248 {
249 }
250
251 private void ProControl(TextBox proTextbox, ATSImage currentImage)
252 {
253 }
254
255 private void chkMiscCOM1_CheckedChanged(object sender, EventArgs e)
256 {
257 ProControl((CheckBox)sender, currentImage);
258 }
259
260 private void chkMiscCOM2_CheckedChanged(object sender, EventArgs e)
261 {
262 ProControl((CheckBox)sender, currentImage);
263 }
264
265 private void chkUsbMemory_CheckedChanged(object sender, EventArgs e)
266 {
267 ProControl((CheckBox)sender, currentImage);
268 }
269
270 private void btnHelp_Click(object sender, EventArgs e)
271 {
272 ShowAtsHelp();
273 }
274
275 private void txtServerPort_TextChanged(object sender, EventArgs e)
276 {
277 ProControl((TextBox)sender, currentImage);
278 }
279
280 } // Form
281 } // Namespace