Example #1
0
        private void Button_Add_Color_Click(object sender, RoutedEventArgs e)
        {
            Mode.Colors.Add(new Color(255, 0, 0));

            ColorControlPanel panel = new ColorControlPanel();

            panel.Margin = new Thickness(10);

            int i = Mode.Colors.Count - 1;

            //I couldn't in ANY way make it bind the color properly, at least this works
            //Binding each value from the RGB is broken
            //Binding the color it self conflicts because the controler uses System.Windows.Media.Color instead of System.Drawing.Color
            //I give up, this is it, MVVM for a later day.
            panel.SelectedColorBrush  = new Media.SolidColorBrush(Media.Color.FromArgb(0, Mode.Colors[i].R, Mode.Colors[i].G, Mode.Colors[i].B));
            panel.InitialColorBrush   = new Media.SolidColorBrush(Media.Color.FromArgb(0, Mode.Colors[i].R, Mode.Colors[i].G, Mode.Colors[i].B));
            panel.DockAlphaVisibility = Visibility.Hidden;
            panel.Style              = (Style)FindResource("StyleColorControlPanel");
            panel.ColorChanged      += colorPicker_ColorChanged;
            panel.LostMouseCapture  += Panel_LostMouseCapture;
            panel.LostKeyboardFocus += Panel_LostKeyboardFocus;


            ContextMenu context = new ContextMenu();
            MenuItem    item    = new MenuItem();

            item.Header = "Remove";
            item.Click += Item_Click;
            context.Items.Add(item);

            panel.ContextMenu = context;

            StackColors.Children.Add(panel);
        }
        private void openColorControls()
        {
            ccpWindow  = new SetColorWin();
            colorPanel = ccpWindow.ColorControls;

            ccpWindow.Show();

            colorPanel.ColorChanged += buttons_ColorChanged;
        }
Example #3
0
        private void Item_Click(object sender, RoutedEventArgs e)
        {
            if (StackColors.Children.Count > 1)
            {
                //Get the parent of the menuitem
                MenuItem          menuItem = sender as MenuItem;
                ColorControlPanel color    = null;
                if (menuItem != null)
                {
                    color = ((ContextMenu)menuItem.Parent).PlacementTarget as ColorControlPanel;
                }

                //Get it's index in the stack
                int index = StackColors.Children.IndexOf(color as UIElement);

                //Remove the color and the stack
                Mode.Colors.RemoveAt(index);
                StackColors.Children.Remove(color);
            }
        }
Example #4
0
        public FixedColors()
        {
            InitializeComponent();

            for (int i = 0; i < Mode.Colors.Count; i++)
            {
                ColorControlPanel panel = new ColorControlPanel();
                panel.Margin = new Thickness(10);

                //I couldn't in ANY way make it bind the color properly, at least this works
                //Binding each value from the RGB is broken
                //Binding the color it self conflicts because the controler uses System.Windows.Media.Color instead of System.Drawing.Color
                //I give up, this is it, MVVM for a later day.

                panel.SelectedColorBrush  = new Media.SolidColorBrush(Media.Color.FromArgb(0, Mode.Colors[i].R, Mode.Colors[i].G, Mode.Colors[i].B));
                panel.InitialColorBrush   = new Media.SolidColorBrush(Media.Color.FromArgb(0, Mode.Colors[i].R, Mode.Colors[i].G, Mode.Colors[i].B));
                panel.DockAlphaVisibility = Visibility.Hidden;
                panel.Style              = (Style)FindResource("StyleColorControlPanel");
                panel.ColorChanged      += colorPicker_ColorChanged;
                panel.LostMouseCapture  += Panel_LostMouseCapture;
                panel.LostKeyboardFocus += Panel_LostKeyboardFocus;

                ContextMenu context = new ContextMenu();
                MenuItem    item    = new MenuItem();
                item.Header = "Remove";
                item.Click += Item_Click;
                context.Items.Add(item);

                panel.ContextMenu = context;
                StackColors.Children.Add(panel);
            }

            FillColor();

            timer = new DispatcherTimer()
            {
                Interval = new System.TimeSpan(App.settings.Speed)
            };
            timer.Tick += Timer_Tick;
        }