public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { Point point = new Point(e.X, e.Y); Point oldPoint = lastPoint; wasMove = true; if (e.Button == MouseButtons.None) { Cursor cursor = null; for (int i = 0; i < drawArea.GraphicsList.Count; i++) { int n = drawArea.GraphicsList[i].HitTest(point); if (n > 0) { cursor = drawArea.GraphicsList[i].GetHandleCursor(n); break; } } if (cursor == null) { cursor = Cursors.Default; } drawArea.Cursor = cursor; return; } if (e.Button != MouseButtons.Left) { return; } int dx = e.X - lastPoint.X; int dy = e.Y - lastPoint.Y; lastPoint.X = e.X; lastPoint.Y = e.Y; if (selectMode == SelectionMode.Size) { if (resizedObject != null) { resizedObject.MoveHandleTo(point, resizedObjectHandle); drawArea.SetDirty(); drawArea.Refresh(); } } if (selectMode == SelectionMode.Move) { List <DrawObject> selectList = new List <DrawObject>(); int n = drawArea.GraphicsList.Count; for (int i = 0; i < n; i++) { if (drawArea.GraphicsList[i].Selected) { drawArea.GraphicsList.SelectAlist(drawArea.GraphicsList[i].TagIDBase); selectList.Add(drawArea.GraphicsList[i]); } } foreach (DrawObject o in selectList) { o.Move(dx, dy); } drawArea.Cursor = Cursors.SizeAll; drawArea.SetDirty(); drawArea.Refresh(); } if (selectMode == SelectionMode.NetSelection) { ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, oldPoint)), Color.Black, FrameStyle.Dashed); ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, point)), Color.Black, FrameStyle.Dashed); return; } }
/// <summary> /// Mouse is moved. /// None button is pressed, or left button is pressed. /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseMove(ImageDrawBox drawArea, MouseEventArgs e) { Point pointscroll = GetEventPointInArea(drawArea, e); Point oldPoint = lastPoint; wasMove = true; // set cursor when mouse button is not pressed if (e.Button == MouseButtons.None) { Cursor cursor = null; for (int i = 0; i < drawArea.GraphicsList.Count; i++) { int n = drawArea.GraphicsList[i].HitTest(pointscroll); if (n > 0) { cursor = drawArea.GraphicsList[i].GetHandleCursor(n); break; } } if (cursor == null) { cursor = Cursors.Default; } drawArea.Cursor = cursor; return; } if (e.Button != MouseButtons.Left) { return; } /// Left button is pressed // Find difference between previous and current position int dx = e.X - lastPoint.X; int dy = e.Y - lastPoint.Y; lastPoint.X = e.X; lastPoint.Y = e.Y; // resize if (selectMode == SelectionMode.Size) { if (resizedObject != null) { resizedObject.MoveHandleTo(pointscroll, resizedObjectHandle); drawArea.SetDirty(); drawArea.Refresh(); drawArea.GraphicsList.Dirty = true; } } // move if (selectMode == SelectionMode.Move) { foreach (DrawObject o in drawArea.GraphicsList.Selection) { //o.Move(dx, dy); o.Move((int)(Math.Round(dx / drawArea.ZoomFactor)), (int)(Math.Round(dy / drawArea.ZoomFactor))); } drawArea.Cursor = Cursors.SizeAll; drawArea.SetDirty(); drawArea.Refresh(); drawArea.GraphicsList.Dirty = true; } if (selectMode == SelectionMode.NetSelection) { // Remove old selection rectangle ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, oldPoint)), Color.Black, FrameStyle.Dashed); // Draw new selection rectangle ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, new Point(e.X, e.Y))), Color.Black, FrameStyle.Dashed); return; } }
private void DrawRectangle() { Rectangle _Rect = 图片框.RectangleToScreen(虚线框); ControlPaint.DrawReversibleFrame(_Rect, Color.White, FrameStyle.Dashed); }
public static void DrawDragRectangles(Rectangle[] newRects, int indent) { foreach (Rectangle r in newRects) { ControlPaint.DrawReversibleFrame(r, Color.Gray, FrameStyle.Thick); } /* * if (newRects.Length > 0) * { * // Create the first region * IntPtr newRegion = CreateRectangleRegion(newRects[0], indent); * * for(int index=1; index<newRects.Length; index++) * { * // Create the extra region * IntPtr extraRegion = CreateRectangleRegion(newRects[index], indent); * * // Remove the intersection of the existing and extra regions * Gdi32.CombineRgn(newRegion, newRegion, extraRegion, (int)Win32.CombineFlags.RGN_XOR); * * // Remove unwanted intermediate objects * Gdi32.DeleteObject(extraRegion); * } * * // Get hold of the DC for the desktop * IntPtr hDC = User32.GetDC(IntPtr.Zero); * * // Define the area we are allowed to draw into * Gdi32.SelectClipRgn(hDC, newRegion); * * Win32.RECT rectBox = new Win32.RECT(); * * // Get the smallest rectangle that encloses region * Gdi32.GetClipBox(hDC, ref rectBox); * * IntPtr brushHandler = GetHalfToneBrush(); * * // Select brush into the device context * IntPtr oldHandle = Gdi32.SelectObject(hDC, brushHandler); * * // Blit to screen using provided pattern brush and invert with existing screen contents * Gdi32.PatBlt(hDC, * rectBox.left, * rectBox.top, * rectBox.right - rectBox.left, * rectBox.bottom - rectBox.top, * (uint)RasterOperations.PATINVERT); * * // Put old handle back again * Gdi32.SelectObject(hDC, oldHandle); * * // Reset the clipping region * Gdi32.SelectClipRgn(hDC, IntPtr.Zero); * * // Remove unwanted region object * Gdi32.DeleteObject(newRegion); * * // Must remember to release the HDC resource! * User32.ReleaseDC(IntPtr.Zero, hDC); * } */ }
/// <summary> /// mapControl中绘制矩形 /// </summary> private void DrawRectangle() { Rectangle rect = this.RectangleToScreen(MouseRect); ControlPaint.DrawReversibleFrame(rect, this.BackColor, FrameStyle.Dashed); }
private void picPreview_MouseDown(object sender, MouseEventArgs e) { if (_fileName.Length <= 0) { return; } _x = e.X; _y = e.Y; switch (_selectedShape) { case Shape.Unknown: break; case Shape.Pen: case Shape.Highlighter: _graphicsPath = new GraphicsPath(); break; case Shape.Eraser: foreach (var path in _shapes) { if (path.Path.GetBounds().Contains(e.Location)) { _shapes.Remove(path); picPreview.Invalidate(); break; } } break; case Shape.Text: frmInsertText frmInsertTextDlg = new frmInsertText(); if (frmInsertTextDlg.ShowDialog(this) == DialogResult.OK) { CustomShape customShape = new CustomShape(); customShape.Shape = Shape.Text; customShape.Pen = new Pen(_selectedColor, 1); GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddString(frmInsertTextDlg.SelectedText, frmInsertTextDlg.SelectedFont.FontFamily, (int)frmInsertTextDlg.SelectedFont.Style, frmInsertTextDlg.SelectedFont.Size, e.Location, StringFormat.GenericTypographic); graphicsPath.FillMode = FillMode.Winding; customShape.Path = graphicsPath; _shapes.Add(customShape); picPreview.Invalidate(); } break; case Shape.Selection: picPreview.Refresh(); foreach (var shape in _shapes) { if (shape.Path.GetBounds().Contains(e.Location)) { var rectf = shape.Path.GetBounds(); var rect = new Rectangle((int)rectf.X, (int)rectf.Y, (int)rectf.Width, (int)rectf.Height); var graphics = picPreview.CreateGraphics(); ControlPaint.DrawReversibleFrame(picPreview.RectangleToScreen(rect), Color.BurlyWood, FrameStyle.Dashed); _shape = shape; break; } } break; default: break; } }
private void zoomEnd(object sender, MouseEventArgs e) { if (zooming) { // the next if is important as when we click without dragging we go back to the original zoom bool mouseMoved = false; if (Math.Abs(currentMousePosition.X - originalMousePosition.X) > 1 || Math.Abs(currentMousePosition.Y - originalMousePosition.Y) > 1) { mouseMoved = true; } if (mouseMoved) { Rectangle startRectangle = new Rectangle(originalMousePosition, new Size(currentMousePosition.X - originalMousePosition.X, currentMousePosition.Y - originalMousePosition.Y)); ControlPaint.DrawReversibleFrame(startRectangle, Color.White, FrameStyle.Thick); // Redraw graph originalMargins = false; this.lblZoom.Visible = true; // different minX and minY must be defiined previously, as the converter will use them to calculate the max double minX2 = Math.Min(screenPixToData(originalMousePosition.X, axis.X), screenPixToData(currentMousePosition.X, axis.X)); double minY2 = Math.Min(screenPixToData(originalMousePosition.Y + 1, axis.Y), screenPixToData(currentMousePosition.Y + 1, axis.Y)); maxX = Math.Max(screenPixToData(originalMousePosition.X, axis.X), screenPixToData(currentMousePosition.X, axis.X)); if (currentMousePosition.Y - originalMousePosition.Y != 1) { maxY = Math.Max(screenPixToData(originalMousePosition.Y, axis.Y), screenPixToData(currentMousePosition.Y, axis.Y)); } minX = minX2; if (currentMousePosition.Y - originalMousePosition.Y != 1) { minY = minY2; // next line is because there is no need to use values of Y under 0 for spectra if (minY < 0) { minY = 0; } horizontalZoom = false; } else { horizontalZoom = true; } clearGraph(); DrawGraph(); } //else //{ // originalMargins = true; // this.lblZoom.Visible = false; // clearGraph(); // DrawGraph(); //} zooming = false; } }
protected override void MouseMove(object sender, MouseEventArgs e) { if (m_EditorMode == EditorMode.Lasso) { ControlPaint.DrawReversibleFrame( Rectangle.FromLTRB(m_StartPoint.X, m_StartPoint.Y, m_CurrentPoint.X, m_CurrentPoint.Y), SystemColors.ActiveBorder, FrameStyle.Dashed); m_CurrentPoint = Control.MousePosition; ControlPaint.DrawReversibleFrame( Rectangle.FromLTRB(m_StartPoint.X, m_StartPoint.Y, m_CurrentPoint.X, m_CurrentPoint.Y), SystemColors.ActiveBorder, FrameStyle.Dashed); } else if (m_EditorMode == EditorMode.DragDrop && !m_Canvas.m_SelectedImgList.IsEmpty()) { foreach (var obj in m_Canvas.m_SelectedImgList) { Point point = m_Canvas.PointToClient(m_StartPoint); Size size = new Size(obj.Rect.Location); obj.Offset = Point.Subtract(point, size); obj.Resize(new Rectangle(Point.Empty, obj.Rect.Size)); obj.Selection = SelectionType.Resize; } m_Canvas.Cursor.SetOffset(m_Canvas.m_SelectedImgList.First().Offset.Invert()); IDataObject data = new DataObject(); data.SetData(m_Canvas.m_SelectedImgList); m_Canvas.DoDragDrop(data, DragDropEffects.All); m_Canvas.DeleteSelectedImages(); m_Canvas.Invalidate(); } else if (m_EditorMode == EditorMode.Edit) { foreach (var obj in m_Canvas.m_SelectedImgList) { switch (obj.Selection) { case SelectionType.Resize: { Point sub = Point.Subtract(Control.MousePosition, new Size(m_CurrentPoint)); Rectangle rect = obj.Rect; switch (m_LastTest) { case TestType.LeftTop: rect.Inflate(-sub.X, -sub.Y); break; case TestType.RightTop: rect.Inflate(sub.X, -sub.Y); break; case TestType.RightBottom: rect.Inflate(sub.X, sub.Y); break; case TestType.LeftBottom: rect.Inflate(-sub.X, sub.Y); break; default: throw new NotImplementedException(); } obj.Resize(rect); } break; case SelectionType.Rotate: { PointF center = obj.Rect.Center(); Point p = m_Canvas.PointToClient(Control.MousePosition); float angle = center.ToAngle(p.Cast()); if (float.IsNaN(m_Angle)) { m_Angle = angle; } else { Debug.WriteLine(angle, " Angle "); obj.Rotate(angle - m_Angle); } } break; default: throw new NotImplementedException(); } m_Canvas.Invalidate(obj.Rect.InflateEx()); } m_CurrentPoint = Control.MousePosition; } else { bool inscope = false; Point point = m_Canvas.PointToClient(Control.MousePosition); foreach (var obj in m_Canvas.m_ImgList) { m_LastTest = obj.Test(point); if (m_LastTest != TestType.None) { inscope = true; Cursor.Current = Cursors.Cross; break; } } if (!inscope) { Cursor.Current = Cursors.Default; } } }
/// <summary> /// Mouse is moved. /// None button is pressed, or left button is pressed. /// </summary> /// <param name="control"></param> /// <param name="e"></param> public override void OnMouseMove(MapControl control, MouseEventArgs e) { Point point = new Point(e.X, e.Y); Point oldPoint = lastPoint; wasMove = true; // set cursor when mouse button is not pressed if (e.Button == MouseButtons.None) { Cursor cursor = null; for (int i = 0; i < control.Objects.Count; i++) { int n = control.Objects[i].HitTest(point); if (n > 0) { cursor = control.Objects[i].GetHandleCursor(n); break; } else if (n == 0) { cursor = Cursors.Hand; break; } } if (cursor == null) { cursor = Cursors.Default; } control.Cursor = cursor; return; } if (e.Button != MouseButtons.Left) { return; } /// Left button is pressed // Find difference between previous and current position int dx = e.X - lastPoint.X; int dy = e.Y - lastPoint.Y; lastPoint.X = e.X; lastPoint.Y = e.Y; // resize if (selectMode == SelectionMode.Size) { if (resizedObject != null) { resizedObject.MoveHandleTo(point, resizedObjectHandle); control.Refresh(); control.SetDirty(); } } // move if (selectMode == SelectionMode.Move) { foreach (DrawObject o in control.Objects.Selection) { o.Move(dx, dy); } control.Cursor = Cursors.Hand; control.Refresh(); control.SetDirty(); } if (selectMode == SelectionMode.NetSelection) { // Remove old selection rectangle ControlPaint.DrawReversibleFrame( control.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, oldPoint)), Color.Black, FrameStyle.Dashed); // Draw new selection rectangle ControlPaint.DrawReversibleFrame( control.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, point)), Color.Black, FrameStyle.Dashed); return; } }
private void pnl_MouseUp(object sender, MouseEventArgs e) { // if (e.Button == MouseButtons.Right) { this.contextMenuStrip1.Items.Clear(); this.contextMenuStrip1.Items.Add("保存"); this.contextMenuStrip1.Items.Add("页面"); this.contextMenuStrip1.Items.Add("背景"); this.contextMenuStrip1.Items.Add("撤销"); this.contextMenuStrip1.Items.Add("重做"); this.contextMenuStrip1.Items.Add("-"); ToolStripMenuItem menu = new ToolStripMenuItem(); menu.Text = "数据"; this.contextMenuStrip1.Items.Add(menu); foreach (System.Data.DataColumn col in tbmain.Columns) { ToolStripMenuItem menu2 = new ToolStripMenuItem(); menu2.Text = col.ColumnName; menu2.Click += this.menuFieldClick; menu.DropDownItems.Add(menu2); } this.contextMenuStrip1.Items.Add("文本"); this.contextMenuStrip1.Items.Add("表格"); this.contextMenuStrip1.Items.Add("竖线"); this.contextMenuStrip1.Items.Add("横线"); this.contextMenuStrip1.Items.Add("图片"); this.contextMenuStrip1.Items.Add("页码"); this.contextMenuStrip1.Items.Add("时间"); this.contextMenuStrip1.Tag = pnl; this.contextMenuStrip1.Show(pnl, e.X, e.Y); } else if (e.Button == MouseButtons.Left) { ControlPaint.DrawReversibleFrame(rec, Color.White, FrameStyle.Dashed); rec = new Rectangle(0, 0, 0, 0); // if (System.Windows.Forms.Control.ModifierKeys != Keys.Control) { foreach (Control con in pnl.Controls) { IPrintObject ins = (IPrintObject)con; ins.Selected = false; } } var rec2 = PrintObjectHelper.CreateRectangle(p, p2); foreach (Control con in pnl.Controls) { var rec3 = new Rectangle(con.Left, con.Top, con.Width, con.Height); if (PrintObjectHelper.RectangleInRectangle(rec3, rec2) == true) { IPrintObject ins = (IPrintObject)con; ins.Selected = true; } } if (SelectObjects.Count == 0) { _fistSelectObject = null; } } }
public override void DrawMovable(Point startPoint, Point endPoint, Pen pen, Form form) { ControlPaint.DrawReversibleFrame(form.RectangleToScreen(rectangle), pen.Color, FrameStyle.Dashed); }
public void OnMouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (mask == null || mask.SelectedControl == null) { return; } Point p = mask.ConvertPoint((Control)sender, e.X, e.Y); if (mask.MoveDrag) { if (Cursor != Cursors.SizeAll) { Cursor = Cursors.SizeAll; } if (mask.MoveDragStart) { mask.MoveDragStart = false; } else { ControlPaint.DrawReversibleFrame(mask.Ghost, Color.Transparent, FrameStyle.Thick); } p.X = p.X - mask.DragPoint.X; p.Y = p.Y - mask.DragPoint.Y; p.X = p.X < 0 ? 0 : p.X; p.Y = p.Y < 0 ? 0 : p.Y; p.X = p.X + mask.SelectedControl.Width > mask.SelectedControl.Parent.Width ? mask.SelectedControl.Parent.Width - mask.SelectedControl.Width : p.X; p.Y = p.Y + mask.SelectedControl.Height > mask.SelectedControl.Parent.Height ? mask.SelectedControl.Parent.Height - mask.SelectedControl.Height : p.Y; p.X = mask.SnapToGrid ? p.X - (p.X % mask.GridSize.Width) : p.X; p.Y = mask.SnapToGrid ? p.Y - (p.Y % mask.GridSize.Height) : p.Y; mask.Ghost.Location = mask.SelectedControl.Parent.PointToScreen(p); StatusBar.LocationStatus(p); ControlPaint.DrawReversibleFrame(mask.Ghost, Color.Transparent, FrameStyle.Thick); } else if (mask.ResizeDrag) { int x, y, w, h; mask.Hide(); switch (mask.ResizeNodeIndex) { case 0: x = p.X - mask.DragPoint.X; x = mask.SnapToGrid ? x - (x % mask.GridSize.Width) : x; w = mask.SelectedControl.Right - x; if (w >= mask.MinControlSize.Width) { mask.SelectedControl.Width = w; mask.SelectedControl.Left = x; } y = p.Y - mask.DragPoint.Y; y = mask.SnapToGrid ? y - (y % mask.GridSize.Height) : y; h = mask.SelectedControl.Bottom - y; if (h >= mask.MinControlSize.Height) { mask.SelectedControl.Height = h; mask.SelectedControl.Top = y; } if (Cursor != Cursors.SizeNWSE) { Cursor = Cursors.SizeNWSE; } StatusBar.LocationStatus(mask.SelectedControl.Location); StatusBar.SizeStatus(mask.SelectedControl.Size); break; case 1: y = p.Y - mask.DragPoint.Y; y = mask.SnapToGrid ? y - (y % mask.GridSize.Height) : y; h = mask.SelectedControl.Bottom - y; if (h >= mask.MinControlSize.Height) { mask.SelectedControl.Height = h; mask.SelectedControl.Top = y; } if (Cursor != Cursors.SizeNS) { Cursor = Cursors.SizeNS; } StatusBar.LocationStatus(mask.SelectedControl.Location); StatusBar.SizeStatus(mask.SelectedControl.Size); break; case 2: w = p.X - mask.DragPoint.X - mask.SelectedControl.Left; w = mask.SnapToGrid ? w - (w % mask.GridSize.Width) : w; if (w >= mask.MinControlSize.Width) { mask.SelectedControl.Width = w; } y = p.Y - mask.DragPoint.Y; y = mask.SnapToGrid ? y - (y % mask.GridSize.Height) : y; h = mask.SelectedControl.Bottom - y; if (h >= mask.MinControlSize.Height) { mask.SelectedControl.Height = h; mask.SelectedControl.Top = y; } if (Cursor != Cursors.SizeNESW) { Cursor = Cursors.SizeNESW; } StatusBar.LocationStatus(mask.SelectedControl.Location); StatusBar.SizeStatus(mask.SelectedControl.Size); break; case 3: x = p.X - mask.DragPoint.X; x = mask.SnapToGrid ? x - (x % mask.GridSize.Width) : x; w = mask.SelectedControl.Right - x; if (w >= mask.MinControlSize.Width) { mask.SelectedControl.Width = w; mask.SelectedControl.Left = x; } if (Cursor != Cursors.SizeWE) { Cursor = Cursors.SizeWE; } StatusBar.LocationStatus(mask.SelectedControl.Location); StatusBar.SizeStatus(mask.SelectedControl.Size); break; case 4: w = p.X - mask.DragPoint.X - mask.SelectedControl.Left; w = mask.SnapToGrid ? w - (w % mask.GridSize.Width) : w; if (w >= mask.MinControlSize.Width) { mask.SelectedControl.Width = w; } if (Cursor != Cursors.SizeWE) { Cursor = Cursors.SizeWE; } StatusBar.SizeStatus(mask.SelectedControl.Size); break; case 5: x = p.X - mask.DragPoint.X; x = mask.SnapToGrid ? x - (x % mask.GridSize.Width) : x; w = mask.SelectedControl.Right - x; if (w >= mask.MinControlSize.Width) { mask.SelectedControl.Width = w; mask.SelectedControl.Left = x; } h = p.Y - mask.DragPoint.Y - mask.SelectedControl.Top; h = mask.SnapToGrid ? h - (h % mask.GridSize.Height) : h; if (h >= mask.MinControlSize.Height) { mask.SelectedControl.Height = h; } if (Cursor != Cursors.SizeNESW) { Cursor = Cursors.SizeNESW; } StatusBar.LocationStatus(mask.SelectedControl.Location); StatusBar.SizeStatus(mask.SelectedControl.Size); break; case 6: h = p.Y - mask.DragPoint.Y - mask.SelectedControl.Top; h = mask.SnapToGrid ? h - (h % mask.GridSize.Height) : h; if (h >= mask.MinControlSize.Height) { mask.SelectedControl.Height = h; } if (Cursor != Cursors.SizeNS) { Cursor = Cursors.SizeNS; } StatusBar.SizeStatus(mask.SelectedControl.Size); break; case 7: w = p.X - mask.DragPoint.X - mask.SelectedControl.Left; w = mask.SnapToGrid ? w - (w % mask.GridSize.Width) : w; if (w >= mask.MinControlSize.Width) { mask.SelectedControl.Width = w; } h = p.Y - mask.DragPoint.Y - mask.SelectedControl.Top; h = mask.SnapToGrid ? h - (h % mask.GridSize.Height) : h; if (h >= mask.MinControlSize.Height) { mask.SelectedControl.Height = h; } if (Cursor != Cursors.SizeNWSE) { Cursor = Cursors.SizeNWSE; } StatusBar.SizeStatus(mask.SelectedControl.Size); break; } } } }
void DrawXorFrame() { ControlPaint.DrawReversibleFrame(rubberRect, rubberRectColor, RubberRectStyle); NeedToEraseRubber = !NeedToEraseRubber; }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { commandChangeState = null; wasMove = false; selectMode = SelectionMode.None; Point point = new Point(e.X, e.Y); foreach (DrawObject o in drawArea.GraphicsList.Selection) { int handleNumber = o.HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; resizedObject = o; resizedObjectHandle = handleNumber; drawArea.GraphicsList.UnselectAll(); o.Selected = true; commandChangeState = new CommandChangeState(drawArea.GraphicsList); break; } } if (selectMode == SelectionMode.None) { int n1 = drawArea.GraphicsList.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (drawArea.GraphicsList[i].HitTest(point) == 0) { o = drawArea.GraphicsList[i]; break; } } if (o != null) { selectMode = SelectionMode.Move; if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { drawArea.GraphicsList.UnselectAll(); } o.Selected = true; commandChangeState = new CommandChangeState(drawArea.GraphicsList); drawArea.Cursor = Cursors.SizeAll; } } if (selectMode == SelectionMode.None) { if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.GraphicsList.UnselectAll(); } selectMode = SelectionMode.NetSelection; } lastPoint.X = e.X; lastPoint.Y = e.Y; startPoint.X = e.X; startPoint.Y = e.Y; drawArea.Capture = true; drawArea.Refresh(); if (selectMode == SelectionMode.NetSelection) { ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)), Color.Black, FrameStyle.Dashed); } }
public static void DrawMouseSelected(Point pFirst, Point pLast) { ControlPaint.DrawReversibleFrame(new Rectangle(pFirst, new Size(pLast.X - pFirst.X, pLast.Y - pFirst.Y)), Color.Black, FrameStyle.Dashed); }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="control"></param> /// <param name="e"></param> public override void OnMouseDown(MapControl control, MouseEventArgs e, int zoom) { commandChangeState = null; wasMove = false; selectMode = SelectionMode.None; Point point = new Point(e.X, e.Y); // Test for resizing (only if control is selected, cursor is on the handle) foreach (DrawObject o in control.Objects.Selection) { int handleNumber = o.HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; // keep resized object in class member resizedObject = o; resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects control.Objects.UnselectAll(); o.Selected = true; commandChangeState = new CommandChangeState(control.Objects); break; } } // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { int n1 = control.Objects.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (control.Objects[i].HitTest(point) == 0) { o = control.Objects[i]; break; } } if (o != null) { selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { control.Objects.UnselectAll(); } // Select clicked object o.Selected = true; commandChangeState = new CommandChangeState(control.Objects); control.Cursor = Cursors.Hand; } } // Net selection if (selectMode == SelectionMode.None) { // click on background if ((Control.ModifierKeys & Keys.Control) == 0) { control.Objects.UnselectAll(); } selectMode = SelectionMode.NetSelection; control.Selected = true; } lastPoint.X = e.X; lastPoint.Y = e.Y; startPoint.X = e.X; startPoint.Y = e.Y; control.Refresh(); if (selectMode == SelectionMode.NetSelection) { // Draw selection rectangle in initial position ControlPaint.DrawReversibleFrame( control.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)), Color.Black, FrameStyle.Dashed); } }
private void DrawRectangle() { ControlPaint.DrawReversibleFrame(m_MouseRect, Color.White, FrameStyle.Dashed); }
public void DrawReversibleFrame(Rectangle rect) { ControlPaint.DrawReversibleFrame(rect, mapPanel.BackColor, FrameStyle.Dashed); }
private void MouseMove(object sender, MouseEventArgs e) { // MessageBox.Show("MouseMove"); if (frm == null) { return; } if (e.Button == MouseButtons.Left) { if (this.IsMoving) { if (ctrlLastLeft == 0) { ctrlLastLeft = ctrlLeft; } if (ctrlLastTop == 0) { ctrlLastTop = ctrlTop; } int locationX = (Cursor.Position.X - this.cursorL + this.frm.DesktopLocation.X + this.Wtap + this.ctrl.Location.X); int locationY = (Cursor.Position.Y - this.cursorT + this.frm.DesktopLocation.Y + this.Htap + this.ctrl.Location.Y); if (locationX < this.frm.DesktopLocation.X + this.Wtap) { locationX = this.frm.DesktopLocation.X + this.Wtap; } if (locationY < this.frm.DesktopLocation.Y + this.Htap) { locationY = this.frm.DesktopLocation.Y + this.Htap; } this.ctrlLeft = locationX; this.ctrlTop = locationY; ctrlRectangle.Location = new System.Drawing.Point(this.ctrlLastLeft, this.ctrlLastTop); ctrlRectangle.Size = new System.Drawing.Size(ctrlWidth, ctrlHeight); ControlPaint.DrawReversibleFrame(ctrlRectangle, Color.Empty, System.Windows.Forms.FrameStyle.Dashed); ctrlLastLeft = ctrlLeft; ctrlLastTop = ctrlTop; ctrlRectangle.Location = new System.Drawing.Point(ctrlLeft, ctrlTop); ctrlRectangle.Size = new System.Drawing.Size(ctrlWidth, ctrlHeight); ControlPaint.DrawReversibleFrame(ctrlRectangle, Color.Empty, System.Windows.Forms.FrameStyle.Dashed); return; } int sizeageX = (Cursor.Position.X - this.frm.DesktopLocation.X - this.Wtap - this.ctrl.Location.X); int sizeageY = (Cursor.Position.Y - this.frm.DesktopLocation.Y - this.Htap - this.ctrl.Location.Y); if (sizeageX < 2) { sizeageX = 1; } if (sizeageY < 2) { sizeageY = 1; } ctrlWidth = sizeageX; ctrlHeight = sizeageY; if (ctrlLastWidth == 0) { ctrlLastWidth = ctrlWidth; } if (ctrlLastHeight == 0) { ctrlLastHeight = ctrlHeight; } if (ctrlIsResizing) { ctrlRectangle.Location = new System.Drawing.Point(this.frm.DesktopLocation.X + this.ctrl.Left + this.Wtap, this.frm.DesktopLocation.Y + this.Htap + this.ctrl.Top); ctrlRectangle.Size = new System.Drawing.Size(ctrlLastWidth, ctrlLastHeight); } ctrlIsResizing = true; ControlPaint.DrawReversibleFrame(ctrlRectangle, Color.Empty, System.Windows.Forms.FrameStyle.Dashed); ctrlLastWidth = ctrlWidth; ctrlLastHeight = ctrlHeight; ctrlRectangle.Location = new System.Drawing.Point(this.frm.DesktopLocation.X + this.Wtap + this.ctrl.Left, this.frm.DesktopLocation.Y + this.Htap + this.ctrl.Top); ctrlRectangle.Size = new System.Drawing.Size(ctrlWidth, ctrlHeight); ControlPaint.DrawReversibleFrame(ctrlRectangle, Color.Empty, System.Windows.Forms.FrameStyle.Dashed); } }
/// <summary> /// 绘制选择框 /// </summary> private void DrawRectangle() { Rectangle rect = RectangleToScreen(mouseRect); ControlPaint.DrawReversibleFrame(rect, Color.Red, FrameStyle.Dashed); }
void DrawDraggingShape() { Point point = designerPanel.PointToScreen(SelectedRose.Location); ControlPaint.DrawReversibleFrame(new Rectangle(point, SelectedRose.Size), SystemColors.ButtonFace, FrameStyle.Dashed); }
private void DrawReversibleRectangle(Rectangle rect) { pbFull.Refresh(); ControlPaint.DrawReversibleFrame(rect, Color.LightGray, FrameStyle.Dashed); }
private void DrawRectangles(object sender) { Rectangle rect = ((Panel)sender).RectangleToScreen(MouseRect); ControlPaint.DrawReversibleFrame(rect, Color.White, FrameStyle.Dashed); }
private void DrawReversibleFrame() { ControlPaint.DrawReversibleFrame(RectangleToScreen(m_ZoomRegion.Rect), Color.Black, FrameStyle.Dashed); }
private void FormDraw_MouseUp(object sender, MouseEventArgs e) { isDrawing = false; ControlPaint.DrawReversibleFrame(rectRegion, this.BackColor, FrameStyle.Dashed); Hide(); }
/// <summary> /// Mouse is moved. /// None button is pressed, ot left button is pressed. /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { #if EWSAPP //Trace.WriteLine("OnMouseMove "); int hittestresult = -1; Point point; //Point OnSnappoint; //Point pt = new Point(); point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); Point pointscroll = GetEventPointInArea(drawArea, e); Point oldPoint = lastPoint; wasMove = true; //toolTip.InitialDelay = 1; int dx = e.X - lastPoint.X; int dy = e.Y - lastPoint.Y; lastPoint.X = e.X; lastPoint.Y = e.Y; switch (e.Button) { case MouseButtons.Left: switch (selectMode) { case SelectionMode.NetSelection: Trace.WriteLine("ToolPointer OnMouseMove MouseButtons.Left SelectionMode.NetSelection"); // Remove old selection rectangle ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, oldPoint)), Color.Black, FrameStyle.Dashed); // Draw new selection rectangle ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, new Point(e.X, e.Y))), Color.Black, FrameStyle.Dashed); drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint); break; case SelectionMode.Move: Trace.WriteLine("ToolPointer OnMouseMove MouseButtons.Left SelectionMode.Move"); foreach (DrawObject o in drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo].Selection) { o.Move(dx, dy); if ((o is DrawFBDBox)) { ((DrawFBDBox)o).UpdateWireConnections(); } } drawArea.Cursor = Cursors.SizeAll; drawArea.Pages.Dirty = true; drawArea.Refresh(); drawArea.Pages.Dirty = true; break; case SelectionMode.Size: Trace.WriteLine("ToolPointer OnMouseMove MouseButtons.Left SelectionMode.Size"); if (resizedObject != null) { resizedObject.MoveHandleTo(pointscroll, resizedObjectHandle); drawArea.Refresh(); drawArea.Pages.Dirty = true; } break; default: break; } break; case MouseButtons.None: Cursor tempcursor = null; foreach (DrawObject o in drawArea.Pages.GraphicPagesList[drawArea.ActivePageNo].Selection) { hittestresult = o.HitTest(point); if (hittestresult > 0) { Trace.WriteLine("ToolPointer OnMouseDown over control points"); tempcursor = o.GetHandleCursor(hittestresult); break; } } if (tempcursor == null) { tempcursor = Cursors.Default; } //drawArea.Cursor = tempcursor; break; default: break; } #endif }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(ImageDrawBox drawArea, MouseEventArgs e) { Point pointscroll = GetEventPointInArea(drawArea, e); commandChangeState = null; wasMove = false; selectMode = SelectionMode.None; // Test for resizing (only if control is selected, cursor is on the handle) foreach (DrawObject o in drawArea.GraphicsList.Selection) { int handleNumber = o.HitTest(pointscroll); if (handleNumber > 0) { selectMode = SelectionMode.Size; // keep resized object in class member resizedObject = o; resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects drawArea.GraphicsList.UnselectAll(); o.Selected = true; commandChangeState = new CommandChangeState(drawArea.GraphicsList); drawArea.GraphicsList.Dirty = true; break; } } // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { int n1 = drawArea.GraphicsList.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (drawArea.GraphicsList[i].HitTest(pointscroll) == 0) { o = drawArea.GraphicsList[i]; break; } } if (o != null) { selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { drawArea.GraphicsList.UnselectAll(); } // Select clicked object o.Selected = true; commandChangeState = new CommandChangeState(drawArea.GraphicsList); drawArea.Cursor = Cursors.SizeAll; drawArea.GraphicsList.Dirty = true; } } // Net selection if (selectMode == SelectionMode.None) { // click on background if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.GraphicsList.UnselectAll(); } selectMode = SelectionMode.NetSelection; } lastPoint.X = e.X; lastPoint.Y = e.Y; startPoint.X = e.X; startPoint.Y = e.Y; drawArea.Capture = true; drawArea.Refresh(); if (selectMode == SelectionMode.NetSelection) { // Draw selection rectangle in initial position ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)), Color.Black, FrameStyle.Dashed); } }
public static void DrawReversibleRect(Rectangle pRect, FrameStyle pStyle) { ControlPaint.DrawReversibleFrame(pRect, Color.Black, pStyle); }
private void DrawFirstRectangle() { ControlPaint.DrawReversibleFrame(rectangle1, SystemColors.Highlight, FrameStyle.Thick); }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(WorkArea workArea, MouseEventArgs e) { selectMode = SelectionMode.None; Point point = new Point(e.X, e.Y); if (workArea.GraphicsList == null) { MessageBox.Show("Nenhum objeto"); return; } // Test for resizing (only if control is selected, cursor is on the handle) foreach (DrawObject o in workArea.GraphicsList.Selection) { int handleNumber = o.HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; // keep resized object in class member resizedObject = o; resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects workArea.GraphicsList.UnselectAll(); o.Selected = true; break; } } // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { int n1 = workArea.GraphicsList.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (workArea.GraphicsList[i].HitTest(point) == 0) { o = workArea.GraphicsList[i]; break; } } if (o != null) { selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { workArea.GraphicsList.UnselectAll(); } // Select clicked object o.Selected = true; workArea.Cursor = Cursors.SizeAll; } } // Net selection if (selectMode == SelectionMode.None) { // click on background if ((Control.ModifierKeys & Keys.Control) == 0) { workArea.GraphicsList.UnselectAll(); } selectMode = SelectionMode.NetSelection; } lastPoint.X = e.X; lastPoint.Y = e.Y; startPoint.X = e.X; startPoint.Y = e.Y; workArea.Capture = true; workArea.Refresh(); if (selectMode == SelectionMode.NetSelection) { // Draw selection rectangle in initial position ControlPaint.DrawReversibleFrame( workArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)), Color.Black, FrameStyle.Dashed); } }