public EditorNode(State state, GraphicNode graphicNode, ModelNode modelNode) { this.state = state; this.graphicNode = graphicNode; this.modelNode = modelNode; opacityTimer.Interval = 100; opacityTimer.Elapsed += new ElapsedEventHandler(opacityTimer_Elapsed); }
internal void CreateNode(ModelNode modelNode, GraphicNode graphicNode) { if (flowChart.InvokeRequired) { flowChart.BeginInvoke(new CreateNodeDelegate(CreateNode), new object[] { modelNode, graphicNode }); } else { creatingNode = true; // turn off flowchart events while we're mid-create. EditorNode editorNode = new EditorNode(this, graphicNode, modelNode); PureComponents.TreeView.Node treeViewNode = null; { treeViewNode = tvNavigation.AddNodeByPath(graphicNode.Path + graphicNode.Tag, graphicNode.Guid.ToString()); treeViewNode.AllowDrop = false; treeViewNode.Tag = editorNode; NewElementSelection(); } EditorArea editorArea = null; bool isVisible = false; if (treeViewNode.Parent != null) // if we're not root, make visibility same as parent. { if (treeViewNode.Parent.Tag is EditorArea) editorArea = treeViewNode.Parent.Tag as EditorArea; isVisible = treeViewNode.Parent.IsSelected; } ModelStencil modelStencil; GraphicStencil graphicStencil = GraphicStencil(graphicNode.Stencil); Box textBox = null, graphicBox = null, modelBox = null, hiddenBox = null; { SysCAD.Protocol.Rectangle textArea = graphicNode.TagArea; if (textArea.IsEmpty) // We haven't got a TagArea stored in the item yet. { if (graphicStencil != null) { textArea = new SysCAD.Protocol.Rectangle(graphicNode.X + graphicStencil.TagArea.X / graphicStencil.DefaultSize.Width * graphicNode.Width, graphicNode.Y + graphicStencil.TagArea.Y / graphicStencil.DefaultSize.Height * graphicNode.Height, graphicStencil.TagArea.Width / graphicStencil.DefaultSize.Width * graphicNode.Width, graphicStencil.TagArea.Height / graphicStencil.DefaultSize.Height * graphicNode.Height); } else { textArea = new SysCAD.Protocol.Rectangle(graphicNode.X, graphicNode.Y + 1.1F * graphicNode.Height, graphicNode.Width, graphicNode.Height / 2.0F); } } textBox = flowChart.CreateBox((float)textArea.X, (float)textArea.Y, (float)textArea.Width, (float)textArea.Height); textBox.RotationAngle = (float)graphicNode.TagAngle; textBox.FillColor = System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black); textBox.FrameColor = System.Drawing.Color.FromArgb(0, 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 = graphicNode.Tag; textBox.Tag = editorNode; editorNode.TextBox = textBox; // Don't set this yet, happens after every zoom because it needs to be scaled. //textBox.Font = graphicNode.TagFont.BaseFont; } if (graphicNode.Stencil != null) { graphicBox = flowChart.CreateBox((float)graphicNode.X, (float)graphicNode.Y, (float)graphicNode.Width, (float)graphicNode.Height); graphicBox.RotationAngle = (float)graphicNode.Angle; graphicBox.ToolTip = graphicNode.Tag + "\n\nClassID: " + "graphicNode.Model"; graphicBox.Style = BoxStyle.Shape; graphicBox.Tag = editorNode; editorNode.GraphicBox = graphicBox; if (GraphicStencil(graphicNode.Stencil) == null) // can't use graphicStencil because the above GraphicShape call will find a stencil even if the shape doesn't exist. { clientProtocol.LogMessage(out requestId, "GraphicStencil not found in library for stencil \'" + graphicNode.Stencil + "\'", SysCAD.Log.MessageType.Warning); } if (graphicStencil != null) { graphicBox.Shape = GetShapeTemplate(graphicStencil, graphicNode.MirrorX, graphicNode.MirrorY); // An attempt to deal with un-clickable non-model graphics... failed, will have to try something else. // perhaps catch the click and look underneath expecially for graphicboxes??? //if (graphicBox.Shape.Outline.Length == 0) //{ // ElementTemplate[] background = new ElementTemplate[4]; // background[0] = new LineTemplate( 0.0F, 0.0F, 0.0F, 100.0F); // background[1] = new LineTemplate( 0.0F, 100.0F, 100.0F, 100.0F); // background[2] = new LineTemplate(100.0F, 100.0F, 100.0F, 0.0F); // background[3] = new LineTemplate(100.0F, 0.0F, 0.0F, 0.0F); // graphicBox.Shape = new ShapeTemplate(background, graphicBox.Shape.Decorations, graphicBox.Shape.TagArea, FillMode.Alternate); // graphicBox.FillColor = System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black); // graphicBox.FrameColor = System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black); //} } else graphicBox.Shape = ShapeTemplate.FromId("Decision2"); if (graphicNode.FillColor.IsEmpty) graphicNode.FillColor = graphicBox.FillColor; else graphicBox.FillColor = graphicNode.FillColor; } creatingNode = false; // we want any events to happen for the last created piece. if (modelNode != null) { modelBox = flowChart.CreateBox((float)graphicNode.X, (float)graphicNode.Y, (float)graphicNode.Width, (float)graphicNode.Height); modelBox.RotationAngle = (float)graphicNode.Angle; modelBox.ToolTip = graphicNode.Tag + "\n\nClassID: " + "graphicNode.Model"; modelBox.Style = BoxStyle.Shape; modelBox.CustomDraw = CustomDraw.Additional; modelBox.Tag = editorNode; editorNode.ModelBox = modelBox; modelStencil = ModelStencil(modelNode.NodeClass); if (modelStencil == null) { clientProtocol.LogMessage(out requestId, "ModelStencil not found in library for shape \'" + modelNode.NodeClass + "\'", SysCAD.Log.MessageType.Error); } if (modelStencil != null) { modelBox.Shape = GetShapeTemplate(modelStencil, graphicNode.MirrorX, graphicNode.MirrorY); //RequestPortInfo test code. //{ // Int64 requestId2; // RequestGraphicPortInfo(out requestId2, graphicNode.Guid, ((Anchor)(modelStencil.Anchors[0])).Tag); //} } else modelBox.Shape = ShapeTemplate.FromId("Decision2"); modelBox.AnchorPattern = GetAnchorPattern(modelStencil, editorNode); modelBox.FillColor = System.Drawing.Color.FromArgb(220, 222, 184, 136); modelBox.FrameColor = System.Drawing.Color.FromArgb(255, 111, 92, 68); graphicBox.EnabledHandles = Handles.None; graphicBox.HandlesStyle = HandlesStyle.Invisible; if (modelBox.Shape.Outline.Length == 0) // we're going to need an invisible box to use for hit-testing. { hiddenBox = flowChart.CreateBox((float)graphicNode.X, (float)graphicNode.Y, (float)graphicNode.Width, (float)graphicNode.Height); hiddenBox.RotationAngle = (float)graphicNode.Angle; hiddenBox.ToolTip = modelNode.Tag + "\n\nClassID: " + "modelNode.Model"; hiddenBox.Style = BoxStyle.Shape; //BoxStyle.Ellipse; // not sure whether to go with ellipse or rectangle here (without corners, it'll get in the way less...) hiddenBox.Shape = GetShapeTemplate(ModelStencil("Tank-1"), graphicNode.MirrorX, graphicNode.MirrorY); hiddenBox.FillColor = System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black); hiddenBox.FrameColor = System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black); hiddenBox.ZBottom(); hiddenBox.Tag = editorNode; editorNode.HiddenBox = hiddenBox; graphicBox.AttachTo(hiddenBox, 0, 0, 100, 100); } } else { if ((graphicBox != null) && (graphicBox.Shape.Outline.Length == 0)) // we're going to need an invisible box to use for hit-testing. { hiddenBox = flowChart.CreateBox((float)graphicNode.X, (float)graphicNode.Y, (float)graphicNode.Width, (float)graphicNode.Height); hiddenBox.RotationAngle = (float)graphicNode.Angle; hiddenBox.ToolTip = graphicNode.Tag + "\n\nClassID: " + "graphicNode.Model"; hiddenBox.Style = BoxStyle.Shape; //BoxStyle.Ellipse; // not sure whether to go with ellipse or rectangle here (without corners, it'll get in the way less...) hiddenBox.Shape = GetShapeTemplate(ModelStencil("Tank-1"), graphicNode.MirrorX, graphicNode.MirrorY); hiddenBox.FillColor = System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black); hiddenBox.FrameColor = System.Drawing.Color.FromArgb(0, System.Drawing.Color.Black); hiddenBox.ZBottom(); hiddenBox.Tag = editorNode; editorNode.HiddenBox = hiddenBox; graphicBox.AttachTo(hiddenBox, 0, 0, 100, 100); } } if (modelBox != null) { textBox.AttachTo(modelBox, AttachToNode.BottomCenter); graphicBox.AttachTo(modelBox, 0, 0, 100, 100); if (editorArea != null) modelBox.AttachTo(editorArea.Box, AttachToNode.TopLeft); } else if (graphicBox != null) { textBox.AttachTo(graphicBox, AttachToNode.BottomCenter); if (hiddenBox != null) hiddenBox.AttachTo(graphicBox, 0, 0, 100, 100); if (editorArea != null) graphicBox.AttachTo(editorArea.Box, AttachToNode.TopLeft); } editorNode.Visible = isVisible; editorNodes.Add(editorNode.Guid, editorNode); } }
//internal void Initialize() //{ // BorderStyle = System.Windows.Forms.BorderStyle.None; // CommentsHeight = 70; // CommentsVisibility = true; // Dock = System.Windows.Forms.DockStyle.Fill; // Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World); // Location = new System.Drawing.Point(0, 0); // Margin = new System.Windows.Forms.Padding(2); //} internal void SetSelectedObject(GraphicNode graphicNode, ModelNode modelNode, State state) { Clear(); this.graphicNode = graphicNode; this.state = state; id = 0; itemGraphic = AppendRootCategory(id++, "Graphic"); //itemGraphicPath = AppendProperty(itemGraphic, id++, "Path", graphicNode, "Path", "", new System.ComponentModel.ReadOnlyAttribute(true)); itemGraphicBoungingRect = AppendProperty(itemGraphic, id++, "Bounding Rectangle", graphicNode, "BoundingRect", ""); //itemGraphicBoungingRectLeft = AppendProperty(itemGraphicBoungingRect, id++, "Left", graphicNode, "X", ""); //itemGraphicBoungingRectTop = AppendProperty(itemGraphicBoungingRect, id++, "Top", graphicNode, "Y", ""); //itemGraphicBoungingRectWidth = AppendProperty(itemGraphicBoungingRect, id++, "Width", graphicNode, "Width", ""); //itemGraphicBoungingRectHeight = AppendProperty(itemGraphicBoungingRect, id++, "Height", graphicNode, "Height", ""); ExpandProperty(itemGraphicBoungingRect, false); //itemGraphicAngle = AppendProperty(itemGraphic, id++, "Angle", graphicNode, "Angle", ""); AppendProperty(itemGraphic, id++, "Opacity", graphicNode, "Opacity", ""); itemGraphicShape = AppendProperty(itemGraphic, id++, "Stencil", graphicNode, "Stencil", ""); itemGraphicShape.Property.Feel = GetRegisteredFeel(PropertyGrid.FeelButton); itemGraphicTag = AppendSubCategory(itemGraphic, id++, "Tag"); itemGraphicTagBoungingRect = AppendProperty(itemGraphicTag, id++, "Bounding Rectangle", graphicNode, "TagArea", ""); //itemGraphicBoungingRectLeft = AppendProperty(itemGraphicTagBoungingRect, id++, "Left", graphicNode, "TagAreaX", ""); //itemGraphicBoungingRectTop = AppendProperty(itemGraphicTagBoungingRect, id++, "Top", graphicNode, "TagAreaY", ""); //itemGraphicBoungingRectWidth = AppendProperty(itemGraphicTagBoungingRect, id++, "Width", graphicNode, "TagAreaWidth", ""); //itemGraphicBoungingRectHeight = AppendProperty(itemGraphicTagBoungingRect, id++, "Height", graphicNode, "TagAreaHeight", ""); ExpandProperty(itemGraphicTagBoungingRect, false); //itemGraphicAngle = AppendProperty(itemGraphicTag, id++, "Angle", graphicNode, "TagAngle", ""); AppendProperty(itemGraphicTag, id++, "Visible", graphicNode, "TagVisible", ""); ExpandProperty(itemGraphicTag, false); itemGraphicFill = AppendSubCategory(itemGraphic, id++, "Fill"); //itemGraphicFillColor = AppendProperty(itemGraphicFill, id++, "Color", graphicNode, "FillColor", ""); //itemGraphicFillMode = AppendProperty(itemGraphicFill, id++, "Mode", graphicNode, "FillMode", ""); ExpandProperty(itemGraphicFill, false); itemGraphicMirror = AppendSubCategory(itemGraphic, id++, "Mirroring"); itemGraphicMirrorX = AppendProperty(itemGraphicMirror, id++, "X", graphicNode, "MirrorX", ""); itemGraphicMirrorX.Property.Feel = GetRegisteredFeel(FeelCheckbox); itemGraphicMirrorX.Property.Value.Look = new PropertyCheckboxLook(); itemGraphicMirrorY = AppendProperty(itemGraphicMirror, id++, "Y", graphicNode, "MirrorY", ""); itemGraphicMirrorY.Property.Feel = GetRegisteredFeel(FeelCheckbox); itemGraphicMirrorY.Property.Value.Look = new PropertyCheckboxLook(); ExpandProperty(itemGraphicMirror, false); itemModel = AppendRootCategory(id++, "Model"); //itemModelGuid = AppendProperty(itemModel, id++, "Guid", modelNode, "Guid", "", new System.ComponentModel.ReadOnlyAttribute(true)); //itemModelClass = AppendProperty(itemModel, id++, "Class", modelNode, "NodeClass", "", new System.ComponentModel.ReadOnlyAttribute(true)); //itemModelTag = AppendProperty(itemModel, id++, "Tag", modelNode, "Tag", ""); }
private void ModifyNode(ModelNode modelNode, GraphicNode graphicNode) { EditorNode editorNode = null; if (!editorNodes.TryGetValue(graphicNode.Guid, out editorNode)) { clientProtocol.LogMessage(out requestId, "ModifyNode: EditorNode not found in library for GraphicNode \'" + graphicNode.Guid + ", " + graphicNode.Tag + "\'", SysCAD.Log.MessageType.Error); return; } editorNode.GraphicNode = graphicNode; editorNode.ModelNode = modelNode; Box graphicBox = editorNode.GraphicBox; Box modelBox = editorNode.ModelBox; Box textBox = editorNode.TextBox; Box hiddenBox = editorNode.HiddenBox; if (graphicBox != null) { graphicBox.BoundingRect = graphicNode.BoundingRect; graphicBox.RotationAngle = (float)graphicNode.Angle; graphicBox.FillColor = graphicNode.FillColor; { GraphicStencil graphicStencil = GraphicStencil(graphicNode.Stencil); if (graphicStencil != null) graphicBox.Shape = State.GetShapeTemplate(graphicStencil, graphicNode.MirrorX, graphicNode.MirrorY); else graphicBox.Shape = ShapeTemplate.FromId("Decision2"); } } if (modelBox != null) { modelBox.BoundingRect = graphicNode.BoundingRect; modelBox.RotationAngle = (float)graphicNode.Angle; ModelStencil modelStencil = ModelStencil(modelNode.NodeClass); if (modelStencil != null) modelBox.Shape = State.GetShapeTemplate(modelStencil, graphicNode.MirrorX, graphicNode.MirrorY); else modelBox.Shape = ShapeTemplate.FromId("Decision2"); modelBox.AnchorPattern = GetAnchorPattern(modelStencil, editorNode); } if (textBox != null) { textBox.BoundingRect = graphicNode.TagArea; textBox.RotationAngle = (float)graphicNode.TagAngle; // We're only rotating the boundingbox, not the action text. } if (hiddenBox != null) { hiddenBox.BoundingRect = graphicNode.BoundingRect; hiddenBox.RotationAngle = (float)graphicNode.Angle; } foreach (Arrow arrow in editorNode.IncomingArrows) { ModifyLink((arrow.Tag as EditorLink).Guid); } foreach (Arrow arrow in editorNode.OutgoingArrows) { ModifyLink((arrow.Tag as EditorLink).Guid); } editorNode.UpdateVisibility(); //if ( //else //{ // clientProtocol.LogMessage(out requestId, "ModifyNode: One of the *boxes missing for GraphicNode \'" + graphicNode.Guid + ", " + graphicNode.Tag + "\'", SysCAD.Log.MessageType.Error); // return; //} }