Skip to content

Commit 324139e

Browse files
committed
Define image grid context menu in xaml
1 parent 0287249 commit 324139e

File tree

4 files changed

+22
-36
lines changed

4 files changed

+22
-36
lines changed

solution/GraphicalDebugging/GeometryWatchControl.xaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
MouseWheel="imageGrid_MouseWheel" >
2424
<Image x:Name="image" Stretch="Fill" Height="Auto" Width="Auto" />
2525
<Canvas x:Name="imageCanvas" Height="Auto" Width="Auto" />
26+
<Grid.ContextMenu>
27+
<ContextMenu x:Name="imageGridContextMenu">
28+
<!--
29+
VsBrushes.DebuggerDataTipInactiveBackground
30+
VsBrushes.DebuggerDataTipInactiveText
31+
-->
32+
<MenuItem x:Name="imageGridContextMenuCopy" Header="Copy" Click="MenuItem_Copy" />
33+
<Separator />
34+
<MenuItem x:Name="imageGridContextMenuResetZoom" Header="Reset View" Click="MenuItem_ResetZoom" />
35+
</ContextMenu>
36+
</Grid.ContextMenu>
2637
</Grid>
2738
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch"
2839
ResizeDirection="Rows"

solution/GraphicalDebugging/GeometryWatchControl.xaml.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -342,24 +342,8 @@ private void UpdateItems(bool load, int modified_index = -1)
342342
image.Source = Util.BitmapToBitmapImage(m_emptyBitmap);
343343
}
344344

345-
imageGrid.ContextMenu = new ContextMenu();
346-
MenuItem mi = new MenuItem
347-
{
348-
Header = "Copy"
349-
};
350-
mi.Click += MenuItem_Copy;
351-
if (imageEmpty)
352-
mi.IsEnabled = false;
353-
imageGrid.ContextMenu.Items.Add(mi);
354-
imageGrid.ContextMenu.Items.Add(new Separator());
355-
MenuItem mi2 = new MenuItem
356-
{
357-
Header = "Reset View"
358-
};
359-
mi2.Click += MenuItem_ResetZoom;
360-
if (imageEmpty)
361-
mi2.IsEnabled = false;
362-
imageGrid.ContextMenu.Items.Add(mi2);
345+
imageGridContextMenuCopy.IsEnabled = !imageEmpty;
346+
imageGridContextMenuResetZoom.IsEnabled = !imageEmpty;
363347
}
364348

365349
private void MenuItem_Copy(object sender, RoutedEventArgs e)

solution/GraphicalDebugging/PlotWatchControl.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
MouseWheel="imageGrid_MouseWheel" >
2424
<Image x:Name="image" Stretch="Fill" Height="Auto" Width="Auto" />
2525
<Canvas x:Name="imageCanvas" Height="Auto" Width="Auto" />
26+
<Grid.ContextMenu>
27+
<ContextMenu x:Name="imageGridContextMenu">
28+
<MenuItem x:Name="imageGridContextMenuCopy" Header="Copy" Click="MenuItem_Copy" />
29+
<Separator />
30+
<MenuItem x:Name="imageGridContextMenuResetZoom" Header="Reset View" Click="MenuItem_ResetZoom" />
31+
</ContextMenu>
32+
</Grid.ContextMenu>
2633
</Grid>
2734
<GridSplitter Grid.Row="1" HorizontalAlignment="Stretch"
2835
ResizeDirection="Rows"

solution/GraphicalDebugging/PlotWatchControl.xaml.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -347,24 +347,8 @@ private void UpdateItems(bool load, int modified_index = -1)
347347
image.Source = Util.BitmapToBitmapImage(m_emptyBitmap);
348348
}
349349

350-
imageGrid.ContextMenu = new ContextMenu();
351-
MenuItem mi = new MenuItem
352-
{
353-
Header = "Copy"
354-
};
355-
mi.Click += MenuItem_Copy;
356-
if (imageEmpty)
357-
mi.IsEnabled = false;
358-
imageGrid.ContextMenu.Items.Add(mi);
359-
imageGrid.ContextMenu.Items.Add(new Separator());
360-
MenuItem mi2 = new MenuItem
361-
{
362-
Header = "Reset View"
363-
};
364-
mi2.Click += MenuItem_ResetZoom;
365-
if (imageEmpty)
366-
mi2.IsEnabled = false;
367-
imageGrid.ContextMenu.Items.Add(mi2);
350+
imageGridContextMenuCopy.IsEnabled = !imageEmpty;
351+
imageGridContextMenuResetZoom.IsEnabled = !imageEmpty;
368352
}
369353

370354
private void MenuItem_Copy(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)