[Run] ViewModels Cleanup (#12209)

* view models cleanup

* removed unused commands
This commit is contained in:
Davide Giacometti
2021-07-15 16:34:27 +02:00
committed by GitHub
parent cdfb566137
commit 55923f2790
7 changed files with 57 additions and 193 deletions

View File

@@ -24,17 +24,13 @@ namespace PowerLauncher.ViewModel
public ObservableCollection<ContextMenuItemViewModel> ContextMenuItems { get; } = new ObservableCollection<ContextMenuItemViewModel>();
public ICommand ActivateContextButtonsHoverCommand { get; set; }
public ICommand ActivateContextButtonsHoverCommand { get; }
public ICommand ActivateContextButtonsSelectionCommand { get; set; }
public ICommand DeactivateContextButtonsHoverCommand { get; }
public ICommand DeactivateContextButtonsHoverCommand { get; set; }
public bool IsSelected { get; private set; }
public ICommand DeactivateContextButtonsSelectionCommand { get; set; }
public bool IsSelected { get; set; }
public bool IsHovered { get; set; }
public bool IsHovered { get; private set; }
private bool _areContextButtonsActive;
@@ -79,9 +75,7 @@ namespace PowerLauncher.ViewModel
LoadContextMenu();
ActivateContextButtonsHoverCommand = new RelayCommand(ActivateContextButtonsHoverAction);
ActivateContextButtonsSelectionCommand = new RelayCommand(ActivateContextButtonsSelectionAction);
DeactivateContextButtonsHoverCommand = new RelayCommand(DeactivateContextButtonsHoverAction);
DeactivateContextButtonsSelectionCommand = new RelayCommand(DeactivateContextButtonsSelectionAction);
}
private void ActivateContextButtonsHoverAction(object sender)
@@ -89,11 +83,6 @@ namespace PowerLauncher.ViewModel
ActivateContextButtons(ActivationType.Hover);
}
private void ActivateContextButtonsSelectionAction(object sender)
{
ActivateContextButtons(ActivationType.Selection);
}
public void ActivateContextButtons(ActivationType activationType)
{
// Result does not contain any context menu items - we don't need to show the context menu ListView at all.
@@ -122,11 +111,6 @@ namespace PowerLauncher.ViewModel
DeactivateContextButtons(ActivationType.Hover);
}
private void DeactivateContextButtonsSelectionAction(object sender)
{
DeactivateContextButtons(ActivationType.Selection);
}
public void DeactivateContextButtons(ActivationType activationType)
{
if (activationType == ActivationType.Selection)
@@ -156,15 +140,14 @@ namespace PowerLauncher.ViewModel
ContextMenuItems.Clear();
foreach (var r in results)
{
ContextMenuItems.Add(new ContextMenuItemViewModel()
{
PluginName = r.PluginName,
Title = r.Title,
Glyph = r.Glyph,
FontFamily = r.FontFamily,
AcceleratorKey = r.AcceleratorKey,
AcceleratorModifiers = r.AcceleratorModifiers,
Command = new RelayCommand(_ =>
ContextMenuItems.Add(new ContextMenuItemViewModel(
r.PluginName,
r.Title,
r.Glyph,
r.FontFamily,
r.AcceleratorKey,
r.AcceleratorModifiers,
new RelayCommand(_ =>
{
bool hideWindow =
r.Action != null &&
@@ -179,8 +162,7 @@ namespace PowerLauncher.ViewModel
// TODO - Do we hide the window
// MainWindowVisibility = Visibility.Collapsed;
}
}),
});
})));
}
}