private void btnFusing_Click(object sender, RoutedEventArgs e) { bool isApplySuccess = false; string strPrinterName = ((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter; FusingResetRecord m_rec = new FusingResetRecord(strPrinterName); AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (worker.InvokeMethod <FusingResetRecord>(strPrinterName, ref m_rec, DllMethodType.SetFusingResetCmd, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { isApplySuccess = true; } } if (isApplySuccess) { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Successfully_"), Brushes.Black); MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple_NoIcon, Application.Current.MainWindow, (string)this.TryFindResource("ResStr_Please_turn_off_the_printer_until_it_cools_to_room_temperature"), (string)this.TryFindResource("ResStr_Prompt")); } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Fail"), Brushes.Red); } }
public void init_config(bool _bDisplayProgressBar = true) { m_psavetime = 1; PowerSaveTimeRecord m_rec = null; AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (_bDisplayProgressBar) { worker.InvokeMethod <PowerSaveTimeRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.GetPowerSaveTime, this); } else { m_rec = worker.GetPowerSaveTime(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter); } if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { m_psavetime = m_rec.Time; } spinnerControl1.FormattedValue = String.Format("{0}", m_psavetime); TextBox tb = spinnerControl1.Template.FindName("tbTextBox", spinnerControl1) as TextBox; tb.TextChanged += new TextChangedEventHandler(SpinnerTextBox_TextChanged); tb.PreviewTextInput += new TextCompositionEventHandler(SpinnerTextBox_PreviewTextInput); tb.PreviewKeyDown += new KeyEventHandler(OnPreviewKeyDown); // UpdateApplyBtnStatus(); }
public bool apply() { bool isApplySuccess = false; byte psavetime = Convert.ToByte(spinnerControl1.Value); if (psavetime < 1 || 30 < psavetime) { psavetime = 1; } PowerSaveTimeRecord m_rec = new PowerSaveTimeRecord(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, psavetime); AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (worker.InvokeMethod <PowerSaveTimeRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.SetPowerSaveTime, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { m_psavetime = psavetime; isApplySuccess = true; } } if (isApplySuccess) { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Successfully_"), Brushes.Black); } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Fail"), Brushes.Red); } return(isApplySuccess); }
public void init_config(bool _bDisplayProgressBar = true) { softAPSettingInit.m_bEnableSoftAp = false; // disable softAPSettingInit.m_ssid = ""; softAPSettingInit.m_pwd = ""; SoftApRecord m_rec = null; AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (_bDisplayProgressBar) { worker.InvokeMethod <SoftApRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.GetSoftAp, this); } else { m_rec = worker.GetSoftAp(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter); } if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { softAPSetting.m_ssid = softAPSettingInit.m_ssid = m_rec.SSID; softAPSetting.m_pwd = softAPSettingInit.m_pwd = m_rec.PWD; softAPSetting.m_bEnableSoftAp = softAPSettingInit.m_bEnableSoftAp = m_rec.WifiEnable; VOP.MainWindow.m_byWifiInitStatus = 0x01; } tbSSID.Text = softAPSettingInit.m_ssid; tbPWD.Text = softAPSettingInit.m_pwd; chkbtn_wifi_enable.IsChecked = softAPSettingInit.m_bEnableSoftAp; }
private void btnLogin_Click(object sender, RoutedEventArgs e) { bool isApplySuccess = false; string strpwd = pbPwd.Password; string strPrinterName = ((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter; string strDrvName = ""; if (false == common.GetPrinterDrvName(strPrinterName, ref strDrvName)) { MessageBoxEx_Simple messageBox = new MessageBoxEx_Simple((string)this.TryFindResource("ResStr_can_not_be_carried_out_due_to_software_has_error__please_try__again_after_reinstall_the_Driver_and_Virtual_Operation_Panel_"), (string)this.FindResource("ResStr_Error")); messageBox.Owner = App.Current.MainWindow; messageBox.ShowDialog(); return; } if (strpwd.Length > 0) { PasswordRecord m_rec = new PasswordRecord(strPrinterName, strpwd); AsyncWorker worker = new AsyncWorker(this); if (worker.InvokeMethod <PasswordRecord>(strPrinterName, ref m_rec, DllMethodType.ConfirmPassword, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { ((MainWindow)App.Current.MainWindow).m_strPassword = strpwd; isApplySuccess = true; } } if (!isApplySuccess) { ((MainWindow)App.Current.MainWindow).m_strPassword = ""; pbPwd.Focus(); pbPwd.SelectAll(); tbkErrorInfo.Foreground = new SolidColorBrush(Colors.Red); tbkErrorInfo.Text = (string)this.FindResource("ResStr_Authentication_error__please_enter_the_password_again_"); } else { this.DialogResult = true; this.Close(); } } else { tbkErrorInfo.Foreground = new SolidColorBrush(Colors.Red); tbkErrorInfo.Text = (string)this.FindResource("ResStr_The_new_password_can_not_be_empty_"); } }
private void OnLoadedIPV6View(object sender, RoutedEventArgs e) { InitFontSize(); AsyncWorker worker = new AsyncWorker(this); worker.InvokeMethod <IPV6InfoRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.GetIpv6Info, this); if (null != m_rec) { if (1 == m_rec.DHCPv6) { btnDHCP.IsChecked = true; } else { btnDHCP.IsChecked = false; } if (1 == m_rec.UseManualAddress) { btnManual.IsChecked = true; } else { btnManual.IsChecked = false; } if (1 == m_rec.UseManualAddress) { tb_ip.Text = m_rec.IPManualAddress; tb_PreSubMask.Text = String.Format("{0}", m_rec.ManualMask); } else { tb_ip.Text = "::"; tb_PreSubMask.Text = String.Format("{0}", 1); } if (1 == m_rec.UseManualAddress) { tb_Gateway.Text = m_rec.IPv6ManualGatewayAddress; // tb_GatewayPreSubMask.Text = String.Format("{0}", m_rec.ManualGatewayAddressMask); } else { tb_Gateway.Text = "::"; // tb_GatewayPreSubMask.Text = String.Format("{0}", 0); } } }
public bool apply() { bool isApplySuccess = false; // soft ap config string str_ssid = tbSSID.Text; string str_pwd = tbPWD.Text; bool isEnableSoftAp = (chkbtn_wifi_enable.IsChecked == true); if (is_InputVailible()) { SoftApRecord m_rec = new SoftApRecord(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, str_ssid, str_pwd, isEnableSoftAp); AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (worker.InvokeMethod <SoftApRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.SetSoftAp, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { softAPSettingInit.m_ssid = softAPSetting.m_ssid = str_ssid; softAPSettingInit.m_pwd = softAPSetting.m_pwd = str_pwd; softAPSettingInit.m_bEnableSoftAp = softAPSetting.m_bEnableSoftAp = isEnableSoftAp; isApplySuccess = true; } } //if (null != event_config_dirty) // event_config_dirty(is_dirty()); } else { if (str_ssid.Length <= 0) { VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_Msg_10"), (string)this.FindResource("ResStr_Warning")); } else if (str_pwd.Length < 8 || str_pwd.Length >= 64) { VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_Msg_3"), (string)this.FindResource("ResStr_Warning")); } } if (isApplySuccess) { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Msg_1"), Brushes.Black); } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Fail"), Brushes.Red); } return(isApplySuccess); }
public bool apply() { bool isApplySuccess = false; string strPWD = pbnewPWD.Password; string strCfPWD = pbConfirmPWD.Password; if (strPWD.Length > 0 && strPWD == strCfPWD) { if (strPWD.Length > 0) { string strPrinterName = ((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter; PasswordRecord m_rec = new PasswordRecord(strPrinterName, strPWD); AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (worker.InvokeMethod <PasswordRecord>(strPrinterName, ref m_rec, DllMethodType.SetPassword, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { ((MainWindow)App.Current.MainWindow).m_strPassword = strCfPWD; isApplySuccess = true; } } } if (isApplySuccess) { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Successfully_"), Brushes.Black); } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Fail"), Brushes.Red); } } else { if (strPWD.Length == 0) { pbnewPWD.Focus(); VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_new_password_can_not_be_empty_"), (string)this.FindResource("ResStr_Error")); } else if (strPWD != strCfPWD) { pbnewPWD.Focus(); pbnewPWD.SelectAll(); VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_passwords_you_entered__are_different__please_try_again_"), (string)this.FindResource("ResStr_Error")); } } return(isApplySuccess); }
private void OnLoadedIPV6View(object sender, RoutedEventArgs e) { InitFontSize(); AsyncWorker worker = new AsyncWorker(this); worker.InvokeMethod <IPV6InfoRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.GetIpv6Info, this); if (null != m_rec) { tbStatelessAddress1.Text = m_rec.StatelessAddress1; tbStatelessAddress2.Text = m_rec.StatelessAddress2; tbStatelessAddress3.Text = m_rec.StatelessAddress3; tbAutoStatefullAddress.Text = m_rec.AutoStatefulAddress; tbLinkLocalAddress.Text = m_rec.IPLinkLocalAddress; tbAutoConfigureGatewayAddress.Text = m_rec.AutoGatewayAddress; } }
public bool apply() { bool isApplySuccess = false; sbyte leadingedge = 1; sbyte sidetoside = 1; sbyte imagedensity = 0; sbyte lowhumiditymode = 0; sbyte platecontrolmode = 2; sbyte primarycoolingmode = 0; GetUIValues(out leadingedge, out sidetoside, out imagedensity, out lowhumiditymode, out platecontrolmode, out primarycoolingmode); string strPrinterName = ((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter; UserCfgRecord m_rec = new UserCfgRecord(strPrinterName, leadingedge, sidetoside, imagedensity, lowhumiditymode, platecontrolmode, primarycoolingmode, true); AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (worker.InvokeMethod <UserCfgRecord>(strPrinterName, ref m_rec, DllMethodType.SetUserConfig, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { m_leadingedge = leadingedge; m_sidetoside = sidetoside; m_imagedensity = imagedensity; m_lowhumiditymode = lowhumiditymode; m_platecontrolmode = platecontrolmode; m_primarycoolingmode = primarycoolingmode; isApplySuccess = true; } } if (isApplySuccess) { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Successfully_"), Brushes.Black); } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Fail"), Brushes.Red); } return(isApplySuccess); }
private void OnLoadWifiView(object sender, RoutedEventArgs e) { btnConnectOthAp.Visibility = Visibility.Hidden; manualConnect.Visibility = Visibility.Hidden; rowManual.Height = new GridLength(0); autoConnect.Visibility = Visibility.Hidden; rowAuto.Height = GridLength.Auto; m_bConnectOthApMode = false; WiFiInfoRecord m_rec = null; AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); worker.InvokeMethod <WiFiInfoRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.GetWiFiInfo, this); if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { wifiSetting.wifiEnable = m_rec.WifiEnable; wifiSetting.m_ssid = m_rec.SSID; wifiSetting.m_pwd = m_rec.PWD; wifiSetting.m_encryption = (byte)m_rec.Encryption; wifiSetting.m_wepKeyId = m_rec.WepKeyId; } if (null != m_rec && 0x01 == (m_rec.WifiEnable & 0x01)) { chkWifi.IsChecked = true; btnConnectOthAp.Visibility = Visibility.Visible; manualConnect.Visibility = Visibility.Hidden; rowManual.Height = new GridLength(0); autoConnect.Visibility = Visibility.Visible; rowAuto.Height = GridLength.Auto; cbo_ssid_refresh(); } else { chkWifi.IsChecked = false; } scrollview.ScrollToTop(); chkDisplayPwd.IsChecked = false; }
private void OnClickWifiCheckBox(object sender, RoutedEventArgs e) { byte wifiEnable = 0; bool bSuccess = false; Nullable <bool> bEnable = chkWifi.IsChecked; if (true == bEnable) { wifiEnable = 1; } byte wifiInit = 0; // Begin: Fix bug # 61388 int result = dll.GetWifiChangeStatus(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref wifiInit); if (0 == result) // success? { VOP.MainWindow.m_byWifiInitStatus = wifiInit; } else { Win32.OutputDebugString("OnClickWifiCheckBox->dll.GetWifiChangeStatus() ---> failed... , Result = " + result.ToString()); } // End: Fix bug # 61388 WiFiInfoRecord m_rec = new WiFiInfoRecord(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, wifiEnable, 1, "", "", EnumEncryptType.WPA2_PSK_AES, 0); AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (worker.InvokeMethod <WiFiInfoRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.SetWiFiInfo, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { bSuccess = true; } } if (!bSuccess) { bEnable = !chkWifi.IsChecked; chkWifi.IsChecked = bEnable; if (((MainWindow)App.Current.MainWindow).m_strPassword.Length == 0) { if (VOP.MainWindow.m_byWifiInitStatus == 0x01 && true == bEnable) { cbo_ssid_refresh(); } } } else { if (true == bEnable) { cbo_ssid_refresh(); } } if (bSuccess) { if (wifiEnable != VOP.MainWindow.m_byWifiInitStatus) { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Msg_1"), Brushes.Black); MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple_NoIcon, Application.Current.MainWindow, (string)this.TryFindResource("ResStr_Msg_1"), (string)this.TryFindResource("ResStr_Prompt")); } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Successfully_"), Brushes.Black); } } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Fail"), Brushes.Red); } }
public void cbo_ssid_refresh(bool _bDisplayProgressBar = true) { wifilist.Children.Clear(); byte wifiInit = 0; int result = dll.GetWifiChangeStatus(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref wifiInit); // Begin: Fix bug # 61388 if (0 == result) // success? { VOP.MainWindow.m_byWifiInitStatus = wifiInit; } else { Win32.OutputDebugString("cbo_ssid_refresh->dll.GetWifiChangeStatus() ---> failed... , Result = " + result.ToString()); } // End: Fix bug # 61388 if (wifiInit == 0x00) { return; } ApListRecord m_rec = null; AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (_bDisplayProgressBar) { worker.InvokeMethod <ApListRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.GetApList, this); } else { m_rec = worker.GetApList(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter); } //WiFiInfoRecord m_wifi = null; //AsyncWorker worker1 = new AsyncWorker(Application.Current.MainWindow); //worker1.InvokeMethod<WiFiInfoRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_wifi, DllMethodType.GetWiFiInfo, this); if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { for (int i = 0; i < m_rec.SsidList.Count; i++) { if (!String.IsNullOrEmpty(m_rec.SsidList[i])) { VOP.Controls.WiFiItem wifiitem = new VOP.Controls.WiFiItem(); wifiitem.SSIDText = m_rec.SsidList[i]; if ((byte)EnumEncryptType.NoSecurity == m_rec.EncryptionList[i]) //No Security { wifiitem.EncryptionText = (string)this.FindResource("ResStr_No_Security"); wifiitem.EncryptType = VOP.EnumEncryptType.NoSecurity; } else if ((byte)EnumEncryptType.WEP == m_rec.EncryptionList[i]) //WEP { wifiitem.EncryptionText = (string)this.FindResource("ResStr_Protected_by_WEP"); wifiitem.EncryptType = VOP.EnumEncryptType.WEP; } else if ((byte)EnumEncryptType.WPA2_PSK_AES == m_rec.EncryptionList[i]) //3. WPA2-PSK-AES { wifiitem.EncryptionText = (string)this.FindResource("ResStr_Protected_by_WPA2"); wifiitem.EncryptType = VOP.EnumEncryptType.WPA2_PSK_AES; } else if ((byte)EnumEncryptType.MixedModePSK == m_rec.EncryptionList[i]) //4.Mixed Mode PSK { wifiitem.EncryptionText = (string)this.FindResource("ResStr_Protected_by_Mixed_Mode_PSK"); wifiitem.EncryptType = VOP.EnumEncryptType.MixedModePSK; } wifiitem.WifiSignalLevel = VOP.Controls.EnumWifiSignalLevel.stronger; if (m_rec.ConnectedStatusList[i] == true) { wifiitem.Connected = true; wifiitem.EncryptionText = (string)this.FindResource("ResStr_Connected"); } wifiitem.ConnectedPropertyChanged += wifiitem_ConnectedPropertyChanged; wifilist.Children.Add(wifiitem); } } } }
public bool apply() { bool isApplySuccess = false; string ssid = ""; string pwd = ""; byte encryption = (byte)EnumEncryptType.WPA2_PSK_AES; byte wepKeyId = 1; byte wifiEnable = 1; GetUIValues(out ssid, out pwd, out encryption, out wepKeyId); if (is_InputVailible()) { if (encryption == (byte)EnumEncryptType.NoSecurity) { pwd = ""; } else if (encryption == (byte)EnumEncryptType.WEP) { if (pwd.Length > 26) { pwd = pwd.Substring(1, 26); } } else { } byte wifiInit = 0; // Begin: Fix bug # 61388 int result = dll.GetWifiChangeStatus(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref wifiInit); if (0 == result) // success? { VOP.MainWindow.m_byWifiInitStatus = wifiInit; } else { Win32.OutputDebugString("apply->dll.GetWifiChangeStatus() ---> failed... , Result = " + result.ToString()); } // End: Fix bug # 61388 WiFiInfoRecord m_rec = new WiFiInfoRecord(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, wifiEnable, 0, ssid, (encryption != (byte)EnumEncryptType.NoSecurity) ? pwd : "", (EnumEncryptType)encryption, wepKeyId); AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (worker.InvokeMethod <WiFiInfoRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.SetWiFiInfo, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { wifiSetting.wifiEnable = m_rec.WifiEnable; wifiSetting.m_ssid = ssid; wifiSetting.m_pwd = pwd; wifiSetting.m_encryption = encryption; wifiSetting.m_wepKeyId = wepKeyId; isApplySuccess = true; } } if (isApplySuccess) { if (wifiEnable != VOP.MainWindow.m_byWifiInitStatus) { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Msg_1"), Brushes.Black); } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Successfully_"), Brushes.Black); } } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Fail"), Brushes.Red); } } else { if (ssid.Length <= 0 || ssid.Length > 32) { VOP.Controls.MessageBoxEx.Show(MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_Msg_9"), (string)this.FindResource("ResStr_Warning")); } else { if (encryption == (byte)EnumEncryptType.WEP) { VOP.Controls.MessageBoxEx.Show(MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_Msg_2"), (string)this.FindResource("ResStr_Warning")); } else { VOP.Controls.MessageBoxEx.Show(MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_Msg_3"), (string)this.FindResource("ResStr_Warning")); } } } //if (isApplySuccess && encryption == (byte)EnumEncryptType.NoSecurity) // tb_pwd.Text = pwd; return(isApplySuccess); }
private void btn_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; if (btn.Name == "btnConnectOthAp") { btnConnectOthAp.Visibility = Visibility.Hidden; manualConnect.Visibility = Visibility.Visible; rowManual.Height = GridLength.Auto; autoConnect.Visibility = Visibility.Hidden; rowAuto.Height = new GridLength(0); wepKey0.IsChecked = true; m_bConnectOthApMode = true; chkDisplayPwd.IsChecked = false; wifiSetting.m_ssid = ""; wifiSetting.m_pwd = ""; wifiSetting.m_encryption = (byte)EnumEncryptType.WPA2_PSK_AES; wifiSetting.m_wepKeyId = 1; WiFiInfoRecord m_rec = null; AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); worker.InvokeMethod <WiFiInfoRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.GetWiFiInfo, this); if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { wifiSetting.m_ssid = m_rec.SSID; wifiSetting.m_pwd = m_rec.PWD; wifiSetting.m_encryption = (byte)m_rec.Encryption; wifiSetting.m_wepKeyId = m_rec.WepKeyId; } tbSSID.Text = wifiSetting.m_ssid; tbPwd.Text = wifiSetting.m_pwd; pbPwd.Password = wifiSetting.m_pwd; common.SelectItemByContext(cboEncrytion, wifiSetting.m_encryption); if (wifiSetting.m_wepKeyId == 0X01) { wepKey0.IsChecked = true; } else if (wifiSetting.m_wepKeyId == 0X02) { wepKey1.IsChecked = true; } else if (wifiSetting.m_wepKeyId == 0X03) { wepKey2.IsChecked = true; } else if (wifiSetting.m_wepKeyId == 0X04) { wepKey3.IsChecked = true; } UpdateControlsStatus(); scrollview.ScrollToTop(); } else if (btn.Name == "btnCancel") { btnConnectOthAp.Visibility = Visibility.Visible; manualConnect.Visibility = Visibility.Hidden; rowManual.Height = new GridLength(0); autoConnect.Visibility = Visibility.Visible; rowAuto.Height = GridLength.Auto; scrollview.ScrollToTop(); m_bConnectOthApMode = false; } else if (btn.Name == "btnConnect") { apply(); } }
private void OnbtnApplyClicked(object sender, RoutedEventArgs e) { bool isSuccess = false; if (m_rec == null) { return; } AsyncWorker worker = new AsyncWorker(this); if (btnDHCP.IsChecked == true) { m_rec.DHCPv6 = 1; } else { m_rec.DHCPv6 = 0; } if (btnManual.IsChecked == true) { m_rec.UseManualAddress = 1; } else { m_rec.UseManualAddress = 0; } IPAddress ip; if (IPAddress.TryParse(tb_ip.Text, out ip)) { if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) { if (ip.Equals(IPAddress.IPv6Loopback) || ip.Equals(IPAddress.IPv6None) || ip.IsIPv6LinkLocal || ip.IsIPv6Multicast) { isIPOK = false; } else { isIPOK = true; } } else { isIPOK = false; } } else { isIPOK = false; } if (btnManual.IsChecked == true) { if (isIPOK == true) { m_rec.IPManualAddress = tb_ip.Text; } else { VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_entered_IP_address__is_wrong__please_confirm_and_enter_again_"), (string)this.FindResource("ResStr_Warning")); tb_ip.Text = ""; tb_ip.Focus(); SetTextBoxBorder(tb_ip, true); return; } } else { m_rec.IPManualAddress = "::"; } uint maskValue; if (uint.TryParse(tb_PreSubMask.Text, out maskValue)) { if (maskValue >= 1 && maskValue <= 128) { isIPMaskOK = true; } else { isIPMaskOK = false; } } else { isIPMaskOK = false; } if (btnManual.IsChecked == true) { if (isIPMaskOK == true) { m_rec.ManualMask = maskValue; } else { VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_subnet_mask_input_error__please_input_again_after_confirmation"), (string)this.FindResource("ResStr_Warning")); tb_PreSubMask.Text = ""; tb_PreSubMask.Focus(); SetTextBoxBorder(tb_PreSubMask, true); return; } } else { m_rec.ManualMask = 1; } IPAddress ipGate; if (IPAddress.TryParse(tb_Gateway.Text, out ipGate)) { if (ipGate.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) { if (ipGate.Equals(IPAddress.IPv6Loopback) || ipGate.Equals(IPAddress.IPv6None) || ipGate.IsIPv6LinkLocal || ipGate.IsIPv6Multicast) { isGateOK = false; } else { isGateOK = true; } } else { isGateOK = false; } } else { isGateOK = false; } if (btnManual.IsChecked == true) { if (isGateOK == true) { m_rec.IPv6ManualGatewayAddress = tb_Gateway.Text; } else { VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_entered_Gateway_is_wrong__please_confirm_and_enter_again_"), (string)this.FindResource("ResStr_Warning")); tb_Gateway.Text = ""; tb_Gateway.Focus(); SetTextBoxBorder(tb_Gateway, true); return; } } else { m_rec.IPv6ManualGatewayAddress = "::"; } //uint gatewayMaskValue; //if (uint.TryParse(tb_GatewayPreSubMask.Text, out gatewayMaskValue)) //{ // if (gatewayMaskValue >= 0 && gatewayMaskValue <= 128) // { // isGateMaskOK = true; // } // else // { // isGateMaskOK = false; // } //} //else //{ // isGateMaskOK = false; //} //if (btnManual.IsChecked == true) //{ // if (isGateMaskOK == true) // { // m_rec.ManualGatewayAddressMask = gatewayMaskValue; // } // else // { // VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_subnet_mask_input_error__please_input_again_after_confirmation"), (string)this.FindResource("ResStr_Warning")); // tb_GatewayPreSubMask.Text = ""; // tb_GatewayPreSubMask.Focus(); // SetTextBoxBorder(tb_GatewayPreSubMask, true); // return; // } //} //else //{ // m_rec.ManualGatewayAddressMask = 0; //} if (worker.InvokeMethod <IPV6InfoRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.SetIpv6Info, this)) { if (m_rec.CmdResult == EnumCmdResult._ACK) { isSuccess = true; } else { isSuccess = false; } } else { isSuccess = false; } if (isSuccess) { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Msg_1"), Brushes.Black); DialogResult = true; } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Fail"), Brushes.Red); } }
public bool init_config(bool _bDisplayProgressBar = true) { bool isInitSuccess = false; m_is_init = true; m_leadingedge = 0; m_sidetoside = 0; m_imagedensity = 0; m_lowhumiditymode = 0; m_platecontrolmode = 2; m_primarycoolingmode = 0; StringBuilder fw_version = new StringBuilder(128); UserCfgRecord m_rec = null; AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); string strPrinterName = ((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter; // dll.GetFWInfo(strPrinterName, fw_version); if (_bDisplayProgressBar) { worker.InvokeMethod <UserCfgRecord>(strPrinterName, ref m_rec, DllMethodType.GetUserConfig, this); } else { m_rec = worker.GetUserCfg(strPrinterName); } if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { m_leadingedge = m_rec.LeadingEdge; m_sidetoside = m_rec.SideToSide; m_imagedensity = m_rec.ImageDensity; m_lowhumiditymode = m_rec.LowHumidityMode; m_platecontrolmode = m_rec.PlateControlMode; m_primarycoolingmode = m_rec.PrimaryCoolingMode; isInitSuccess = true; } spinCtlEdge.Value = m_leadingedge; spinCtlSide2Side.Value = m_sidetoside; spinCtlDensity.Value = m_imagedensity; if (1 == m_lowhumiditymode) { chkHumidity.IsChecked = true; } else { chkHumidity.IsChecked = false; } if (0 == m_platecontrolmode) { chkPlateControlMode.IsChecked = true; } else { chkPlateControlMode.IsChecked = false; } if (1 == m_primarycoolingmode) { chkCoolingMode.IsChecked = true; } else { chkCoolingMode.IsChecked = false; } return(isInitSuccess); }
public void init_config(bool _bDisplayProgressBar = true) { m_is_init = true; TcpIpSetting.m_mode_ipversion = 0; TcpIpSetting.m_mode_ipaddress = (byte)EnumIPType.DHCP; TcpIpSetting.m_ip0 = 0; TcpIpSetting.m_ip1 = 0; TcpIpSetting.m_ip2 = 0; TcpIpSetting.m_ip3 = 0; TcpIpSetting.m_mask0 = 0; TcpIpSetting.m_mask1 = 0; TcpIpSetting.m_mask2 = 0; TcpIpSetting.m_mask3 = 0; TcpIpSetting.m_gate0 = 0; TcpIpSetting.m_gate1 = 0; TcpIpSetting.m_gate2 = 0; TcpIpSetting.m_gate3 = 0; IpInfoRecord m_rec = null; AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); string strPrinterName = ((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter; m_printerName = strPrinterName; if (_bDisplayProgressBar) { worker.InvokeMethod <IpInfoRecord>(strPrinterName, ref m_rec, DllMethodType.GetIpInfo, this); } else { m_rec = worker.GetIpInfo(strPrinterName); } if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { byte[] arr = m_rec.Ip.GetAddressBytes(); TcpIpSetting.m_ip0 = arr[0]; TcpIpSetting.m_ip1 = arr[1]; TcpIpSetting.m_ip2 = arr[2]; TcpIpSetting.m_ip3 = arr[3]; arr = m_rec.Mask.GetAddressBytes(); TcpIpSetting.m_mask0 = arr[0]; TcpIpSetting.m_mask1 = arr[1]; TcpIpSetting.m_mask2 = arr[2]; TcpIpSetting.m_mask3 = arr[3]; arr = m_rec.Gate.GetAddressBytes(); TcpIpSetting.m_gate0 = arr[0]; TcpIpSetting.m_gate1 = arr[1]; TcpIpSetting.m_gate2 = arr[2]; TcpIpSetting.m_gate3 = arr[3]; TcpIpSetting.m_mode_ipversion = m_rec.IpVersion; TcpIpSetting.m_mode_ipaddress = (byte)m_rec.IpAddressMode; } string addr_ip = ""; string addr_mask = ""; string addr_gate = ""; addr_ip += TcpIpSetting.m_ip0.ToString(); addr_ip += "."; addr_ip += TcpIpSetting.m_ip1.ToString(); addr_ip += "."; addr_ip += TcpIpSetting.m_ip2.ToString(); addr_ip += "."; addr_ip += TcpIpSetting.m_ip3.ToString(); addr_mask += TcpIpSetting.m_mask0.ToString(); addr_mask += "."; addr_mask += TcpIpSetting.m_mask1.ToString(); addr_mask += "."; addr_mask += TcpIpSetting.m_mask2.ToString(); addr_mask += "."; addr_mask += TcpIpSetting.m_mask3.ToString(); addr_gate += TcpIpSetting.m_gate0.ToString(); addr_gate += "."; addr_gate += TcpIpSetting.m_gate1.ToString(); addr_gate += "."; addr_gate += TcpIpSetting.m_gate2.ToString(); addr_gate += "."; addr_gate += TcpIpSetting.m_gate3.ToString(); tb_ip.Text = addr_ip; tb_mask.Text = addr_mask; tb_gate.Text = addr_gate; rdbtn_dhcp.IsChecked = ((byte)EnumIPType.DHCP == TcpIpSetting.m_mode_ipaddress); //Add by KevinYin for BMS Bug 56149 begin rdbtn_static.IsChecked = !rdbtn_dhcp.IsChecked; //Add by KevinYin for BMS Bug 56149 end if (true == rdbtn_dhcp.IsChecked) { tb_ip.IsEnabled = false; tb_gate.IsEnabled = false; tb_mask.IsEnabled = false; } else { tb_ip.IsEnabled = true; tb_gate.IsEnabled = true; tb_mask.IsEnabled = true; } }
public bool apply() { bool isSuccess = false; // get network info string addr_ip = tb_ip.Text; string addr_mask = tb_mask.Text; string addr_gate = tb_gate.Text; enum_addr_mode addr_mode = enum_addr_mode.Manual; addr_mode = rdbtn_dhcp.IsChecked == true ? enum_addr_mode.DHCP : enum_addr_mode.Manual; // byte mode_ipversion = 0; // 0-ipv4,1-ipv6 byte mode_ipaddress = (byte)EnumIPType.DHCP; byte ip0 = 0; byte ip1 = 0; byte ip2 = 0; byte ip3 = 0; byte mask0 = 0; byte mask1 = 0; byte mask2 = 0; byte mask3 = 0; byte gate0 = 0; byte gate1 = 0; byte gate2 = 0; byte gate3 = 0; mode_ipaddress = (byte)addr_mode; bool isIPOK = ParseIP(addr_ip, ref ip0, ref ip1, ref ip2, ref ip3); bool isGateOK = ParseIP(addr_gate, ref gate0, ref gate1, ref gate2, ref gate3); bool isMaskOK = ParseNetworkMask(addr_mask, ref mask0, ref mask1, ref mask2, ref mask3); if (mode_ipaddress == (byte)enum_addr_mode.Manual) { if ((ip0 >= 224 || ip0 == 127)) { isIPOK = false; } if ((ip0 == 192 && ip0 == 168 && ip0 == 186 && ip0 == 1)) { isIPOK = false; } } if (isGateOK) { if ((gate0 >= 224 || gate0 == 127)) { isGateOK = false; } } if (mode_ipaddress == (byte)enum_addr_mode.Manual) { if (false == isIPOK) { VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_entered_IP_address__is_wrong__please_confirm_and_enter_again_"), (string)this.FindResource("ResStr_Warning")); tb_ip.Text = ""; tb_ip.Focus(); return(false); } else if (false == isGateOK) { VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_entered_Gateway_is_wrong__please_confirm_and_enter_again_"), (string)this.FindResource("ResStr_Warning")); tb_gate.Text = ""; tb_gate.Focus(); return(false); } else if (false == isMaskOK) { VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_subnet_mask_input_error__please_input_again_after_confirmation"), (string)this.FindResource("ResStr_Warning")); tb_mask.Text = ""; tb_mask.Focus(); return(false); } if (isIPOK && isMaskOK) { Int32 nIP = ip3 | (ip2 << 8) | (ip1 << 16) | (ip0 << 24); Int32 nSubMask = mask3 | (mask2 << 8) | (mask1 << 16) | (mask0 << 24); if (isIPOK && (nIP != 0x00000000 && nSubMask != 0x00000000) && (0xffffffff == ((nIP | nSubMask) & 0xffffffff) || (0x00000000 == ((~nSubMask) & nIP)))) { isIPOK = false; if (0xffffffff == ((nIP | nSubMask) & 0xffffffff)) { VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_combination_of_IP_address_and_subnet_mask_is_invalid__All_of_the_bits_in_the_host_address_portion_of_the_IP_address_are_set_to_1__Please_enter_a_valid_combination_of_IP_address_and_subnet_mask_"), (string)this.FindResource("ResStr_Warning")); tb_ip.Focus(); return(false); } else if ((0x00000000 == ((~nSubMask) & nIP))) { VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.Simple, Application.Current.MainWindow, (string)this.FindResource("ResStr_The_combination_of_IP_address_and_subnet_mask_is_invalid__All_of_the_bits_in_the_host_address_portion_of_the_IP_address_are_set_to_0__Please_enter_a_valid_combination_of_IP_address_and_subnet_mask_"), (string)this.FindResource("ResStr_Warning")); tb_ip.Focus(); return(false); } } } } if ((mode_ipaddress == (byte)enum_addr_mode.Manual && true == isIPOK && true == isMaskOK && true == isGateOK) || mode_ipaddress == (byte)enum_addr_mode.DHCP) { IpInfoRecord m_rec = new IpInfoRecord(); byte[] arr = new byte[4]; string strPrinterName = ((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter; m_rec.PrinterName = strPrinterName; m_rec.IpVersion = TcpIpSetting.m_mode_ipversion; m_rec.IpAddressMode = (EnumIPType)mode_ipaddress; arr[0] = ip0; arr[1] = ip1; arr[2] = ip2; arr[3] = ip3; m_rec.Ip = new IPAddress(arr); arr[0] = mask0; arr[1] = mask1; arr[2] = mask2; arr[3] = mask3; m_rec.Mask = new IPAddress(arr); arr[0] = gate0; arr[1] = gate1; arr[2] = gate2; arr[3] = gate3; m_rec.Gate = new IPAddress(arr); AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (worker.InvokeMethod <IpInfoRecord>(strPrinterName, ref m_rec, DllMethodType.SetIpInfo, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { // TcpIpSetting.m_mode_ipversion = mode_ipversion; TcpIpSetting.m_mode_ipaddress = mode_ipaddress; TcpIpSetting.m_ip0 = ip0; TcpIpSetting.m_ip1 = ip1; TcpIpSetting.m_ip2 = ip2; TcpIpSetting.m_ip3 = ip3; TcpIpSetting.m_mask0 = mask0; TcpIpSetting.m_mask1 = mask1; TcpIpSetting.m_mask2 = mask2; TcpIpSetting.m_mask3 = mask3; TcpIpSetting.m_gate0 = gate0; TcpIpSetting.m_gate1 = gate1; TcpIpSetting.m_gate2 = gate2; TcpIpSetting.m_gate3 = gate3; //Add by KevinYin for BMS Bug 55147 begin IPAddress ipAddress; IPAddress.TryParse(addr_ip, out ipAddress); if (null != ipAddress) { if (ipAddress.AddressFamily == AddressFamily.InterNetwork) { tb_ip.Text = ipAddress.ToString(); } } IPAddress.TryParse(addr_mask, out ipAddress); if (null != ipAddress) { if (ipAddress.AddressFamily == AddressFamily.InterNetwork) { tb_mask.Text = ipAddress.ToString(); } } IPAddress.TryParse(addr_gate, out ipAddress); if (null != ipAddress) { if (ipAddress.AddressFamily == AddressFamily.InterNetwork) { tb_gate.Text = ipAddress.ToString(); } } //Add by KevinYin for BMS Bug 55147 end isSuccess = true; } } } if (isSuccess) { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Msg_1"), Brushes.Black); } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Fail"), Brushes.Red); } return(isSuccess); }
public bool apply() { bool isApplySuccess = false; string pwd = ""; byte wepKeyId = 1; byte wifiEnable = 1; GetUIValues(out pwd, out wepKeyId); if (is_InputVailible()) { if (EncryptType == EnumEncryptType.NoSecurity) { pwd = ""; } else if (EncryptType == EnumEncryptType.WEP) { if (pwd.Length > 26) { pwd = pwd.Substring(1, 26); } } else { } byte wifiInit = 0; dll.GetWifiChangeStatus(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref wifiInit); VOP.MainWindow.m_byWifiInitStatus = wifiInit; WiFiInfoRecord m_rec = new WiFiInfoRecord(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, wifiEnable, 0, SSIDText, (EncryptType != EnumEncryptType.NoSecurity) ? pwd : "", EncryptType, wepKeyId); AsyncWorker worker = new AsyncWorker(Application.Current.MainWindow); if (worker.InvokeMethod <WiFiInfoRecord>(((MainWindow)App.Current.MainWindow).statusPanelPage.m_selectedPrinter, ref m_rec, DllMethodType.SetWiFiInfo, this)) { if (null != m_rec && m_rec.CmdResult == EnumCmdResult._ACK) { isApplySuccess = true; } } } if (isApplySuccess) { Connected = true; EncryptionText = (string)this.FindResource("ResStr_Connected"); tbPwd.Text = pwd; pbPwd.Password = pwd; } if (isApplySuccess) { if (wifiEnable != VOP.MainWindow.m_byWifiInitStatus) { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Msg_1"), Brushes.Black); } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Successfully_"), Brushes.Black); } } else { ((MainWindow)App.Current.MainWindow).statusPanelPage.ShowMessage((string)this.FindResource("ResStr_Setting_Fail"), Brushes.Red); } return(isApplySuccess); }