Пример #1
0
 private void LayerRemovedHandler(object sender, IndexEventArgs e)
 {
 }
Пример #2
0
 private void LayerInsertedHandler(object sender, IndexEventArgs e)
 {
     Layer layer = (Layer)this.Document.Layers[e.Index];
     this.ActiveLayer = layer;
     layer.PropertyChanging += LayerPropertyChangingHandler;
     layer.PropertyChanged += LayerPropertyChangedHandler;
 }
Пример #3
0
        private void LayerRemovingHandler(object sender, IndexEventArgs e)
        {
            Layer layer = (Layer)this.Document.Layers[e.Index];
            layer.PropertyChanging -= LayerPropertyChangingHandler;
            layer.PropertyChanged -= LayerPropertyChangedHandler;

            // pick a new valid layer!
            int newLayerIndex;

            if (e.Index == this.Document.Layers.Count - 1)
            {
                newLayerIndex = e.Index - 1;
            }
            else
            {
                newLayerIndex = e.Index + 1;
            }

            if (newLayerIndex >= 0 && newLayerIndex < this.Document.Layers.Count)
            {
                this.ActiveLayer = (Layer)this.Document.Layers[newLayerIndex];
            }
            else
            {
                if (this.Document.Layers.Count == 0)
                {
                    this.ActiveLayer = null;
                }
                else
                {
                    this.ActiveLayer = (Layer)this.Document.Layers[0];
                }
            }
        }
Пример #4
0
        private void HsvGradientControl_ValueChanged(object sender, IndexEventArgs e)
        {
            if (IgnoreChangedEvents)
            {
                return;
            }

            int hue;
            if (sender == hueGradientControl)
            {
                hue = (hueGradientControl.Value * 360) / 255;
            }
            else
            {
                hue = (int)hueUpDown.Value;
            }

            int saturation;
            if (sender == saturationGradientControl)
            {
                saturation = (saturationGradientControl.Value * 100) / 255;
            }
            else
            {
                saturation = (int)saturationUpDown.Value;
            }

            int value;
            if (sender == valueGradientControl)
            {
                value = (valueGradientControl.Value * 100) / 255;
            }
            else
            {
                value = (int)valueUpDown.Value;
            }

            HsvColor hsvColor = new HsvColor(hue, saturation, value);
            colorWheel.HsvColor = hsvColor;
            RgbColor rgbColor = hsvColor.ToRgb();
            ColorBgra color = ColorBgra.FromBgra((byte)rgbColor.Blue, (byte)rgbColor.Green, (byte)rgbColor.Red, (byte)alphaUpDown.Value);

            Utility.SetNumericUpDownValue(hueUpDown, hsvColor.Hue);
            Utility.SetNumericUpDownValue(saturationUpDown, hsvColor.Saturation);
            Utility.SetNumericUpDownValue(valueUpDown, hsvColor.Value);

            Utility.SetNumericUpDownValue(redUpDown, rgbColor.Red);
            Utility.SetNumericUpDownValue(greenUpDown, rgbColor.Green);
            Utility.SetNumericUpDownValue(blueUpDown, rgbColor.Blue);
            
            string hexText = GetHexNumericUpDownValue(rgbColor.Red, rgbColor.Green, rgbColor.Blue);
            hexBox.Text = hexText;
            
            switch (WhichUserColor)
            {
                case WhichUserColor.Primary:
                    UserPrimaryColor = color;
                    OnRelinquishFocus();
                    break;

                case WhichUserColor.Secondary:
                    UserSecondaryColor = color;
                    OnRelinquishFocus();
                    break;

                default:
                    throw new InvalidEnumArgumentException("WhichUserColor property");
            }

            Update();
        }
Пример #5
0
        private void RgbGradientControl_ValueChanged(object sender, IndexEventArgs ce)
        {
            if (IgnoreChangedEvents)
            {
                return;
            }

            int red;
            if (sender == redGradientControl)
            {
                red = redGradientControl.Value;
            }
            else
            {
                red = (int)redUpDown.Value;
            }

            int green;
            if (sender == greenGradientControl)
            {
                green = greenGradientControl.Value;
            }
            else
            {
                green = (int)greenUpDown.Value;
            }

            int blue;
            if (sender == blueGradientControl)
            {
                blue = blueGradientControl.Value;
            }
            else
            {
                blue = (int)blueUpDown.Value;
            }

            int alpha;
            if (sender == alphaGradientControl)
            {
                alpha = alphaGradientControl.Value;
            }
            else
            {
                alpha = (int)alphaUpDown.Value;
            }

            Color rgbColor = Color.FromArgb(alpha, red, green, blue);
            HsvColor hsvColor = HsvColor.FromColor(rgbColor);

            PushIgnoreChangedEvents();
            Utility.SetNumericUpDownValue(hueUpDown, hsvColor.Hue);
            Utility.SetNumericUpDownValue(saturationUpDown, hsvColor.Saturation);
            Utility.SetNumericUpDownValue(valueUpDown, hsvColor.Value);

            Utility.SetNumericUpDownValue(redUpDown, rgbColor.R);
            Utility.SetNumericUpDownValue(greenUpDown, rgbColor.G);
            Utility.SetNumericUpDownValue(blueUpDown, rgbColor.B);
            PopIgnoreChangedEvents();
            Utility.SetNumericUpDownValue(alphaUpDown, rgbColor.A);

            string hexText = GetHexNumericUpDownValue(rgbColor.R, rgbColor.G, rgbColor.B);
            hexBox.Text = hexText;

            ColorBgra color = ColorBgra.FromColor(rgbColor);

            switch (WhichUserColor)
            {
                case WhichUserColor.Primary:
                    UserPrimaryColor = color;
                    OnRelinquishFocus();
                    break;

                case WhichUserColor.Secondary:
                    UserSecondaryColor = color;
                    OnRelinquishFocus();
                    break;

                default:
                    throw new InvalidEnumArgumentException("WhichUserColor property");
            }

            Update();
        }
Пример #6
0
 private void LayerRemovedHandler(object sender, IndexEventArgs e)
 {
     LayerElement lec = layerControls[e.Index];
     this.thumbnailManager.RemoveFromQueue(lec.Layer);
     lec.Click -= this.elementClickDelegate;
     lec.DoubleClick -= this.elementDoubleClickDelegate;
     lec.KeyUp -= keyUpDelegate;
     lec.Layer = null;
     layerControls.Remove(lec);
     layerControlPanel.Controls.Remove(lec);
     lec.Dispose();
     PerformLayout();
 }
Пример #7
0
 private void LayerInsertedHandler(object sender, IndexEventArgs e)
 {
     this.SuspendLayout();
     this.layerControlPanel.SuspendLayout();
     Layer layer = (Layer)this.document.Layers[e.Index];
     LayerElement lec = new LayerElement();
     lec.ThumbnailManager = this.thumbnailManager;
     lec.ThumbnailSize = this.thumbnailSize;
     InitializeLayerElement(lec, layer);
     layerControls.Insert(e.Index, lec);
     layerControlPanel.Controls.Add(lec);
     layerControlPanel.ScrollControlIntoView(lec);
     lec.Select();
     SetActive(lec);
     lec.RefreshPreview();
     this.layerControlPanel.ResumeLayout(false);
     this.ResumeLayout(false);
     this.layerControlPanel.PerformLayout();
     PerformLayout();
 }