Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/DynamicDataDisplay/Charts/Navigation/Navigation/DefaultContextMenu.cs @ 12503

Last change on this file since 12503 was 12503, checked in by aballeit, 9 years ago

#2283 added GUI and charts; fixed MCTS

File size: 2.5 KB
Line 
1#define _template
2
3using System.Collections.Generic;
4using System.Windows;
5using System.Windows.Controls;
6using Microsoft.Win32;
7using System.Windows.Media.Imaging;
8using System.Windows.Media;
9using System.Reflection;
10using System;
11
12namespace Microsoft.Research.DynamicDataDisplay.Navigation
13{
14  /// <summary>This class is responsible for displaying and populating default context menu</summary>
15  public partial class DefaultContextMenu : NavigationBase
16  {
17    static BitmapImage helpIcon;
18    static BitmapImage copyScreenshotIcon;
19    static BitmapImage saveScreenshotIcon;
20    static BitmapImage fitToViewIcon;
21    static DefaultContextMenu()
22    {
23      helpIcon = LoadIcon("HelpIcon");
24      saveScreenshotIcon = LoadIcon("SaveIcon");
25      copyScreenshotIcon = LoadIcon("CopyScreenshotIcon");
26      fitToViewIcon = LoadIcon("FitToViewIcon");
27    }
28
29    private static BitmapImage LoadIcon(string name)
30    {
31      Assembly currentAssembly = typeof(DefaultContextMenu).Assembly;
32
33      BitmapImage icon = new BitmapImage();
34      icon.BeginInit();
35      icon.StreamSource = currentAssembly.GetManifestResourceStream("Microsoft.Research.DynamicDataDisplay.Resources." + name + ".png");
36      icon.EndInit();
37      return icon;
38    }
39
40    public DefaultContextMenu()
41    {
42      InitContextMenu();
43    }
44
45    public void InitContextMenu()
46    {
47      ContextMenu menu = new ContextMenu();
48      MenuItem fitToViewMenuItem = new MenuItem
49      {
50        Header = "Fit to view",
51        ToolTip = "Make visible area fit to display entire contents",
52        Icon = new Image { Source = fitToViewIcon },
53        Command = ChartCommands.FitToView
54      };
55
56      MenuItem savePictureMenuItem = new MenuItem
57      {
58        Header = "Save picture",
59        ToolTip = "Specify name of image file to save screenshot to",
60        Icon = new Image { Source = saveScreenshotIcon },
61        Command = ChartCommands.SaveScreenshot
62      };
63
64      MenuItem copyPictureMenuItem = new MenuItem
65      {
66        Header = "Copy picture",
67        ToolTip = "Copy screenshot of charts to clipboard",
68        Icon = new Image { Source = copyScreenshotIcon },
69        Command = ChartCommands.CopyScreenshot
70      };
71
72      MenuItem quickHelpMenuItem = new MenuItem
73      {
74        Header = "Quick Help",
75        ToolTip = "View brief instructions",
76        Command = ChartCommands.ShowHelp,
77        Icon = new Image { Source = helpIcon }
78      };
79
80      List<MenuItem> menuItems = new List<MenuItem> {
81        fitToViewMenuItem,
82        copyPictureMenuItem,
83        savePictureMenuItem,
84                quickHelpMenuItem,
85      };
86      menu.ItemsSource = menuItems;
87
88      ContextMenu = menu;
89    }
90  }
91}
Note: See TracBrowser for help on using the repository browser.