When watch folder edited restart watcher, added edit watch folder button

This commit is contained in:
Jaex 2017-10-15 16:51:48 +03:00
parent e19c60f81e
commit 2d58380025
3 changed files with 1701 additions and 1390 deletions

View file

@ -240,6 +240,7 @@ private void InitializeComponent()
this.pgTaskSettings = new System.Windows.Forms.PropertyGrid();
this.chkOverrideAdvancedSettings = new System.Windows.Forms.CheckBox();
this.tttvMain = new ShareX.HelpersLib.TabToTreeView();
this.btnWatchFolderEdit = new System.Windows.Forms.Button();
this.tcTaskSettings.SuspendLayout();
this.tpTask.SuspendLayout();
this.cmsDestinations.SuspendLayout();
@ -1933,6 +1934,7 @@ private void InitializeComponent()
//
// tpWatchFolders
//
this.tpWatchFolders.Controls.Add(this.btnWatchFolderEdit);
this.tpWatchFolders.Controls.Add(this.cbWatchFolderEnabled);
this.tpWatchFolders.Controls.Add(this.lvWatchFolderList);
this.tpWatchFolders.Controls.Add(this.btnWatchFolderRemove);
@ -2034,6 +2036,7 @@ private void InitializeComponent()
//
this.pgTaskSettings.CategoryForeColor = System.Drawing.SystemColors.InactiveCaptionText;
resources.ApplyResources(this.pgTaskSettings, "pgTaskSettings");
this.pgTaskSettings.LineColor = System.Drawing.SystemColors.ControlDark;
this.pgTaskSettings.Name = "pgTaskSettings";
this.pgTaskSettings.PropertySort = System.Windows.Forms.PropertySort.Categorized;
this.pgTaskSettings.ToolbarVisible = false;
@ -2057,6 +2060,13 @@ private void InitializeComponent()
this.tttvMain.TreeViewSize = 190;
this.tttvMain.TabChanged += new ShareX.HelpersLib.TabToTreeView.TabChangedEventHandler(this.tttvMain_TabChanged);
//
// btnWatchFolderEdit
//
resources.ApplyResources(this.btnWatchFolderEdit, "btnWatchFolderEdit");
this.btnWatchFolderEdit.Name = "btnWatchFolderEdit";
this.btnWatchFolderEdit.UseVisualStyleBackColor = true;
this.btnWatchFolderEdit.Click += new System.EventHandler(this.btnWatchFolderEdit_Click);
//
// TaskSettingsForm
//
resources.ApplyResources(this, "$this");
@ -2356,5 +2366,6 @@ private void InitializeComponent()
private System.Windows.Forms.TextBox txtUploaderFiltersExtensions;
private System.Windows.Forms.ComboBox cbImagePNGBitDepth;
private System.Windows.Forms.Label lblImagePNGBitDepth;
private System.Windows.Forms.Button btnWatchFolderEdit;
}
}

View file

@ -366,7 +366,7 @@ public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
{
foreach (WatchFolderSettings watchFolder in TaskSettings.WatchFolderList)
{
AddWatchFolder(watchFolder);
WatchFolderAdd(watchFolder);
}
}
@ -1424,6 +1424,41 @@ private void lvActions_ItemMoved(object sender, int oldIndex, int newIndex)
#region Watch folders
private void WatchFolderAdd(WatchFolderSettings watchFolderSetting)
{
if (watchFolderSetting != null)
{
Program.WatchFolderManager.AddWatchFolder(watchFolderSetting, TaskSettings);
ListViewItem lvi = new ListViewItem(watchFolderSetting.FolderPath ?? "");
lvi.Tag = watchFolderSetting;
lvi.SubItems.Add(watchFolderSetting.Filter ?? "");
lvi.SubItems.Add(watchFolderSetting.IncludeSubdirectories.ToString());
lvWatchFolderList.Items.Add(lvi);
}
}
private void WatchFolderEditSelected()
{
if (lvWatchFolderList.SelectedItems.Count > 0)
{
ListViewItem lvi = lvWatchFolderList.SelectedItems[0];
WatchFolderSettings watchFolder = lvi.Tag as WatchFolderSettings;
using (WatchFolderForm form = new WatchFolderForm(watchFolder))
{
if (form.ShowDialog() == DialogResult.OK)
{
lvi.Text = watchFolder.FolderPath ?? "";
lvi.SubItems[1].Text = watchFolder.Filter ?? "";
lvi.SubItems[2].Text = watchFolder.IncludeSubdirectories.ToString();
Program.WatchFolderManager.UpdateWatchFolderState(watchFolder);
}
}
}
}
private void cbWatchFolderEnabled_CheckedChanged(object sender, EventArgs e)
{
if (loaded)
@ -1443,42 +1478,14 @@ private void btnWatchFolderAdd_Click(object sender, EventArgs e)
{
if (form.ShowDialog() == DialogResult.OK)
{
AddWatchFolder(form.WatchFolder);
WatchFolderAdd(form.WatchFolder);
}
}
}
private void lvWatchFolderList_MouseDoubleClick(object sender, MouseEventArgs e)
private void btnWatchFolderEdit_Click(object sender, EventArgs e)
{
if (lvWatchFolderList.SelectedItems.Count > 0)
{
ListViewItem lvi = lvWatchFolderList.SelectedItems[0];
WatchFolderSettings watchFolder = lvi.Tag as WatchFolderSettings;
using (WatchFolderForm form = new WatchFolderForm(watchFolder))
{
if (form.ShowDialog() == DialogResult.OK)
{
lvi.Text = watchFolder.FolderPath ?? "";
lvi.SubItems[1].Text = watchFolder.Filter ?? "";
lvi.SubItems[2].Text = watchFolder.IncludeSubdirectories.ToString();
}
}
}
}
private void AddWatchFolder(WatchFolderSettings watchFolderSetting)
{
if (watchFolderSetting != null)
{
Program.WatchFolderManager.AddWatchFolder(watchFolderSetting, TaskSettings);
ListViewItem lvi = new ListViewItem(watchFolderSetting.FolderPath ?? "");
lvi.Tag = watchFolderSetting;
lvi.SubItems.Add(watchFolderSetting.Filter ?? "");
lvi.SubItems.Add(watchFolderSetting.IncludeSubdirectories.ToString());
lvWatchFolderList.Items.Add(lvi);
}
WatchFolderEditSelected();
}
private void btnWatchFolderRemove_Click(object sender, EventArgs e)
@ -1492,6 +1499,11 @@ private void btnWatchFolderRemove_Click(object sender, EventArgs e)
}
}
private void lvWatchFolderList_MouseDoubleClick(object sender, MouseEventArgs e)
{
WatchFolderEditSelected();
}
#endregion Watch folders
#region Tools

File diff suppressed because it is too large Load diff