/// <summary> /// Auto login if User Credentials exists in Config file. /// if no Data show Login Form /// </summary> private void AutoLogin() { bool accountExists = false; var currentForumAccount = new ForumAccount(); foreach (var forumAccount in CacheController.Instance().UserSettings.ForumsAccount.Where( forumAccount => forumAccount.ForumURL.Equals(CacheController.Instance().UserSettings.CurrentForumUrl)).Where( forumAccount => !string.IsNullOrEmpty(forumAccount.UserName) && !string.IsNullOrEmpty(forumAccount.UserPassWord))) { currentForumAccount = forumAccount; accountExists = true; } if (accountExists) { if (currentForumAccount.GuestAccount) { this.cameThroughCorrectLogin = true; } else { LoginManager lgnMgr = new LoginManager(currentForumAccount.UserName, currentForumAccount.UserPassWord); if (lgnMgr.DoLogin(CacheController.Instance().UserSettings.CurrentForumUrl)) { this.cameThroughCorrectLogin = true; } else { Login frmLgn = new Login(); frmLgn.ShowDialog(this); DialogResult result = TopMostMessageBox.Show( this._ResourceManager.GetString("mbExit"), this._ResourceManager.GetString("mbExitTtl"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Application.Exit(); } } } } else { Login frmLgn = new Login(); frmLgn.ShowDialog(this); Application.Exit(); } }
/// <summary> /// Go To the Login Dialog to add a New Forum Account /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void AddNewAccount_Click(object sender, EventArgs e) { this.Visible = false; Login frmLgn = new Login(); frmLgn.ShowDialog(this); this.CheckAccountMenu(); this.SwitchAccount(null); this.Visible = true; }
/// <summary> /// Switches the current forum account to the forum Url /// </summary> /// <param name="forumUrl">The forum URL.</param> private void SwitchCurrentForumAccount(string forumUrl) { ForumAccount currentAccount = null; foreach (var forumAccount in CacheController.Instance().UserSettings.ForumsAccount.Where(forumAccount => forumUrl.StartsWith(forumAccount.ForumURL)).Where( forumAccount => !string.IsNullOrEmpty(forumAccount.UserName) && !string.IsNullOrEmpty(forumAccount.UserPassWord))) { currentAccount = forumAccount; } if (currentAccount != null) { CacheController.Instance().UserSettings.CurrentForumUrl = currentAccount.ForumURL; CacheController.Instance().UserSettings.CurrentUserName = currentAccount.UserName; if (currentAccount.GuestAccount) { this.cameThroughCorrectLogin = true; this.CheckAccountMenu(); } else { var lgnMgr = new LoginManager(currentAccount.UserName, currentAccount.UserPassWord); if (lgnMgr.DoLogin(CacheController.Instance().UserSettings.CurrentForumUrl)) { this.cameThroughCorrectLogin = true; this.CheckAccountMenu(); } else { this.Visible = false; Login frmLgn = new Login(); frmLgn.ShowDialog(this); this.Visible = true; } } } else { return; } var header = this._ResourceManager.GetString("ttlHeader"); #if (PGRIPPER) Text = string.Format( "PG-Ripper {0}.{1}.{2}{3}{4}", Assembly.GetExecutingAssembly().GetName().Version.Major.ToString("0"), Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString("0"), Assembly.GetExecutingAssembly().GetName().Version.Build.ToString("0"), Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString("0"), string.Format("{0}{1}\" @ {2} ]", header, CacheController.Instance().UserSettings.CurrentUserName, CacheController.Instance().UserSettings.CurrentForumUrl)); #elif (PGRIPPERX) Text = string.Format("PG-Ripper X {0}.{1}.{2}{3}{4}", Assembly.GetExecutingAssembly().GetName().Version.Major.ToString("0"), Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString("0"), Assembly.GetExecutingAssembly().GetName().Version.Build.ToString("0"), Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString("0"), string.Format("{0}{1}\" @ {2} ]", header, CacheController.Instance().UserSettings.CurrentUserName, CacheController.Instance().UserSettings.CurrentForumUrl)); #else Text = string.Format( "PG-Ripper {0}.{1}.{2}{3}{4}", Assembly.GetExecutingAssembly().GetName().Version.Major.ToString("0"), Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString("0"), Assembly.GetExecutingAssembly().GetName().Version.Build.ToString("0"), Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString("0"), string.Format( "{0}{1}\" @ {2} ]", header, CacheController.Instance().UserSettings.CurrentUserName, CacheController.Instance().UserSettings.CurrentForumUrl)); #endif }
/// <summary> /// Loads the settings. /// </summary> private void LoadSettings() { CacheController.Instance().UserSettings = SettingsHelper.LoadSettings(); // Max. Threads CacheController.Instance().UserSettings.ThreadLimit = CacheController.Instance().UserSettings.ThreadLimit == -1 ? 3 : CacheController.Instance().UserSettings.ThreadLimit; ThreadManager.GetInstance().SetThreadThreshHold(CacheController.Instance().UserSettings.ThreadLimit); if (string.IsNullOrEmpty(CacheController.Instance().UserSettings.DownloadFolder)) { CacheController.Instance().UserSettings.DownloadFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); this.DownloadFolder.Text = CacheController.Instance().UserSettings.DownloadFolder; SettingsHelper.SaveSettings(CacheController.Instance().UserSettings); } this.DownloadFolder.Text = CacheController.Instance().UserSettings.DownloadFolder; // Load "Download Options" try { this.comboBox1.SelectedIndex = Convert.ToInt32(CacheController.Instance().UserSettings.DownloadOptions); } catch (Exception) { CacheController.Instance().UserSettings.DownloadOptions = "0"; this.comboBox1.SelectedIndex = 0; } this.TopMost = CacheController.Instance().UserSettings.TopMost; // Load Language Setting try { switch (CacheController.Instance().UserSettings.Language) { case "de-DE": this._ResourceManager = new ResourceManager( "Ripper.Languages.german", Assembly.GetExecutingAssembly()); break; case "fr-FR": this._ResourceManager = new ResourceManager( "Ripper.Languages.french", Assembly.GetExecutingAssembly()); break; case "en-EN": this._ResourceManager = new ResourceManager( "Ripper.Languages.english", Assembly.GetExecutingAssembly()); break; default: this._ResourceManager = new ResourceManager( "Ripper.Languages.english", Assembly.GetExecutingAssembly()); break; } this.AdjustCulture(); } catch (Exception) { this._ResourceManager = new ResourceManager( "Ripper.Languages.english", Assembly.GetExecutingAssembly()); } switch (CacheController.Instance().UserSettings.AfterDownloads) { case 0: this.doNothingToolStripMenuItem.Checked = true; this.closeRipperToolStripMenuItem.Checked = false; break; case 1: this.doNothingToolStripMenuItem.Checked = false; this.closeRipperToolStripMenuItem.Checked = true; break; } // Load Show Last Download Image this.groupBox4.Visible = CacheController.Instance().UserSettings.ShowLastDownloaded; this.showLastImageToolStripMenuItem.Checked = CacheController.Instance().UserSettings.ShowLastDownloaded; this.useCliboardMonitoringToolStripMenuItem.Checked = CacheController.Instance().UserSettings.ClipBWatch; try { var accountNotFound = CacheController.Instance().UserSettings.ForumsAccount.Where( forumAccount => forumAccount.ForumURL.Equals(CacheController.Instance().UserSettings.CurrentForumUrl)).Any( forumAccount => !string.IsNullOrEmpty(forumAccount.UserName) && !string.IsNullOrEmpty(forumAccount.UserPassWord)); if (accountNotFound) { return; } var frmLgn = new Login(); frmLgn.ShowDialog(this); if (this.cameThroughCorrectLogin) { return; } var result = TopMostMessageBox.Show( this._ResourceManager.GetString("mbExit"), this._ResourceManager.GetString("mbExitTtl"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Application.Exit(); } } catch (Exception) { Login frmLgn = new Login(); frmLgn.ShowDialog(this); if (this.cameThroughCorrectLogin) { this.CheckAccountMenu(); return; } var result = TopMostMessageBox.Show( this._ResourceManager.GetString("mbExit"), this._ResourceManager.GetString("mbExitTtl"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Application.Exit(); } } }
/// <summary> /// Loads All Settings /// </summary> public void LoadSettings() { // Load Forum Url try { if (!string.IsNullOrEmpty(SettingsHelper.LoadSetting("ForumURL"))) { CacheController.Instance().UserSettings.ForumURL = SettingsHelper.LoadSetting("ForumURL"); } else { CacheController.Instance().UserSettings.ForumURL = "http://vipergirls.to/"; SettingsHelper.SaveSetting("ForumURL", CacheController.Instance().UserSettings.ForumURL); } } catch (Exception) { CacheController.Instance().UserSettings.ForumURL = "http://vipergirls.to/"; SettingsHelper.SaveSetting("ForumURL", CacheController.Instance().UserSettings.ForumURL); } // Load "Offline Modus" Setting try { CacheController.Instance().UserSettings.OfflMode = bool.Parse(SettingsHelper.LoadSetting("OfflineModus")); } catch (Exception) { CacheController.Instance().UserSettings.OfflMode = false; } // Load "Firefox Exension Enabled" Setting try { CacheController.Instance().UserSettings.Extension = bool.Parse(SettingsHelper.LoadSetting("FFExtension")); } catch (Exception) { CacheController.Instance().UserSettings.Extension = false; } try { if (!string.IsNullOrEmpty(SettingsHelper.LoadSetting("TxtFolder"))) { CacheController.Instance().UserSettings.TxtFolder = SettingsHelper.LoadSetting("TxtFolder"); } } catch (Exception) { CacheController.Instance().UserSettings.TxtFolder = null; } // Load "Clipboard Watch" Setting try { CacheController.Instance().UserSettings.ClipBWatch = bool.Parse(SettingsHelper.LoadSetting("clipBoardWatch")); } catch (Exception) { CacheController.Instance().UserSettings.ClipBWatch = true; } try { CacheController.Instance().UserSettings.ShowPopUps = bool.Parse(SettingsHelper.LoadSetting("Show Popups")); } catch (Exception) { CacheController.Instance().UserSettings.ShowPopUps = true; } try { CacheController.Instance().UserSettings.SubDirs = bool.Parse(SettingsHelper.LoadSetting("SubDirs")); } catch (Exception) { CacheController.Instance().UserSettings.SubDirs = true; } try { CacheController.Instance().UserSettings.AutoThank = bool.Parse(SettingsHelper.LoadSetting("Auto TK Button")); } catch (Exception) { CacheController.Instance().UserSettings.AutoThank = false; } try { CacheController.Instance().UserSettings.DownInSepFolder = bool.Parse(SettingsHelper.LoadSetting("DownInSepFolder")); } catch (Exception) { CacheController.Instance().UserSettings.DownInSepFolder = true; } try { CacheController.Instance().UserSettings.SavePids = bool.Parse(SettingsHelper.LoadSetting("SaveRippedPosts")); } catch (Exception) { CacheController.Instance().UserSettings.SavePids = true; } try { CacheController.Instance().UserSettings.ShowCompletePopUp = bool.Parse(SettingsHelper.LoadSetting("Show Downloads Complete PopUp")); } catch (Exception) { CacheController.Instance().UserSettings.ShowCompletePopUp = true; } // min. Image Count for Thanks try { CacheController.Instance().UserSettings.MinImageCount = !string.IsNullOrEmpty(SettingsHelper.LoadSetting("minImageCountThanks")) ? int.Parse(SettingsHelper.LoadSetting("minImageCountThanks")) : 3; } catch (Exception) { CacheController.Instance().UserSettings.MinImageCount = 3; } // Max. Threads try { CacheController.Instance().UserSettings.ThreadLimit = -1; CacheController.Instance().UserSettings.ThreadLimit = Convert.ToInt32(SettingsHelper.LoadSetting("Thread Limit")); ThreadManager.GetInstance().SetThreadThreshHold(CacheController.Instance().UserSettings.ThreadLimit == -1 ? 3 : CacheController.Instance().UserSettings.ThreadLimit); } catch (Exception) { CacheController.Instance().UserSettings.ThreadLimit = 3; ThreadManager.GetInstance().SetThreadThreshHold(3); } try { CacheController.Instance().UserSettings.DownloadFolder = SettingsHelper.LoadSetting("Download Folder"); this.DownloadFolder.Text = CacheController.Instance().UserSettings.DownloadFolder; if (string.IsNullOrEmpty(CacheController.Instance().UserSettings.DownloadFolder)) { CacheController.Instance().UserSettings.DownloadFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); this.DownloadFolder.Text = CacheController.Instance().UserSettings.DownloadFolder; SettingsHelper.SaveSetting("Download Folder", DownloadFolder.Text); } } catch (Exception) { CacheController.Instance().UserSettings.DownloadFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); DownloadFolder.Text = CacheController.Instance().UserSettings.DownloadFolder; SettingsHelper.SaveSetting("Download Folder", DownloadFolder.Text); CacheController.Instance().UserSettings.DownloadFolder = DownloadFolder.Text; } // Load "Download Options" try { CacheController.Instance().UserSettings.DownloadOptions = SettingsHelper.LoadSetting("Download Options"); switch (CacheController.Instance().UserSettings.DownloadOptions) { case "0": comboBox1.SelectedIndex = 0; break; case "1": comboBox1.SelectedIndex = 1; break; case "2": comboBox1.SelectedIndex = 2; break; default: comboBox1.SelectedIndex = 0; break; } } catch (Exception) { CacheController.Instance().UserSettings.DownloadOptions = "0"; comboBox1.SelectedIndex = 0; } // Load "Always on Top" Setting try { CacheController.Instance().UserSettings.TopMost = bool.Parse(SettingsHelper.LoadSetting("Always OnTop")); TopMost = CacheController.Instance().UserSettings.TopMost; } catch (Exception) { CacheController.Instance().UserSettings.TopMost = false; TopMost = false; } // Load Language Setting try { CacheController.Instance().UserSettings.Language = SettingsHelper.LoadSetting("UserLanguage"); switch (CacheController.Instance().UserSettings.Language) { case "de-DE": this._ResourceManager = new ResourceManager("Ripper.Languages.german", Assembly.GetExecutingAssembly()); break; case "fr-FR": this._ResourceManager = new ResourceManager("Ripper.Languages.french", Assembly.GetExecutingAssembly()); break; case "en-EN": this._ResourceManager = new ResourceManager("Ripper.Languages.english", Assembly.GetExecutingAssembly()); break; /*case "zh-CN": this._ResourceManager = new ResourceManager("Ripper.Languages.chinese-cn", Assembly.GetExecutingAssembly()); break;*/ default: this._ResourceManager = new ResourceManager("Ripper.Languages.english", Assembly.GetExecutingAssembly()); break; } this.AdjustCulture(); } catch (Exception) { this._ResourceManager = new ResourceManager("Ripper.Languages.english", Assembly.GetExecutingAssembly()); } // Load "Guest Mode" Setting try { CacheController.Instance().UserSettings.GuestMode = bool.Parse(SettingsHelper.LoadSetting("GuestMode")); if (CacheController.Instance().UserSettings.GuestMode) { CacheController.Instance().UserSettings.AutoThank = false; } } catch (Exception) { CacheController.Instance().UserSettings.GuestMode = false; } if (CacheController.Instance().UserSettings.GuestMode) { return; } // Load "ShowLastDownloaded" Setting try { CacheController.Instance().UserSettings.ShowLastDownloaded = bool.Parse(SettingsHelper.LoadSetting("ShowLastDownloaded")); } catch (Exception) { CacheController.Instance().UserSettings.ShowLastDownloaded = false; } // Load "ShowLastDownloaded" Setting try { CacheController.Instance().UserSettings.AfterDownloads = Convert.ToInt32(SettingsHelper.LoadSetting("AfterDownloads")); } catch (Exception) { CacheController.Instance().UserSettings.AfterDownloads = 0; } switch (CacheController.Instance().UserSettings.AfterDownloads) { case 0: this.doNothingToolStripMenuItem.Checked = true; this.closeRipperToolStripMenuItem.Checked = false; break; case 1: this.doNothingToolStripMenuItem.Checked = false; this.closeRipperToolStripMenuItem.Checked = true; break; } // Load Show Last Download Image this.groupBox4.Visible = CacheController.Instance().UserSettings.ShowLastDownloaded; this.showLastImageToolStripMenuItem.Checked = CacheController.Instance().UserSettings.ShowLastDownloaded; this.useCliboardMonitoringToolStripMenuItem.Checked = CacheController.Instance().UserSettings.ClipBWatch; try { CacheController.Instance().UserSettings.User = SettingsHelper.LoadSetting("User"); // Import old Password try { string sOldPass = Utility.EncodePassword(SettingsHelper.LoadSetting("Pass")).Replace("-", string.Empty).ToLower(); SettingsHelper.SaveSetting("Password", sOldPass); SettingsHelper.DeleteSetting("Pass"); CacheController.Instance().UserSettings.Pass = sOldPass; } catch (Exception) { CacheController.Instance().UserSettings.Pass = null; } CacheController.Instance().UserSettings.Pass = SettingsHelper.LoadSetting("Password"); } catch (Exception) { Login frmLgn = new Login(); frmLgn.ShowDialog(this); if (!this.cameThroughCorrectLogin) { DialogResult result = TopMostMessageBox.Show( this._ResourceManager.GetString("mbExit"), this._ResourceManager.GetString("mbExitTtl"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Application.Exit(); } } } }
/// <summary> /// Auto login if User Credentials exists in Config file. /// if no Data show Login Form /// </summary> public void AutoLogin() { if (CacheController.Instance().UserSettings.User != null && CacheController.Instance().UserSettings.Pass != null) { LoginManager lgnMgr = new LoginManager(CacheController.Instance().UserSettings.User, CacheController.Instance().UserSettings.Pass); if (lgnMgr.DoLogin(CacheController.Instance().UserSettings.ForumURL)) { this.cameThroughCorrectLogin = true; } else { Login frmLgn = new Login(); frmLgn.ShowDialog(this); DialogResult result = TopMostMessageBox.Show( this._ResourceManager.GetString("mbExit"), this._ResourceManager.GetString("mbExitTtl"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Application.Exit(); } } } else { Login frmLgn = new Login(); frmLgn.ShowDialog(this); this.cameThroughCorrectLogin = false; } }