Ejemplo n.º 1
0
        public void CreateAndSaveUserScope()
        {
            var settings = JsonSettingsBase.Load <UserSettings>();

            settings.Save();
            Assert.IsTrue(settings.GetFullPath().EndsWith(@"\Adam O'Neil Software\My Sample App\UserSettings.json"));
        }
Ejemplo n.º 2
0
        public void VerifyEncryptedValue()
        {
            const string testValue = "whatever";

            var settings = new AppSettings(); // will simply overwrite any existing settings

            settings.SensitiveValue = testValue;
            settings.Save();

            // inspect the json directly
            string fileName = settings.GetFullPath();

            using (StreamReader reader = File.OpenText(fileName))
            {
                string      json = reader.ReadToEnd();
                AppSettings test = JsonConvert.DeserializeObject <AppSettings>(json);

                // the sensitive value on disk is not the same as in memory and not just empty
                Assert.IsTrue(!settings.SensitiveValue.Equals(test.SensitiveValue) && !string.IsNullOrEmpty(test.SensitiveValue));
            }

            // when we load from disk, the sensitive value is what we started with
            settings = JsonSettingsBase.Load <AppSettings>();
            Assert.IsTrue(settings.SensitiveValue.Equals(testValue));
        }
Ejemplo n.º 3
0
 private void frmMain_Load(object sender, System.EventArgs e)
 {
     _settings        = JsonSettingsBase.Load <AppSettings>();
     _binder.Document = _settings;
     _binder.Add(tbUrl, m => m.Url);
     _binder.Add(bldLocalPath, m => m.LocalPath);
     _binder.LoadValues();
 }
Ejemplo n.º 4
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            try
            {
                _columnSizer = new ListViewColumnSizer(lvBlobs);
                _options     = JsonSettingsBase.Load <Options>();
                _options.FormPosition?.Apply(this);

                FillAccounts();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Ejemplo n.º 5
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            try
            {
                fgvLocal.SizingGrip = false;

                _settings = JsonSettingsBase.Load <AppSettings>();
                _settings.FormPosition?.Apply(this);
                FillLocalPathMenu();
                FillStorageAccountMenu();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
 private void frmDbConnection_Load(object sender, EventArgs e)
 {
     try
     {
         _settings = JsonSettingsBase.Load <ConnectionDialogSettings>();
         var serverNames = _settings?.Servers?.Select(s => new ComboBoxItem <Server>(s, s.Name)).ToArray();
         if (serverNames != null)
         {
             cbServer.Items.AddRange(serverNames);
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.FullMessage());
     }
 }
Ejemplo n.º 7
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            _settings = JsonSettingsBase.Load <AppSettings>();
            _styles   = LoadStyles();

            cbStyle.Items.AddRange(_styles);
            cbOrientation.FillFromEnum <Orientation>();

            LoadFields();
            InitDataBinding();

            if (File.Exists(tbAssembly.Text))
            {
                _assembly = dsAssembly.FromAssembly(tbAssembly.Text);
                InitDataGrids();
            }
        }
Ejemplo n.º 8
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            _settings = JsonSettingsBase.Load <Settings>();
            _settings.AddDefaultLocations();
            _settings.AddDefaultIgnorePaths();
            _settings?.FormPosition?.Apply(this);
            btnSettings.Checked             = _settings.SettingsExpanded;
            splitContainer1.Panel2Collapsed = !_settings.SettingsExpanded;

            FillLocations();

            _locationBinder = new LocationGridBinder(dataGridView1, _settings);
            _locationBinder.Fill(_settings.Locations);

            _ignoreBinder = new IgnorePathsGridBinder(dataGridView2, _settings);
            _ignoreBinder.Fill(_settings.IgnorePaths);

            tbFilename.Focus();
        }
Ejemplo n.º 9
0
        private async void FrmMain_Load(object sender, EventArgs e)
        {
            try
            {
                _settings = JsonSettingsBase.Load <Settings>();
                if (_settings.Recent == null)
                {
                    _settings.Recent = new HashSet <string>();
                }
                _settings.FormPosition?.Apply(this);

                FillRecentItems();

                cbFilterActive.Fill(new Dictionary <bool, string>()
                {
                    { true, "Active" },
                    { false, "Inactive" }
                });
                cbFilterActive.SetValue(true);

                if (File.Exists(_settings.DatabaseFile))
                {
                    Database = PromptOpenDatabasePwd(_settings.DatabaseFile, out bool getSinglePwd, out string entryName);

                    if (getSinglePwd)
                    {
                        CopyPasswordToClipboard(entryName);
                        Application.Exit();
                        return;
                    }
                }
                else
                {
                    Database = PromptCreateDatabase();
                }

                await BindDataGridAsync();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Ejemplo n.º 10
0
        private async void frmMain_Load(object sender, EventArgs e)
        {
            _settings = JsonSettingsBase.Load <AppSettings>();

            var binder = new ControlBinder <AppSettings>();

            binder.Document = _settings;
            binder.Add(tbAccountName, m => m.AccountName);
            binder.Add(tbAccountKey, m => m.AccountKey);
            binder.Add(bldLocalPath, m => m.LocalPath);
            binder.LoadValues();

            if (StartAutomatically())
            {
                await RunBackupInnerAsync();

                this.Close();
                Application.Exit();
            }
        }
        private void frmDbConnection_Load(object sender, EventArgs e)
        {
            try
            {
                _settings = JsonSettingsBase.Load <ConnectionDialogSettings>();
                var serverNames = _settings?.Servers?.Select(s => new ListItem <Server>(s, s.Name)).ToArray();
                if (serverNames != null)
                {
                    cbServer.Items.AddRange(serverNames);
                }

                if (!AllowWindowsAuthentication)
                {
                    rbAuthenticationDb.Checked      = true;
                    rbAuthenticationWindows.Enabled = false;
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.FullMessage());
            }
        }
Ejemplo n.º 12
0
        private async void frmMain_Load(object sender, EventArgs e)
        {
            try
            {
                _settings = JsonSettingsBase.Load <Settings>();
                _settings.FormPosition?.ApplyToForm(this);

                tslRootPath.Text = _settings.RootFolder;
                tslStatus.Text   = "Ready";

                FillSortOptions();

                await LoadLibraryAsync();

                _player = new SongPlayer(_settings.RootFolder);
                dgvPlayer.DataSource = _player;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }