/// <summary> /// The overview rectangle should only appear selected if the <see cref="T:Northwoods.Go.GoOverview" /> /// supports resizing (i.e. <see cref="P:Northwoods.Go.GoView.AllowSelect" /> and <see cref="P:Northwoods.Go.GoView.AllowResize" /> are true), /// and even then the handles will not be seen since their <see cref="T:Northwoods.Go.GoHandle" />.<see cref="T:Northwoods.Go.GoHandleStyle" /> /// is <see cref="F:Northwoods.Go.GoHandleStyle.None" />. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { GoView view = sel.View; if (view != null && view.CanSelectObjects() && view.CanResizeObjects()) { view.ResizeHandleSize = new SizeF(4f / view.DocScale, 4f / view.DocScale); RemoveSelectionHandles(sel); RectangleF bounds = Bounds; GoHandle goHandle = sel.CreateResizeHandle(this, selectedObj, new PointF(bounds.Left, bounds.Top), 2, filled: true) as GoHandle; if (goHandle != null) { goHandle.Style = GoHandleStyle.None; } goHandle = (sel.CreateResizeHandle(this, selectedObj, new PointF(bounds.Right, bounds.Top), 4, filled: true) as GoHandle); if (goHandle != null) { goHandle.Style = GoHandleStyle.None; } goHandle = (sel.CreateResizeHandle(this, selectedObj, new PointF(bounds.Right, bounds.Bottom), 8, filled: true) as GoHandle); if (goHandle != null) { goHandle.Style = GoHandleStyle.None; } goHandle = (sel.CreateResizeHandle(this, selectedObj, new PointF(bounds.Left, bounds.Bottom), 16, filled: true) as GoHandle); if (goHandle != null) { goHandle.Style = GoHandleStyle.None; } } }
/// <summary> /// Create a new selection object containing an image of all of the real selected objects. /// </summary> /// <returns>a new <see cref="T:Northwoods.Go.GoSelection" /> holding view objects that represent the /// objects in the <see cref="P:Northwoods.Go.GoView.Selection" /></returns> /// <remarks> /// This creates a new <see cref="T:Northwoods.Go.GoSelection" /> for this view. /// The objects that are in this selection have been added to the default /// layer of the view. /// </remarks> public virtual GoSelection CreateDragSelection() { GoSelection goSelection = new GoSelection(null); PointF position = base.CurrentObject.Position; SizeF offset = GoTool.SubtractPoints(base.CurrentObject.Location, position); GoDragRectangle goDragRectangle = new GoDragRectangle(); goDragRectangle.Bounds = base.CurrentObject.Bounds; goDragRectangle.Offset = offset; goDragRectangle.Visible = false; base.View.Layers.Default.Add(goDragRectangle); goSelection.Add(goDragRectangle); GoCollection goCollection = new GoCollection(); goCollection.InternalChecksForDuplicates = false; foreach (GoObject item in (EffectiveSelection != null) ? EffectiveSelection : base.Selection) { goCollection.Add(item.DraggingObject); } base.View.Document.Layers.SortByZOrder(goCollection); RectangleF bounds = GoDocument.ComputeBounds(goCollection, base.View); float num = 1E+21f; float num2 = 1E+21f; foreach (GoObject item2 in goCollection) { if (item2.Top < num) { num = item2.Top; } if (item2.Left < num2) { num2 = item2.Left; } } float num3 = base.View.WorldScale.Width; if (bounds.Width * num3 > 2000f || bounds.Height * num3 > 2000f) { num3 *= Math.Min(2000f / (bounds.Width * num3), 2000f / (bounds.Height * num3)); } Bitmap bitmapFromCollection = base.View.GetBitmapFromCollection(goCollection, bounds, num3, paper: false); GoDragImage goDragImage = new GoDragImage(); goDragImage.Image = bitmapFromCollection; goDragImage.Bounds = new RectangleF(bounds.X, bounds.Y, (float)bitmapFromCollection.Width / num3, (float)bitmapFromCollection.Height / num3); if (num < 1E+21f && num2 < 1E+21f) { goDragImage.Offset = new SizeF(num2 - bounds.X + offset.Width, num - bounds.Y + offset.Height); } else { goDragImage.Offset = offset; } base.View.Layers.Default.Add(goDragImage); goSelection.Add(goDragImage); return(goSelection); }
/// <summary> /// If Resizable and Reshapable, support individual triangle vertex /// resize handles. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { if (!CanResize() || !CanReshape()) { base.AddSelectionHandles(sel, selectedObj); return; } PointF pointF = default(PointF); PointF pointF2 = default(PointF); PointF pointF3 = default(PointF); PointF pointF4 = default(PointF); bool flag = A.X <= B.X; bool flag2 = A.Y <= D.Y; sel.RemoveHandles(this); if (flag && flag2) { pointF = A; pointF2 = B; pointF3 = D; pointF4 = C; } else if (!flag && flag2) { pointF = B; pointF2 = A; pointF3 = C; pointF4 = D; } else if (flag && !flag2) { pointF = D; pointF2 = C; pointF3 = A; pointF4 = B; } else { pointF = C; pointF2 = D; pointF3 = B; pointF4 = A; } PointF loc = new PointF((pointF.X + pointF3.X) / 2f, (pointF.Y + pointF3.Y) / 2f); sel.CreateResizeHandle(this, selectedObj, loc, 256, filled: true); loc = new PointF((pointF2.X + pointF4.X) / 2f, (pointF2.Y + pointF4.Y) / 2f); sel.CreateResizeHandle(this, selectedObj, loc, 64, filled: true); loc = new PointF((pointF.X + pointF2.X) / 2f, (pointF.Y + pointF2.Y) / 2f); sel.CreateResizeHandle(this, selectedObj, loc, 32, filled: true); loc = new PointF((pointF3.X + pointF4.X) / 2f, (pointF3.Y + pointF4.Y) / 2f); sel.CreateResizeHandle(this, selectedObj, loc, 128, filled: true); sel.CreateResizeHandle(this, selectedObj, A, 1034, filled: true); sel.CreateResizeHandle(this, selectedObj, B, 1035, filled: true); sel.CreateResizeHandle(this, selectedObj, C, 1036, filled: true); sel.CreateResizeHandle(this, selectedObj, D, 1037, filled: true); }
/// <summary> /// When <see cref="P:Northwoods.Go.GoBalloon.Reanchorable" /> is true, add a special handle that lets the user change the <see cref="P:Northwoods.Go.GoBalloon.Anchor" /> /// by dragging the end point of the balloon to another object. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { base.AddSelectionHandles(sel, selectedObj); if (Reanchorable) { IGoHandle handle = sel.CreateResizeHandle(this, selectedObj, ComputeAnchorPoint(), 1026, filled: true); MakeDiamondResizeHandle(handle, 1); } }
/// <summary> /// If <see cref="M:Northwoods.Go.GoObject.CanReshape" /> and <see cref="P:Northwoods.Go.GoCube.ReshapableDepth" /> /// are true, this supports a depth control handle. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { base.AddSelectionHandles(sel, selectedObj); if (CanReshape() && ReshapableDepth) { PointF loc = getPoints()[1]; IGoHandle handle = sel.CreateResizeHandle(this, selectedObj, loc, 1033, filled: true); MakeDiamondResizeHandle(handle, 1); } }
/// <summary> /// If Resizable and Reshapable, support individual triangle vertex /// resize handles. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { if (!CanResize() || !CanReshape()) { base.AddSelectionHandles(sel, selectedObj); return; } sel.RemoveHandles(this); sel.CreateResizeHandle(this, selectedObj, A, 8192, filled: true); sel.CreateResizeHandle(this, selectedObj, B, 8193, filled: true); sel.CreateResizeHandle(this, selectedObj, C, 8194, filled: true); }
/// <summary> /// If <see cref="M:Northwoods.Go.GoObject.CanReshape" /> and <see cref="P:Northwoods.Go.GoParallelogram.ReshapableSkew" /> /// are true, this supports a skew control handle. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { base.AddSelectionHandles(sel, selectedObj); if (CanReshape() && ReshapableSkew) { RectangleF bounds = Bounds; SizeF skew = Skew; PointF pointF = default(PointF); pointF = (Direction ? new PointF(bounds.X + skew.Width, bounds.Y + skew.Height) : new PointF(bounds.X + bounds.Width - skew.Width, bounds.Y + skew.Height)); IGoHandle handle = sel.CreateResizeHandle(this, selectedObj, pointF, 1038, filled: true); MakeDiamondResizeHandle(handle, 1); } }
/// <summary> /// If <see cref="M:Northwoods.Go.GoObject.CanReshape" /> and <see cref="P:Northwoods.Go.GoCylinder.ResizableRadius" /> /// are true, this supports a radius control handle. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { base.AddSelectionHandles(sel, selectedObj); if (CanReshape() && ResizableRadius) { RectangleF bounds = Bounds; PointF pointF = default(PointF); float minorRadius = MinorRadius; pointF = ((Orientation == Orientation.Vertical) ? ((Perspective != 0 && Perspective != GoPerspective.TopRight) ? new PointF(bounds.X + bounds.Width / 2f, bounds.Y + bounds.Height - 2f * minorRadius) : new PointF(bounds.X + bounds.Width / 2f, bounds.Y + 2f * minorRadius)) : ((Perspective == GoPerspective.TopLeft || Perspective == GoPerspective.BottomLeft) ? new PointF(bounds.X + 2f * minorRadius, bounds.Y + bounds.Height / 2f) : new PointF(bounds.X + bounds.Width - 2f * minorRadius, bounds.Y + bounds.Height / 2f))); IGoHandle handle = sel.CreateResizeHandle(this, selectedObj, pointF, 1032, filled: true); MakeDiamondResizeHandle(handle, (Orientation == Orientation.Horizontal) ? 64 : 128); } }
/// <summary> /// If <see cref="M:Northwoods.Go.GoObject.CanReshape" /> and <see cref="P:Northwoods.Go.GoOctagon.ReshapableCorner" /> /// are true, this supports corner control handles. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { base.AddSelectionHandles(sel, selectedObj); if (CanReshape() && ReshapableCorner) { RectangleF bounds = Bounds; PointF loc = new PointF(bounds.X + Corner.Width, bounds.Y); IGoHandle handle = sel.CreateResizeHandle(this, selectedObj, loc, 1030, filled: true); MakeDiamondResizeHandle(handle, 64); loc = new PointF(bounds.X, bounds.Y + Corner.Height); handle = sel.CreateResizeHandle(this, selectedObj, loc, 1031, filled: true); MakeDiamondResizeHandle(handle, 128); } }
/// <summary> /// If <see cref="M:Northwoods.Go.GoObject.CanReshape" /> is true, supports angle control handles if /// <see cref="P:Northwoods.Go.GoPie.ResizableStartAngle" /> and/or <see cref="P:Northwoods.Go.GoPie.ResizableEndAngle" /> are true. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { base.AddSelectionHandles(sel, selectedObj); if (CanReshape()) { if (ResizableStartAngle) { PointF pointAtAngle = GetPointAtAngle(StartAngle); IGoHandle handle = sel.CreateResizeHandle(this, selectedObj, pointAtAngle, 1039, filled: true); MakeDiamondResizeHandle(handle, 1); } if (ResizableEndAngle) { PointF pointAtAngle2 = GetPointAtAngle(StartAngle + SweepAngle); IGoHandle handle2 = sel.CreateResizeHandle(this, selectedObj, pointAtAngle2, 1040, filled: true); MakeDiamondResizeHandle(handle2, 1); } } }
/// <summary> /// Clean up after any drag. /// </summary> /// <remarks> /// This restores any hidden selection handles, removes any /// drag selection objects, and stops the current transaction. /// </remarks> public override void Stop() { base.View.Document.SuspendsRouting = false; if (!base.View.DragRoutesRealtime && base.View.DragsRealtime && base.TransactionResult != null) { base.View.Document.DoDelayedRouting(EffectiveSelection); } base.View.StopAutoScroll(); if (mySelectionHidden) { mySelectionHidden = false; base.Selection.AddAllSelectionHandles(); } ClearDragSelection(); myEffectiveSelection = null; MoveOffset = default(SizeF); base.CurrentObject = null; SelectsWhenStarts = true; StopTransaction(); }
/// <summary> /// Display the appropriate selected appearance, normally, resize selection handles /// at each point of the polygon. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> /// <remarks> /// If this polygon is resizable and reshapable, we add resize selection /// handles at each polygon point, with handle IDs equal to /// <see cref="F:Northwoods.Go.GoObject.LastHandle" /> plus the index of the point. /// </remarks> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { GoView view = sel.View; bool flag = view?.CanResizeObjects() ?? true; bool flag2 = view?.CanReshapeObjects() ?? true; if (!(CanResize() && flag) || !(CanReshape() && flag2)) { base.AddSelectionHandles(sel, selectedObj); return; } sel.RemoveHandles(this); checked { int num = PointsCount - 1; for (int i = 0; i <= num; i++) { PointF point = GetPoint(i); sel.CreateResizeHandle(this, selectedObj, point, 8192 + i, filled: true); } } }
/// <summary> /// Handles should never be selected, so they should not get their own selection handles. /// </summary> /// <param name="sel"></param> /// <param name="selectedObj"></param> public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) { }
/// <summary> /// Just call <see cref="M:Northwoods.Go.GoOverviewRectangle.AddSelectionHandles(Northwoods.Go.GoSelection,Northwoods.Go.GoObject)" />. /// </summary> /// <param name="sel"></param> public override void OnGotSelection(GoSelection sel) { AddSelectionHandles(sel, this); }
public static void AddRectangleHandles(GoObject myObject, RectangleF rect, PointF center, float angle, GoSelection sel, GoObject selectedObj) { GoView view = sel.View; bool flag = view?.CanResizeObjects() ?? true; bool flag2 = view?.CanReshapeObjects() ?? true; if (myObject.CanResize() && flag) { float x = rect.X; float x2 = rect.X + rect.Width / 2f; float x3 = rect.X + rect.Width; float y = rect.Y; float y2 = rect.Y + rect.Height / 2f; float y3 = rect.Y + rect.Height; double num = (double)angle * Math.PI / 180.0; double cosine = Math.Cos(num); double sine = Math.Sin(num); SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x, y), center, cosine, sine), 2, filled: true), angle); SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x3, y), center, cosine, sine), 4, filled: true), angle); SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x3, y3), center, cosine, sine), 8, filled: true), angle); SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x, y3), center, cosine, sine), 16, filled: true), angle); if (myObject.CanReshape() && flag2) { SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x2, y), center, cosine, sine), 32, filled: true), angle); SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x3, y2), center, cosine, sine), 64, filled: true), angle); SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x2, y3), center, cosine, sine), 128, filled: true), angle); SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x, y2), center, cosine, sine), 256, filled: true), angle); } } }
/// <summary> /// Provide default behavior, when not running some other tool. /// </summary> /// <remarks> /// By default this handles: /// <list type="bullet"> /// <item>Delete: the Delete key deletes the current selection</item> /// <item>Select All: Ctrl-A selects all selectable document objects</item> /// <item>Copy, Cut, Paste: The Ctrl-C, Ctrl-Insert, Ctrl-X, Shift-Delete, Ctrl-V, and Shift-Insert keys do the standard clipboard operations</item> /// <item>Edit: the F2 key starts in-place editing of the current node's text label</item> /// <item>PageDown, PageUp: The PageDown and PageUp keys scroll vertically; Shift-PageDown and Shift-PageUp /// scroll horizontally</item> /// <item>Home, End: the Home and End keys scroll to the left side and right sides of the document; /// Ctrl-Home and Ctrl-End scroll to the top-left and bottom-right corners of the document, respectively</item> /// <item>Undo, Redo: Ctrl-Z and Ctrl-Y (or Ctrl-Shift-Z) perform undo and redo</item> /// <item>Arrow keys: moves the selection in the given direction, or else scrolls the view that way; /// the Ctrl modifier causes the movement or scrolling to just be one pixel at a time. /// This uses the <see cref="P:Northwoods.Go.GoView.ArrowMoveLarge" /> and <see cref="P:Northwoods.Go.GoView.ArrowMoveSmall" /> properties /// to control how far the selection is moved.</item> /// <item>Escape: the Escape key may clear the selection and then cancels the current input operation</item> /// <item>letters and digits: selects the next node whose text starts with that character</item> /// </list> /// However, the value of <see cref="T:Northwoods.Go.GoView" />.<see cref="P:Northwoods.Go.GoView.DisableKeys" /> can disable /// each of these behaviors. /// </remarks> public override void DoKeyDown() { GoInputEventArgs lastInput = base.LastInput; bool control = lastInput.Control; bool shift = lastInput.Shift; GoViewDisableKeys disableKeys = base.View.DisableKeys; Keys key = lastInput.Key; if (key == Keys.Delete && (disableKeys & GoViewDisableKeys.Delete) == 0) { base.View.EditDelete(); return; } if (control && key == Keys.A && (disableKeys & GoViewDisableKeys.SelectAll) == 0) { base.View.SelectAll(); return; } if (((control && key == Keys.C) /*|| (control && key == Keys.Insert) bylzy*/) && (disableKeys & GoViewDisableKeys.Clipboard) == 0) { base.View.EditCopy(); return; } if (((control && key == Keys.X) || (shift && key == Keys.Delete)) && (disableKeys & GoViewDisableKeys.Clipboard) == 0) { base.View.EditCut(); return; } if (((control && key == Keys.V) || (shift && key == Keys.Insert)) && (disableKeys & GoViewDisableKeys.Clipboard) == 0) { base.View.EditPaste(); return; } if (key == Keys.F2 && (disableKeys & GoViewDisableKeys.Edit) == 0) { base.View.EditEdit(); return; } if (key == Keys.Next && (disableKeys & GoViewDisableKeys.Page) == 0) { if (shift) { base.View.ScrollPage(1f, 0f); } else { base.View.ScrollPage(0f, 1f); } return; } if (key == Keys.Prior && (disableKeys & GoViewDisableKeys.Page) == 0) { if (shift) { base.View.ScrollPage(-1f, 0f); } else { base.View.ScrollPage(0f, -1f); } return; } if (key == Keys.Home && (disableKeys & GoViewDisableKeys.Home) == 0) { RectangleF rectangleF = base.View.ComputeDocumentBounds(); if (control) { base.View.DocPosition = new PointF(rectangleF.X, rectangleF.Y); } else { base.View.DocPosition = new PointF(rectangleF.X, base.View.DocPosition.Y); } return; } if (key == Keys.End && (disableKeys & GoViewDisableKeys.End) == 0) { RectangleF rectangleF2 = base.View.ComputeDocumentBounds(); SizeF docExtentSize = base.View.DocExtentSize; PointF pointF = control ? new PointF(rectangleF2.X + rectangleF2.Width - docExtentSize.Width, rectangleF2.Y + rectangleF2.Height - docExtentSize.Height) : new PointF(rectangleF2.X + rectangleF2.Width - docExtentSize.Width, base.View.DocPosition.Y); base.View.DocPosition = new PointF(Math.Max(0f, pointF.X), Math.Max(0f, pointF.Y)); return; } if (control && !shift && key == Keys.Z && (disableKeys & GoViewDisableKeys.Undo) == 0) { base.View.Undo(); return; } if (((control && key == Keys.Y) || (control && shift && key == Keys.Z)) && (disableKeys & GoViewDisableKeys.Undo) == 0) { base.View.Redo(); return; } if (key == Keys.Escape && (disableKeys & GoViewDisableKeys.CancelDeselects) == 0) { if (base.View.CanSelectObjects()) { base.Selection.Clear(); } base.DoKeyDown(); return; } if (key == Keys.Up || key == Keys.Down || key == Keys.Left || key == Keys.Right) { float num = 0f; float num2 = 0f; switch (key) { case Keys.Left: num = 0f - base.View.WorldScale.Width; break; case Keys.Right: num = base.View.WorldScale.Width; break; case Keys.Up: num2 = 0f - base.View.WorldScale.Height; break; case Keys.Down: num2 = base.View.WorldScale.Height; break; } if (!base.View.Selection.IsEmpty && base.View.CanMoveObjects() && (disableKeys & GoViewDisableKeys.ArrowMove) == 0) { float num3 = 1f; num3 = ((!control) ? base.View.ArrowMoveLarge : base.View.ArrowMoveSmall); GoToolDragging goToolDragging = base.View.FindMouseTool(typeof(GoToolDragging), subclass: true) as GoToolDragging; if (goToolDragging != null) { GoSelection sel = goToolDragging.ComputeEffectiveSelection(base.View.Selection, move: true); base.View.MoveSelection(sel, new SizeF(num * num3, num2 * num3), grid: true); base.View.RaiseSelectionMoved(); base.View.ScrollRectangleToVisible(base.View.Selection.Primary.Bounds); } } else if ((disableKeys & GoViewDisableKeys.ArrowScroll) == 0) { if (control) { base.View.DocPosition = new PointF(base.View.DocPosition.X + num, base.View.DocPosition.Y + num2); } else { base.View.ScrollLine(num, num2); } } else { base.DoKeyDown(); } return; } bool flag = false; if (!control && !lastInput.Alt && (disableKeys & GoViewDisableKeys.SelectsByFirstChar) == 0) { string text = TypeDescriptor.GetConverter(typeof(Keys)).ConvertToString(null, CultureInfo.CurrentCulture, lastInput.Key); char c = '\0'; if (text.Length == 1) { c = text[0]; } else if (text.Length == 2 && text[0] == 'D') { c = text[1]; } if (char.IsLetterOrDigit(c)) { flag = base.View.SelectNextNode(c); } } if (!flag) { base.DoKeyDown(); } }
/// <summary> /// Perform the drag, for both moving and copying, including the final move or copy /// on a mouse up event. /// </summary> /// <param name="evttype"></param> /// <remarks> /// Whether the drag is performing a move or a copy is determined by the /// value of the <see cref="M:Northwoods.Go.GoToolDragging.MayBeCopying" /> and <see cref="M:Northwoods.Go.GoToolDragging.MayBeMoving" /> predicates. /// This method is sensitive to the <see cref="P:Northwoods.Go.GoView.DragsRealtime" /> property. /// When this property is false, dragging uses the <see cref="P:Northwoods.Go.GoToolDragging.DragSelection" /> /// selection instead of the normal <see cref="P:Northwoods.Go.GoView.Selection" /> collection. /// It calls <see cref="M:Northwoods.Go.GoToolDragging.MakeDragSelection" /> to create the drag selection if needed /// and then moves the drag selection. /// When not copying and when <see cref="P:Northwoods.Go.GoView.DragsRealtime" /> is true, it calls /// <see cref="M:Northwoods.Go.GoToolDragging.ClearDragSelection" /> to stop using any drag selection and then it /// moves the regular <see cref="P:Northwoods.Go.GoView.Selection" />. /// </remarks> public virtual void DoDragging(GoInputState evttype) { if (base.CurrentObject == null) { return; } SizeF sizeF = GoTool.SubtractPoints(base.LastInput.DocPoint, base.CurrentObject.Position); SizeF sizeF2 = new SizeF(sizeF.Width - MoveOffset.Width, sizeF.Height - MoveOffset.Height); bool flag = MayBeCopying() && MustBeCopying(); bool flag2 = MayBeMoving(); DragEventArgs dragEventArgs = base.LastInput.DragEventArgs; if (dragEventArgs != null && !base.View.IsInternalDragDrop(dragEventArgs)) { flag = false; } if (EffectiveSelection == null) { myEffectiveSelection = ComputeEffectiveSelection(base.Selection, !flag); } if (evttype != GoInputState.Finish) { GoSelection goSelection = null; if (flag || !base.View.DragsRealtime) { MakeDragSelection(); goSelection = DragSelection; } else if (flag2) { ClearDragSelection(); goSelection = EffectiveSelection; } if (goSelection != null) { GoObject goObject = null; foreach (GoObject item in goSelection) { if (!(item is IGoLink) && item.CanMove()) { goObject = item; break; } } SizeF offset = sizeF2; if (goObject != null) { PointF location = goObject.Location; PointF p = new PointF(location.X + sizeF2.Width, location.Y + sizeF2.Height); p = base.View.SnapPoint(p, goObject); offset.Width = p.X - location.X; offset.Height = p.Y - location.Y; } base.View.MoveSelection(goSelection, offset, grid: false); } return; } SizeF offset2 = sizeF2; if (DragSelection != null) { offset2 = GoTool.SubtractPoints(base.CurrentObject.Position, DragSelectionOriginalObject.Position); ClearDragSelection(); } if (flag) { if (CopiesEffectiveSelection) { myEffectiveSelection = ComputeEffectiveSelection(base.Selection, move: false); base.View.CopySelection(EffectiveSelection, offset2, grid: true); } else { base.View.CopySelection(base.Selection, offset2, grid: true); } } else if (flag2) { if (EffectiveSelection == null) { myEffectiveSelection = ComputeEffectiveSelection(base.Selection, move: true); } base.View.MoveSelection(EffectiveSelection, offset2, grid: true); } }
/// <summary> /// Produce a new <see cref="T:Northwoods.Go.GoSelection" /> that is the real set of objects /// to be moved by <see cref="M:Northwoods.Go.GoView.MoveSelection(Northwoods.Go.GoSelection,System.Drawing.SizeF,System.Boolean)" /> or copied by /// <see cref="M:Northwoods.Go.GoView.CopySelection(Northwoods.Go.GoSelection,System.Drawing.SizeF,System.Boolean)" />. /// </summary> /// <param name="coll"></param> /// <param name="move">true for moving, false for copying</param> /// <returns>a <see cref="T:Northwoods.Go.GoSelection" /> that is cached as <see cref="P:Northwoods.Go.GoToolDragging.EffectiveSelection" /></returns> /// <remarks> /// This method is used to try to avoid problems with double-moving /// due to duplicate entries or both a parent and its child being in /// the argument collection. /// This also removes objects whose <see cref="P:Northwoods.Go.GoObject.DraggingObject" /> /// is null or has a false value for <see cref="M:Northwoods.Go.GoObject.CanMove" /> (if /// <paramref name="move" /> is true) or a false value for <see cref="M:Northwoods.Go.GoObject.CanCopy" /> /// (if <paramref name="move" /> is false). /// Furthermore this adds to the collection all links that have both /// ports in the selection. /// </remarks> public virtual GoSelection ComputeEffectiveSelection(IGoCollection coll, bool move) { Dictionary <GoObject, bool> dictionary = new Dictionary <GoObject, bool>(); GoCollection goCollection = null; GoSelection goSelection = new GoSelection(null); foreach (GoObject item in coll) { GoObject draggingObject = item.DraggingObject; if (draggingObject != null && !(move ? (!draggingObject.CanMove()) : (!draggingObject.CanCopy())) && !alreadyDragged(dictionary, draggingObject)) { dictionary[draggingObject] = true; if (!draggingObject.IsTopLevel) { if (goCollection == null) { goCollection = new GoCollection(); } goCollection.Add(draggingObject); } goSelection.Add(draggingObject); } } if (EffectiveSelectionIncludesLinks) { GoObject[] array = goSelection.CopyArray(); for (int i = 0; i < array.Length; i++) { IGoNode goNode = array[i] as IGoNode; if (goNode != null) { foreach (IGoLink destinationLink in goNode.DestinationLinks) { if (!alreadyDragged(dictionary, destinationLink.GoObject) && (destinationLink.ToPort == null || alreadyDragged(dictionary, destinationLink.ToPort.GoObject))) { dictionary[destinationLink.GoObject] = true; goSelection.Add(destinationLink.GoObject); } } foreach (IGoLink sourceLink in goNode.SourceLinks) { if (!alreadyDragged(dictionary, sourceLink.GoObject) && (sourceLink.FromPort == null || alreadyDragged(dictionary, sourceLink.FromPort.GoObject))) { dictionary[sourceLink.GoObject] = true; goSelection.Add(sourceLink.GoObject); } } } } } if (goCollection != null) { GoCollection goCollection2 = null; foreach (GoObject item2 in goSelection) { GoObject draggingObject2 = item2.DraggingObject; if (draggingObject2 is GoGroup) { foreach (GoObject item3 in goCollection) { if (item3.IsChildOf(draggingObject2)) { if (goCollection2 == null) { goCollection2 = new GoCollection(); } goCollection2.Add(item3); } } } } if (goCollection2 != null) { foreach (GoObject item4 in goCollection2) { goSelection.Remove(item4); } return(goSelection); } } return(goSelection); }