Esempio n. 1
0
 private void CaseChange(CASE temp)
 {
     if (NowCase == CASE.polygon && temp != CASE.polygon)
     {
         pn.FinishDraw = true;
         OperaStep.AddStep(pn);
         RefreshPictureBox();
         pn = null;
     }
     else if (NowCase == CASE.Bezier && temp != CASE.Bezier)
     {
         bz.FinishDraw = true;
         OperaStep.AddStep(bz);
         RefreshPictureBox();
         bz = null;
     }
     else if (NowCase == CASE.Bsplines && temp != CASE.Bsplines)
     {
         bs.FinishDraw = true;
         OperaStep.AddStep(bs);
         RefreshPictureBox();
         bs = null;
     }
     NowCase = temp;
 }
Esempio n. 2
0
 private void button_back_Click(object sender, EventArgs e)
 {
     //TODO:撤销当前步骤
     OperaStep.BackStep();
     RefreshPictureBox();
     IsBack = true;
 }
Esempio n. 3
0
 private void button_front_Click(object sender, EventArgs e)
 {
     //TODO:快进当前步骤
     OperaStep.NextStep();
     RefreshPictureBox();
 }
Esempio n. 4
0
 private void RefreshPictureBox()
 {
     pictureBox.Image = (Image)Backgroud.Clone();
     OperaStep.DrawOperation();
 }
Esempio n. 5
0
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (IsBack)
            {
                OperaStep.RemoveNullStep();
            }

            //设置起点
            x0 = e.X;
            y0 = e.Y;

            FrontImage = pictureBox.Image.Clone() as Image;

            //标记鼠标摁下
            IsMouseDown = true;

            switch (NowCase)
            {
            case CASE.NoOperation:
                break;

            case CASE.Bezier:
                break;

            case CASE.line:
                break;

            case CASE.roundness:
                break;

            case CASE.ellipse:
                break;

            case CASE.rectangle:
                break;

            case CASE.pencil:
                break;

            case CASE.clip:
                break;

            case CASE.selected:
                if (selectedShape != null)
                {
                    if (selectedShape.PointInIt(x0, y0))
                    {
                        CaseChange(CASE.Panning);
                    }
                    else
                    {
                        selectedShape.unSelectShape();
                        //CaseChange(CASE.NoOperation);
                        selectedShape = null;
                    }
                }
                break;

            case CASE.polygon:
                break;

            case CASE.Panning:
                break;

            default:
                break;
            }
        }
Esempio n. 6
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)//鼠标左键松开
        {
            if (NowCase == CASE.selected)
            {
                if (selectedShape != null)
                {
                    selectedShape.unSelectShape();
                }
                selectedShape = OperaStep.SelectShape(x0, y0);
                if (selectedShape != null)
                {
                    selectedShape.InitButton();
                    selectedShape.SelectShape();
                }
            }

            RefreshPictureBox();
            if (IsMouseDown)
            {
                IsMouseDown = false;
            }

            switch (NowCase)
            {
            case CASE.NoOperation:
                break;

            case CASE.line:
                Line l = new Line();
                l.InitLine(pictureBox, color, x0, y0, e.X, e.Y);
                l.Draw();
                OperaStep.AddStep(l);
                break;

            case CASE.roundness:
                Roundness r = new Roundness();
                r.InitRoundness(pictureBox, color, x0, y0, e.X, e.Y);
                r.Draw();
                OperaStep.AddStep(r);
                break;

            case CASE.ellipse:
                Ellipse ee = new Ellipse();
                ee.InitEllipse(pictureBox, color, x0, y0, e.X, e.Y);
                ee.Draw();
                OperaStep.AddStep(ee);
                break;

            case CASE.rectangle:
                Rect re = new Rect();
                re.InitRectangle(pictureBox, color, x0, y0, e.X, e.Y);
                re.Draw();
                OperaStep.AddStep(re);
                break;

            case CASE.pencil:
                break;

            case CASE.clip:
                OperaStep.ClipAllShapes(Math.Min(x0, e.X), Math.Min(y0, e.Y), Math.Max(x0, e.X), Math.Max(y0, e.Y));
                RefreshPictureBox();
                break;

            case CASE.selected:
                break;

            case CASE.polygon:
                pn.AddPoint(e.X, e.Y);
                pn.UpdateEdge(e.X, e.Y);
                pn.Draw();
                break;

            case CASE.Bezier:
                bz.AddControlPoint(e.X, e.Y);
                bz.UpdateEdge(e.X, e.Y);
                bz.Draw();
                break;

            case CASE.Bsplines:
                bs.AddControlPoint(e.X, e.Y);
                bs.UpdateEdge(e.X, e.Y);
                bs.Draw();
                break;

            case CASE.Panning:
                selectedShape.Setdxdy(e.X - x0, e.Y - y0);
                if (selectedShape.GetShapeType() != ShapeType.polygon)
                {
                    selectedShape.UpdatePoint();
                }
                else
                {
                    ((Polygon)selectedShape).Updatedxdy();
                }
                selectedShape.Draw();
                CaseChange(CASE.selected);
                break;

            default:
                break;
            }
        }