public CustomMenuItem(string text, ref CustomMenuItem menuItem) { this.Header = text; menuItem.Items.Add(this); }
public Ringy() { this.Width = STANDARD_ICON_DIMENSION * 4.5; this.Height = this.Width; this.ShowInTaskbar = false; this.WindowStyle = WindowStyle.None; this.WindowStartupLocation = WindowStartupLocation.CenterScreen; this.AllowsTransparency = true; this.Background = new SolidColorBrush(Colors.Transparent); mainRingyCanvas = new Canvas(); backgroundStackPanel = new StackPanel(); backgroundStackPanel.Margin = new Thickness(uniformLength: (this.Width - STANDARD_BACKGROUND_IMAGE_DIMENSION) / 2); iconGrid = new Grid(); //iconGrid.ShowGridLines = true; // NOTE: For debugging purpose only iconGrid.Width = this.Width; iconGrid.Height = this.Height; ColumnDefinition[] iconGridColumnDefinition = new ColumnDefinition[TOTAL_NO_OF_GRID_ROW_COLUMN]; RowDefinition[] iconGridRowDefinition = new RowDefinition[TOTAL_NO_OF_GRID_ROW_COLUMN]; for (int i = 0; i < TOTAL_NO_OF_GRID_ROW_COLUMN; i++) { iconGridColumnDefinition[i] = new ColumnDefinition(); iconGridRowDefinition[i] = new RowDefinition(); iconGrid.ColumnDefinitions.Add(iconGridColumnDefinition[i]); iconGrid.RowDefinitions.Add(iconGridRowDefinition[i]); } ContextMenu ringyContextMenu = new ContextMenu(); optionsMenuItem = new CustomMenuItem(text: "Options", contextMenu: ref ringyContextMenu); ringyContextMenu.Items.Add(new System.Windows.Controls.Separator()); animationEffectMenuItem = new CustomMenuItem(text: "Animation Effect", contextMenu: ref ringyContextMenu); zoomAnimationEffectMenuItem = new CustomMenuItem(text: "Zoom", menuItem: ref animationEffectMenuItem); fadeAnimationEffectMenuItem = new CustomMenuItem(text: "Fade", menuItem: ref animationEffectMenuItem); rotateAnimationEffectMenuItem = new CustomMenuItem(text: "Rotate", menuItem: ref animationEffectMenuItem); showIconLabelMenuItem = new CustomMenuItem(text: "Show Icon Label", contextMenu: ref ringyContextMenu); ringyContextMenu.Items.Add(new System.Windows.Controls.Separator()); helpMenuItem = new CustomMenuItem(text: "Help", contextMenu: ref ringyContextMenu); contentsMenuItem = new CustomMenuItem(text: "Contents", menuItem: ref helpMenuItem); aboutMenuItem = new CustomMenuItem(text: "About", menuItem: ref helpMenuItem); // Adding Contents this.Content = mainRingyCanvas; mainRingyCanvas.Children.Add(backgroundStackPanel); mainRingyCanvas.Children.Add(iconGrid); this.ContextMenu = ringyContextMenu; // Initializing Settings refreshRingy(); // Adding Event Handler optionsMenuItem.Click += new RoutedEventHandler(optionsMenuItem_Click); zoomAnimationEffectMenuItem.Click += new RoutedEventHandler(AnimationEffectMenuItem_Click); fadeAnimationEffectMenuItem.Click += new RoutedEventHandler(AnimationEffectMenuItem_Click); rotateAnimationEffectMenuItem.Click += new RoutedEventHandler(AnimationEffectMenuItem_Click); showIconLabelMenuItem.Click += new RoutedEventHandler(showIconLabelMenuItem_Click); contentsMenuItem.Click += new RoutedEventHandler(contentsMenuItem_Click); aboutMenuItem.Click += new RoutedEventHandler(aboutMenuItem_Click); }