Esempio n. 1
0
        private void PostSite_Login(object sender, LoginEventArgs e)
        {
            Action a = () =>
            {
                this.Cursor = Cursors.Arrow;

                if (this.leechClient.PostSite.User.IsLoggedIn)
                {
                    this.txtPostLogin.IsEnabled = this.txtPostPasswrd.IsEnabled
                        = this.txtBaseUrl.IsEnabled
                        = this.lstForumType.IsEnabled
                        = false;
                    this.btnPostLogin.Content = "Logout";
                    this.imgPost.Source = new BitmapImage(new Uri("Images/LoggedIn.png", UriKind.Relative));

                    Cfg.Default.PostPassword = this.txtPostPasswrd.Password;
                }
                else
                {
                    var msgResult = MessageBox.Show(
                        Res.MsgLoginFailed,
                        "Log-in Failed",
                        MessageBoxButton.YesNoCancel,
                        MessageBoxImage.Error,
                        MessageBoxResult.No
                    );

                    if (msgResult == MessageBoxResult.Yes)
                    {
                        string url = this.leechClient.PostSite.BaseUrl + this.leechClient.PostSite.LoginPath;
                        string usr = this.leechClient.PostSite.User.Username;
                        string pswd = this.leechClient.PostSite.User.Password;

                        var win = new ManualLoginWindow(url, usr, pswd);
                        win.Owner = this;
                        var result = win.ShowDialog();

                        if (result != null && result != false)
                        {
                            this.leechClient.PostSite.User.IsLoggedIn = true;
                            this.leechClient.PostSite.User.Cookies = win.CollectedCookies;

                            this.txtPostLogin.IsEnabled = this.txtPostPasswrd.IsEnabled
                                = this.txtBaseUrl.IsEnabled
                                = this.lstForumType.IsEnabled
                                = false;
                            this.btnPostLogin.Content = "Logout";
                            this.imgPost.Source = new BitmapImage(new Uri("Images/LoggedIn.png", UriKind.Relative));
                        }
                    }
                }

                if (this.leechClient.Reader.Type.User.IsLoggedIn && this.leechClient.PostSite.User.IsLoggedIn)
                {
                    this.btnStartLeeching.IsEnabled = true;
                    this.txtStatus.Text = "Ready...";
                }
                else
                {
                    this.btnStartLeeching.IsEnabled = false;
                    this.txtStatus.Text = "Waiting for both Post and Leech login...";
                }
            };

            this.Dispatcher.Invoke(a, DispatcherPriority.Normal);
        }
Esempio n. 2
0
        private void LeechSite_Login(object sender, LoginEventArgs e)
        {
            Action a = () =>
            {
                this.Cursor = Cursors.Arrow;

                if (this.leechClient.Reader.Type.User.IsLoggedIn)
                {
                    this.cbLeechSite.IsEnabled                     = this.txtLeechLogin.IsEnabled
                                                                   = this.txtLeechPasswrd.IsEnabled
                                                                   = this.btnCreateAccount.IsEnabled
                                                                   = false;
                    this.btnLeechLogin.Content                     = "Logout";
                    this.imgLeech.Source = new BitmapImage(new Uri("Images/LoggedIn.png", UriKind.Relative));

                    Cfg.Default.LeechPassword = this.txtLeechPasswrd.Password;
                }
                else
                {
                    var msgResult = MessageBox.Show(
                        Res.MsgLoginFailed,
                        "Log-in Failed",
                        MessageBoxButton.YesNoCancel,
                        MessageBoxImage.Error,
                        MessageBoxResult.No
                        );

                    if (msgResult == MessageBoxResult.Yes)
                    {
                        string url  = this.leechClient.Reader.Type.BaseUrl + this.leechClient.Reader.Type.LoginPath;
                        string usr  = this.leechClient.Reader.Type.User.Username;
                        string pswd = this.leechClient.Reader.Type.User.Password;

                        var win = new ManualLoginWindow(url, usr, pswd);
                        win.Owner = this;
                        var result = win.ShowDialog();

                        if (result != null && result != false)
                        {
                            this.leechClient.Reader.Type.User.IsLoggedIn = true;
                            this.leechClient.Reader.Type.User.Cookies    = win.CollectedCookies;

                            this.cbLeechSite.IsEnabled                     = this.txtLeechLogin.IsEnabled
                                                                           = this.txtLeechPasswrd.IsEnabled
                                                                           = this.btnCreateAccount.IsEnabled
                                                                           = false;
                            this.btnLeechLogin.Content                     = "Logout";
                            this.imgLeech.Source = new BitmapImage(new Uri("Images/LoggedIn.png", UriKind.Relative));
                        }
                    }
                }

                if (this.leechClient.Reader.Type.User.IsLoggedIn && this.leechClient.PostSite.User.IsLoggedIn)
                {
                    this.btnStartLeeching.IsEnabled = true;
                    this.txtStatus.Text             = "Ready...";
                }
                else
                {
                    this.btnStartLeeching.IsEnabled = false;
                    this.txtStatus.Text             = "Waiting for both Post and Leech login...";
                }
            };

            this.Dispatcher.Invoke(a, DispatcherPriority.Normal);
        }