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); } }
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(); } }
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); }
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); }