public override void CopyToClipboard(IGoCollection coll) { base.CopyToClipboard(coll); RectangleF bounds = GoDocument.ComputeBounds(coll, this); Metafile mf = GetMetafileFromCollection(coll, bounds, this.DocScale, false); PutEnhMetafileOnClipboard(this.Handle, mf); }
/// <summary> /// Call <see cref="M:Northwoods.Go.GoView.RaiseSelectionStarting" /> and <see cref="M:Northwoods.Go.GoView.RaiseSelectionFinished" /> /// around the addition of all of the objects in the given collection to this selection. /// </summary> /// <param name="coll"></param> public override void AddRange(IGoCollection coll) { if (coll != null && !coll.IsEmpty) { GoView view = View; view?.RaiseSelectionStarting(); base.AddRange(coll); view?.RaiseSelectionFinished(); } }
/// <summary> /// Iterate over the <see cref="T:Northwoods.Go.GoObject" />s in the given collection <paramref name="coll" /> /// and <see cref="M:Northwoods.Go.GoCollection.Add(Northwoods.Go.GoObject)" /> each one to this collection. /// </summary> /// <param name="coll"></param> public virtual void AddRange(IGoCollection coll) { if (coll != null) { foreach (GoObject item in coll) { Add(item); } } }
public override GoSelection ComputeEffectiveSelection(IGoCollection selection, bool move) { var result = base.ComputeEffectiveSelection(selection, move); if (move || CopiesEffectiveSelection) { AddSubtrees(result); } return(result); }
public static void AddSubtrees(IGoCollection selection) { var collection = new Hashtable(); foreach (var obj in selection) { addReachable(collection, obj as IGoNode); } foreach (GoObject obj in collection.Keys) { selection.Add(obj); } }
/// <summary> /// Make sure each link, either directly in the given collection, or connected to the nodes in /// the given collection, belong to the appropriate <see cref="T:Northwoods.Go.GoSubGraphBase" />. /// </summary> /// <param name="coll"></param> /// <param name="behind">whether to add the <paramref name="coll" /> at the beginning of the list /// of the subgraph's children (thus behind all other subgraph children), or at the end of the list /// (thus appearing in front of all the other subgraph children)</param> /// <param name="layer">the <see cref="T:Northwoods.Go.GoLayer" /> for links whose ports do not both belong to a <see cref="T:Northwoods.Go.GoSubGraphBase" /></param> /// <remarks> /// This calls <see cref="M:Northwoods.Go.GoSubGraphBase.ReparentToCommonSubGraph(Northwoods.Go.GoObject,Northwoods.Go.GoObject,Northwoods.Go.GoObject,System.Boolean,Northwoods.Go.GoLayer)" /> for each <see cref="T:Northwoods.Go.IGoLink" /> in the /// <paramref name="coll" /> collection, or for each <see cref="T:Northwoods.Go.IGoLink" /> connected to each <see cref="T:Northwoods.Go.IGoNode" /> /// in the <paramref name="coll" /> collection. /// </remarks> public static void ReparentAllLinksToSubGraphs(IGoCollection coll, bool behind, GoLayer layer) { GoCollection goCollection = new GoCollection(); foreach (GoObject item in coll) { goCollection.Add(item); } foreach (GoObject item2 in goCollection) { IGoNode goNode = item2 as IGoNode; if (goNode != null) { foreach (IGoLink link in goNode.Links) { if (link != null && link.FromPort != null && link.ToPort != null) { ReparentToCommonSubGraph(link.GoObject, link.FromPort.GoObject, link.ToPort.GoObject, behind, layer); } } } else { IGoPort goPort = item2 as IGoPort; if (goPort != null) { foreach (IGoLink link2 in goPort.Links) { if (link2 != null && link2.FromPort != null && link2.ToPort != null) { ReparentToCommonSubGraph(link2.GoObject, link2.FromPort.GoObject, link2.ToPort.GoObject, behind, layer); } } } else { IGoLink goLink = item2 as IGoLink; if (goLink != null && goLink.FromPort != null && goLink.ToPort != null) { ReparentToCommonSubGraph(goLink.GoObject, goLink.FromPort.GoObject, goLink.ToPort.GoObject, behind, layer); } } } } }
/// <summary> /// Unlike the standard behavior provided by <see cref="T:Northwoods.Go.GoGroup" />'s <see cref="M:Northwoods.Go.GoGroup.PickObjects(System.Drawing.PointF,System.Boolean,Northwoods.Go.IGoCollection,System.Int32)" />, /// subgraphs allow the picking of more than one child, if they overlap each other at the given point. /// </summary> /// <param name="p"></param> /// <param name="selectableOnly"></param> /// <param name="coll"></param> /// <param name="max"></param> /// <returns></returns> /// <remarks> /// If <see cref="M:Northwoods.Go.GoObject.CanView" /> is false for this group, no children are added to the collection. /// </remarks> public override IGoCollection PickObjects(PointF p, bool selectableOnly, IGoCollection coll, int max) { if (coll == null) { coll = new GoCollection(); } if (coll.Count >= max) { return(coll); } if (!GoObject.ContainsRect(Bounds, p)) { return(coll); } if (!CanView()) { return(coll); } foreach (GoObject backward in base.Backwards) { GoSubGraphBase goSubGraphBase = backward as GoSubGraphBase; if (goSubGraphBase != null) { goSubGraphBase.PickObjects(p, selectableOnly, coll, max); } else { GoObject goObject = backward.Pick(p, selectableOnly); if (goObject != null) { coll.Add(goObject); if (coll.Count >= max) { return(coll); } } } } if (PickableBackground && (!selectableOnly || CanSelect())) { coll.Add(this); } return(coll); }
public virtual Metafile GetMetafileFromCollection(IGoCollection coll, RectangleF bounds, float scale, bool paper) { lock (typeof(GoView)) { Graphics gbm = CreateGraphics(); IntPtr bufdc = gbm.GetHdc(); MemoryStream str = new MemoryStream(); Metafile mf = new Metafile(str, bufdc, bounds, MetafileFrameUnit.Pixel, EmfType.EmfPlusDual); Graphics gmf = Graphics.FromImage(mf); gmf.PageUnit = GraphicsUnit.Pixel; gmf.SmoothingMode = this.SmoothingMode; gmf.TextRenderingHint = this.TextRenderingHint; gmf.InterpolationMode = this.InterpolationMode; gmf.CompositingQuality = this.CompositingQuality; gmf.PixelOffsetMode = this.PixelOffsetMode; if (paper) { RectangleF b = bounds; b.Inflate(1, 1); PaintPaperColor(gmf, b); } foreach (GoObject obj in coll) { if (!obj.CanView()) { continue; } obj.Paint(gmf, this); } gmf.Dispose(); gbm.ReleaseHdc(bufdc); gbm.Dispose(); mf.Dispose(); byte[] data = str.GetBuffer(); return(new Metafile(new MemoryStream(data, false))); } }
/// <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); }
/// <summary> /// Call <c>Control.DoDragDrop</c> /// </summary> /// <param name="coll">a collection of objects being dragged, /// normally the view's <see cref="P:Northwoods.Go.GoView.Selection" /></param> /// <param name="allow">this is passed as the second argument to <c>Control.DoDragDrop</c></param> /// <remarks> /// This is in a separate method for easy overriding, so that you can /// substitute other serializable objects or <c>IDataObject</c>s to be /// dragged out to other windows. /// </remarks> public virtual void DoDragDrop(IGoCollection coll, DragDropEffects allow) { base.View.DoDragDrop(coll, allow); }