예제 #1
0
        /// <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);
        }
예제 #2
0
        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();
                }
            }
        }
예제 #3
0
        //========================================================================================
        // 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();
        }
예제 #4
0
        //========================================================================================
        // 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();
        }
예제 #5
0
        /// <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);
            }
        }
예제 #6
0
        /// <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);
            }
        }
예제 #7
0
        //========================================================================================
        // Constructor
        //========================================================================================

        /// <summary>
        /// Initialize a new instance.
        /// </summary>

        public UsbManager()
        {
            this.window     = null;
            this.handler    = null;
            this.isDisposed = false;
        }
예제 #8
0
        /// <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);
            }
        }
예제 #9
0
 //========================================================================================
 // Constructor
 //========================================================================================
 /// <summary>
 /// Initialize a new instance.
 /// </summary>
 public UsbManager()
 {
     this.window = null;
     this.handler = null;
     this.isDisposed = false;
 }
예제 #10
0
 public void DriverLogin()
 {
     var window = new DriverWindow();
     window.DataContext = new DriverViewModel(new UserModel() {IsAdmin = false, Id = 9999, Firstname = "Charlie", Lastname = "Hepbo"});
     window.Show();
 }
예제 #11
0
        /// <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);
            }
        }
예제 #12
0
파일: Window.cs 프로젝트: ventor3000/guppy
 virtual public void Minimize()
 {
     DriverWindow.Minimize();
 }
예제 #13
0
파일: Window.cs 프로젝트: ventor3000/guppy
 virtual public void Maximize()
 {
     DriverWindow.Maximize();
 }
예제 #14
0
파일: Window.cs 프로젝트: ventor3000/guppy
 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 = "";
                }
            }
        }