Add temporary remove all monitoring paths for IO-996.

This commit is contained in:
Patrick Fic
2021-05-10 10:09:53 -07:00
parent 3625d595ad
commit d59834d6ce
6 changed files with 63 additions and 5 deletions

View File

@@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ImEX Systems Inc.")]
[assembly: AssemblyProduct("ImEX Online Partner")]
[assembly: AssemblyCopyright("Copyright © Snapt Software Inc. 2020")]
[assembly: AssemblyCopyright("Copyright © Snapt Software Inc. 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View File

@@ -213,6 +213,15 @@ namespace BodyshopPartner.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Remove All Paths.
/// </summary>
public static string Label_RemoveAllPaths {
get {
return ResourceManager.GetString("Label_RemoveAllPaths", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _Restart.
/// </summary>

View File

@@ -168,6 +168,9 @@
<data name="Label_Remove" xml:space="preserve">
<value>Re_move</value>
</data>
<data name="Label_RemoveAllPaths" xml:space="preserve">
<value>Remove All Paths</value>
</data>
<data name="Label_Restart" xml:space="preserve">
<value>_Restart</value>
</data>

View File

@@ -70,13 +70,38 @@ namespace BodyshopPartner.ViewModels
{
_removeMonitoringPathCommand = new RelayCommand(
p => true,
p => RemoveFolderMonitoringPath(p as Models.Monitor)
p =>
{
RemoveFolderMonitoringPath(p as Models.Monitor);
}
);
}
return _removeMonitoringPathCommand;
}
}
private ICommand _removeAllMonitoringPathCommand;
public ICommand RemoveAllMonitoringPathCommand
{
get
{
if (_removeAllMonitoringPathCommand == null)
{
_removeAllMonitoringPathCommand = new RelayCommand(
p => true,
p =>
{
RemoveAllFolderMonitors();
}
);
}
return _removeAllMonitoringPathCommand;
}
}
private ICommand _startFolderMonitorsCommand;
public ICommand StartFolderMonitorsCommand
{

View File

@@ -179,6 +179,24 @@ namespace BodyshopPartner.ViewModels
IndeterminateLoading = false;
}
public void RemoveAllFolderMonitors()
{
IndeterminateLoading = true;
if (MonitoringPaths.Count > 0)
foreach (var m in MonitoringPaths.ToList())
{
logger.Debug("Removing folder {0} to monitoring paths.", m.FilePath);
m.StopMonitor();
MonitoringPaths.Remove(m);
}
Properties.Settings.Default.MonitoringPaths = MonitoringPaths.Select(x => x.FilePath).ToList();
Properties.Settings.Default.Save();
IndeterminateLoading = false;
}
public void BrowseForQbFolder()
{

View File

@@ -21,6 +21,7 @@
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
Loaded="Window_Loaded"
Name="MainWindow"
Closing="Window_Closing">
<Window.DataContext>
<vm:MainViewModel />
@@ -59,8 +60,7 @@
DoubleClickCommand="{Binding OpenMainWindowCommand}"
DoubleClickCommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
PopupActivation="LeftClick"
MenuActivation="RightClick"
>
MenuActivation="RightClick">
<!--<tb:TaskbarIcon.TrayPopup>
<Border Background="{DynamicResource MaterialDesignPaper}"
BorderBrush="Black"
@@ -149,6 +149,9 @@
<Button Command="{Binding StopFolderMonitorsCommand, UpdateSourceTrigger=PropertyChanged}"
Margin="8"
Content="{x:Static p:Resources.Label_StopAllMonitors}" />
<Button Command="{Binding RemoveAllMonitoringPathCommand, UpdateSourceTrigger=PropertyChanged}"
Margin="8"
Content="{x:Static p:Resources.Label_RemoveAllPaths}" />
<Separator />
<Button Command="{Binding BrowseForQbFolderCommand, UpdateSourceTrigger=PropertyChanged}"
Margin="8"
@@ -197,7 +200,7 @@
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Command="{Binding DataContext.RemoveMonitoringPathCommand,
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
ElementName=MainWindow}"
CommandParameter="{Binding .}"
Style="{StaticResource MaterialDesignOutlinedButton}"
Margin="4"