mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
[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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user