Пример #1
0
        private ColorPaletteButton generateColorButton(int columnNumber, Color fillColor,
                                                       ColorPaletteButton.StackPosition position)
        {
            ColorPaletteButton button = new ColorPaletteButton(fillColor, position);

            button.ColorSelected += this.onColorButtonColorSelected;
            button.Width          = this._buttonSize.Width;
            button.Height         = this._buttonSize.Height;
            button.Margin         = new Thickness(2.0);
            Grid.SetColumn(button, columnNumber);
            return(button);
        }
Пример #2
0
        private ColorPaletteButton generateColorButton(int columnNumber, int rowNum, Color fillColor,
                                                       ColorPaletteButton.StackPosition position)
        {
            ColorPaletteButton button = new ColorPaletteButton(fillColor, position);

            button.IsSelected     = false; // IsCurrentSelectedColor(fillColor);
            button.ColorSelected += this.onColorButtonColorSelected;
            button.Width          = this._buttonSize.Width;
            button.Height         = this._buttonSize.Height;
            Grid.SetColumn(button, columnNumber);
            Grid.SetRow(button, rowNum);
            if (rowNum == 0)
            {
                button.Margin = new Thickness(2.0, 2.0, 2.0, 0.0);
                return(button);
            }
            if (rowNum < (this.MaxRows - 1))
            {
                button.Margin = new Thickness(2.0, 0.0, 2.0, 0.0);
                return(button);
            }
            button.Margin = new Thickness(2.0, 0.0, 2.0, 2.0);
            return(button);
        }
Пример #3
0
        internal void generateColorButtons()
        {
            Color colorWhite = System.Windows.Media.Colors.White;
            Color colorBlack = System.Windows.Media.Colors.Black;

            // detach all click handlers
            foreach (ColorPaletteButton btn in _colorButtons)
            {
                btn.ColorSelected -= this.onColorButtonColorSelected;
            }

            this._colorButtons.Clear();
            int colNum = 0;
            Collection <Color> themeColors = ThemeColors ?? Colors;

            ColorPaletteButton.StackPosition position = ColorPaletteButton.StackPosition.None;
            if (themeColors != null)
            {
                foreach (Color currentColor in themeColors)
                {
                    Color color3;
                    int   rowNum = 0;
                    int   num5;

                    colNum++;
                    color3 = currentColor;
                    this._colorButtons.Add(this.generateColorButton(colNum - 1, color3,
                                                                    ColorPaletteButton.StackPosition.None));
                    rowNum = 0;
                    if (ColorToDouble(color3) <= 0.699999988079071)
                    {
                        num5 = (int)Math.Floor((double)(((double)this.MaxRows) / 2.0));
                        int num6 = (int)Math.Ceiling((double)(((double)this.MaxRows) / 2.0));
                        for (int i = 0; i < num6; i++)
                        {
                            float num8 = ((float)(i + 1)) / (num6 + 1f);
                            position = i == 0 ? ColorPaletteButton.StackPosition.Top : ColorPaletteButton.StackPosition.Middle;
                            this._colorButtons.Add(this.generateColorButton(colNum - 1, rowNum++, generateColor(colorWhite, color3, num8),
                                                                            position));
                        }
                        int num9 = 0;

                        while (num9 < num5)
                        {
                            float num10 = ((float)(num9 + 1)) / ((float)num5);
                            num10   *= 0.7f;
                            position = num9 < num5 - 1 ? ColorPaletteButton.StackPosition.Middle : ColorPaletteButton.StackPosition.Bottom;
                            this._colorButtons.Add(this.generateColorButton(colNum - 1, rowNum++, generateColor(color3, colorBlack, num10),
                                                                            position));
                            num9++;
                        }
                        continue;
                    }
                    int num3 = 0;
                    while (num3 < this.MaxRows)
                    {
                        float num4 = ((float)(num3 + 1)) / (this.MaxRows + 1f);
                        num4 *= 0.7f;

                        if (num3 == 0)
                        {
                            position = ColorPaletteButton.StackPosition.Top;
                        }
                        else if (num3 == this.MaxRows - 1)
                        {
                            position = ColorPaletteButton.StackPosition.Bottom;
                        }
                        else
                        {
                            position = ColorPaletteButton.StackPosition.Middle;
                        }

                        this._colorButtons.Add(this.generateColorButton(colNum - 1, rowNum++, generateColor(color3, colorBlack, num4),
                                                                        position));
                        num3++;
                    }
                }
            }
        }