Beispiel #1
0
        public void SetParametersFromShape(IShape shape)
        {
            //Фигура

            if (shape is Shape)
            {
                Shape currentShape = shape as Shape;

                //Fore

                Pen shapePen = currentShape.Pen;
                this.FColor = shapePen.Color;

                //Back, если фигура заполнена

                if (currentShape.IsFill)
                {
                    Brush shapeBrush = currentShape.Brush;
                    if (shapeBrush is SolidBrush)
                    {
                        this.BColor = ((SolidBrush)shapeBrush).Color;
                    }
                    else
                    {
                        this.BColor = ((HatchBrush)shapeBrush).BackgroundColor;
                    }
                }
            }

            //Заливка

            else
            {
                MyFill currentFill = shape as MyFill;
                this.FColor = currentFill.FillColor;
            }

            this.Invalidate();
        }
Beispiel #2
0
        void canvas_MouseClick(object sender, MouseEventArgs e)
        {
            if (this.isEdit)
            {
                return;
            }

            switch (this.typeTool)
            {
                case SHAPES.FILLTOOL:
                    {
                        MyFill currentFill = null;
                        if (e.Button == System.Windows.Forms.MouseButtons.Left)
                        {
                            currentFill = new MyFill(e.Location, this.colorChoicer.BColor);
                        }
                        this.shapesList.Add(currentFill);

                        this.UpdateShapeListComboBox();

                        this.BufferToCanvas();
                    }
                    break;
                case SHAPES.COLORCHOICE:
                    {
                        Graphics g = this.canvas.CreateGraphics();
                        IntPtr hDc = g.GetHdc();
                        uint clr = MyFill.GetPixel(hDc, e.X, e.Y);
                        uint R = clr & 0xFF;
                        uint G = (clr >> 8) & 0xFF;
                        uint B = (clr >> 16) & 0xFF;
                        Color currentColor = Color.FromArgb(255, (int)R, (int)G, (int)B);
                        if (e.Button == System.Windows.Forms.MouseButtons.Left)
                        {
                            this.colorChoicer.FColor = currentColor;
                        }
                        else if (e.Button == System.Windows.Forms.MouseButtons.Right)
                        {
                            this.colorChoicer.BColor = currentColor;
                        }
                        this.colorChoicer.Invalidate();
                        g.ReleaseHdc();
                    }
                    break;
                default:
                    break;
            }
        }
Beispiel #3
0
        private void Fill(Point pos)
        {
            MyFill currentFill = null;
            currentFill = new MyFill(pos, this.colorChoicer.BColor);
            this.shapesList.Add(currentFill);

            this.UpdateShapeListComboBox();

            this.BufferToCanvas();
        }