[FZ Editor] Replace ItemsControls with GridViews (#11066)

* LayoutItemsControl to GridView

* ContextMenu

* Added contextmenu items

* Context menu keyboard support

Co-authored-by: Niels Laute <niels9001@hotmail.com>
This commit is contained in:
Niels Laute
2021-05-04 13:49:38 +02:00
committed by GitHub
parent f4f481c498
commit d586814308
6 changed files with 500 additions and 226 deletions

View File

@@ -104,13 +104,6 @@ namespace FancyZonesEditor
// Select(((Grid)sender).DataContext as LayoutModel);
}
private void LayoutItem_Click(object sender, MouseButtonEventArgs e)
{
LayoutModel selectedLayoutModel = ((Grid)sender).DataContext as LayoutModel;
Select(selectedLayoutModel);
Apply();
}
private void LayoutItem_Focused(object sender, RoutedEventArgs e)
{
// Ignore focus on Edit button click
@@ -261,6 +254,8 @@ namespace FancyZonesEditor
private void EditZones_Click(object sender, RoutedEventArgs e)
{
var dataContext = ((FrameworkElement)sender).DataContext;
Select((LayoutModel)dataContext);
EditLayoutDialog.Hide();
var mainEditor = App.Overlay;
if (!(mainEditor.CurrentDataContext is LayoutModel model))
@@ -332,19 +327,6 @@ namespace FancyZonesEditor
InvalidateVisual();
}
private void MonitorItem_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return || e.Key == Key.Space)
{
monitorViewModel.SelectCommand.Execute((MonitorInfoModel)(sender as Border).DataContext);
}
}
private void MonitorItem_MouseDown(object sender, MouseButtonEventArgs e)
{
monitorViewModel.SelectCommand.Execute((MonitorInfoModel)(sender as Border).DataContext);
}
// EditLayout: Cancel changes
private void EditLayoutDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
@@ -380,12 +362,12 @@ namespace FancyZonesEditor
private async void DeleteLayout(FrameworkElement element)
{
var dialog = new ModernWpf.Controls.ContentDialog()
var dialog = new ContentDialog()
{
Title = FancyZonesEditor.Properties.Resources.Are_You_Sure,
Content = FancyZonesEditor.Properties.Resources.Are_You_Sure_Description,
PrimaryButtonText = FancyZonesEditor.Properties.Resources.Delete,
SecondaryButtonText = FancyZonesEditor.Properties.Resources.Cancel,
Title = Properties.Resources.Are_You_Sure,
Content = Properties.Resources.Are_You_Sure_Description,
PrimaryButtonText = Properties.Resources.Delete,
SecondaryButtonText = Properties.Resources.Cancel,
};
var result = await dialog.ShowAsync();
@@ -430,5 +412,16 @@ namespace FancyZonesEditor
e.Handled = true;
}
}
private void Layout_ItemClick(object sender, ItemClickEventArgs e)
{
Select(e.ClickedItem as LayoutModel);
Apply();
}
private void Monitor_ItemClick(object sender, ItemClickEventArgs e)
{
monitorViewModel.SelectCommand.Execute(e.ClickedItem as MonitorInfoModel);
}
}
}