Beispiel #1
0
        private void MouseDownColorButtons(object sender, MouseEventArgs e)
        {
            PaintButton ourSender = (sender as PaintButton);

            switch (e.Button)
            {
            case System.Windows.Forms.MouseButtons.Left:
                if (ourSender != currentColorButton)
                {
                    currentColorButton.Stroke = Color.Black;
                    ourSender.Stroke          = Color.Red;
                    currentColorButton        = ourSender;
                }
                break;

            case System.Windows.Forms.MouseButtons.Right:
                ColorDialog dialogColor = new ColorDialog();
                if (dialogColor.ShowDialog() == DialogResult.OK)
                {
                    ourSender.BackColor = dialogColor.Color;
                }
                dialogColor.Dispose();
                break;
            }
        }
Beispiel #2
0
 private void PickTool(PaintButton tool)
 {
     if (tool != currentButton)
     {
         currentButton.Stroke = Color.Black;
         tool.Stroke          = Color.Red;
         currentButton        = tool;
         if (ChangedTool != null)
         {
             ChangedTool.Invoke(this, new EventArgs());
         }
     }
 }
Beispiel #3
0
        private void InitCustom()
        {
            buttons.Add(penButton);
            penButton.ImagePath = @"..\..\icons\pencil.png";

            buttons.Add(textButton);
            textButton.ImagePath = @"..\..\icons\text.png";

            buttons.Add(eraserButton);
            eraserButton.ImagePath = @"..\..\icons\eraser.png";

            buttons.Add(pipetteButton);
            pipetteButton.ImagePath = @"..\..\icons\pipette.png";

            buttons.Add(lineButton);
            lineButton.ImagePath = @"..\..\icons\line.png";

            buttons.Add(rectangleButton);
            rectangleButton.ImagePath = @"..\..\icons\rectangle.png";

            buttons.Add(ellipseButton);
            ellipseButton.ImagePath = @"..\..\icons\ellipse.png";
            for (int i = 0; i < buttons.Count; i++)
            {
                buttons[i].Stroke = Color.Black;
                buttons[i].Click += ClickButtons;
            }

            currentButton        = penButton;
            currentButton.Stroke = Color.Red;
            PickTool(Tool.Pen);

            currentColorButton        = firstColorButton;
            currentColorButton.Stroke = Color.Red;
            secondColorButton.Stroke  = Color.Black;

            Anchor = ((AnchorStyles)((((AnchorStyles.Top) | AnchorStyles.Left) | AnchorStyles.Right)));
            Dock   = DockStyle.Top;

            firstColorButton.MouseDown  += MouseDownColorButtons;
            secondColorButton.MouseDown += MouseDownColorButtons;

            dashStyleComboBox.SelectedItem = "Solid";
        }
Beispiel #4
0
        private PaintButton GetToolButton(Tool tool)
        {
            PaintButton gettingTool = null;

            switch (tool)
            {
            case Tool.Ellipse:
                gettingTool = ellipseButton;
                break;

            case Tool.Eraser:
                gettingTool = eraserButton;
                break;

            case Tool.Line:
                gettingTool = lineButton;
                break;

            case Tool.Pen:
                gettingTool = penButton;
                break;

            case Tool.Pipette:
                gettingTool = pipetteButton;
                break;

            case Tool.Rectangle:
                gettingTool = rectangleButton;
                break;

            case Tool.Text:
                gettingTool = textButton;
                break;
            }
            return(gettingTool);
        }