Пример #1
0
        private void PictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            flag = false;

            switch (drawMode)
            {
            case DrawMode.penMode:
            case DrawMode.eraserMode:
                DrawingData dd = new DrawingData();
                dd.pen        = p;
                dd.startPoint = CurPos;
                drawingSaveData.Add(dd);
                break;

            case DrawMode.line:
                DrawingData sd = new DrawingData();
                sd.startPoint = ClickPos;
                sd.endPoint   = pictureBox1.PointToClient(new Point(Control.MousePosition.X, Control.MousePosition.Y));
                lineSaveData.Add(sd);
                break;

            case DrawMode.curve:
                CurveData cd = new CurveData();
                cd.startPoint = ClickPos;
                cd.endPoint   = pictureBox1.PointToClient(new Point(Control.MousePosition.X, Control.MousePosition.Y));
                curveSaveData.Add(cd);
                curveFlag1 = true;
                break;

            case DrawMode.rect:
                recSaveData.Add(rec);
                break;

            case DrawMode.circle:
                circleSaveSData.Add(rec);
                break;

            case DrawMode.cloudMark:
                CloudMark cm = new CloudMark();
                cm.message = text;
                cm.rec     = rec;
                cloudMarkSaveData.Add(cm);
                break;

            case DrawMode.heart:
                Heart heart = new Heart();
                heart.message = text;
                heart.rec     = rec;
                heartSaveData.Add(heart);
                break;
            }

            if (drawMode == DrawMode.rect)
            {
                Graphics g = Graphics.FromImage(picBmp);
                g.DrawRectangle(p, rec);
            }
        }
Пример #2
0
        private void PictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            Color color;

            CurPos = pictureBox1.PointToClient(new Point(Control.MousePosition.X, Control.MousePosition.Y));

            if (drawMode == DrawMode.eraserMode)
            {
                color = Color.White;
            }
            else
            {
                color = Color.Aquamarine;
            }

            pictureBox1.Image = picBmp;

            p = new Pen(color)
            {
                Width = curLineSize
            };

            if (flag)
            {
                switch (drawMode)
                {
                case DrawMode.penMode:
                case DrawMode.eraserMode:
                    g.DrawEllipse(p, CurPos.X, CurPos.Y, p.Width, p.Width);     //타원 그리기
                    DrawingData dd = new DrawingData();
                    dd.pen        = p;
                    dd.startPoint = CurPos;
                    drawingSaveData.Add(dd);
                    break;

                case DrawMode.line:     //선 그리기
                    if (e.Button == MouseButtons.Left)
                    {
                        DrawAll();
                    }
                    break;

                case DrawMode.curve:     //곡선 그리기
                    if (e.Button == MouseButtons.Left)
                    {
                        DrawAll();
                        curveFlag2 = true;
                    }
                    break;

                case DrawMode.rect:     //직사각형 그리기
                    if (e.Button == MouseButtons.Left)
                    {
                        DrawAll();
                    }
                    break;

                case DrawMode.circle:     //타원형 그리기
                    if (e.Button == MouseButtons.Left)
                    {
                        DrawAll();
                    }
                    break;

                case DrawMode.cloudMark:
                    if (e.Button == MouseButtons.Left)     //클라우드 마크 그리기
                    {
                        DrawAll();
                    }
                    break;

                case DrawMode.heart:
                    if (e.Button == MouseButtons.Left)     //하트 그리기
                    {
                        DrawAll();
                    }
                    break;
                }
            }
        }