예제 #1
0
        public MainWindow()
        {
            _app = App.CurrentApp;
            InitializeComponent();
            _dashboardViewModel = (Dashboard)FindResource("DashboardViewModel");
            _searchViewModel    = (SearchDescriptor)FindResource("SearchViewModel");
            var authConfig = _configurationManager.GetAuthConfig();

            _dashboardViewModel.UserName = authConfig.UserName;
            ExpirationDate.SelectedDate  = DateTime.Now.AddDays(-1);

            if (string.IsNullOrEmpty(_dashboardViewModel.UserName))
            {
                _dashboardViewModel.LoginInfoEnabled = true;
                UserNameBox.Focus();
            }
            else if (string.IsNullOrEmpty(authConfig.AuthToken))
            {
                _dashboardViewModel.LoginInfoEnabled = true;
                Password.Focus();
            }
            else
            {
                Password.Password = "******";
                Login.Content     = "退出";
            }
            VersionRun.Text = CurrentVersionBlock.Text = GetVersionInfo();
        }
예제 #2
0
        public LoginPage()
        {
            InitializeComponent();
            _SerializationService = Template10.Services.SerializationService.SerializationService.Json;

            Loaded += (sender, args) =>
            {
                if (string.IsNullOrEmpty(UserNameBox.Text))
                {
                    UserNameBox.Focus(FocusState.Keyboard);
                }
                else
                {
                    PasswordBox.Focus(FocusState.Keyboard);
                }
            };

            KeyUp += (sender, args) =>
            {
                if (args.Key == VirtualKey.Enter)
                {
                    LoginButton_OnClick(sender, args);
                }
            };
        }
예제 #3
0
 public Login()
 {
     InitializeComponent();
     UserNameBox.Focus();
     UserName = null;
     Password = null;
 }
예제 #4
0
        private void ConnectBtn_Click(object sender, EventArgs e)
        {
            myFTP        = new MyFTP();
            myFTP.Server = ServerBox.Text.Trim();
            if (myFTP.Server.Length == 0)
            {
                ServerWarning.Visible = true;
                ServerBox.Focus();
                return;
            }
            ServerWarning.Visible = false;
            myFTP.UserName        = UserNameBox.Text.Trim();
            if (myFTP.UserName.Length == 0)
            {
                UserWarning.Visible = true;
                UserNameBox.Focus();
                return;
            }
            UserWarning.Visible = false;
            myFTP.Password      = PwdBox.Text.Trim();
            try { myFTP.Port = int.Parse(PortBox.Text); }catch { PortWarning.Visible = true; PortBoxLabel.Focus(); return; }
            PortWarning.Visible = false;

            RemoteTree.Nodes.Clear();
            AddLog($"正在尝试连接 {myFTP.Server}:{myFTP.Port}......");
            try { myFTP.Connect(); } catch (Exception ex) { AddLog("错误: " + ex.Message, 1); return; }
            AddLog($"FTP已连接到 {myFTP.Server}:{myFTP.Port}, 成功登录!");
            Text = $"极简FTP [{myFTP.Server}:{myFTP.Port}]";
            PreLoadRemoteTree();
        }
예제 #5
0
        public LoginPage()
        {
            InitializeComponent();

            ViewModel = new LoginViewModel();
            ViewModel.Authenticated += new System.EventHandler(User_Authenticated);
            DataContext              = ViewModel;
            UserNameBox.Focus();
        }
예제 #6
0
        public StartUpForm()
        {
            InitializeComponent();

            //AB - Creates a random number between 100 and 999 and displays it as the current number of online users.
            Random r = new Random();

            label3.Text = Convert.ToString(r.Next(100, 1000));

            //AB & ABo - Cursor starts in the text box when the form is launched.
            UserNameBox.SelectionStart = UserNameBox.Text.Length;
            UserNameBox.Focus();
        }
