using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace AnywhereTS { public partial class frmClientMiscellany : Form { public frmClientMiscellany() { InitializeComponent(); } public ATSImage currentImage = null; // The current client configuration. Will be set by caller. public bool isPro = false; // The current program version. Will be set by caller. private void frmClientMiscellany_Load(object sender, EventArgs e) { // Initate controls from current configuration // Initate controls on misc tab currentImage.RuntimeConfig.NumLock = true; currentImage.RuntimeConfig.MiscRedirectCom1 = false; currentImage.RuntimeConfig.MiscRedirectCom2 = false; currentImage.RuntimeConfig.UsbDrive = ATSImageRuntimeConfig.ATSUsbDrive.None; currentImage.RuntimeConfig.ServerPort = -1; chkMiscDailyreboot.Checked = currentImage.RuntimeConfig.DailyReboot; chkMiscReconnect.Checked = !currentImage.RuntimeConfig.ReconnectPrompt; chkMiscMousefix.Checked = currentImage.RuntimeConfig.MiscMousefix; chkMiscFlippedFix.Checked = currentImage.RuntimeConfig.MiscFlippedFix; chkMiscNoaccel.Checked = currentImage.RuntimeConfig.MiscNoAcceleration; chkMiscNumLock.Checked = currentImage.RuntimeConfig.NumLock; // Initiate keyboard combo cboKeyboard.Items.AddRange(ATSKeyboard.keyboardDescription); // Load keyboard descriptions cboKeyboard.SelectedIndex = ATSKeyboard.KeyboardCodeToIndex(currentImage.RuntimeConfig.KeyboardMap); // Initiate timezone combo cboTimezone.Items.AddRange(ATSTimeZone.timeZoneCode); // Load timezones cboTimezone.SelectedIndex = ATSTimeZone.TimeZoneCodeToIndex(currentImage.RuntimeConfig.TimeZone); // Initiate RDP controls chkMiscFloppyRedirect.Checked = currentImage.RuntimeConfig.RedirectFloppy; chkMiscCDredirect.Checked = currentImage.RuntimeConfig.RedirectCD; chkMiscCOM1.Checked = currentImage.RuntimeConfig.MiscRedirectCom1; chkMiscCOM2.Checked = currentImage.RuntimeConfig.MiscRedirectCom2; chkUsbMemory.Checked = currentImage.RuntimeConfig.UsbDrive == ATSImageRuntimeConfig.ATSUsbDrive.One; // Initialise server port if (currentImage.RuntimeConfig.ServerPort == -1) { txtServerPort.Text = ""; } else { txtServerPort.Text = currentImage.RuntimeConfig.ServerPort.ToString(); } if (currentImage.DesigntimeConfig.OnlyUseRDP) { // Remove ICA tab tabClientProperties.TabPages.Remove(tabClientProperties.TabPages["tabIca"]); } else { // Initiate ICA controls chkIcaCompression.Checked = currentImage.RuntimeConfig.ICACompression; if (currentImage.RuntimeConfig.IcaAudioQuality == ATSImageRuntimeConfig.ATSIcaAudioQuality.Low) tbrIcaAudioQuality.Value = 1; else if (currentImage.RuntimeConfig.IcaAudioQuality == ATSImageRuntimeConfig.ATSIcaAudioQuality.Medium) tbrIcaAudioQuality.Value = 2; else if (currentImage.RuntimeConfig.IcaAudioQuality == ATSImageRuntimeConfig.ATSIcaAudioQuality.High) tbrIcaAudioQuality.Value = 3; else throw new Exception("Error: Unhandled audio quality (66432)"); if (currentImage.RuntimeConfig.ICAProtocol == ATSImageRuntimeConfig.ATSIcaProtocol.ATSUDP) radIcaProtocolUDP.Checked = true; else if (currentImage.RuntimeConfig.ICAProtocol == ATSImageRuntimeConfig.ATSIcaProtocol.ATSHTTPOnTCP) radIcaProtocolHTTP.Checked = true; else throw new Exception("Error: Unhandlced ICA protocol (60032)"); int i = cboIcaEncryption.FindStringExact(currentImage.RuntimeConfig.ICAEncryption); if (i != -1) // Check if the item was found in the combobox. { cboIcaEncryption.SelectedIndex = i; } else throw new Exception("Error: Unhandlced ICA encryption(60033)"); } // Initate the Network Boot tab if (currentImage.DesigntimeConfig.BootPackage == 0) { radEtherboot.Checked = true; } else { radPxelinux.Checked = true; } } private void btnOk_Click(object sender, EventArgs e) { // Update current configuration from controls // Update from Misc tab currentImage.RuntimeConfig.NumLock = chkMiscNumLock.Checked; currentImage.RuntimeConfig.DailyReboot = chkMiscDailyreboot.Checked; currentImage.RuntimeConfig.ReconnectPrompt = !chkMiscReconnect.Checked; currentImage.RuntimeConfig.MiscMousefix = chkMiscMousefix.Checked; currentImage.RuntimeConfig.MiscFlippedFix = chkMiscFlippedFix.Checked; currentImage.RuntimeConfig.MiscNoAcceleration = chkMiscNoaccel.Checked; currentImage.RuntimeConfig.TimeZone = cboTimezone.Items[cboTimezone.SelectedIndex].ToString(); currentImage.RuntimeConfig.KeyboardMap = ATSKeyboard.keyboardCode[cboKeyboard.SelectedIndex]; // If RDP tab exists (removed if in ICA mode) if (tabClientProperties.TabPages.ContainsKey("tabRdp")) { // Save RDP controls currentImage.RuntimeConfig.MiscRedirectCom1 = chkMiscCOM1.Checked; currentImage.RuntimeConfig.MiscRedirectCom2 = chkMiscCOM2.Checked; currentImage.RuntimeConfig.RedirectFloppy = chkMiscFloppyRedirect.Checked; currentImage.RuntimeConfig.RedirectCD = chkMiscCDredirect.Checked; if (chkUsbMemory.Checked) { currentImage.RuntimeConfig.UsbDrive = ATSImageRuntimeConfig.ATSUsbDrive.One; } else { currentImage.RuntimeConfig.UsbDrive = ATSImageRuntimeConfig.ATSUsbDrive.None; } // Validate and convert server port if (txtServerPort.Text.Trim().Length == 0) { // No server port specified currentImage.RuntimeConfig.ServerPort = -1; } else { // The user has specified a server port try { currentImage.RuntimeConfig.ServerPort = Int32.Parse(txtServerPort.Text.Trim()); } catch (Exception) { tabClientProperties.SelectTab("TabRdp"); MessageBox.Show("Invalid server port!"); txtServerPort.Focus(); txtServerPort.SelectAll(); return; } if (currentImage.RuntimeConfig.ServerPort < 0 || currentImage.RuntimeConfig.ServerPort > 65535) { // Value to high or to low tabClientProperties.SelectTab("TabRdp"); MessageBox.Show("Invalid server port!"); txtServerPort.Focus(); txtServerPort.SelectAll(); return; } } } // If ICA tab exists (removed if in RDP mode) if (tabClientProperties.TabPages.ContainsKey("tabIca")) { currentImage.RuntimeConfig.ICACompression = chkIcaCompression.Checked; currentImage.RuntimeConfig.ICAEncryption = cboIcaEncryption.Items[cboIcaEncryption.SelectedIndex].ToString(); if (radIcaProtocolUDP.Checked) currentImage.RuntimeConfig.ICAProtocol = ATSImageRuntimeConfig.ATSIcaProtocol.ATSUDP; else currentImage.RuntimeConfig.ICAProtocol = ATSImageRuntimeConfig.ATSIcaProtocol.ATSHTTPOnTCP; if (tbrIcaAudioQuality.Value == 1) currentImage.RuntimeConfig.IcaAudioQuality = ATSImageRuntimeConfig.ATSIcaAudioQuality.Low; else if (tbrIcaAudioQuality.Value == 2) currentImage.RuntimeConfig.IcaAudioQuality = ATSImageRuntimeConfig.ATSIcaAudioQuality.Medium; else currentImage.RuntimeConfig.IcaAudioQuality = ATSImageRuntimeConfig.ATSIcaAudioQuality.High; } // Save Network Boot tab if (radEtherboot.Checked) { currentImage.DesigntimeConfig.BootPackage = 0; } else { currentImage.DesigntimeConfig.BootPackage = 1; } DialogResult = DialogResult.OK; } // Display context sensitive ATS help, depending on mode (default properties or normal properties) and selected tab private void ShowAtsHelp() { string helpKeyword = ""; switch (tabClientProperties.SelectedTab.Name) { case "tabRdp": helpKeyword = "advancedclientoptionsrdp.htm"; break; case "tabIca": helpKeyword = "advancedclientoptionsica.htm"; break; case "tabMisc": helpKeyword = "advancedclientoptionsmisc.htm"; break; case "tabBoot": helpKeyword = "advancedclientoptionsnetworkboot.htm"; break; default: throw new Exception("Error: Invalid tab (63320): " + tabClientProperties.SelectedTab.Name); } Help.ShowHelp(this, ATSGlobals.strHelpFilePath, HelpNavigator.Topic, helpKeyword); } private void frmClientMiscellany_HelpRequested(object sender, HelpEventArgs hlpevent) { hlpevent.Handled = true; } private void frmClientMiscellany_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F1) { // F1 pressed, show ATS help ShowAtsHelp(); } } private void chkMiscNumLock_CheckedChanged(object sender, EventArgs e) { ProControl((CheckBox)sender, currentImage); } private void ProControl(CheckBox proCheckbox, ATSImage currentImage) { } private void ProControl(TextBox proTextbox, ATSImage currentImage) { } private void chkMiscCOM1_CheckedChanged(object sender, EventArgs e) { ProControl((CheckBox)sender, currentImage); } private void chkMiscCOM2_CheckedChanged(object sender, EventArgs e) { ProControl((CheckBox)sender, currentImage); } private void chkUsbMemory_CheckedChanged(object sender, EventArgs e) { ProControl((CheckBox)sender, currentImage); } private void btnHelp_Click(object sender, EventArgs e) { ShowAtsHelp(); } private void txtServerPort_TextChanged(object sender, EventArgs e) { ProControl((TextBox)sender, currentImage); } } // Form } // Namespace