Ejemplo n.º 1
0
        private void BeziersBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            newPoint = new MousePoint(e.X, e.Y);
            switch (newType)
            {
            case MainWindow.ImageType.CircleAt:
                star[starCount++] = newPoint.StartP;
                tempPoint.Add(new DPoint(new Point[] { newPoint.StartP }, Color.DarkRed, 1));
                BeziersBox.Invalidate();
                break;

            case MainWindow.ImageType.Beziers:
                tpointCollection.Add(newPoint.StartP);
                newPoint.StartP.Offset(-2, -2);
                Rectangle r  = new Rectangle(newPoint.StartP, new Size(4, 4));
                Region    rr = new Region(r);
                regionCollection.Add(rr);
                Point startp2 = newPoint.StartP;
                startp2.Offset(4, 4);
                pointList.Add(new DHollowRectangle(new Point[] { newPoint.StartP, startp2 }, Color.DarkRed, 1));
                BeziersBox.Invalidate();
                break;

            case MainWindow.ImageType.Set:
                for (int i = 0; i < regionCollection.Count; i++)
                {
                    if (regionCollection[i].IsVisible(newPoint.StartP))
                    {
                        newPoint     = new MousePoint(e.X, e.Y);
                        beziersPoint = i;
                        BezierIndex  = Found(i);
                        pointChange  = true;
                        break;
                    }
                }
                break;
            }
        }
 private void BeziersBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button != MouseButtons.Left)
         return;
     newPoint = new MousePoint(e.X, e.Y);
     switch(newType)
     {
         case MainWindow.ImageType.CircleAt:
             star[starCount++] = newPoint.StartP;
             tempPoint.Add(new DPoint(new Point[]{newPoint.StartP}, Color.DarkRed,1));
             BeziersBox.Invalidate();
             break;
         case MainWindow.ImageType.Beziers:
             tpointCollection.Add(newPoint.StartP);
             newPoint.StartP.Offset(-2,-2);
             Rectangle r = new Rectangle(newPoint.StartP,new Size(4,4));
             Region rr = new Region(r);
             regionCollection.Add(rr);
             Point startp2 = newPoint.StartP;
             startp2.Offset(4,4);
             pointList.Add(new DHollowRectangle(new Point[]{newPoint.StartP,startp2},Color.DarkRed,1));
             BeziersBox.Invalidate();
             break;
         case MainWindow.ImageType.Set:
             for(int i=0;i<regionCollection.Count;i++)
             {
                 if(regionCollection[i].IsVisible(newPoint.StartP))
                 {
                     newPoint = new MousePoint(e.X,e.Y);
                     beziersPoint = i;
                     BezierIndex = Found(i);
                     pointChange = true;
                     break;
                 }
             }
             break;
     }
 }
 private void Drawing_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button != MouseButtons.Left)
         return;
     newPoint.EndX = e.X;
     newPoint.EndY = e.Y;
     this.statusBar.Panels[1].Text="Point:"+e.X.ToString() + "," + e.Y.ToString();
     switch(newType)
     {
         case ImageType.Path:
             mousePath.AddLine(e.X,e.Y,e.X,e.Y);
             break;
         case ImageType.Eraser:
             Point p = newPoint.EndP;
             p.Offset(-EraserSize,-EraserSize);
             newRegion = new Region(new Rectangle(p, new Size(EraserSize*2,EraserSize*2)));
             notchangeList.Add(new DEraser(newPoint.EndP, newColor, EraserSize));
             break;
         case ImageType.Pick:
             if(picked == true&&changed !=true)
             {
                 mouseMove = true;
                 int MoveX = newPoint.EndP.X-newPoint.StartP.X;
                 int MoveY = newPoint.EndP.Y-newPoint.StartP.Y;
                 RegionMove(regionIndex, MoveX,MoveY);
                 if(drawImageType[regionIndex]!=(int)ImageType.Path)
                 {
                     drawingList[regionIndex].pointchange(pointArray[regionIndex]);
                 }
                 else
                 {
                     regionPath = (GraphicsPath)mousePath.Clone();
                     Matrix translateMatrix = new Matrix();
                     translateMatrix.Translate(MoveX, MoveY);
                     regionPath.Transform(translateMatrix);
                     drawingList[regionIndex].pathChange(regionPath,false);
                 }
                 PointChange(regionIndex);
             }
             if(changed ==true&&drawImageType[regionIndex]!=(int)ImageType.Path)
             {
                 mouseMove = true;
                 pointArray[regionIndex][pointIndex] = newPoint.EndP;
                 if(drawImageType[regionIndex]==(int)ImageType.Rectangle
                     ||drawImageType[regionIndex]==(int)ImageType.FillRectangle
                     ||drawImageType[regionIndex]==(int)ImageType.Ellipse
                     ||drawImageType[regionIndex]==(int)ImageType.FillEllipse)
                 {
                     tempChangePoint = new MousePoint(pointArray[regionIndex][1-pointIndex].X, pointArray[regionIndex][1-pointIndex].Y);
                     tempChangePoint.EndX = pointArray[regionIndex][pointIndex].X;
                     tempChangePoint.EndY = pointArray[regionIndex][pointIndex].Y;
                     regionCollection[regionIndex] = new Region(tempChangePoint.Rect);
                 }
                 drawingList[regionIndex].pointchange(pointArray[regionIndex]);
                 PointChange(regionIndex);
             }
             break;
     }
     Drawing.Invalidate();
 }
 /// <summary>
 /// ����¼�
 /// </summary>		
 private void Drawing_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button != MouseButtons.Left)
         return;
     newPoint = new MousePoint(e.X, e.Y);
     switch(newType)
     {
         case ImageType.Path:
             mousePath = new GraphicsPath();
             mousePath.AddLine(e.X,e.Y,e.X,e.Y);
             break;
         case ImageType.Eraser:
             eraser = true;
             newPoint.EndX = e.X;
             newPoint.EndY = e.Y;
             Point p = newPoint.StartP;
             p.Offset(-2,-2);
             newRegion = new Region(new Rectangle(p, new Size(4,4)));
             break;
         case ImageType.Text:
             newForm.Show();
             break;
         case ImageType.Polygon:
             pointCollection.Add(newPoint.StartP);
             tempPoint.Add(new DPoint(new Point[1]{newPoint.StartP}, newColor,lineWidth));
             Drawing.Invalidate();
             break;
         case ImageType.Curve:
             pointCollection.Add(newPoint.StartP);
             tempPoint.Add(new DPoint(new Point[1]{newPoint.StartP}, newColor,lineWidth));
             Drawing.Invalidate();
             break;
         case ImageType.ClosedCurve:
             pointCollection.Add(newPoint.StartP);
             tempPoint.Add(new DPoint(new Point[1]{newPoint.StartP}, newColor,lineWidth));
             Drawing.Invalidate();
             break;
         case ImageType.Pick:
             if(picked == true)
             {
                 for(int k=0;k<regionArrayCollection[regionIndex].Length;k++)
                 {
                     if(regionArrayCollection[regionIndex][k].IsVisible(newPoint.StartP))
                     {
                         pointIndex = k;
                         changed = true;
                         break;
                     }
                     else
                         changed = false;
                 }
                 if(changed == true)
                     break;
             }
             int m = regionIndex;
             if(picked == true)
                 m = (regionIndex+1)%regionCollection.Count;		//ѭ����һ�ʼ
             int n = 0;
             for(;n<regionCollection.Count;n++)
             {
                 if(m >= regionCollection.Count)
                     m = 0;
                 if(regionCollection[m++].IsVisible(newPoint.StartP))
                 {
                     pointViewList = new DShapeList();
                     regionIndex = m-1;
                     tempMovePoint = new Point[pointArray[regionIndex].Length];
                     for(int j=0;j<pointArray[regionIndex].Length;j++)
                     {
                         tempMovePoint[j] = pointArray[regionIndex][j];
                     }
                     PointView(regionIndex);
                     Drawing.Invalidate();
                     picked = true;
                     if(drawImageType[regionIndex]==(int)ImageType.Path)
                     {
                         mousePath = drawingList[regionIndex].pathChange(mousePath,true);
                     }
                     changed = false;
                     break;
                 }
                 else
                 {
                     pointViewList = new DShapeList();
                     Drawing.Invalidate();
                     picked = false;
                 }
             }
             break;
     }
 }