예제 #1
0
        /// <summary>
        /// Creates a <see cref="MenuItem"/> for a <see cref="Color"/>.
        /// </summary>
        /// <param name="color">A <see cref="Color"/>.</param>
        private void CreateColorMenuItem(Color color)
        {
            MenuItem menuItem = new MenuItem();

            menuItem.Header      = this.GetHeaderForColor(color);
            menuItem.Tag         = color;
            menuItem.IsCheckable = true;
            menuItem.Click      += this.ColorMenuItemClick;
            menuItem.Click      += this.CheckableMenuItemClick;

            this.colorMenuItem.Items.Add(menuItem);
            this.selectableColorMenuItems.Add(menuItem);
        }
예제 #2
0
        /// <summary>
        /// Invoked when the <see cref="addCustomColorMenuItem"/> is clicked.
        /// </summary>
        /// <param name="sender">The <see cref="MenuItem"/> where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private void AddCustomColorMenuItemClick(object sender, RoutedEventArgs e)
        {
            ColorDialog dialog = new ColorDialog();

            dialog.AnyColor     = true;
            dialog.FullOpen     = true;
            dialog.CustomColors = ColorManager.Instance.AllColors
                                  .Where(c => c != Color.DefaultColor)
                                  .Select(c => c.ToInt())
                                  .ToArray();

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                Color color = new Color(dialog.Color.R, dialog.Color.G, dialog.Color.B);
                ColorManager.Instance.Add(color);
                this.timerWindow.Options.Color = color;
            }
        }
예제 #3
0
        /// <summary>
        /// Returns an object that can be set for the <see cref="MenuItem.Header"/> of a <see cref="MenuItem"/> that
        /// displays a <see cref="Color"/>.
        /// </summary>
        /// <param name="color">A <see cref="Color"/>.</param>
        /// <returns>An object that can be set for the <see cref="MenuItem.Header"/>.</returns>
        private object GetHeaderForColor(Color color)
        {
            Border border = new Border();

            border.Background   = color.Brush;
            border.CornerRadius = new CornerRadius(2);
            border.Width        = 8;
            border.Height       = 8;

            TextBlock textBlock = new TextBlock();

            textBlock.Text   = color.Name ?? Properties.Resources.ContextMenuCustomColorMenuItem;
            textBlock.Margin = new Thickness(5, 0, 0, 0);

            StackPanel stackPanel = new StackPanel();

            stackPanel.Orientation = Orientation.Horizontal;
            stackPanel.Children.Add(border);
            stackPanel.Children.Add(textBlock);
            return(stackPanel);
        }
예제 #4
0
        /// <summary>
        /// Returns an object that can be set for the <see cref="MenuItem.Header"/> of a <see cref="MenuItem"/> that
        /// displays a <see cref="Color"/>.
        /// </summary>
        /// <param name="color">A <see cref="Color"/>.</param>
        /// <returns>An object that can be set for the <see cref="MenuItem.Header"/>.</returns>
        private object GetHeaderForColor(Color color)
        {
            Border border = new Border();
            border.Background = color.Brush;
            border.CornerRadius = new CornerRadius(2);
            border.Width = 8;
            border.Height = 8;

            TextBlock textBlock = new TextBlock();
            textBlock.Text = color.Name ?? Properties.Resources.ContextMenuCustomColorMenuItem;
            textBlock.Margin = new Thickness(5, 0, 0, 0);

            StackPanel stackPanel = new StackPanel();
            stackPanel.Orientation = Orientation.Horizontal;
            stackPanel.Children.Add(border);
            stackPanel.Children.Add(textBlock);
            return stackPanel;
        }
예제 #5
0
        /// <summary>
        /// Creates a <see cref="MenuItem"/> for a <see cref="Color"/>.
        /// </summary>
        /// <param name="color">A <see cref="Color"/>.</param>
        private void CreateColorMenuItem(Color color)
        {
            MenuItem menuItem = new MenuItem();
            menuItem.Header = this.GetHeaderForColor(color);
            menuItem.Tag = color;
            menuItem.IsCheckable = true;
            menuItem.Click += this.ColorMenuItemClick;
            menuItem.Click += this.CheckableMenuItemClick;

            this.colorMenuItem.Items.Add(menuItem);
            this.selectableColorMenuItems.Add(menuItem);
        }
예제 #6
0
        /// <summary>
        /// Invoked when the <see cref="addCustomColorMenuItem"/> is clicked.
        /// </summary>
        /// <param name="sender">The <see cref="MenuItem"/> where the event handler is attached.</param>
        /// <param name="e">The event data.</param>
        private void AddCustomColorMenuItemClick(object sender, RoutedEventArgs e)
        {
            ColorDialog dialog = new ColorDialog();
            dialog.AnyColor = true;
            dialog.FullOpen = true;
            dialog.CustomColors = ColorManager.Instance.AllColors
                .Where(c => c != Color.DefaultColor)
                .Select(c => c.ToInt())
                .ToArray();

            DialogResult result = dialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                Color color = new Color(dialog.Color.R, dialog.Color.G, dialog.Color.B);
                ColorManager.Instance.Add(color);
                this.timerWindow.Options.Color = color;
            }
        }