/// <summary> /// Mouse move - resize new polygon /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { drawArea.Cursor = Cursor; if ( e.Button != MouseButtons.Left ) return; if ( newPolygon == null ) return; // precaution Point point = new Point(e.X, e.Y); int distance = (e.X - lastX)*(e.X - lastX) + (e.Y - lastY)*(e.Y - lastY); if ( distance < minDistance ) { // Distance between last two points is less than minimum - // move last point newPolygon.MoveHandleTo(point, newPolygon.HandleCount); } else { // Add new point newPolygon.AddPoint(point); lastX = e.X; lastY = e.Y; } drawArea.Refresh(); }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { // Create new polygon, add it to the list // and keep reference to it newPolygon = new DrawPolygon(e.X, e.Y, e.X + 1, e.Y + 1); AddNewObject(drawArea, newPolygon); lastX = e.X; lastY = e.Y; }
/// <summary> /// Left mouse is released. /// New object is created and resized. /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { drawArea.GraphicsList[0].Normalize(); drawArea.AddCommandToHistory(new CommandAdd(drawArea.GraphicsList[0])); drawArea.ActiveTool = DrawArea.DrawToolType.Pointer; drawArea.Capture = false; drawArea.Refresh(); }
public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); drawArea.Cursor = Cursor; if (e.Button == MouseButtons.Left) { drawArea.TheLayers[drawArea.TheLayers.ActiveLayerIndex].Graphics.Dirty = true; } }
public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { drawArea.Cursor = Cursor; if ( e.Button == MouseButtons.Left ) { Point point = new Point(e.X, e.Y); drawArea.GraphicsList[0].MoveHandleTo(point, 2); drawArea.Refresh(); } }
/// <summary> /// Add new object to draw area. /// Function is called when user left-clicks draw area, /// and one of ToolObject-derived tools is active. /// </summary> /// <param name="drawArea"></param> /// <param name="o"></param> protected void AddNewObject(DrawArea drawArea, DrawObject o) { drawArea.GraphicsList.UnselectAll(); o.Selected = true; drawArea.GraphicsList.Add(o); drawArea.Capture = true; drawArea.Refresh(); drawArea.SetDirty(); }
/// <summary> /// Left nouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { _drawingInProcess = false; newPolyLine = null; } else { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); if (drawArea.PenType == DrawingPens.PenType.Generic) { if (_drawingInProcess == false) { newPolyLine = new DrawPolyLine(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.LineColor, drawArea.LineWidth); newPolyLine.EndPoint = new Point(p.X + 1, p.Y + 1); AddNewObject(drawArea, newPolyLine); _drawingInProcess = true; } else { // Drawing is in process, so simply add a new point newPolyLine.AddPoint(p); newPolyLine.EndPoint = p; } } else { if (_drawingInProcess == false) { newPolyLine = new DrawPolyLine(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.PenType); newPolyLine.EndPoint = new Point(p.X + 1, p.Y + 1); AddNewObject(drawArea, newPolyLine); _drawingInProcess = true; } else { // Drawing is in process, so simply add a new point newPolyLine.AddPoint(p); newPolyLine.EndPoint = p; } } } }
public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { int al = drawArea.TheLayers.ActiveLayerIndex; Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); if (drawArea.TheLayers[al].Graphics.Count > 0) drawArea.TheLayers[al].Graphics[0].Normalize(); if (startPoint.X < p.X && startPoint.Y < p.Y) AddNewObject(drawArea, new DrawPie(startPoint.X, startPoint.Y, p.X - startPoint.X, p.Y - startPoint.Y, System.Drawing.Color.Lime, System.Drawing.Color.Lime, true, drawArea.LineWidth, 0, 45)); else if (startPoint.X < p.X && startPoint.Y > p.Y) AddNewObject(drawArea, new DrawPie(startPoint.X, startPoint.Y, p.X - startPoint.X, startPoint.Y-p.Y, System.Drawing.Color.Lime, System.Drawing.Color.Lime, true, drawArea.LineWidth, 0, -45)); else if (startPoint.X > p.X && startPoint.Y < p.Y) AddNewObject(drawArea, new DrawPie(startPoint.X, startPoint.Y, startPoint.X-p.X, p.Y - startPoint.Y, System.Drawing.Color.Lime, System.Drawing.Color.Lime, true, drawArea.LineWidth, 180, -45)); else if (startPoint.X > p.X && startPoint.Y > p.Y) AddNewObject(drawArea, new DrawPie(startPoint.X, startPoint.Y, startPoint.X-p.X, startPoint.Y-p.Y, System.Drawing.Color.Lime, System.Drawing.Color.Lime, true, drawArea.LineWidth, 180, 45)); drawArea.AddCommandToHistory(new CommandAdd(drawArea.TheLayers[drawArea.TheLayers.ActiveLayerIndex].Graphics[0])); drawArea.ActiveTool = DrawToolType.Pointer; drawArea.Capture = false; drawArea.Refresh(); }
public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { Cursor = _openHand; }
/// <summary> /// Mouse move - resize new polygon /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { drawArea.Cursor = Cursor; if (e.Button != MouseButtons.Left) return; if (newPolyLine == null) return; // precaution Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); // move last point newPolyLine.MoveHandleTo(point, newPolyLine.HandleCount); drawArea.Refresh(); }
/// <summary> /// Left mouse button is released /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public virtual void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new DrawRectangle(e.X, e.Y, 1, 1)); }
public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { //newPolygon = null; //base.OnMouseUp(drawArea, e); }
public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new DrawLine(e.X, e.Y, e.X + 1, e.Y + 1)); IsComplete = true; }
/// <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) { Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); int al = drawArea.TheLayers.ActiveLayerIndex; wasMove = true; //toolTip.InitialDelay = 1; // set cursor when mouse button is not pressed if (e.Button == MouseButtons.None) { Cursor cursor = null; if (drawArea.TheLayers[al].Graphics != null) { // Hide tooltip in case it was displayed //toolTip.Hide(drawArea); for (int i = 0; i < drawArea.TheLayers[al].Graphics.Count; i++) { int n = drawArea.TheLayers[al].Graphics[i].HitTest(point); if (n > 0) { cursor = drawArea.TheLayers[al].Graphics[i].GetHandleCursor(n); break; } //if (n == 0) // toolTip.Show(drawArea.TheLayers[al].Graphics[i].TipText, drawArea, point, 250); } } 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 = point.X - lastPoint.X; int dy = point.Y - lastPoint.Y; lastPoint.X = point.X; lastPoint.Y = point.Y; // resize if (selectMode == SelectionMode.Size) { if (resizedObject != null) { resizedObject.MoveHandleTo(point, resizedObjectHandle); drawArea.Refresh(); } } // move if (selectMode == SelectionMode.Move) { int n = drawArea.TheLayers[al].Graphics.SelectionCount; for (int i = 0; i < n; i++) { drawArea.TheLayers[al].Graphics.GetSelectedObject(i).Move(dx, dy); } drawArea.Cursor = Cursors.SizeAll; drawArea.Refresh(); } if (selectMode == SelectionMode.NetSelection) { drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint); drawArea.Refresh(); return; } }
protected virtual void adjustForMinimumSize(DrawArea drawArea) { }
/// <summary> /// Show Properties dialog. Return true if list is changed /// </summary> /// <param name="parent"></param> /// <returns></returns> public bool ShowPropertiesDialog(DrawArea parent) { if (SelectionCount < 1) return false; GraphicsProperties properties = GetProperties(); PropertiesDialog dlg = new PropertiesDialog(); dlg.Properties = properties; CommandChangeState c = new CommandChangeState(this); if (dlg.ShowDialog(parent) != DialogResult.OK) return false; if ( ApplyProperties(properties) ) { c.NewState(this); parent.AddCommandToHistory(c); } return true; }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { _selectMode = SelectionMode.None; PointF point = new Point(e.X, e.Y); // Test for resizing (only if control is selected, cursor is on the handle) int n = drawArea.GraphicsList.SelectionCount; for (int i = 0; i < n; i++) { DrawObject o = drawArea.GraphicsList.GetSelectedObject(i); int handleNumber = o.HitTest(point); bool hitOnOutline = o.HitOnCircumferance; if (handleNumber > 0) { _selectMode = SelectionMode.Size; // keep resized object in class members _resizedObject = o; _resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects drawArea.GraphicsList.UnselectAll(); o.Selected = true; o.MouseClickOnHandle(handleNumber); break; } if (hitOnOutline && (n == 1)) //only one item is selected { _selectMode = SelectionMode.Size; o.MouseClickOnBorder(); o.Selected = true; } } // 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(point) == 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; drawArea.Cursor = Cursors.SizeAll; } } // Net selection if (_selectMode == SelectionMode.None) { // click on background if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.GraphicsList.UnselectAll(); } _selectMode = SelectionMode.NetSelection; drawArea.DrawNetRectangle = true; } _lastPoint.X = e.X; _lastPoint.Y = e.Y; _startPoint.X = e.X; _startPoint.Y = e.Y; drawArea.Capture = true; drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint); drawArea.Refresh(); }
/// <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(DrawArea drawArea, 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 < 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; } /// 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); drawArea.SetDirty(); drawArea.Refresh(); } } // move if (selectMode == SelectionMode.Move) { foreach (DrawObject o in drawArea.GraphicsList.Selection) { o.Move(dx, dy); } drawArea.Cursor = Cursors.SizeAll; drawArea.SetDirty(); drawArea.Refresh(); } 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, point)), Color.Black, FrameStyle.Dashed); return; } }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { _selectMode = SelectionMode.None; PointF point = new Point(e.X, e.Y); // òåñò äëÿ ðåñàéçà int n = drawArea.GraphicsList.SelectionCount; for (int i = 0; i < n; i++) { DrawObject o = drawArea.GraphicsList.GetSelectedObject(i); int handleNumber = o.HitTest(point); bool hitOnOutline = o.HitOnCircumferance; if (handleNumber > 0) { _selectMode = SelectionMode.Size; // äåðæèì èçìåíÿåìûé îáúåêò â ÷ëåíàõ êëàññà _resizedObject = o; _resizedObjectHandle = handleNumber; // ïðè ðåñàéçå îäíîãî îáúåêòà, àíñåëåêòÿòñÿ âñå îñòàëüíûå drawArea.GraphicsList.UnselectAll(); o.Selected = true; o.MouseClickOnHandle(handleNumber); break; } if (hitOnOutline && (n == 1)) // åñëè òîëüêî îäèí îáúåêò âûáðàí { _selectMode = SelectionMode.Size; o.MouseClickOnBorder(); o.Selected = true; } } // òåñò äëÿ ñäâèãà 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; // àíñåëåêòíóòü âñå, åñëè íå çàæàò ctrl è êëèêíóòíûé îáúåêò åùå íå âûáðàí if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { drawArea.GraphicsList.UnselectAll(); } // âûáðàòü êëèêíóòûé îáúåêò o.Selected = true; drawArea.Cursor = Cursors.SizeAll; } } if (_selectMode == SelectionMode.None) { // êëèê íà çàäíåì ôîíå if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.GraphicsList.UnselectAll(); } _selectMode = SelectionMode.NetSelection; drawArea.DrawNetRectangle = true; } _lastPoint.X = e.X; _lastPoint.Y = e.Y; _startPoint.X = e.X; _startPoint.Y = e.Y; drawArea.Capture = true; drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint); drawArea.Refresh(); }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { 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 drawArea.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 drawArea.GraphicsList.UnselectAll(); o.Selected = true; commandChangeState = new CommandChangeState(drawArea.GraphicsList); 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(point) == 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; } } // 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); } }
private void MainForm_Load(object sender, EventArgs e) { // Create draw area drawArea = new DrawArea(); drawArea.Location = new System.Drawing.Point(0, 0); drawArea.Size = new System.Drawing.Size(10, 10); drawArea.Owner = this; this.Controls.Add(drawArea); // Helper objects (DocManager and others) InitializeHelperObjects(); drawArea.Initialize(this, docManager); ResizeDrawArea(); LoadSettingsFromRegistry(); // Submit to Idle event to set controls state at idle time Application.Idle += delegate(object o, EventArgs a) { SetStateOfControls(); }; // Open file passed in the command line if (ArgumentFile.Length > 0) OpenDocument(ArgumentFile); // Subscribe to DropDownOpened event for each popup menu // (see details in MainForm_DropDownOpened) foreach (ToolStripItem item in menuStrip1.Items) { if (item.GetType() == typeof(ToolStripMenuItem)) { ((ToolStripMenuItem)item).DropDownOpened += MainForm_DropDownOpened; } } }
/// <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) { Point point = new Point(e.X, e.Y); // 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(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; } /// 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); drawArea.SetDirty(); drawArea.Refresh(); } } // move if (selectMode == SelectionMode.Move) { int n = drawArea.GraphicsList.SelectionCount; for (int i = 0; i < n; i++) { drawArea.GraphicsList.GetSelectedObject(i).Move(dx, dy); } drawArea.Cursor = Cursors.SizeAll; drawArea.SetDirty(); drawArea.Refresh(); } if (selectMode == SelectionMode.NetSelection) { drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint); drawArea.Refresh(); return; } }
/// <summary> /// 获取绘画区域 /// </summary> /// <param name="drawCamera"></param> /// <param name="drawIRCamera"></param> public void SetDrawArea(DrawArea drawCamera, DrawArea drawIRCamera) { drawAreaCamera = drawCamera; drawAreaIRCamera = drawIRCamera; }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { commandChangeState = null; wasMove = false; selectMode = SelectionMode.None; Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); // Test for resizing (only if control is selected, cursor is on the handle) int al = drawArea.TheLayers.ActiveLayerIndex; int n = drawArea.TheLayers[al].Graphics.SelectionCount; for (int i = 0; i < n; i++) { DrawObject o = drawArea.TheLayers[al].Graphics.GetSelectedObject(i); int handleNumber = o.HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; // keep resized object in class members resizedObject = o; resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects drawArea.TheLayers[al].Graphics.UnselectAll(); o.Selected = true; commandChangeState = new CommandChangeState(drawArea.TheLayers); break; } } // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { int n1 = drawArea.TheLayers[al].Graphics.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (drawArea.TheLayers[al].Graphics[i].HitTest(point) == 0) { o = drawArea.TheLayers[al].Graphics[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.TheLayers[al].Graphics.UnselectAll(); } // Select clicked object o.Selected = true; commandChangeState = new CommandChangeState(drawArea.TheLayers); drawArea.Cursor = Cursors.SizeAll; } } // Net selection if (selectMode == SelectionMode.None) { // click on background if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.TheLayers[al].Graphics.UnselectAll(); } selectMode = SelectionMode.NetSelection; drawArea.DrawNetRectangle = true; } lastPoint.X = point.X; lastPoint.Y = point.Y; startPoint.X = point.X; startPoint.Y = point.Y; drawArea.Capture = true; drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint); drawArea.Refresh(); }
/// <summary> /// Delete selected items /// </summary> private void DeleteSelection() { DrawArea.DeleteSelection(); }
public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { var point = new Point(e.X, e.Y); // óñòàíîâêà êóðñîðà, êîãäà ìûøü íå çàæàòà 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 (drawArea.GraphicsList[i].HitOnCircumferance) { cursor = drawArea.GraphicsList[i].GetOutlineCursor(n); break; } } if (cursor == null) { cursor = Cursors.Default; } drawArea.Cursor = cursor; return; } if (e.Button != MouseButtons.Left) { return; } // íàæàòèå ëåâîé êíîïêè // ðàçíèöà ìåæäó ïðåä. è òåê. ïîçèöèåé float dx = e.X - _lastPoint.X; float 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) { int n = drawArea.GraphicsList.SelectionCount; for (int i = 0; i < n; i++) { drawArea.GraphicsList.GetSelectedObject(i).Move(dx, dy); } drawArea.Cursor = Cursors.SizeAll; drawArea.SetDirty(); drawArea.Refresh(); } if (_selectMode == SelectionMode.NetSelection) { drawArea.NetRectangle = DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint); drawArea.Refresh(); return; } }
/// <summary> /// Undo /// </summary> private void CommandUndo() { DrawArea.Undo(); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new DrawText(e.X, e.Y)); }
/// <summary> /// Redo /// </summary> private void CommandRedo() { DrawArea.Redo(); }
public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { newPolygon = null; base.OnMouseUp(drawArea, e); }
private bool _drawingInProcess = false; // Set to true when drawing /// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { _drawingInProcess = false; newConnector = null; } else { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); int objectID = -1; p = TestForConnection(drawArea, p, out objectID); if (drawArea.PenType == DrawingPens.PenType.Generic) { if (_drawingInProcess == false) { newConnector = new DrawConnector(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.LineColor, drawArea.LineWidth); newConnector.EndPoint = new Point(p.X + 1, p.Y + 1); if (objectID > -1) { newConnector.StartIsAnchored = true; newConnector.StartObjectId = objectID; } AddNewObject(drawArea, newConnector); _drawingInProcess = true; } else { // Drawing is in process, so simply add a new point newConnector.AddPoint(p); newConnector.EndPoint = p; if (objectID > -1) { newConnector.EndIsAnchored = true; newConnector.EndObjectId = objectID; _drawingInProcess = false; } } } else { if (_drawingInProcess == false) { newConnector = new DrawConnector(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.PenType); newConnector.EndPoint = new Point(p.X + 1, p.Y + 1); if (objectID > -1) { newConnector.StartIsAnchored = true; newConnector.StartObjectId = objectID; } AddNewObject(drawArea, newConnector); _drawingInProcess = true; } else { // Drawing is in process, so simply add a new point newConnector.AddPoint(p); newConnector.EndPoint = p; if (objectID > -1) { newConnector.EndIsAnchored = true; newConnector.EndObjectId = objectID; _drawingInProcess = false; } } } } }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { Point p = GetEventPointInArea(drawArea, e); AddNewObject(drawArea, new DrawEllipse(p.X, p.Y, 1, 1)); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { drawArea.Cursor = _closedHand; }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new DrawLine(e.X, e.Y, e.X + 1, e.Y + 1)); }
public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e) { drawArea.Cursor = e.Button == MouseButtons.Left ? _closedHand : _openHand; }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { AddNewObject(drawArea, new DrawEllipse(e.X, e.Y, 1, 1)); }
public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { startPoint = drawArea.BackTrackMouse(new Point(e.X, e.Y)); // AddNewObject(drawArea, new DrawPie(p.X, p.Y, 1, 1, drawArea.LineColor, drawArea.FillColor, drawArea.DrawFilled, drawArea.LineWidth, 0, 45)); }