Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 75 additions & 13 deletions src/ConfigurationForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions src/ConfigurationForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public ConfigurationForm(ConfigurationFormData data)
EnsureCheckEnabledGroupBox(m_chkDefaultUseLegacyCreds,
m_grpDriveAuthDefaults);
EnsureCheckEnabledGroupBox(m_chkUseLegacyCreds, m_grpDriveAuth);
EnsureCheckEnabledGroupBox(m_chkUseFileScope, m_grpFileScope);

Text = GdsDefs.ProductName;
DatabaseFilePath = string.Empty;
Expand Down Expand Up @@ -110,6 +111,9 @@ public ConfigurationForm(ConfigurationFormData data)
m_chkDontSaveAuthToken,
m_lnkAuthTokenHelp,
m_chkSyncOnReopen,
m_lblTargetFile,
m_chkUseFileScope,
m_btnSelectFile,
};
foreach (Control c in textCx)
{
Expand Down Expand Up @@ -147,6 +151,14 @@ public ConfigurationForm(ConfigurationFormData data)
}
m_btnGetColors.Enabled = string.IsNullOrWhiteSpace(m_txtFolderDefault.Text);
m_bColorsQueried = false;

m_btnSelectFile.Click += HandleSelectFile;
}

private async void HandleSelectFile(object sender, EventArgs e)
{
await m_data.PickFile();
m_data.EntryBindingSource.ResetBindings(false); // somewhat hacky way to refresh bound values to re-read datasource
}

static void EnsureCheckEnabledGroupBox(CheckBox chk, GroupBox grp)
Expand Down Expand Up @@ -329,6 +341,20 @@ protected override void OnLoad(EventArgs args)
binding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
m_chkSyncOnReopen.DataBindings.Add(binding);

// File scope options
Debug.Assert(m_chkUseFileScope is CheckBox);
binding = new Binding("Checked",
bindingSource,
"UseFileScope");
binding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;
m_chkUseFileScope.DataBindings.Add(binding);

Debug.Assert(m_txtTargetFile is TextBox);
binding = new Binding("Text",
bindingSource,
"FileScopeFileTarget");
m_txtTargetFile.DataBindings.Add(binding);

// Select first "active" entry in the accounts combo.
IEnumerable<EntryConfiguration> actives = m_data.Entries
.Where(e => e.ActiveAccount.HasValue &&
Expand Down Expand Up @@ -611,5 +637,10 @@ private void m_chkUseLegacyCreds_CheckedChanged(object sender, EventArgs e)
{
m_grpDriveAuth.Enabled = m_chkUseLegacyCreds.Checked;
}

private void m_UseFileScope_CheckedChanged(object sender, EventArgs e)
{
m_grpFileScope.Enabled = m_chkUseFileScope.Checked;
}
}
}
14 changes: 13 additions & 1 deletion src/ConfigurationFormData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ class ConfigurationFormData : IDisposable, INotifyPropertyChanged
public delegate Task<IEnumerable<Color>> ColorProvider(
EntryConfiguration ec, DatabaseContext dbCtx);

public delegate Task<FilePick> FilePicker(EntryConfiguration ec,
DatabaseContext dbCtx);

IEnumerable<Color> m_colors;
readonly ColorProvider m_colorProvider;
readonly FilePicker m_picker;
readonly PwDatabase m_db;
PluginConfig m_config;

public ConfigurationFormData(IList<EntryConfiguration> entries,
ColorProvider colorProvider, PwDatabase db)
ColorProvider colorProvider, FilePicker picker, PwDatabase db)
{
Entries = entries;
EntryBindingSource = new BindingSource
Expand All @@ -56,6 +60,7 @@ public ConfigurationFormData(IList<EntryConfiguration> entries,

m_colors = null;
m_colorProvider = colorProvider;
m_picker = picker;
m_db = db;
DefaultUseKpgs3ClientId =
SyncConfiguration.IsEmpty(
Expand Down Expand Up @@ -348,6 +353,13 @@ IEnumerable<Color> result
return m_colors;
}

public async Task PickFile()
{
EntryConfiguration current;
current = EntryBindingSource.Current as EntryConfiguration;
await m_picker(current, new DatabaseContext(m_db));
}

void RaisePropertyChanged(string propName)
{
if (PropertyChanged != null)
Expand Down
Loading