private void picRubberBandLayer_MouseMove(object sender, MouseEventArgs e) { //Processing the InfoBox if (g_blFileIsOpened || g_blFileIsNewed) { if (m_blAdjusting == true) { if (m_intAjustingState != 0) { switch (m_intAjustingState) //1.tanslate 2.scale 3.rotate 4.move center { case 1: Size TransSize = new Size(e.X - m_ptStart.X, e.Y - m_ptStart.Y); g_lstSelectedShapeList[g_lstSelectedShapeList.Count - 1].Translate(TransSize); //move the shape m_abAdjustingBox.Translate(TransSize); //move the control box this.picRubberBandLayer.Invalidate(); this.pnlBackground.Invalidate(); m_ptStart = new Point(e.X, e.Y); break; case 2: m_abAdjustingBox.Scale(new Point(e.X,e.Y)); //Scale the adjustingbox this.picRubberBandLayer.Invalidate(); this.pnlBackground.Invalidate(); break; case 3: m_ptEnd = new Point(e.X, e.Y); SetRotation(m_ptStart, m_ptEnd); //Set up the RotationMatrix m_abAdjustingBox.Rotate(m_dbRotationMatrix); this.picRubberBandLayer.Invalidate(); this.pnlBackground.Invalidate(); break; case 4: m_abAdjustingBox.m_ptRotationCenter = new Point(e.X, e.Y); this.pnlBackground.Invalidate(); break; } } } else { if (m_blOperating == false) //get cursor's RGB color when it is not on operating { Graphics tempGraphics = Graphics.FromImage(g_bmCache); Point screen = ((Control)sender).PointToScreen(new Point(e.X, e.Y)); tempGraphics.CopyFromScreen(screen.X, screen.Y, 0, 0, new Size(1, 1)); //copy the (X,Y) in screen point to a 1*1 bitmap cache m_clrPixelColor = g_bmCache.GetPixel(0, 0); //Get the pixel color of cashe frmInfoBox.SetCurrentCursor(e.Location); m_btPixelColorR = m_clrPixelColor.R; m_btPixelColorG = m_clrPixelColor.G; m_btPixelColorB = m_clrPixelColor.B; frmInfoBox.SetColorRGB(m_btPixelColorR, m_btPixelColorG, m_btPixelColorB); } else //Refresh the size of shape when in operating { if (ToolBoxForm.g_tmUsingToolMode == ToolBoxForm.ToolMode.Rectangle || ToolBoxForm.g_tmUsingToolMode == ToolBoxForm.ToolMode.Ellipse) { frmInfoBox.SetSize(m_ptStart, m_ptEnd); } } if (m_blOperating == true) { switch (ToolBoxForm.g_tmUsingToolMode) { case ToolBoxForm.ToolMode.Move: Size translation = new Size(e.X - m_ptStart.X, e.Y - m_ptStart.Y); foreach (Shape G in g_lstSelectedShapeList) //Translate the selected shape { G.Translate(translation); } this.pnlBackground.Invalidate(); //Move the Adjustingbox with the shape m_ptStart = new Point(e.X, e.Y); //Prepare for the next StartPoint break; case ToolBoxForm.ToolMode.Line: m_lnNewLine.SetEnd(e.Location); picRubberBandLayer.Invalidate(); //Refresh the picture box to realize rubber band break; case ToolBoxForm.ToolMode.Curve: m_cvNewCurve = new Curve(m_ptStart, e.Location); picRubberBandLayer.Invalidate(); //Refresh the picture box to realize rubber band break; case ToolBoxForm.ToolMode.Rectangle: m_ptEnd = new Point(e.X, e.Y); m_rtNewRect = new Rect(m_ptStart, m_ptEnd, m_blShiftKeyDown); m_rtNewRect.SetPen(ColorBoxForm.g_clrSelectedColor1, //Set up the pen ToolBoxForm.g_ftLineWidth); picRubberBandLayer.Invalidate(); break; case ToolBoxForm.ToolMode.Text: //The Text Frame m_ptEnd = new Point(e.X, e.Y); m_txtNewText = new Text(m_ptStart, m_ptEnd); m_txtNewText.SetPen(DashStyle.Dot, Color.Black, 1); //Dash Dot Frame picRubberBandLayer.Invalidate(); break; case ToolBoxForm.ToolMode.Ellipse: m_ptEnd = new Point(e.X, e.Y); m_elNewElli = new Elli(m_ptStart, m_ptEnd, m_blShiftKeyDown); m_elNewElli.SetPen(ColorBoxForm.g_clrSelectedColor1, ToolBoxForm.g_ftLineWidth); picRubberBandLayer.Invalidate(); break; case ToolBoxForm.ToolMode.RoundedRectangle: m_ptEnd = new Point(e.X, e.Y); m_rrNewRdRect = new RoundedRect(m_ptStart, m_ptEnd, m_blShiftKeyDown); m_rrNewRdRect.g_blRdRectHasBeenCreated = true; m_rrNewRdRect.SetPen(ColorBoxForm.g_clrSelectedColor1, ToolBoxForm.g_ftLineWidth); picRubberBandLayer.Invalidate(); break; case ToolBoxForm.ToolMode.Pencil: Graphics g = Graphics.FromImage(g_bmBackground); //Drawing line continually to make a free line pencil g.DrawLine(m_penPencil, m_ptStart.X, m_ptStart.Y, e.X, e.Y); g.SmoothingMode = SmoothingMode.HighQuality; g.PixelOffsetMode = PixelOffsetMode.HighSpeed; m_ptStart.X = e.X; m_ptStart.Y = e.Y; this.pnlBackground.Invalidate(); break; case ToolBoxForm.ToolMode.Eraser: Graphics g2 = Graphics.FromImage(g_bmBackground); int r2 = ToolBoxForm.g_intEraserWidth / 2; g2.FillEllipse(m_brsEraserBrush, e.X - r2, e.Y - r2, r2 * 2, r2 * 2); this.pnlBackground.Invalidate(); break; case ToolBoxForm.ToolMode.Brush: Graphics g3 = Graphics.FromImage(g_bmBackground); g3.SmoothingMode = SmoothingMode.HighQuality; g3.PixelOffsetMode = PixelOffsetMode.HighSpeed; int r = ToolBoxForm.g_intBrushWidth / 2; m_ptStart = e.Location; switch (ToolBoxForm.g_intBrushStyle) //Initialize the brush according to the selection { case 1: g3.FillEllipse(m_brsSolidBrush, m_ptStart.X - r, m_ptStart.Y - r, 2 * r, 2 * r); break; case 2: g3.FillEllipse(m_brsHatchBrush, m_ptStart.X - r, m_ptStart.Y - r, 2 * r, 2 * r); break; case 3: g3.FillEllipse(m_brsLinearBrush, m_ptStart.X - r, m_ptStart.Y - r, 2 * r, 2 * r); break; } m_ptStart = e.Location; this.pnlBackground.Invalidate(); break; } } else { switch (ToolBoxForm.g_tmUsingToolMode) { case ToolBoxForm.ToolMode.Curve: if (m_cvNewCurve.m_blCurveIsWaiting == true) { if (g_lstShapeList[g_lstShapeList.Count - 1].GetCurrentNode(e.Location) >= 0) //Change the icon when cursor is on one node { this.Cursor = new Cursor(GetType(), "Cursors.PanToolCursor.cur"); } else { this.Cursor = new Cursor(GetType(), "Cursors.GenericToolCursor.cur"); } } if (m_cvNewCurve.m_blCurveAdjusting == true) { this.Cursor = new Cursor(GetType(), "Cursors.PanToolCursorMouseDown.cur"); g_lstShapeList[g_lstShapeList.Count - 1].SetNode(m_intCurveNodeIndex, e.Location); picRubberBandLayer.Invalidate(); } break; } } } } }