Ejemplo n.º 1
0
        private void fastDraw1_MouseDown(object sender, MouseEventArgs e)
        {
            if (DrawToolActive == DrawTool.PaintBucket)
            {
                if (e.Button != MouseButtons.Left && e.Button != MouseButtons.Right)
                {
                    return;
                }

                var point = TranslatePoint(e.X, e.Y);

                Color ColorClicked = DrawingImage.GetPixel(point.X, point.Y);
                if (ColorClicked.A == 0)
                {
                    ColorClicked = Color.Transparent;
                }

                Color ColorToSet = Color.Empty;
                if (e.Button == MouseButtons.Left)
                {
                    ColorToSet = colorPickEdit1.Color;
                }
                else if (e.Button == MouseButtons.Right)
                {
                    ColorToSet = colorPickEdit2.Color;
                }
                UnlockedBitmap = new LockBitmap(DrawingImage);
                UnlockedBitmap.LockBits();

                FloodArea(point.X, point.Y, ColorToSet, ColorClicked);

                UnlockedBitmap.UnlockBits();
                UnlockedBitmap = null;

                fastDraw1.Refresh();
            }
            else
            {
                IsMouseDown    = true;
                prevMouse      = e.Location;
                UnlockedBitmap = new LockBitmap(DrawingImage);
                UnlockedBitmap.LockBits();

                DrawPixel(e.X, e.Y, e.Button, true);

                UnlockedBitmap.UnlockBits();
                UnlockedBitmap = null;

                fastDraw1.Refresh();
            }
        }
Ejemplo n.º 2
0
        private void fastDraw1_MouseMove(object sender, MouseEventArgs e)
        {
            if (!IsMouseDown)
            {
                return;
            }
            UnlockedBitmap = new LockBitmap(DrawingImage);
            UnlockedBitmap.LockBits();

            DrawLine(prevMouse.X, prevMouse.Y, e.Location.X, e.Location.Y, e.Button);

            UnlockedBitmap.UnlockBits();
            UnlockedBitmap = null;

            fastDraw1.Refresh();

            prevMouse = e.Location;
        }