コード例 #1
0
        public MainWindow(OaIni oaIni)
        {
            InitializeComponent();
            _oaIni = oaIni;
            // Set the startup position and the startup state to "not visible"
            SetWindowToBottomRightOfScreen();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);

            // Locate these storyboards and "cache" them - we only ever want to find these once for performance reasons
            gridFadeOutStoryBoard = (Storyboard)this.TryFindResource("gridFadeOutStoryBoard");
            gridFadeOutStoryBoard.Completed += new EventHandler(gridFadeOutStoryBoard_Completed);
            gridFadeInStoryBoard = (Storyboard)TryFindResource("gridFadeInStoryBoard");
            gridFadeInStoryBoard.Completed += new EventHandler(gridFadeInStoryBoard_Completed);
            if (_connect())
            {
                _login();
                _sendMessage("Version");
            }
        }
コード例 #2
0
ファイル: Login.xaml.cs プロジェクト: IvanYang/ApolloOa2011
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            lblMessages.Content = null;
            if (string.IsNullOrWhiteSpace(txtJobNo.Text) || string.IsNullOrWhiteSpace(txtPassword.Password))
            {
                if (string.IsNullOrWhiteSpace(txtJobNo.Text))
                {
                    lblMessages.Content = "请输入用户名;";
                }
                if (string.IsNullOrWhiteSpace(txtPassword.Password))
                {
                    lblMessages.Content += "请输入密码;";
                }
            }
            else
            {
                OaIni oaIni = new OaIni
                                  {
                                      JobNo = txtJobNo.Text,
                                      Password = txtPassword.Password,
                                      IsSavePassword = chkPassword.IsChecked == true,
                                      IsAutoLog = chkLogin.IsChecked == true,
                                      ServerIp = cbServerIp.SelectedIndex == 0 ? "192.168.1.80" : "113.105.185.82",
                                      Port = 8885
                                  };

                var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "oa.ini");
                bool isExists = System.IO.File.Exists(path);
                if (isExists)
                {
                    System.IO.File.Delete(path);
                }
                using (StreamWriter sw = System.IO.File.CreateText(path))
                {
                    sw.WriteLine(JavaScriptConvert.SerializeObject(oaIni));
                }
                MainWindow mainWindow = new MainWindow(oaIni);
                mainWindow.Show();
                this.Close();
            }
        }