protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); /* if (m_commandType == eCommandType.pan) { m_panOffset.X += m_dragOffset.X; m_panOffset.Y += m_dragOffset.Y; m_dragOffset = new PointF(0, 0); } */ moving = false; ispaste = false; List<IDrawObject> hitlist = null; Rectangle screenSelRect = Rectangle.Empty; if (m_selection != null) { screenSelRect = m_selection.ScreenRect(); RectangleF selectionRect = m_selection.Selection(m_canvaswrapper); if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Eraser")) { List<Line> l=CanvasCtrl.M_canvas.lines; for (int i = l.Count-1;i>=0; i--) { if (l[i].P2.X < screenSelRect.Left || l[i].P1.X > screenSelRect.Right || l[i].P1.Y > screenSelRect.Bottom || l[i].P1.Y < screenSelRect.Top) { } else { lines.RemoveAt(i); } } } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("chance color")) { List<Line> l = CanvasCtrl.M_canvas.lines; for (int i = l.Count - 1; i >= 0; i--) { if (l[i].P2.X < screenSelRect.Left || l[i].P1.X > screenSelRect.Right || l[i].P1.Y > screenSelRect.Bottom || l[i].P1.Y < screenSelRect.Top) { } else { Line l1; if (lines[i].isRed) { l1= new Line(lines[i].P1, lines[i].P2, 0, false); } else { l1 = new Line(lines[i].P1, lines[i].P2, 0, true); } lines.RemoveAt(i); lines.Add(l1); } } } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("move")) { moving = true; //将移动状态设为正在移动 mr = new MovingRegion(screenSelRect); //新建移动范围 List<Line> selectedLines = mr.getLines(); //选中的线 lastY = e.Y; //设置初始纵轴位置 lastX = e.X; //设置初始横轴位置 List<Line> l = CanvasCtrl.M_canvas.lines; for (int i = l.Count - 1; i >= 0; i--) { if (l[i].P2.X < screenSelRect.Left || l[i].P1.X > screenSelRect.Right || l[i].P1.Y > screenSelRect.Bottom || l[i].P1.Y < screenSelRect.Top) { } else { Line l1 = new Line(l[i].P1, l[i].P2, l[i].S, l[i].isRed, l[i].Color); selectedLines.Add(l1); lines.Remove(l[i]); } } } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Cut")) { pr = new MovingRegion(screenSelRect); //新建移动范围 List<Line> selectedLines = pr.getLines(); //选中的线 lastY = e.Y; //设置初始纵轴位置 lastX = e.X; //设置初始横轴位置 List<Line> l = CanvasCtrl.M_canvas.lines; for (int i = l.Count - 1; i >= 0; i--) { if (l[i].P2.X < screenSelRect.Left || l[i].P1.X > screenSelRect.Right || l[i].P1.Y > screenSelRect.Bottom || l[i].P1.Y < screenSelRect.Top) { } else { Line l1 = new Line(l[i].P1, l[i].P2, l[i].S, l[i].isRed, l[i].Color); selectedLines.Add(l1); lines.Remove(l[i]); } } } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Copy")) { pr = new MovingRegion(screenSelRect); //新建移动范围 List<Line> selectedLines = pr.getLines(); //选中的线 lastY = e.Y; //设置初始纵轴位置 lastX = e.X; //设置初始横轴位置 List<Line> l = CanvasCtrl.M_canvas.lines; for (int i = l.Count - 1; i >= 0; i--) { if (l[i].P2.X < screenSelRect.Left || l[i].P1.X > screenSelRect.Right || l[i].P1.Y > screenSelRect.Bottom || l[i].P1.Y < screenSelRect.Top) { } else { Line l1 = new Line(l[i].P1,l[i].P2,l[i].S,l[i].isRed,l[i].Color); selectedLines.Add(l1); } } } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Paste")) { ispaste = true; } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Pai")) { List<Line> l = CanvasCtrl.M_canvas.orlines; if(e.Y>=42&&e.Y<177) l.Add(new Line(new PointF(e.X,40),new PointF(e.X,179),Color.White,5)); else if(e.Y>=257&&e.Y<393) l.Add(new Line(new PointF(e.X,255),new PointF(e.X,395),Color.White,5)); else if (e.Y >= 473 && e.Y < 609) l.Add(new Line(new PointF(e.X, 470), new PointF(e.X, 608), Color.White,5)); else if (e.Y >= 690 && e.Y < 820) l.Add(new Line(new PointF(e.X, 688), new PointF(e.X, 822), Color.White,5)); DoInvalidate(true); } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Jie")) { List<Line> l = CanvasCtrl.M_canvas.orlines; if (e.Y >= 42 && e.Y < 177) l.Add(new Line(new PointF(e.X, 42), new PointF(e.X, 177), Color.Black,2)); else if (e.Y >= 257 && e.Y < 393) l.Add(new Line(new PointF(e.X, 257), new PointF(e.X, 393), Color.Black,2)); else if (e.Y >= 473 && e.Y < 609) l.Add(new Line(new PointF(e.X, 473), new PointF(e.X, 609), Color.Black,2)); else if (e.Y >= 690 && e.Y < 820) l.Add(new Line(new PointF(e.X, 690), new PointF(e.X, 820), Color.Black,2)); DoInvalidate(true); } if (selectionRect != RectangleF.Empty) { // is any selection rectangle. use it for selection hitlist = m_model.GetHitObjects(m_canvaswrapper, selectionRect, m_selection.AnyPoint()); DoInvalidate(true); } else { // else use mouse point UnitPoint mousepoint = ToUnit(new PointF(e.X, e.Y)); hitlist = m_model.GetHitObjects(m_canvaswrapper, mousepoint); } m_selection = null; } if (m_commandType == eCommandType.draw && m_newObject != null) { UnitPoint mousepoint = ToUnit(m_mousedownPoint); if (m_snappoint != null) mousepoint = m_snappoint.SnapPoint; m_newObject.OnMouseUp(m_canvaswrapper, mousepoint, m_snappoint); } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); /* * if (m_commandType == eCommandType.pan) * { * m_panOffset.X += m_dragOffset.X; * m_panOffset.Y += m_dragOffset.Y; * m_dragOffset = new PointF(0, 0); * } */ moving = false; ispaste = false; List <IDrawObject> hitlist = null; Rectangle screenSelRect = Rectangle.Empty; if (m_selection != null) { screenSelRect = m_selection.ScreenRect(); RectangleF selectionRect = m_selection.Selection(m_canvaswrapper); if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Eraser")) { List <Line> l = CanvasCtrl.M_canvas.lines; for (int i = l.Count - 1; i >= 0; i--) { if (l[i].P2.X <screenSelRect.Left || l[i].P1.X> screenSelRect.Right || l[i].P1.Y > screenSelRect.Bottom || l[i].P1.Y < screenSelRect.Top) { } else { lines.RemoveAt(i); } } } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("chance color")) { List <Line> l = CanvasCtrl.M_canvas.lines; for (int i = l.Count - 1; i >= 0; i--) { if (l[i].P2.X <screenSelRect.Left || l[i].P1.X> screenSelRect.Right || l[i].P1.Y > screenSelRect.Bottom || l[i].P1.Y < screenSelRect.Top) { } else { Line l1; if (lines[i].isRed) { l1 = new Line(lines[i].P1, lines[i].P2, 0, false); } else { l1 = new Line(lines[i].P1, lines[i].P2, 0, true); } lines.RemoveAt(i); lines.Add(l1); } } } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("move")) { moving = true; //将移动状态设为正在移动 mr = new MovingRegion(screenSelRect); //新建移动范围 List <Line> selectedLines = mr.getLines(); //选中的线 lastY = e.Y; //设置初始纵轴位置 lastX = e.X; //设置初始横轴位置 List <Line> l = CanvasCtrl.M_canvas.lines; for (int i = l.Count - 1; i >= 0; i--) { if (l[i].P2.X <screenSelRect.Left || l[i].P1.X> screenSelRect.Right || l[i].P1.Y > screenSelRect.Bottom || l[i].P1.Y < screenSelRect.Top) { } else { Line l1 = new Line(l[i].P1, l[i].P2, l[i].S, l[i].isRed, l[i].Color); selectedLines.Add(l1); lines.Remove(l[i]); } } } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Cut")) { pr = new MovingRegion(screenSelRect); //新建移动范围 List <Line> selectedLines = pr.getLines(); //选中的线 lastY = e.Y; //设置初始纵轴位置 lastX = e.X; //设置初始横轴位置 List <Line> l = CanvasCtrl.M_canvas.lines; for (int i = l.Count - 1; i >= 0; i--) { if (l[i].P2.X <screenSelRect.Left || l[i].P1.X> screenSelRect.Right || l[i].P1.Y > screenSelRect.Bottom || l[i].P1.Y < screenSelRect.Top) { } else { Line l1 = new Line(l[i].P1, l[i].P2, l[i].S, l[i].isRed, l[i].Color); selectedLines.Add(l1); lines.Remove(l[i]); } } } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Copy")) { pr = new MovingRegion(screenSelRect); //新建移动范围 List <Line> selectedLines = pr.getLines(); //选中的线 lastY = e.Y; //设置初始纵轴位置 lastX = e.X; //设置初始横轴位置 List <Line> l = CanvasCtrl.M_canvas.lines; for (int i = l.Count - 1; i >= 0; i--) { if (l[i].P2.X <screenSelRect.Left || l[i].P1.X> screenSelRect.Right || l[i].P1.Y > screenSelRect.Bottom || l[i].P1.Y < screenSelRect.Top) { } else { Line l1 = new Line(l[i].P1, l[i].P2, l[i].S, l[i].isRed, l[i].Color); selectedLines.Add(l1); } } } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Paste")) { ispaste = true; } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Pai")) { List <Line> l = CanvasCtrl.M_canvas.orlines; if (e.Y >= 42 && e.Y < 177) { l.Add(new Line(new PointF(e.X, 40), new PointF(e.X, 179), Color.White, 5)); } else if (e.Y >= 257 && e.Y < 393) { l.Add(new Line(new PointF(e.X, 255), new PointF(e.X, 395), Color.White, 5)); } else if (e.Y >= 473 && e.Y < 609) { l.Add(new Line(new PointF(e.X, 470), new PointF(e.X, 608), Color.White, 5)); } else if (e.Y >= 690 && e.Y < 820) { l.Add(new Line(new PointF(e.X, 688), new PointF(e.X, 822), Color.White, 5)); } DoInvalidate(true); } else if (CanvasCtrl.M_canvas.m_drawObjectId.Equals("Jie")) { List <Line> l = CanvasCtrl.M_canvas.orlines; if (e.Y >= 42 && e.Y < 177) { l.Add(new Line(new PointF(e.X, 42), new PointF(e.X, 177), Color.Black, 2)); } else if (e.Y >= 257 && e.Y < 393) { l.Add(new Line(new PointF(e.X, 257), new PointF(e.X, 393), Color.Black, 2)); } else if (e.Y >= 473 && e.Y < 609) { l.Add(new Line(new PointF(e.X, 473), new PointF(e.X, 609), Color.Black, 2)); } else if (e.Y >= 690 && e.Y < 820) { l.Add(new Line(new PointF(e.X, 690), new PointF(e.X, 820), Color.Black, 2)); } DoInvalidate(true); } if (selectionRect != RectangleF.Empty) { // is any selection rectangle. use it for selection hitlist = m_model.GetHitObjects(m_canvaswrapper, selectionRect, m_selection.AnyPoint()); DoInvalidate(true); } else { // else use mouse point UnitPoint mousepoint = ToUnit(new PointF(e.X, e.Y)); hitlist = m_model.GetHitObjects(m_canvaswrapper, mousepoint); } m_selection = null; } if (m_commandType == eCommandType.draw && m_newObject != null) { UnitPoint mousepoint = ToUnit(m_mousedownPoint); if (m_snappoint != null) { mousepoint = m_snappoint.SnapPoint; } m_newObject.OnMouseUp(m_canvaswrapper, mousepoint, m_snappoint); } }