} // end of function /// <summary> /// Adds the selected objects from rectangular selection. Here, we do not activate a grip. /// Instead, we only show the selection rectangles. /// </summary> /// <param name="selObjects">The selected objects to add.</param> private void AddSelectedObjectsFromRectangularSelection(IList <IHitTestObject> selObjects) { _selectedObjects.AddRange(selObjects); DisplayedGripLevel = 1; DisplayedGrips = GetGripsFromSelectedObjects(); ActiveGrip = null; }
/// <summary> /// Handles the mouse up event. /// </summary> /// <param name="e">MouseEventArgs as provided by the view.</param> /// <returns>The next mouse state handler that should handle mouse events.</returns> public override void OnMouseUp(System.Windows.Forms.MouseEventArgs e) { base.OnMouseUp(e); if (ActiveGrip != null) { bool bRefresh = _wereObjectsMoved; // repaint the graph when objects were really moved bool bRepaint = false; _wereObjectsMoved = false; _grac.Doc.EndUpdate(ref _graphDocumentChangedSuppressor); bool chooseNextLevel = ActiveGrip.Deactivate(); ActiveGrip = null; if (chooseNextLevel && null != SingleSelectedHitTestObject) { DisplayedGripLevel = SingleSelectedHitTestObject.GetNextGripLevel(DisplayedGripLevel); bRepaint = true; } if (bRefresh) { _grac.WinFormsController.RefreshGraph(); // redraw the contents } else if (bRepaint) { _grac.WinFormsController.RepaintGraphArea(); } } }
/// <summary> /// Handles the mouse up event. /// </summary> /// <param name="position">Mouse position.</param> /// <param name="e">MouseEventArgs as provided by the view.</param> /// <returns>The next mouse state handler that should handle mouse events.</returns> public override void OnMouseUp(PointD2D position, MouseButtonEventArgs e) { base.OnMouseUp(position, e); if (e.LeftButton == MouseButtonState.Released && null != _rectangleSelectionArea_GraphCoordinates) { _grac.FindGraphObjectInRootLayerRectangle(_rectangleSelectionArea_GraphCoordinates.Value, out var foundObjects); AddSelectedObjectsFromRectangularSelection(foundObjects); (_grac.ViewObject as IGraphView).ReleaseCaptureMouseOnCanvas(); _rectangleSelectionArea_GraphCoordinates = null; _grac.RenderOverlay(); } else if (ActiveGrip != null) { bool bRefresh = _wereObjectsMoved; // repaint the graph when objects were really moved bool bRepaint = false; _wereObjectsMoved = false; _grac.Doc.Resume(ref _graphDocumentChangedSuppressor); bool chooseNextLevel = ActiveGrip.Deactivate(); ActiveGrip = null; if (chooseNextLevel && null != SingleSelectedHitTestObject) { DisplayedGripLevel = SingleSelectedHitTestObject.GetNextGripLevel(DisplayedGripLevel); bRepaint = true; } _grac.RenderOverlay(); } }
/// <summary> /// Handles the MouseDown event when the object pointer tool is selected /// </summary> /// <param name="e">The mouse event args</param> /// <remarks> /// The strategy to handle the mousedown event is as following: /// /// Have we clicked on already selected objects? /// if yes (we have clicked on already selected objects) and the shift or control key was pressed -> deselect the object and repaint /// if yes (we have clicked on already selected objects) and none shift nor control key was pressed-> activate the object moving mode /// if no (we have not clicked on already selected objects) and shift or control key was pressed -> search for the object and add it to the selected objects, then aktivate moving mode /// if no (we have not clicked on already selected objects) and no shift or control key pressed -> if a object was found add it to the selected objects and activate moving mode /// if no object was found clear the selection list, deactivate moving mode /// </remarks> public override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { base.OnMouseDown(e); if (e.Button != MouseButtons.Left) { return; // then there is nothing to do here } // first, if we have a mousedown without shift key and the // position has changed with respect to the last mousedown // we have to deselect all objects bool bControlKey = (Keys.Control == (Control.ModifierKeys & Keys.Control)); // Control pressed bool bShiftKey = (Keys.Shift == (Control.ModifierKeys & Keys.Shift)); PointF mouseXY = new PointF(e.X, e.Y); // Mouse pixel coordinates PointF graphXY = _grac.WinFormsController.PixelToPrintableAreaCoordinates(mouseXY); // Graph area coordinates ActiveGrip = GripHitTest(graphXY); if ((ActiveGrip is SuperGrip) && (bShiftKey || bControlKey)) { var superGrip = ActiveGrip as SuperGrip; IHitTestObject hitTestObj; IGripManipulationHandle gripHandle; if (superGrip.GetHittedElement(graphXY, out gripHandle, out hitTestObj)) { _selectedObjects.Remove(hitTestObj); superGrip.Remove(gripHandle); _grac.WinFormsController.RefreshGraph(); // repaint the graph return; } } else if (ActiveGrip != null) { ActiveGrip.Activate(graphXY, false); return; } // search for a object first IHitTestObject clickedObject; int clickedLayerNumber = 0; _grac.WinFormsController.FindGraphObjectAtPixelPosition(mouseXY, false, out clickedObject, out clickedLayerNumber); if (!bShiftKey && !bControlKey) // if shift or control are pressed, we add the object to the selection list and start moving mode { ClearSelections(); } if (null != clickedObject) { AddSelectedObject(graphXY, clickedObject); } } // end of function
public void Remove(IGripManipulationHandle gripHandle) { for (int i = GripList.Count - 1; i >= 0; i--) { if (object.ReferenceEquals(gripHandle, GripList[i])) { GripList.RemoveAt(i); HittedList.RemoveAt(i); break; } } }
/// <summary> /// Clears the selection list and repaints the graph if neccessary /// </summary> public void ClearSelections() { bool bRepaint = (_selectedObjects.Count > 0); // is a repaint neccessary _selectedObjects.Clear(); DisplayedGrips = null; ActiveGrip = null; if (bRepaint) { _grac.WinFormsController.RepaintGraphArea(); } }
/// <summary> /// Clears the selection list and repaints the graph if neccessary /// </summary> public void ClearSelections() { bool bRepaint = (_selectedObjects.Count > 0); // is a repaint neccessary _selectedObjects.Clear(); DisplayedGrips = null; ActiveGrip = null; if (bRepaint) { _grac.RenderOverlay(); } }
public bool GetHittedElement(PointD2D point, out IGripManipulationHandle gripHandle, out IHitTestObject hitObject) { for (int i = GripList.Count - 1; i >= 0; i--) { if (GripList[i].IsGripHitted(point)) { gripHandle = GripList[i]; hitObject = HittedList[i]; return(true); } } gripHandle = null; hitObject = null; return(false); }
/// <summary> /// Handles the MouseDown event when the object pointer tool is selected /// </summary> /// <param name="position">Mouse position.</param> /// <param name="e">The mouse event args</param> /// <remarks> /// The strategy to handle the mousedown event is as following: /// /// Have we clicked on already selected objects? /// if yes (we have clicked on already selected objects) and the shift or control key was pressed -> deselect the object and repaint /// if yes (we have clicked on already selected objects) and none shift nor control key was pressed-> activate the object moving mode /// if no (we have not clicked on already selected objects) and shift or control key was pressed -> search for the object and add it to the selected objects, then aktivate moving mode /// if no (we have not clicked on already selected objects) and no shift or control key pressed -> if a object was found add it to the selected objects and activate moving mode /// if no object was found clear the selection list, deactivate moving mode /// </remarks> public override void OnMouseDown(PointD2D position, MouseButtonEventArgs e) { base.OnMouseDown(position, e); if (e.LeftButton != MouseButtonState.Pressed) { return; // then there is nothing to do here } // first, if we have a mousedown without shift key and the // position has changed with respect to the last mousedown // we have to deselect all objects var keyboardModifiers = System.Windows.Input.Keyboard.Modifiers; bool bControlKey = keyboardModifiers.HasFlag(ModifierKeys.Control); bool bShiftKey = keyboardModifiers.HasFlag(ModifierKeys.Shift); var mousePixelCoord = position; // Mouse pixel coordinates var rootLayerCoord = _grac.ConvertMouseToRootLayerCoordinates(mousePixelCoord); // Graph area coordinates ActiveGrip = GripHitTest(rootLayerCoord); if ((ActiveGrip is SuperGrip) && (bShiftKey || bControlKey)) { var superGrip = ActiveGrip as SuperGrip; if (superGrip.GetHittedElement(rootLayerCoord, out var gripHandle, out var hitTestObj)) { _selectedObjects.Remove(hitTestObj); superGrip.Remove(gripHandle); return; } } else if (ActiveGrip != null) { ActiveGrip.Activate(rootLayerCoord, false); return; } _grac.FindGraphObjectAtPixelPosition(mousePixelCoord, false, out var clickedObject, out var clickedLayerNumber); if (!bShiftKey && !bControlKey) // if shift or control are pressed, we add the object to the selection list and start moving mode { ClearSelections(); } if (null != clickedObject) { AddSelectedObject(rootLayerCoord, clickedObject); } } // end of function
public override IGripManipulationHandle[] GetGrips(int gripLevel) { if (gripLevel <= 1) { var ls = (LineShape)_hitobject; var pts = new PointD3D[] { PointD3D.Empty, (PointD3D)ls.Size }; for (int i = 0; i < pts.Length; i++) { var pt = ls._transformation.Transform(pts[i]); pt = Transformation.Transform(pt); pts[i] = pt; } var grips = new IGripManipulationHandle[gripLevel == 0 ? 1 : 3]; // Translation grips var bounds = ls.Bounds; var wn = PolylineMath3D.GetWestNorthVectors(bounds.Size); var transformation = Matrix4x3.NewFromBasisVectorsAndLocation(wn.Item1, wn.Item2, bounds.Size.Normalized, PointD3D.Empty); transformation.AppendTransform(ls._transformation); transformation.AppendTransform(Transformation); double t1 = 0.55 * ls._linePen.Thickness1; double t2 = 0.55 * ls._linePen.Thickness2; var rect = new RectangleD3D(-t1, -t2, 0, 2 * t1, 2 * t2, bounds.Size.Length); var objectOutline = new RectangularObjectOutline(rect, transformation); grips[0] = new MovementGripHandle(this, objectOutline, null); // PathNode grips if (gripLevel == 1) { grips[2] = grips[0]; // put the movement grip to the background, the two NodeGrips need more priority var gripRadius = Math.Max(t1, t2); grips[0] = new PathNodeGripHandle(this, new VectorD3D(0, 0, 0), pts[0], gripRadius); grips[1] = new PathNodeGripHandle(this, new VectorD3D(1, 1, 1), pts[1], gripRadius); } return(grips); } else { return(base.GetGrips(gripLevel)); } }
public override void OnMouseDown(PointD3D position, MouseButtonEventArgs e) { base.OnMouseDown(position, e); if (e.ChangedButton == MouseButton.Left) { var hitData = new HitTestPointData(_grac.Doc.Camera.GetHitRayMatrix(position)); // first, if we have a mousedown without shift key and the // position has changed with respect to the last mousedown // we have to deselect all objects var keyboardModifiers = System.Windows.Input.Keyboard.Modifiers; bool bControlKey = keyboardModifiers.HasFlag(ModifierKeys.Control); bool bShiftKey = keyboardModifiers.HasFlag(ModifierKeys.Shift); ActiveGrip = GripHitTest(hitData); if ((ActiveGrip is SuperGrip) && (bShiftKey || bControlKey)) { var superGrip = ActiveGrip as SuperGrip; if (superGrip.GetHittedElement(hitData, out var gripHandle, out var hitTestObj)) { _selectedObjects.Remove(hitTestObj); superGrip.Remove(gripHandle); return; } } else if (ActiveGrip != null) { ActiveGrip.Activate(hitData, false); return; } _grac.FindGraphObjectAtPixelPosition(hitData, false, out var clickedObject, out var clickedLayerNumber); if (!bShiftKey && !bControlKey) // if shift or control are pressed, we add the object to the selection list and start moving mode { ClearSelections(); } if (null != clickedObject) { AddSelectedObject(hitData, clickedObject); } } }
public override IGripManipulationHandle[] GetGrips(double pageScale, int gripLevel) { if (gripLevel <= 1) { var ls = (ClosedCardinalSpline)_hitobject; var pts = new PointF[ls._curvePoints.Count]; var offset = ls.Location.AbsoluteVectorPivotToLeftUpper; for (int i = 0; i < pts.Length; i++) { pts[i] = (PointF)(ls._curvePoints[i] + offset); var pt = ls._transformation.TransformPoint(pts[i]); pt = Transformation.TransformPoint(pt); pts[i] = pt; } var grips = new IGripManipulationHandle[gripLevel == 0 ? 1 : 1 + ls._curvePoints.Count]; // Translation grips var path = new GraphicsPath(); path.AddClosedCurve(pts, (float)ls._tension); path.Widen(new Pen(Color.Black, (float)(6 / pageScale))); grips[grips.Length - 1] = new MovementGripHandle(this, path, null); // PathNode grips if (gripLevel == 1) { float gripRadius = (float)(3 / pageScale); for (int i = 0; i < ls._curvePoints.Count; i++) { grips[i] = new ClosedCardinalSplinePathNodeGripHandle(this, i, pts[i], gripRadius); } } return(grips); } else { return(base.GetGrips(pageScale, gripLevel)); } }
private void AddSelectedObject(PointD2D graphXY, IHitTestObject clickedObject) { _selectedObjects.Add(clickedObject); DisplayedGripLevel = 1; DisplayedGrips = GetGripsFromSelectedObjects(); if (_selectedObjects.Count == 1) // single object selected { ActiveGrip = GripHitTest(graphXY); if (ActiveGrip != null) { ActiveGrip.Activate(graphXY, true); } } else // multiple objects selected { ActiveGrip = DisplayedGrips[0]; // this is our SuperGrip DisplayedGrips[0].Activate(graphXY, true); } _grac.RenderOverlay(); }
public override IGripManipulationHandle[] GetGrips(double pageScale, int gripLevel) { if (gripLevel <= 1) { var ls = (LineShape)_hitobject; var pts = new PointF[] { new PointF(0, 0), new PointF((float)ls.Width, (float)ls.Height) }; for (int i = 0; i < pts.Length; i++) { var pt = ls._transformation.TransformPoint(pts[i]); pt = Transformation.TransformPoint(pt); pts[i] = pt; } var grips = new IGripManipulationHandle[gripLevel == 0 ? 1 : 3]; // Translation grips var path = new GraphicsPath(); path.AddLine(pts[0], pts[1]); path.Widen(new Pen(Color.Black, (float)(6 / pageScale))); grips[0] = new MovementGripHandle(this, path, null); // PathNode grips if (gripLevel == 1) { grips[2] = grips[0]; // put the movement grip to the background, the two NodeGrips need more priority float gripRadius = (float)(3 / pageScale); grips[0] = new PathNodeGripHandle(this, new PointF(0, 0), pts[0], gripRadius); grips[1] = new PathNodeGripHandle(this, new PointF(1, 1), pts[1], gripRadius); } return(grips); } else { return(base.GetGrips(pageScale, gripLevel)); } }
/// <summary> /// Handles the MouseDown event when the object pointer tool is selected /// </summary> /// <param name="position">Mouse position.</param> /// <param name="e">The mouse event args</param> /// <remarks> /// The strategy to handle the mousedown event is as following: /// /// Have we clicked on already selected objects? /// if yes (we have clicked on already selected objects) and the shift or control key was pressed -> deselect the object and repaint /// if yes (we have clicked on already selected objects) and none shift nor control key was pressed-> activate the object moving mode /// if no (we have not clicked on already selected objects) and shift or control key was pressed -> search for the object and add it to the selected objects, then aktivate moving mode /// if no (we have not clicked on already selected objects) and no shift or control key pressed -> if a object was found add it to the selected objects and activate moving mode /// if no object was found clear the selection list, deactivate moving mode /// </remarks> public override void OnMouseDown(PointD2D position, MouseButtonEventArgs e) { base.OnMouseDown(position, e); if (e.LeftButton != MouseButtonState.Pressed) return; // then there is nothing to do here // first, if we have a mousedown without shift key and the // position has changed with respect to the last mousedown // we have to deselect all objects var keyboardModifiers = System.Windows.Input.Keyboard.Modifiers; bool bControlKey = keyboardModifiers.HasFlag(ModifierKeys.Control); bool bShiftKey = keyboardModifiers.HasFlag(ModifierKeys.Shift); var mousePixelCoord = position; // Mouse pixel coordinates var rootLayerCoord = _grac.ConvertMouseToRootLayerCoordinates(mousePixelCoord); // Graph area coordinates ActiveGrip = GripHitTest(rootLayerCoord); if ((ActiveGrip is SuperGrip) && (bShiftKey || bControlKey)) { var superGrip = ActiveGrip as SuperGrip; IHitTestObject hitTestObj; IGripManipulationHandle gripHandle; if (superGrip.GetHittedElement(rootLayerCoord, out gripHandle, out hitTestObj)) { _selectedObjects.Remove(hitTestObj); superGrip.Remove(gripHandle); return; } } else if (ActiveGrip != null) { ActiveGrip.Activate(rootLayerCoord, false); return; } // search for a object first IHitTestObject clickedObject; int[] clickedLayerNumber = null; _grac.FindGraphObjectAtPixelPosition(mousePixelCoord, false, out clickedObject, out clickedLayerNumber); if (!bShiftKey && !bControlKey) // if shift or control are pressed, we add the object to the selection list and start moving mode ClearSelections(); if (null != clickedObject) AddSelectedObject(rootLayerCoord, clickedObject); } // end of function
} // end of function /// <summary> /// Adds the selected objects from rectangular selection. Here, we do not activate a grip. /// Instead, we only show the selection rectangles. /// </summary> /// <param name="selObjects">The selected objects to add.</param> private void AddSelectedObjectsFromRectangularSelection(IList<IHitTestObject> selObjects) { _selectedObjects.AddRange(selObjects); DisplayedGripLevel = 1; DisplayedGrips = GetGripsFromSelectedObjects(); ActiveGrip = null; }
public override void OnMouseDown(PointD3D position, MouseButtonEventArgs e) { base.OnMouseDown(position, e); if (e.ChangedButton == MouseButton.Left) { var hitData = new HitTestPointData(_grac.Doc.Camera.GetHitRayMatrix(position)); // first, if we have a mousedown without shift key and the // position has changed with respect to the last mousedown // we have to deselect all objects var keyboardModifiers = System.Windows.Input.Keyboard.Modifiers; bool bControlKey = keyboardModifiers.HasFlag(ModifierKeys.Control); bool bShiftKey = keyboardModifiers.HasFlag(ModifierKeys.Shift); ActiveGrip = GripHitTest(hitData); if ((ActiveGrip is SuperGrip) && (bShiftKey || bControlKey)) { var superGrip = ActiveGrip as SuperGrip; IHitTestObject hitTestObj; IGripManipulationHandle gripHandle; if (superGrip.GetHittedElement(hitData, out gripHandle, out hitTestObj)) { _selectedObjects.Remove(hitTestObj); superGrip.Remove(gripHandle); return; } } else if (ActiveGrip != null) { ActiveGrip.Activate(hitData, false); return; } // search for a object first IHitTestObject clickedObject; int[] clickedLayerNumber = null; _grac.FindGraphObjectAtPixelPosition(hitData, false, out clickedObject, out clickedLayerNumber); if (!bShiftKey && !bControlKey) // if shift or control are pressed, we add the object to the selection list and start moving mode ClearSelections(); if (null != clickedObject) AddSelectedObject(hitData, clickedObject); } }
public bool GetHittedElement(PointD2D point, out IGripManipulationHandle gripHandle, out IHitTestObject hitObject) { for (int i = GripList.Count - 1; i >= 0; i--) { if (GripList[i].IsGripHitted(point)) { gripHandle = GripList[i]; hitObject = HittedList[i]; return true; } } gripHandle = null; hitObject = null; return false; }
public void Add(IGripManipulationHandle gripHandle, IHitTestObject hitTestObject) { GripList.Add(gripHandle); HittedList.Add(hitTestObject); }
public override IGripManipulationHandle[] GetGrips(double pageScale, int gripLevel) { if (gripLevel <= 1) { LineShape ls = (LineShape)_hitobject; PointF[] pts = new PointF[] { new PointF(0, 0), new PointF((float)ls.Width, (float)ls.Height) }; for (int i = 0; i < pts.Length; i++) { var pt = ls._transformation.TransformPoint(pts[i]); pt = this.Transformation.TransformPoint(pt); pts[i] = pt; } IGripManipulationHandle[] grips = new IGripManipulationHandle[gripLevel == 0 ? 1 : 3]; // Translation grips GraphicsPath path = new GraphicsPath(); path.AddLine(pts[0], pts[1]); path.Widen(new Pen(Color.Black, (float)(6 / pageScale))); grips[0] = new MovementGripHandle(this, path, null); // PathNode grips if (gripLevel == 1) { grips[2] = grips[0]; // put the movement grip to the background, the two NodeGrips need more priority float gripRadius = (float)(3 / pageScale); grips[0] = new PathNodeGripHandle(this, new PointF(0, 0), pts[0], gripRadius); grips[1] = new PathNodeGripHandle(this, new PointF(1, 1), pts[1], gripRadius); } return grips; } else { return base.GetGrips(pageScale, gripLevel); } }
private void AddSelectedObject(HitTestPointData hitPoint, IHitTestObject clickedObject) { _selectedObjects.Add(clickedObject); DisplayedGripLevel = 1; DisplayedGrips = GetGripsFromSelectedObjects(); if (_selectedObjects.Count == 1) // single object selected { ActiveGrip = GripHitTest(hitPoint); if (ActiveGrip != null) ActiveGrip.Activate(hitPoint, true); } else // multiple objects selected { ActiveGrip = DisplayedGrips[0]; // this is our SuperGrip DisplayedGrips[0].Activate(hitPoint, true); } _grac.RenderOverlay(); }
/// <summary> /// Clears the selection list and repaints the graph if neccessary /// </summary> public void ClearSelections() { bool bRepaint = (_selectedObjects.Count>0); // is a repaint neccessary _selectedObjects.Clear(); DisplayedGrips = null; ActiveGrip = null; if(bRepaint) _grac.WinFormsController.RepaintGraphArea(); }
} // end of function private void AddSelectedObject(PointF graphXY, IHitTestObject clickedObject) { _selectedObjects.Add(clickedObject); DisplayedGripLevel = 1; DisplayedGrips = GetGripsFromSelectedObjects(); if (_selectedObjects.Count == 1) // single object selected { ActiveGrip = GripHitTest(graphXY); if (ActiveGrip != null) ActiveGrip.Activate(graphXY, true); } else // multiple objects selected { ActiveGrip = DisplayedGrips[0]; // this is our SuperGrip DisplayedGrips[0].Activate(graphXY, true); } _grac.WinFormsController.RepaintGraphArea(); }
/// <summary> /// Handles the MouseDown event when the object pointer tool is selected /// </summary> /// <param name="e">The mouse event args</param> /// <remarks> /// The strategy to handle the mousedown event is as following: /// /// Have we clicked on already selected objects? /// if yes (we have clicked on already selected objects) and the shift or control key was pressed -> deselect the object and repaint /// if yes (we have clicked on already selected objects) and none shift nor control key was pressed-> activate the object moving mode /// if no (we have not clicked on already selected objects) and shift or control key was pressed -> search for the object and add it to the selected objects, then aktivate moving mode /// if no (we have not clicked on already selected objects) and no shift or control key pressed -> if a object was found add it to the selected objects and activate moving mode /// if no object was found clear the selection list, deactivate moving mode /// </remarks> public override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { base.OnMouseDown(e); if (e.Button != MouseButtons.Left) return; // then there is nothing to do here // first, if we have a mousedown without shift key and the // position has changed with respect to the last mousedown // we have to deselect all objects bool bControlKey = (Keys.Control == (Control.ModifierKeys & Keys.Control)); // Control pressed bool bShiftKey = (Keys.Shift == (Control.ModifierKeys & Keys.Shift)); PointF mouseXY = new PointF(e.X, e.Y); // Mouse pixel coordinates PointF graphXY = _grac.WinFormsController.PixelToPrintableAreaCoordinates(mouseXY); // Graph area coordinates ActiveGrip = GripHitTest(graphXY); if ((ActiveGrip is SuperGrip) && (bShiftKey || bControlKey)) { var superGrip = ActiveGrip as SuperGrip; IHitTestObject hitTestObj; IGripManipulationHandle gripHandle; if (superGrip.GetHittedElement(graphXY, out gripHandle, out hitTestObj)) { _selectedObjects.Remove(hitTestObj); superGrip.Remove(gripHandle); _grac.WinFormsController.RefreshGraph(); // repaint the graph return; } } else if (ActiveGrip != null) { ActiveGrip.Activate(graphXY, false); return; } // search for a object first IHitTestObject clickedObject; int clickedLayerNumber = 0; _grac.WinFormsController.FindGraphObjectAtPixelPosition(mouseXY, false, out clickedObject, out clickedLayerNumber); if (!bShiftKey && !bControlKey) // if shift or control are pressed, we add the object to the selection list and start moving mode ClearSelections(); if (null != clickedObject) AddSelectedObject(graphXY, clickedObject); } // end of function
public override IGripManipulationHandle[] GetGrips(double pageScale, int gripLevel) { if (gripLevel <= 1) { ClosedCardinalSpline ls = (ClosedCardinalSpline)_hitobject; PointF[] pts = new PointF[ls._curvePoints.Count]; var offset = ls.Location.AbsoluteVectorPivotToLeftUpper; for (int i = 0; i < pts.Length; i++) { pts[i] = (PointF)(ls._curvePoints[i] + offset); var pt = ls._transformation.TransformPoint(pts[i]); pt = this.Transformation.TransformPoint(pt); pts[i] = pt; } IGripManipulationHandle[] grips = new IGripManipulationHandle[gripLevel == 0 ? 1 : 1 + ls._curvePoints.Count]; // Translation grips GraphicsPath path = new GraphicsPath(); path.AddClosedCurve(pts, (float)ls._tension); path.Widen(new Pen(Color.Black, (float)(6 / pageScale))); grips[grips.Length - 1] = new MovementGripHandle(this, path, null); // PathNode grips if (gripLevel == 1) { float gripRadius = (float)(3 / pageScale); for (int i = 0; i < ls._curvePoints.Count; i++) { grips[i] = new ClosedCardinalSplinePathNodeGripHandle(this, i, pts[i], gripRadius); } } return grips; } else { return base.GetGrips(pageScale, gripLevel); } }
/// <summary> /// Clears the selection list and repaints the graph if neccessary /// </summary> public void ClearSelections() { bool bRepaint = (_selectedObjects.Count > 0); // is a repaint neccessary _selectedObjects.Clear(); DisplayedGrips = null; ActiveGrip = null; if (bRepaint) _grac.RenderOverlay(); }
/// <summary> /// Handles the mouse up event. /// </summary> /// <param name="position">Mouse position.</param> /// <param name="e">MouseEventArgs as provided by the view.</param> /// <returns>The next mouse state handler that should handle mouse events.</returns> public override void OnMouseUp(PointD3D position, MouseButtonEventArgs e) { base.OnMouseUp(position, e); /* if (e.LeftButton == MouseButtonState.Released && null != _rectangleSelectionArea_GraphCoordinates) { List<IHitTestObject> foundObjects; _grac.FindGraphObjectInRootLayerRectangle(_rectangleSelectionArea_GraphCoordinates.Value, out foundObjects); AddSelectedObjectsFromRectangularSelection(foundObjects); _grac.ReleaseMouseCapture(); _rectangleSelectionArea_GraphCoordinates = null; _grac.RenderOverlay(); return; } */ if (e.ChangedButton == MouseButton.Left) { if (ActiveGrip != null) { bool bRefresh = _wereObjectsMoved; // repaint the graph when objects were really moved bool bRepaint = false; _wereObjectsMoved = false; _grac.Doc.Resume(ref _graphDocumentChangedSuppressor); bool chooseNextLevel = ActiveGrip.Deactivate(); ActiveGrip = null; if (chooseNextLevel && null != SingleSelectedHitTestObject) { DisplayedGripLevel = SingleSelectedHitTestObject.GetNextGripLevel(DisplayedGripLevel); bRepaint = true; } _grac.RenderOverlay(); } } }
/// <summary> /// Handles the mouse up event. /// </summary> /// <param name="e">MouseEventArgs as provided by the view.</param> /// <returns>The next mouse state handler that should handle mouse events.</returns> public override void OnMouseUp(System.Windows.Forms.MouseEventArgs e) { base.OnMouseUp(e); if(ActiveGrip!=null) { bool bRefresh = _wereObjectsMoved; // repaint the graph when objects were really moved bool bRepaint = false; _wereObjectsMoved = false; _grac.Doc.EndUpdate(ref _graphDocumentChangedSuppressor); bool chooseNextLevel = ActiveGrip.Deactivate(); ActiveGrip = null; if (chooseNextLevel && null!=SingleSelectedHitTestObject) { DisplayedGripLevel = SingleSelectedHitTestObject.GetNextGripLevel(DisplayedGripLevel); bRepaint = true; } if (bRefresh) _grac.WinFormsController.RefreshGraph(); // redraw the contents else if(bRepaint) _grac.WinFormsController.RepaintGraphArea(); } }
public override IGripManipulationHandle[] GetGrips(int gripLevel) { if (gripLevel <= 1) { LineShape ls = (LineShape)_hitobject; PointD3D[] pts = new PointD3D[] { PointD3D.Empty, (PointD3D)ls.Size }; for (int i = 0; i < pts.Length; i++) { var pt = ls._transformation.Transform(pts[i]); pt = this.Transformation.Transform(pt); pts[i] = pt; } IGripManipulationHandle[] grips = new IGripManipulationHandle[gripLevel == 0 ? 1 : 3]; // Translation grips var bounds = ls.Bounds; var wn = PolylineMath3D.GetWestNorthVectors(bounds.Size); var transformation = Matrix4x3.NewFromBasisVectorsAndLocation(wn.Item1, wn.Item2, bounds.Size.Normalized, PointD3D.Empty); transformation.AppendTransform(ls._transformation); transformation.AppendTransform(this.Transformation); double t1 = 0.55 * ls._linePen.Thickness1; double t2 = 0.55 * ls._linePen.Thickness2; var rect = new RectangleD3D(-t1, -t2, 0, 2 * t1, 2 * t2, bounds.Size.Length); var objectOutline = new RectangularObjectOutline(rect, transformation); grips[0] = new MovementGripHandle(this, objectOutline, null); // PathNode grips if (gripLevel == 1) { grips[2] = grips[0]; // put the movement grip to the background, the two NodeGrips need more priority var gripRadius = Math.Max(t1, t2); grips[0] = new PathNodeGripHandle(this, new VectorD3D(0, 0, 0), pts[0], gripRadius); grips[1] = new PathNodeGripHandle(this, new VectorD3D(1, 1, 1), pts[1], gripRadius); } return grips; } else { return base.GetGrips(gripLevel); } }