Exemple #1
0
        private void PopulateScreenFromSettings(BloodSpider.Services.Common.Settings settings)
        {
            if (settings != null && settings.Login != null)
            {
                BloodSpider.Services.Common.Settings.LoginRow loginRow = settings.Login.FirstOrDefault();

                if (loginRow != null)
                {
                    this.txtUsername.Text = StringCipher.Decrypt(loginRow.Username, true);
                    this.txtPassword.Text = StringCipher.Decrypt(loginRow.Password, true);
                }
            }

            if (settings != null && settings.Options != null)
            {
                BloodSpider.Services.Common.Settings.OptionsRow optionRow = settings.Options.FirstOrDefault();

                if (optionRow != null)
                {
                    this.chkAutoUpload.Checked        = !optionRow.AutoUpload;
                    this.chkShowNotifications.Checked = optionRow.ShowNotifications;
                    this.chkAutoReportErrors.Checked  = optionRow.AutoReportErrors;
                }
            }
        }
Exemple #2
0
        private bool CheckSettingsFile()
        {
            //read settings file
            _settings = Statics.ReadSettingsFile();

            if (_settings == null || _settings.Options == null)
            {
                _settings = new BloodSpider.Services.Common.Settings();
                _settings.Options.AddOptionsRow(!chkAutoUpload.Checked, chkShowNotifications.Checked, chkAutoReportErrors.Checked);
                _settings.Login.AddLoginRow(string.Empty, string.Empty);

                return(false);
            }

            return(true);
        }
Exemple #3
0
        private void SaveSettings()
        {
            //save settings on save button click
            try
            {
                using (BloodSpider.Services.Common.Settings settings = new BloodSpider.Services.Common.Settings())
                {
                    BloodSpider.Services.Common.Settings.LoginRow loginRow = settings.Login.NewLoginRow();
                    loginRow.Username = StringCipher.Encrypt(this.txtUsername.Text.Trim(), true);
                    loginRow.Password = StringCipher.Encrypt(this.txtPassword.Text.Trim(), true);

                    settings.Login.AddLoginRow(loginRow);

                    settings.Options.AddOptionsRow(!chkAutoUpload.Checked, chkShowNotifications.Checked, chkAutoReportErrors.Checked);

                    _settings = settings;

                    //save settings file
                    Statics.SaveSettingsFile(_settings);

                    //show that all settings were saved successfully
                    ShowNotificationBalloon(3000, "BloodSpider Settings", "User settings were successfully saved.", ToolTipIcon.Info);
                }
            }
            catch (UnauthorizedAccessException uaex)
            {
                Error("002", uaex);
            }
            catch (Exception ex)
            {
                if (string.IsNullOrWhiteSpace(this.txtUsername.Text))
                {
                    ShowNotificationBalloon(10000, "BloodSpider Settings", "Username can not be blank.", ToolTipIcon.Error);
                }
                else if (string.IsNullOrWhiteSpace(this.txtPassword.Text))
                {
                    ShowNotificationBalloon(10000, "BloodSpider Settings", "Password can not be blank.", ToolTipIcon.Error);
                }

                Error("003", ex);
            }
            finally
            {
                ShowWindow(false);
            }
        }
        private bool CheckSettingsFile()
        {
            //read settings file
            _settings = Statics.ReadSettingsFile();

            if (_settings == null || _settings.Options == null)
            {
                _settings = new BloodSpider.Services.Common.Settings();
                _settings.Options.AddOptionsRow(!chkAutoUpload.Checked, chkShowNotifications.Checked, chkAutoReportErrors.Checked);
                _settings.Login.AddLoginRow(string.Empty, string.Empty);

                return false;
            }

            return true;
        }
        private void SaveSettings()
        {
            //save settings on save button click
            try
            {
                using (BloodSpider.Services.Common.Settings settings = new BloodSpider.Services.Common.Settings())
                {
                    BloodSpider.Services.Common.Settings.LoginRow loginRow = settings.Login.NewLoginRow();
                    loginRow.Username = StringCipher.Encrypt(this.txtUsername.Text.Trim(), true);
                    loginRow.Password = StringCipher.Encrypt(this.txtPassword.Text.Trim(), true);

                    settings.Login.AddLoginRow(loginRow);

                    settings.Options.AddOptionsRow(!chkAutoUpload.Checked, chkShowNotifications.Checked, chkAutoReportErrors.Checked);

                    _settings = settings;

                    //save settings file
                    Statics.SaveSettingsFile(_settings);

                    //show that all settings were saved successfully
                    ShowNotificationBalloon(3000, "BloodSpider Settings", "User settings were successfully saved.", ToolTipIcon.Info);
                }
            }
            catch (UnauthorizedAccessException uaex)
            {
                Error("002", uaex);
            }
            catch (Exception ex)
            {
                if (string.IsNullOrWhiteSpace(this.txtUsername.Text))
                    ShowNotificationBalloon(10000, "BloodSpider Settings", "Username can not be blank.", ToolTipIcon.Error);
                else if (string.IsNullOrWhiteSpace(this.txtPassword.Text))
                    ShowNotificationBalloon(10000, "BloodSpider Settings", "Password can not be blank.", ToolTipIcon.Error);

                Error("003", ex);
            }
            finally
            {
                ShowWindow(false);
            }
        }