public static string GetShapeAddr(Shapes shape) { switch (shape) { case Shapes.Circle: return @"WhiteCircle50x50.png"; case Shapes.Square: return @"White10x10.png"; case Shapes.Triangle: return @"WhiteTriangle50x50.png"; case Shapes.Star: return @"WhiteStar50x50.png"; case Shapes.Mountains: return @"WhiteMountains50x50.png"; case Shapes.T: return @"WhiteT50x50.png"; case Shapes.Tent: return @"WhiteTent50x50.png"; case Shapes.Pentagon: return @"WhitePentagon50x50.png"; case Shapes.DoubleRhombus: return @"WhiteDoubleRhombus50x50.png"; case Shapes.Rhombus: return @"WhiteRhombus50x50.png"; } throw new ArgumentException("Unknown shape"); }
protected virtual Shapes.IDiagramLine CreateTemporaryLink(Shapes.IDiagramPort fromPort, Shapes.IDiagramPort toPort) { Shapes.IDiagramLine link1 = (Shapes.IDiagramLine)Activator.CreateInstance(base.View.LineType); if ((link1 == null) || (link1.DiagramShape == null)) { return null; } link1.FromPort = fromPort; link1.ToPort = toPort; Shapes.DiagramShape obj1 = link1.DiagramShape; if (obj1 is Shapes.LineGraph) { Shapes.LineGraph link2 = (Shapes.LineGraph)obj1; if (this.myOrthogonalSet) { link2.Orthogonal = this.Orthogonal; } link2.AdjustingStyle = Shapes.LineAdjustingStyle.Calculate; } else if (obj1 is Shapes.TextLine) { Shapes.TextLine link3 = (Shapes.TextLine)obj1; if (this.myOrthogonalSet) { link3.Orthogonal = this.Orthogonal; } link3.AdjustingStyle = Shapes.LineAdjustingStyle.Calculate; } base.View.Layers.Default.Add(obj1); return link1; }
public virtual void AddHandle(Shapes.DiagramShape obj, IShapeHandle handle) { if (this.myHandles == null) { this.myHandles = new Hashtable(); } object obj1 = this.myHandles[obj]; if (obj1 == null) { this.myHandles[obj] = handle; } else if (obj1 is ArrayList) { ArrayList list1 = (ArrayList)obj1; list1.Add(handle); } else { ArrayList list2 = new ArrayList(); list2.Add(obj1); list2.Add(handle); this.myHandles[obj] = list2; } if (this.View != null) { this.View.Layers.Default.Add(handle.DiagramShape); } }
// // // This is just very slow, so I've disabled it... // private void OnSelectDisplayItem(object sender, Shapes.DisplayItem displayItem) { treeElements.SelectedNodes = null; //treeElements.Nodes.Find(); //TreeNode visibleNode = null; //foreach (Shapes.PreviewPixel pixel in displayItem.Shape.Pixels) //{ // if (pixel.Node != null) // { // } //} //if (visibleNode != null) //{ // bool selectParent = true; // foreach (TreeNode node in visibleNode.Parent.Nodes) // { // selectParent = (selectParent && treeElements.SelectedNodes.Contains(node)); // } // if (selectParent) // { // treeElements.SelectedNodes = null; // treeElements.AddSelectedNode(visibleNode.Parent); // visibleNode.Parent.Collapse(); // visibleNode.Parent.EnsureVisible(); // } // else // { // visibleNode.EnsureVisible(); // } //} }
public Shapes.IDiagramShapeCollection AddCollection(Shapes.IDiagramShapeCollection coll, bool reparentLinks) { Shapes.DiagramShapeCollection collection1 = new Shapes.DiagramShapeCollection(); foreach (Shapes.DiagramShape obj1 in coll) { collection1.Add(obj1); } CollectionEnumerator enumerator2 = collection1.GetEnumerator(); while (enumerator2.MoveNext()) { Shapes.DiagramShape obj2 = enumerator2.Current; bool flag1 = obj2.Layer != null; if (flag1) { Shapes.GroupShape.setAllNoClear(obj2, true); obj2.Remove(); } this.Add(obj2); if (flag1) { Shapes.GroupShape.setAllNoClear(obj2, false); } } if (reparentLinks && this.IsInDocument) { Shapes.SubGraphNode.ReparentAllLinksToSubGraphs(collection1, true, this.Document.LinksLayer); } return collection1; }
public void Add(Shapes.DiagramShape obj) { if (obj != null) { if (obj.Layer != null) { if (obj.Layer.LayerCollectionContainer != this.LayerCollectionContainer) { throw new ArgumentException("Cannot add an object to a layer when it is already part of a different document's or view's layer."); } if (obj.Parent != null) { throw new ArgumentException("Cannot add an object to a layer when it is part of a group."); } DiagramLayer layer1 = obj.Layer; if (layer1 != this) { this.changeLayer(obj, layer1, false); } } else { if (obj.Parent != null) { obj.Parent.Remove(obj); } this.addToLayer(obj, false); } } if (this.ShapeAdded != null) { this.ShapeAdded(this, new SelectionEventArgs(obj)); } }
public EntityData(BoundingBox box, Color color, Shapes shape, string name, string office) { Box = box; Color = color; Shape = shape; Name = name; Office = office; }
private bool alreadyDragged(Hashtable draggeds, Shapes.DiagramShape o) { for (Shapes.DiagramShape obj1 = o; obj1 != null; obj1 = obj1.Parent) { if (draggeds.Contains(obj1)) { return true; } } return false; }
protected virtual Shapes.IDiagramPort CreateTemporaryPort(Shapes.IDiagramPort port, PointF pnt, bool forToPort, bool atEnd) { GoTemporaryPort port1 = new GoTemporaryPort(); port1.Target = port as Shapes.DiagramPort; if ((port != null) && (port.DiagramShape != null)) { port1.Size = port.DiagramShape.Size; } port1.Center = pnt; port1.Style = Shapes.DiagramPortStyle.None; base.View.Layers.Default.Add(port1); return port1; }
public override void Add(Shapes.DiagramShape obj) { if (obj != null) { DiagramView view1 = this.View; if ((((view1 == null) || (view1.Selection != this)) || (this.Count < view1.MaximumSelectionCount)) && !this.Contains(obj)) { if (((view1 != null) && (obj.Document != view1.Document)) && (obj.View != view1)) { throw new ArgumentException("Selected objects must belong to the view or its document"); } this.addToSelection(obj); } } }
public Shape() { m_shape = Shapes.I; m_orientation = Orientations.Up; m_squares = new List<Square>(4); m_location = new Point(100, 100); m_blockSize = new Size(10, 10); for (int i = 0; i < 4; i++) m_squares.Add( new Square( new Point(m_location.X, m_location.Y - (i + 1) * m_blockSize.Height), new Size(m_blockSize.Width - 2, m_blockSize.Height - 2) ) ); }
private void OnSelectDisplayItem(object sender, Shapes.DisplayItem displayItem) { Shapes.DisplayItemBaseControl setupControl = displayItem.Shape.GetSetupControl(); if (setupControl != null) { propertiesForm.ShowSetupControl(setupControl); } reenableToolButtons(); }
public override PointF GetToLinkPoint(Shapes.IDiagramLine link) { if (this.Target != null) { return this.Target.GetToLinkPoint(link); } return base.GetToLinkPoint(link); }
public virtual void StartNewLink(Shapes.IDiagramPort port, PointF dc) { if (port != null) { base.StartTransaction(); this.myLinkingNew = true; if (this.IsValidFromPort(port)) { this.Forwards = true; this.StartPort = this.CreateTemporaryPort(port, port.DiagramShape.Center, false, false); this.EndPort = this.CreateTemporaryPort(port, dc, true, true); this.Link = this.CreateTemporaryLink(this.StartPort, this.EndPort); } else { this.Forwards = false; this.StartPort = this.CreateTemporaryPort(port, port.DiagramShape.Center, true, false); this.EndPort = this.CreateTemporaryPort(port, dc, false, true); this.Link = this.CreateTemporaryLink(this.EndPort, this.StartPort); } base.View.Cursor = Cursors.Hand; } }
internal string NewImage(UndirectedGraph<Pixel, TaggedUndirectedEdge<Pixel, EdgeTag>> g,Shapes shapes, string fileName = "image.svg") { svg = new SVGDocument(Width * scale + 1, Height * scale + 1); String data = ""; Color color = new Color(); foreach( Shape shape in shapes) { data = "M "; Pixel lastPixel = null; for (int i = 0; i < shape.Count; i++) { ArrayList curve = ((Curve)shape[i]).curveToPoints(); if ( i != 0 && !curve[0].Equals(lastPixel)) // Corrige curvas que possa estar no sentido errado curve.Reverse(); Pixel pixel = curve[0] as Pixel; lastPixel = curve[curve.Count - 1] as Pixel; if (i == 0) data += pixel.x + "," + pixel.y; curve.Add(curve[curve.Count - 1]); data += catmullRom2bezier(curve) + " "; color = ((Curve)((ArrayList)shape)[0]).color; } svg.DrawPath(color, color, 0.01, data); } /* foreach (var v in g.Vertices) { svg.DrawCircle(Color.Blue, Color.Transparent, 0, v.x * 7 + 7 / 2, v.y * 7 + 7 / 2, 1); }*/ //Retorna o nome do arquivo salvo svg.Save(fileName); return fileName; }
public virtual bool IsValidToPort(Shapes.IDiagramPort toPort) { if (!this.ForwardsOnly) { return toPort.CanLinkTo(); } return false; }
private Shapes.IDiagramPort pickNearestPort1(Shapes.DiagramShape obj, PointF dc, Shapes.IDiagramPort bestPort, ref float bestDist) { Shapes.IDiagramPort port1 = obj as Shapes.IDiagramPort; if (port1 != null) { PointF tf1 = this.PortPoint(port1, dc); float single1 = dc.X - tf1.X; float single2 = dc.Y - tf1.Y; float single3 = (single1 * single1) + (single2 * single2); if (single3 <= bestDist) { object obj1 = null; if (this.ValidPortsCache != null) { obj1 = this.ValidPortsCache[port1]; } if (obj1 == ToolLinking.Valid) { bestPort = port1; bestDist = single3; } else if (obj1 != ToolLinking.Invalid) { if ((this.Forwards && this.IsValidLink(this.OriginalStartPort, port1)) || (!this.Forwards && this.IsValidLink(port1, this.OriginalStartPort))) { if (this.ValidPortsCache != null) { this.ValidPortsCache[port1] = ToolLinking.Valid; } bestPort = port1; bestDist = single3; } else if (this.ValidPortsCache != null) { this.ValidPortsCache[port1] = ToolLinking.Invalid; } } } } Shapes.GroupShape group1 = obj as Shapes.GroupShape; if (group1 != null) { Shapes.GroupEnumerator enumerator2 = group1.GetEnumerator(); Shapes.GroupEnumerator enumerator1 = enumerator2.GetEnumerator(); while (enumerator1.MoveNext()) { Shapes.DiagramShape obj2 = enumerator1.Current; bestPort = this.pickNearestPort1(obj2, dc, bestPort, ref bestDist); } } return bestPort; }
public virtual void DoCancelRelink(Shapes.IDiagramLine oldlink, Shapes.IDiagramPort fromPort, Shapes.IDiagramPort toPort) { oldlink.FromPort = fromPort; oldlink.ToPort = toPort; base.TransactionResult = null; }
public virtual PointF PortPoint(Shapes.IDiagramPort port, PointF dc) { Shapes.DiagramPort port1 = port.DiagramShape as Shapes.DiagramPort; if (port1 == null) { return port.DiagramShape.Center; } Shapes.DiagramShape obj1 = port1.PortObject; if ((obj1 == null) || (obj1.Layer == null)) { obj1 = port1; } SizeF ef1 = obj1.Size; float single1 = 10f / base.View.WorldScale.Width; if ((ef1.Width < single1) && (ef1.Height < single1)) { return obj1.Center; } return port1.GetLinkPointFromPoint(dc); }
public virtual void DoNewLink(Shapes.IDiagramPort fromPort, Shapes.IDiagramPort toPort) { Shapes.IDiagramLine link1 = base.View.CreateLink(fromPort, toPort); if (link1 != null) { base.TransactionResult = "New Link"; base.View.RaiseLinkCreated(link1.DiagramShape); } else { base.TransactionResult = null; } }
public virtual void StartRelink(Shapes.IDiagramLine oldlink, Shapes.IDiagramPort oldport, PointF dc) { if (oldlink != null) { Shapes.DiagramShape obj1 = oldlink.DiagramShape; if ((obj1 != null) && (obj1.Layer != null)) { base.StartTransaction(); this.myLinkingNew = false; this.OriginalEndPort = oldport; this.Link = oldlink; if (oldlink.ToPort == oldport) { this.Forwards = true; this.OriginalStartPort = oldlink.FromPort; PointF tf1 = dc; if (this.OriginalStartPort != null) { tf1 = this.OriginalStartPort.DiagramShape.Center; } else if (oldlink is Shapes.LineGraph) { Shapes.LineGraph link1 = (Shapes.LineGraph)oldlink; if (link1.PointsCount > 0) { tf1 = link1.GetPoint(0); } } else if (oldlink is Shapes.TextLine) { Shapes.TextLine link2 = (Shapes.TextLine)oldlink; if (link2.RealLink.PointsCount > 0) { tf1 = link2.RealLink.GetPoint(0); } } this.StartPort = this.CreateTemporaryPort(this.OriginalStartPort, tf1, false, false); oldlink.FromPort = this.StartPort; this.EndPort = this.CreateTemporaryPort(this.OriginalEndPort, dc, true, true); oldlink.ToPort = this.EndPort; } else if (oldlink.FromPort == oldport) { this.Forwards = false; this.OriginalStartPort = oldlink.ToPort; PointF tf2 = dc; if (this.OriginalStartPort != null) { tf2 = this.OriginalStartPort.DiagramShape.Center; } else if (oldlink is Shapes.LineGraph) { Shapes.LineGraph link3 = (Shapes.LineGraph)oldlink; if (link3.PointsCount > 0) { tf2 = link3.GetPoint(link3.PointsCount - 1); } } else if (oldlink is Shapes.TextLine) { Shapes.TextLine link4 = (Shapes.TextLine)oldlink; if (link4.RealLink.PointsCount > 0) { tf2 = link4.RealLink.GetPoint(link4.RealLink.PointsCount - 1); } } this.StartPort = this.CreateTemporaryPort(this.OriginalStartPort, tf2, true, false); oldlink.ToPort = this.StartPort; this.EndPort = this.CreateTemporaryPort(this.OriginalEndPort, dc, false, true); oldlink.FromPort = this.EndPort; } base.View.Cursor = Cursors.Hand; } } }
public virtual void DoNoNewLink(Shapes.IDiagramPort fromPort, Shapes.IDiagramPort toPort) { base.TransactionResult = null; }
public override float GetToLinkDir(Shapes.IDiagramLine link) { if (this.Target != null) { return this.Target.GetToLinkDir(link); } return base.GetToLinkDir(link); }
public virtual void DoNoRelink(Shapes.IDiagramLine oldlink, Shapes.IDiagramPort fromPort, Shapes.IDiagramPort toPort) { Shapes.DiagramShape obj1 = oldlink.DiagramShape; if ((obj1 != null) && (obj1.Layer != null)) { if (obj1.Movable) { oldlink.FromPort = fromPort; oldlink.ToPort = toPort; base.TransactionResult = "Relink"; base.View.RaiseLinkRelinked(oldlink.DiagramShape); return; } if (obj1.CanDelete()) { CancelEventArgs args1 = new CancelEventArgs(); base.View.RaiseSelectionDeleting(args1); if (!args1.Cancel) { obj1.Remove(); base.View.RaiseSelectionDeleted(); base.TransactionResult = "Relink"; return; } this.DoCancelMouse(); } else { this.DoCancelMouse(); } } base.TransactionResult = null; }
public Shape(Shapes shapeType, PointF position, SizeF size = default(SizeF), float rotation = 0f, GameObjectType type = GameObjectType.None) : base(GetShapeAddr(shapeType), position, size, type: type, rotation: rotation) { ShapeType = shapeType; }
public virtual void DoRelink(Shapes.IDiagramLine oldlink, Shapes.IDiagramPort fromPort, Shapes.IDiagramPort toPort) { oldlink.FromPort = fromPort; oldlink.ToPort = toPort; Shapes.SubGraphNode.ReparentToCommonSubGraph(oldlink.DiagramShape, (fromPort != null) ? fromPort.DiagramShape : null, (toPort != null) ? toPort.DiagramShape : null, true, base.View.Document.LinksLayer); base.TransactionResult = "Relink"; base.View.RaiseLinkRelinked(oldlink.DiagramShape); }
private void OnDeSelectDisplayItem(object sender, Shapes.DisplayItem displayItem) { propertiesForm.ShowSetupControl(null); reenableToolButtons(); }
public virtual bool IsValidFromPort(Shapes.IDiagramPort fromPort) { return fromPort.CanLinkFrom(); }
protected ShapeSprite(Shapes shape, float penWidth, Color foreColor, Color backColor) { this.Shape = shape; this.PenWidth = penWidth; this.ForeColor = foreColor; this.BackColor = backColor; this.CornerRounding = 16; }
public virtual bool IsValidLink(Shapes.IDiagramPort fromPort, Shapes.IDiagramPort toPort) { if ((fromPort != null) && (toPort != null)) { return fromPort.IsValidLink(toPort); } return true; }