//private System.IO.StreamWriter debugLog; public EditorLink(State state, GraphicLink graphicLink, ModelLink modelLink) { this.state = state; this.graphicLink = graphicLink; this.modelLink = modelLink; opacityTimer.Interval = 100; opacityTimer.Elapsed += new ElapsedEventHandler(opacityTimer_Elapsed); //debugLog = new System.IO.StreamWriter("c:\\" + guid.ToString() + " - " + tag + ".log"); }
internal void SetSelectedObject(GraphicLink graphicLink, ModelLink modelLink, State state) { Clear(); this.graphicLink = graphicLink; this.state = state; id = 0; linkGraphic = AppendRootCategory(id++, "Graphic"); //linkGraphicGuid = AppendProperty(linkGraphic, id++, "Guid", graphicLink, "Guid", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkGraphicOrigin = AppendProperty(linkGraphic, id++, "Origin", graphicLink, "Origin", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkGraphicDestination = AppendProperty(linkGraphic, id++, "Destination", graphicLink, "Destination", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkGraphicOriginPortID = AppendProperty(linkGraphic, id++, "Origin Port ID", graphicLink, "OriginPortID", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkGraphicDestinationPortID = AppendProperty(linkGraphic, id++, "Destination Port ID", graphicLink, "DestinationPortID", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkGraphicTag = AppendProperty(linkGraphic, id++, "Tag", graphicLink, "Tag", ""); linkModel = AppendRootCategory(id++, "Model"); //linkModelClass = AppendProperty(linkModel, id++, "Class", modelLink, "LinkClass", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkModelOrigin = AppendProperty(linkModel, id++, "Origin", modelLink, "Origin", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkModelDestination = AppendProperty(linkModel, id++, "Destination", modelLink, "Destination", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkModelOriginPort = AppendProperty(linkModel, id++, "Origin Port", modelLink, "OriginPort", "", new System.ComponentModel.ReadOnlyAttribute(true)); //linkModelDestinationPort = AppendProperty(linkModel, id++, "Destination Port", modelLink, "DestinationPort", "", new System.ComponentModel.ReadOnlyAttribute(true)); }
internal void CreateLink(ModelLink modelLink, GraphicLink graphicLink) { if (flowChart.InvokeRequired) { flowChart.BeginInvoke(new CreateLinkDelegate(CreateLink), new object[] { modelLink, graphicLink }); } else { bool isVisible = false; { EditorNode destinationNode, originNode; if ( (editorNodes.TryGetValue(graphicLink.Origin, out originNode)) && (editorNodes.TryGetValue(graphicLink.Destination, out destinationNode)) ) { isVisible = ((originNode.Visible) || (destinationNode.Visible)); } } Box textBox = null; { SysCAD.Protocol.Rectangle textArea = graphicLink.TagArea; if (textArea.IsEmpty) // We haven't got a TagArea stored in the item yet. { SysCAD.Protocol.Point pointOrigin = new SysCAD.Protocol.Point(); SysCAD.Protocol.Point pointDestination = new SysCAD.Protocol.Point(); SysCAD.Protocol.Point pointCenter = new SysCAD.Protocol.Point(); if (graphicLink.ControlPoints != null && graphicLink.ControlPoints.Count > 1) { pointOrigin = graphicLink.ControlPoints[0]; pointDestination = graphicLink.ControlPoints[graphicLink.ControlPoints.Count - 1]; pointCenter = new SysCAD.Protocol.Point((pointDestination.X + pointOrigin.X) / 2.0F, (pointDestination.Y + pointOrigin.Y) / 2.0F); } textArea = new SysCAD.Protocol.Rectangle(pointCenter.X, pointCenter.Y + 4.0, 20.0, 4.0); } textBox = flowChart.CreateBox((float)textArea.X, (float)textArea.Y, (float)textArea.Width, (float)textArea.Height); textBox.RotationAngle = (float)graphicLink.TagAngle; textBox.FillColor = System.Drawing.Color.FromArgb(1, System.Drawing.Color.Black); textBox.FrameColor = System.Drawing.Color.FromArgb(1, System.Drawing.Color.Black); textBox.RotateContents = true; textBox.Style = BoxStyle.Shape; textBox.Shape = ShapeTemplate.FromId("Rectangle"); textBox.EnabledHandles = Handles.ResizeTopLeft | Handles.ResizeTopRight | Handles.ResizeBottomRight | Handles.ResizeBottomLeft | Handles.ResizeTopCenter | Handles.ResizeMiddleRight | Handles.ResizeBottomCenter | Handles.ResizeMiddleLeft | Handles.Move; textBox.Text = graphicLink.Tag; } Arrow arrow = flowChart.CreateArrow(new PointF(0.0F, 0.0F), new PointF(10.0F, 10.0F)); arrow.CustomDraw = CustomDraw.Additional; { switch (modelLink.LinkClass) { case "Pipe-1": break; case "CtrlLink": arrow.PenColor = System.Drawing.Color.Gray; break; default: arrow.PenColor = System.Drawing.Color.Red; break; } EditorNode origin = null; EditorNode destination = null; origin = Item(graphicLink.Origin); destination = Item(graphicLink.Destination); if (origin == null) { clientProtocol.LogMessage(out requestId, "Origin Guid " + graphicLink.Origin + " not found for link " + graphicLink.Tag, SysCAD.Log.MessageType.Error); return; } if (destination == null) { clientProtocol.LogMessage(out requestId, "Destination Guid " + graphicLink.Destination + " not found for link " + graphicLink.Tag, SysCAD.Log.MessageType.Error); return; } SysCAD.Protocol.Point pointOrigin = new SysCAD.Protocol.Point(); SysCAD.Protocol.Point pointDestination = new SysCAD.Protocol.Point(); if (graphicLink.ControlPoints != null && graphicLink.ControlPoints.Count > 1) { pointOrigin = graphicLink.ControlPoints[0]; pointDestination = graphicLink.ControlPoints[graphicLink.ControlPoints.Count - 1]; } if (origin != null) { if (origin.HiddenBox != null) arrow.Origin = origin.HiddenBox; else arrow.Origin = origin.ModelBox; } if (destination != null) { if (destination.HiddenBox != null) arrow.Destination = destination.HiddenBox; else arrow.Destination = destination.ModelBox; } if ((modelLink.OriginPort != null) && ((origin.ModelBox.Tag as EditorNode).anchorTagToInt.ContainsKey(modelLink.OriginPort + graphicLink.OriginPortID.ToString()))) arrow.OrgnAnchor = (origin.ModelBox.Tag as EditorNode).anchorTagToInt[modelLink.OriginPort + graphicLink.OriginPortID.ToString()]; else { Console.WriteLine("(origin.ModelBox.Tag as EditorNode).modelNode : " + (origin.ModelBox.Tag as EditorNode).ModelNode.Guid.ToString() + " : " + (origin.ModelBox.Tag as EditorNode).ModelNode.NodeClass.ToString() + " : " + (origin.ModelBox.Tag as EditorNode).ModelNode.Tag.ToString()); Console.WriteLine("modelLink.OriginPort : " + modelLink.OriginPort); Console.WriteLine("graphicLink.OriginPortID.ToString() : " + graphicLink.OriginPortID.ToString()); Console.WriteLine("anchorTagToInt Key:Value pairs:"); foreach (string key in (origin.ModelBox.Tag as EditorNode).anchorTagToInt.Keys) { Console.WriteLine(" " + key + " : " + (origin.ModelBox.Tag as EditorNode).anchorTagToInt[key].ToString()); } Console.WriteLine(); Console.WriteLine(); arrow.DestAnchor = -1; } if ((modelLink.DestinationPort != null) && ((destination.ModelBox.Tag as EditorNode).anchorTagToInt.ContainsKey(modelLink.DestinationPort + graphicLink.DestinationPortID.ToString()))) arrow.DestAnchor = (destination.ModelBox.Tag as EditorNode).anchorTagToInt[modelLink.DestinationPort + graphicLink.DestinationPortID.ToString()]; else { Console.WriteLine("(destination.ModelBox.Tag as EditorNode).modelNode : " + (destination.ModelBox.Tag as EditorNode).ModelNode.Guid.ToString() + " : " + (destination.ModelBox.Tag as EditorNode).ModelNode.NodeClass.ToString() + " : " + (destination.ModelBox.Tag as EditorNode).ModelNode.Tag.ToString()); Console.WriteLine("modelLink.DestinationPort : " + modelLink.DestinationPort); Console.WriteLine("graphicLink.DestinationPortID.ToString() : " + graphicLink.DestinationPortID.ToString()); Console.WriteLine("anchorTagToInt Key:Value pairs:"); foreach (string key in (destination.ModelBox.Tag as EditorNode).anchorTagToInt.Keys) { Console.WriteLine(" " + key + " : " + (destination.ModelBox.Tag as EditorNode).anchorTagToInt[key].ToString()); } Console.WriteLine(); Console.WriteLine(); arrow.DestAnchor = -1; } String originTag = ""; if (origin != null) originTag = origin.Tag; String destinationTag = ""; if (destination != null) destinationTag = destination.Tag; String originPort = ""; if (modelLink.OriginPort != null) originPort = modelLink.OriginPort; String destinationPort = ""; if (modelLink.DestinationPort != null) destinationPort = modelLink.DestinationPort; arrow.ToolTip = "Tag:" + graphicLink.Tag + "\nSrc: " + originTag + ":" + originPort + "\nDst: " + destinationTag + ":" + destinationPort; arrow.ArrowHead = ArrowHead.Triangle; arrow.Style = ArrowStyle.Cascading; if (graphicLink.ControlPoints != null && graphicLink.ControlPoints.Count > 1) { SetControlPoints(arrow, graphicLink.ControlPoints); } if (graphicLink.ControlPoints[0].X == graphicLink.ControlPoints[1].X) { arrow.CascadeOrientation = Orientation.Auto; } else { arrow.CascadeOrientation = Orientation.Auto; } } EditorLink editorLink = new EditorLink(this, graphicLink, modelLink); editorLink.Arrow = arrow; editorLink.TextBox = textBox; editorLink.UpdateVisibility(); arrow.Tag = editorLink; textBox.Tag = editorLink; editorLinks.Add(editorLink.Guid, editorLink); NewElementSelection(); } }
public void SetArrow(State state, Arrow arrow, GraphicLink graphicLink, ModelLink modelLink) { EditorLink link = new EditorLink(state, graphicLink, modelLink); link.Arrow = arrow; editorLinks.Add(graphicLink.Guid, link); }
private void ModifyLink(ModelLink modelLink, GraphicLink graphicLink) { EditorLink editorLink = null; if (!editorLinks.TryGetValue(graphicLink.Guid, out editorLink)) { clientProtocol.LogMessage(out requestId, "ModifyLink: EditorLink not found in library for graphicLink \'" + graphicLink.Guid + ", " + graphicLink.Tag + "\'", SysCAD.Log.MessageType.Error); return; } Arrow arrow = editorLink.Arrow; Box text = editorLink.TextBox; if ((arrow != null) && (text != null)) { State.SetControlPoints(arrow, graphicLink.ControlPoints); text.BoundingRect = graphicLink.TagArea; text.RotationAngle = (float)graphicLink.TagAngle; } else { clientProtocol.LogMessage(out requestId, "ModifyLink: One of the objects missing for GraphicNode \'" + graphicLink.Guid + ", " + graphicLink.Tag + "\'", SysCAD.Log.MessageType.Error); return; } }
private void fcFlowChart_ArrowCreated(object sender, ArrowEventArgs e) { tempArrowKey++; String newLinkTag = "A_" + tempArrowKey.ToString(CultureInfo.InvariantCulture); e.Arrow.Text = newLinkTag; GraphicNode origin = null; GraphicNode destination = null; ModelNode modelOrigin = null; ModelNode modelDestination = null; String originPort = ""; String destinationPort = ""; Int16 originPortID = -1; Int16 destinationPortID = -1; List<SysCAD.Protocol.Point> controlPoints; SysCAD.Protocol.Rectangle textArea; if (newDestinationBox != null) { if (!((state.ClientProtocol.graphic.Nodes.TryGetValue((newDestinationBox.Tag as EditorNode).Guid, out destination)) && (state.ClientProtocol.model.Nodes.TryGetValue(destination.ModelGuid, out modelDestination)))) { state.ClientProtocol.LogMessage(out requestId, "Node missing for destination Box " + newDestinationBox.Tag, SysCAD.Log.MessageType.Error); return; } if (newDestinationAnchor != -1) { String fullAnchor = (newDestinationBox.Tag as EditorNode).anchorIntToTag[newDestinationAnchor]; String anchorName = fullAnchor.TrimEnd(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }); Int16 anchorID = Convert.ToInt16(fullAnchor.Substring(anchorName.Length), CultureInfo.InvariantCulture); destinationPort = anchorName; destinationPortID = anchorID; } } if (oldOriginBox != null) { if (!((state.ClientProtocol.graphic.Nodes.TryGetValue((newOriginBox.Tag as EditorNode).Guid, out origin)) && (state.ClientProtocol.model.Nodes.TryGetValue(origin.ModelGuid, out modelOrigin)))) { state.ClientProtocol.LogMessage(out requestId, "Node missing for origin Box " + newDestinationBox.Tag, SysCAD.Log.MessageType.Error); return; } if (oldOriginAnchor != -1) { String fullAnchor = (oldOriginBox.Tag as EditorNode).anchorIntToTag[oldOriginAnchor]; String anchorName = fullAnchor.TrimEnd(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }); Int16 anchorID = Convert.ToInt16(fullAnchor.Substring(anchorName.Length), CultureInfo.InvariantCulture); originPort = anchorName; originPortID = anchorID; } } controlPoints = State.GetControlPoints(e.Arrow.ControlPoints); textArea = new SysCAD.Protocol.Rectangle(0.0, 0.0, 0.0, 0.0); fcFlowChart.DeleteObject(e.Arrow); form1.ToolStripStatusLabel.Text = ""; //arrowBeingModified.CustomDraw = CustomDraw.None; arrowBeingModifiedSelectionHandle = -1; arrowBeingModified = null; originAnchorChosen = null; destinationAnchorChosen = null; ModelLink modelLink = new ModelLink(new Guid(), string.Empty, "Pipe-1", modelOrigin.Guid, modelDestination.Guid, originPort, destinationPort); GraphicLink graphicLink = new GraphicLink(new Guid(), modelLink.Guid, string.Empty, origin.Guid, originPortID, destination.Guid, destinationPortID, controlPoints, 1.0, textArea, 0.0, new SysCAD.Protocol.Font(), true); SysCAD.Protocol.Action action = new SysCAD.Protocol.Action(); action.Create.Add(modelLink); action.Create.Add(graphicLink); AddAction(action); }