/// <summary> /// Must unregister registered hot keys before destroying the native driver window. /// </summary> public void Dispose() { if (isDisposed) { return; } if (window != null) { foreach (HotKey key in keys.Values) { KeyInterops.UnregisterHotKey(window.Handle, key.HotId); } } if (keys != null) { keys.Clear(); keys = null; } if (window != null) { window.KeyPressed -= DoKeyPressed; window.Dispose(); window = null; } isDisposed = true; GC.SuppressFinalize(this); }
private async void btnLogin_Click(object sender, RoutedEventArgs e) { //var loginModel = new LoginModel() {Username = txtUserName.Text, Password = pwbPassword.Password}; HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://moggeapi.azurewebsites.net/"); //client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); Helpers.CredentialHelper.Credential = Convert.ToBase64String(Encoding.UTF8.GetBytes(txtUserName.Text + ":" + pwbPassword.Password)); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Helpers.CredentialHelper.Credential); var response = await client.GetAsync("api/user/getaccesslevel"); if (response.IsSuccessStatusCode) { var user = JsonConvert.DeserializeObject <UserModel>(await response.Content.ReadAsStringAsync()); if (user.IsAdmin) { var window = new AdminStartWindow(); window.DataContext = new AdminStartViewModel(user); window.Show(); this.Close(); } else { var window = new DriverWindow(); window.DataContext = new DriverViewModel(user); window.Show(); this.Close(); } } }
//======================================================================================== // Constructor //======================================================================================== /// <summary> /// Initialize a new instance, creating an internal driver window and loading /// initial hot key definitions. /// </summary> public KeyManager() { IsEnabled = true; keys = new Dictionary <HotKeyAction, HotKey>(); window = new DriverWindow(); window.KeyPressed += DoKeyPressed; dataPath = Path.Combine(PathHelper.ApplicationDataPath, Resx.FilenameHotkeys); Load(); }
//======================================================================================== // Constructor //======================================================================================== /// <summary> /// Initialize a new instance, creating an internal driver window and loading /// initial hot key definitions. /// </summary> public KeyManager() { this.IsEnabled = true; this.keys = new Dictionary<HotKeyAction, HotKey>(); this.window = new DriverWindow(); this.window.KeyPressed += new HKEventHandler(DoKeyPressed); this.dataPath = Path.Combine( PathHelper.ApplicationDataPath, Resx.FilenameHotkeys); Load(); }
/// <summary> /// Must shutdown the driver window. /// </summary> public void Dispose() { if (!isDisposed) { if (window != null) { window.StateChanged -= new UsbStateChangedEventHandler(DoStateChanged); window.Dispose(); window = null; } isDisposed = true; GC.SuppressFinalize(this); } }
/// <summary> /// Must shutdown the driver window. /// </summary> public void Dispose() { if (!isDisposed) { if (window != null) { window.StateChanged -= DoStateChanged; window.Dispose(); window = null; } isDisposed = true; GC.SuppressFinalize(this); } }
//======================================================================================== // Constructor //======================================================================================== /// <summary> /// Initialize a new instance. /// </summary> public UsbManager() { this.window = null; this.handler = null; this.isDisposed = false; }
public void DriverLogin() { var window = new DriverWindow(); window.DataContext = new DriverViewModel(new UserModel() {IsAdmin = false, Id = 9999, Firstname = "Charlie", Lastname = "Hepbo"}); window.Show(); }
/// <summary> /// Must unregister registered hot keys before destroying the native driver window. /// </summary> public void Dispose() { if (!isDisposed) { if (window != null) { foreach (HotKey key in keys.Values) { KeyInterops.UnregisterHotKey(window.Handle, key.HotID); } } if (keys != null) { keys.Clear(); keys = null; } if (window != null) { window.KeyPressed -= new HKEventHandler(DoKeyPressed); window.Dispose(); window = null; } isDisposed = true; GC.SuppressFinalize(this); } }
virtual public void Minimize() { DriverWindow.Minimize(); }
virtual public void Maximize() { DriverWindow.Maximize(); }
virtual public void Close(object response) { DriverWindow.Close(response); }
private void btnEnter_Click(object sender, RoutedEventArgs e) { if (TBoxLog.Text == null) { MessageBox.Show("Введите данные"); } else if (TBoxLog.Text == "admin" & TBoxPass.Password == password) { AdminWindow AW = new AdminWindow(); AW.mainWindow = this; AW.connect = mainConnect; TBoxPass.Password = TBoxLog.Text = ""; AW.ShowDialog(); } else { try { if (TBoxLog.Text.Length == 11) { cmmnd.Connection = mainConnect; cmmnd.CommandText = "select Client_ID from Client where C_Phone_number = " + TBoxLog.Text.ToString(); SqlDataReader Reader = cmmnd.ExecuteReader(); if (!Reader.Read()) { throw new Exception(); } ClientWindow CW = new ClientWindow() { ClientID = int.Parse(Reader[0].ToString()) }; CW.mainWindow = this; TBoxLog.Text = TBoxPass.Password = ""; CW.connect = mainConnect; Reader.Close(); CW.ShowDialog(); } else if (TBoxLog.Text.Length == 12) { cmmnd.Connection = mainConnect; cmmnd.CommandText = "select Driver_ID from Driver where Licence_number = " + "'" + TBoxLog.Text.ToString() + "'"; SqlDataReader Reader = cmmnd.ExecuteReader(); if (!Reader.Read()) { throw new Exception(); } DriverWindow DW = new DriverWindow() { DriverID = int.Parse(Reader[0].ToString()) }; DW.mainWindow = this; TBoxLog.Text = TBoxPass.Password = ""; DW.connect = mainConnect; Reader.Close(); DW.ShowDialog(); } else { throw new Exception(); } } catch { MessageBox.Show("Проверьте введенные данные"); TBoxLog.Text = TBoxPass.Password = ""; } } }