예제 #7
0
        private void LoginPage_Loaded(object sender, RoutedEventArgs e)
        {
            Pivot.Background = (ImageBrush)App.Current.Resources["BackgroundBrush"];
            var settings = IsolatedStorageSettings.ApplicationSettings;

            if (settings.Contains("UserName"))
            {
                UserNameBox.Text       = (string)settings["UserName"];
                UserNameBox.Foreground = new SolidColorBrush(Colors.Black);
                FakePasswordBox.Focus();
                settings.Remove("UserName");
                settings.Save();
            }
            else
            {
                UserNameBox.Focus();
            }
        }
        /// <summary>
        /// LogIn button click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LogInButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(UserNameBox.Text))
            {
                errorMsg = new AlertOK("Message", "Please enter your user name!");
                errorMsg.ShowDialog();

                //MessageBox.Show("Please enter your user name!", "Message", MessageBoxButton.OK, MessageBoxImage.Warning);
                UserNameBox.Focus();
                return;
            }
            try
            {
                using (HotelManagementSystemEntities test = new HotelManagementSystemEntities())
                {
                    var query = from o in test.LogIns where o.UserName == UserNameBox.Text && o.PassWord == PassWordBox.Password select o;
                    if (query.SingleOrDefault() != null)
                    {
                        MainWindow MainHome = new MainWindow();

                        this.Close();
                        //Application.Current.Shutdown();

                        MainHome.ShowDialog();
                        // this.LogInPage.Close();
                    }
                    else
                    {
                        errorMsg = new AlertOK("Message", "Your user-name or password is incorrect.");
                        errorMsg.ShowDialog();
                        // MessageBox.Show("Your user-name or password is incorrect.","Message",MessageBoxButton.OK,MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                errorMsg = new AlertOK("Message", ex.Message);
                errorMsg.ShowDialog();
                //MessageBox.Show(ex.Message,"Message",MessageBoxButton.OK,MessageBoxImage.Error);
            }
        }
 public LogIn()
 {
     InitializeComponent();
     UserNameBox.Focus();
 }
예제 #10
0
        private async void Signin_OnClick(object sender, RoutedEventArgs e)
        {
            if (_dashboardViewModel.LoginInfoEnabled)
            {
                Login.IsEnabled = false;
                _dashboardViewModel.LoginInfoEnabled = false;

                var pageFetcher = ComponentFactory.GetPageFetcher();
                var isSignedIn  = false;
                try
                {
                    var name     = _dashboardViewModel.UserName;
                    var password = Password.Password;
                    if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(password))
                    {
                        //TODO:Use wpf data validation
                        MessageBox.Show("别瞎输、瞎点。");
                        return;
                    }
                    SigninProgress.Visibility = Visibility.Visible;
                    var authToken = await pageFetcher.Signin(name, password);

                    isSignedIn = true;
                    _configurationManager.SaveAuthConfig(new AuthConfig {
                        UserName = name, AuthToken = authToken
                    });
                    Password.Password = "******";
                    _dashboardViewModel.LoginInfoEnabled = false;
                    Login.Content = "退出";
                }
                catch (CannotSigninException cse)
                {
                    MessageBox.Show(string.IsNullOrEmpty(cse.Message) ? "登录不了,可能是网络不行。" : cse.Message);
                }
                finally
                {
                    Login.IsEnabled           = true;
                    SigninProgress.Visibility = Visibility.Hidden;
                    if (!isSignedIn)
                    {
                        _dashboardViewModel.LoginInfoEnabled = true;
                        if (string.IsNullOrWhiteSpace(_dashboardViewModel.UserName))
                        {
                            UserNameBox.Focus();
                        }
                        else
                        {
                            Password.Focus();
                        }
                    }
                }
            }
            else
            {
                ComponentFactory.GetPageFetcher().Signout();
                _configurationManager.SaveAuthConfig(new AuthConfig {
                    UserName = _dashboardViewModel.UserName, AuthToken = ""
                });
                _dashboardViewModel.LoginInfoEnabled = true;
                Password.Clear();
                Password.Focus();
                Login.Content = "登录";
            }
        }
예제 #11
0
        public SignInWindow()
        {
            InitializeComponent();

            UserNameBox.Focus();
        }