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); } }
static public AnchorPattern GetAnchorPattern(ModelStencil modelStencil, EditorNode item) { AnchorPointCollection anchorPointCollection = new AnchorPointCollection(); if ((modelStencil != null) && (modelStencil.Anchors != null)) { item.anchorIntToTag.Clear(); item.anchorTagToInt.Clear(); int anchorInt = 0; foreach (Anchor anchor in modelStencil.Anchors) { int anchorPtInt = 0; foreach (SysCAD.Protocol.Point point in anchor.Positions) { Double x = point.X; if (item.MirrorX) x = 100.0 - x; Double y = point.Y; if (item.MirrorY) y = 100.0 - y; MarkStyle markStyle = MarkStyle.Circle; // Use circle in any other case. switch (anchor.Look) { case 0: markStyle = MarkStyle.Circle; break; case 1: markStyle = MarkStyle.Cross; break; case 2: markStyle = MarkStyle.Rectangle; break; case 3: markStyle = MarkStyle.X; break; } AnchorPoint anchorPoint = new AnchorPoint((short)x, (short)y, true, true, markStyle, System.Drawing.Color.Green); anchorPoint.Tag = anchor; anchorPointCollection.Add(anchorPoint); item.anchorIntToTag.Add(anchorInt, anchor.Tag + anchorPtInt.ToString()); item.anchorTagToInt.Add(anchor.Tag + anchorPtInt.ToString(), anchorInt); anchorInt++; anchorPtInt++; } } } return new AnchorPattern(anchorPointCollection); }
private void SetHoverMembers(MouseEventArgs e) { PointF ptF = fcFlowChart.ClientToDoc(new System.Drawing.Point(e.X, e.Y)); Arrow hoverArrow = fcFlowChart.GetArrowAt(ptF, 2.0F); Box hoverBox = fcFlowChart.GetBoxAt(ptF, 2.0F); hoverLink = null; hoverNode = null; hoverArea = null; if ((hoverArrow != null) && (hoverArrow.Tag is EditorLink)) hoverLink = hoverArrow.Tag as EditorLink; if ((hoverBox != null) && (hoverBox.Tag is EditorNode)) hoverNode = hoverBox.Tag as EditorNode; else { foreach (EditorNode node in state.Nodes) { if (node.Locked) { if (((node.ModelBox != null) && (node.ModelBox.BoundingRect.Contains(ptF))) || ((node.GraphicBox != null) && (node.GraphicBox.BoundingRect.Contains(ptF))) || ((node.TextBox != null) && (node.TextBox.BoundingRect.Contains(ptF))) || ((node.HiddenBox != null) && (node.HiddenBox.BoundingRect.Contains(ptF)))) { hoverNode = node; return; } } } } if ((hoverBox != null) && (hoverBox.Tag is EditorArea)) hoverArea = (hoverBox.Tag as EditorArea); else { foreach (EditorArea area in state.Areas) { if (area.Box.BoundingRect.Contains(ptF)) { hoverArea = area; return; } } } }
private void fcFlowChart_Click(object sender, EventArgs e) { MouseEventArgs me = e as MouseEventArgs; SetHoverMembers(me); form1.ModeModify(); if (me.Button == MouseButtons.Right) { ContextMenu theMenu = new ContextMenu(); if (hoverNode != null) { contextNode = hoverNode; if (hoverNode.Locked) theMenu.MenuItems.Add("Unlock", new EventHandler(UnlockNode)); else { MenuItem arrangeMenu = theMenu.MenuItems.Add("Align Nodes..."); arrangeMenu.MenuItems.Add("Top", new EventHandler(AlignTop)); arrangeMenu.MenuItems.Add("Bottom", new EventHandler(RouteLinks)); arrangeMenu.MenuItems.Add("Left", new EventHandler(RouteLinks)); arrangeMenu.MenuItems.Add("Right", new EventHandler(RouteLinks)); arrangeMenu.MenuItems.Add("Center (H)", new EventHandler(RouteLinks)); arrangeMenu.MenuItems.Add("Center (V)", new EventHandler(RouteLinks)); theMenu.MenuItems.Add("-"); theMenu.MenuItems.Add("Route Links", new EventHandler(RouteLinks)); theMenu.MenuItems.Add("Raise to Top", new EventHandler(RaiseNodeToTop)); theMenu.MenuItems.Add("Send to Bottom", new EventHandler(SendNodeToBottom)); theMenu.MenuItems.Add("-"); theMenu.MenuItems.Add("Lock", new EventHandler(LockNode)); } form1.ModeModify(); } else if (hoverArea != null) { contextArea = hoverArea; if (hoverArea.Locked) theMenu.MenuItems.Add("Unlock", new EventHandler(UnlockArea)); else { theMenu.MenuItems.Add("Raise to Top", new EventHandler(RaiseAreaToTop)); theMenu.MenuItems.Add("Send to Bottom", new EventHandler(SendAreaToBottom)); theMenu.MenuItems.Add("-"); theMenu.MenuItems.Add("Lock", new EventHandler(LockArea)); } form1.ModeModify(); } else if (hoverLink != null) { theMenu.MenuItems.Add("Route Link", new EventHandler(RouteLink)); theMenu.MenuItems.Add("Disconnect Origin", new EventHandler(DisconnectOrigin)); theMenu.MenuItems.Add("Disconnect Destination", new EventHandler(DisconnectDestination)); form1.ModeModify(); } theMenu.MenuItems.Add("-"); theMenu.MenuItems.Add("Layout Flowchart (!!Broken in an interesting way in latest release!!)", new EventHandler(LayoutFlowchart)); theMenu.MenuItems.Add("Insert Symbol", new EventHandler(InsertSymbol)); theMenu.Show(fcFlowChart, me.Location); } }
private void fcFlowChart_MouseMove(object sender, MouseEventArgs e) { SetHoverMembers(e); EditorNode editorNode = null; form1.fcHoverview.ClearAll(); form1.hoverviewIncomingLinks.Clear(); form1.hoverviewOutgoingLinks.Clear(); // Update Hoverview. if (hoverNode != null) { editorNode = hoverNode; form1.hoverviewIncomingLinks.Clear(); form1.hoverviewOutgoingLinks.Clear(); if (hoverNode.ModelBox != null) { foreach (Arrow arrow in hoverNode.ModelBox.IncomingArrows) form1.hoverviewIncomingLinks.Add(arrow.Tag as EditorLink); foreach (Arrow arrow in hoverNode.ModelBox.OutgoingArrows) form1.hoverviewOutgoingLinks.Add(arrow.Tag as EditorLink); } } else if (fcFlowChart.Selection.Boxes.Count == 1) { editorNode = fcFlowChart.Selection.Boxes[0].Tag as EditorNode; form1.hoverviewIncomingLinks.Clear(); form1.hoverviewOutgoingLinks.Clear(); foreach (Arrow arrow in fcFlowChart.Selection.Boxes[0].IncomingArrows) form1.hoverviewIncomingLinks.Add(arrow.Tag as EditorLink); foreach (Arrow arrow in fcFlowChart.Selection.Boxes[0].OutgoingArrows) form1.hoverviewOutgoingLinks.Add(arrow.Tag as EditorLink); } if (editorNode != null) { ModelNode modelNode = editorNode.ModelNode; if (modelNode != null) { ModelStencil modelStencil = State.ModelStencil(modelNode.NodeClass); if (modelStencil != null) { float scale; if (form1.fcHoverview.Size.Width / modelStencil.DefaultSize.Width > form1.fcHoverview.Size.Height / modelStencil.DefaultSize.Height) { scale = (float)(form1.fcHoverview.Size.Height / modelStencil.DefaultSize.Height) / 5.0F; } else { scale = (float)(form1.fcHoverview.Size.Width / modelStencil.DefaultSize.Width) / 5.0F; } //float scale = 100.0F / (float)Math.Sqrt((float)graphicStencil.defaultSize.Width * (float)graphicStencil.default5Size.Width + (float)graphicStencil.defaultSize.Height * (float)graphicStencil.defaultSize.Height); form1.fcHoverview.AntiAlias = SmoothingMode.AntiAlias; form1.hoverviewBox = form1.fcHoverview.CreateBox(0.0F, 0.0F, (float)modelStencil.DefaultSize.Width * scale, (float)modelStencil.DefaultSize.Height * scale); form1.hoverviewBox.FillColor = System.Drawing.Color.FromArgb(220, 222, 184, 136); form1.hoverviewBox.FrameColor = System.Drawing.Color.FromArgb(255, 111, 92, 68); //Table table = form1.fcHoverview.CreateTable(0.0F, 10.0F + (float)graphicStencil.defaultSize.Height * scale, 80.0F, 30.0F); //table.Caption = "Ports"; //table.ColumnCount = 2; //int i = table.AddRow(); if (modelStencil != null) form1.hoverviewBox.Shape = State.GetShapeTemplate(modelStencil, false, false); else form1.hoverviewBox.Shape = ShapeTemplate.FromId("Decision2"); form1.hoverviewBox.AnchorPattern = State.GetAnchorPattern(modelStencil, editorNode); form1.hoverviewBox.Tag = editorNode; form1.hoverviewBox.Visible = true; form1.hoverviewBox.Style = BoxStyle.Shape; foreach (EditorLink link in form1.hoverviewIncomingLinks) { Arrow arrow = state.Arrow(link.Guid); int portId = 0; (editorNode.ModelBox.Tag as EditorNode).anchorTagToInt.TryGetValue(link.ModelLink.DestinationPort + link.GraphicLink.DestinationPortID.ToString(CultureInfo.InvariantCulture), out portId); if (form1.hoverviewBox.AnchorPattern.Points.Count > portId) { PointF anchorPointPos = FrmFlowChart.GetRelativeAnchorPosition(new SysCAD.Protocol.Rectangle(form1.hoverviewBox.BoundingRect), form1.hoverviewBox.AnchorPattern.Points[portId].X, form1.hoverviewBox.AnchorPattern.Points[portId].Y, form1.hoverviewBox.RotationAngle).ToPointF(); PointF pt1 = Flowchart2Hoverbox(link.Arrow.Destination.BoundingRect, form1.hoverviewBox.BoundingRect, arrow.ControlPoints[arrow.ControlPoints.Count - 2]); PointF pt2 = Flowchart2Hoverbox(link.Arrow.Destination.BoundingRect, form1.hoverviewBox.BoundingRect, arrow.ControlPoints[arrow.ControlPoints.Count - 1]); ///Box box1 = form1.fcHoverview.CreateBox(pt1.X*2.0F, pt1.Y, 0.001F, 0.01F); //box1.Visible = false; //box1.FillColor = System.Drawing.Color.FromArgb(20, 222, 184, 136); //box1.FrameColor = System.Drawing.Color.FromArgb(25, 111, 92, 68); //Box box2 = form1.fcHoverview.CreateBox(pt2.X, pt2.Y, 0.001F, 0.01F); //box2.Visible = false; Arrow arrow1 = form1.fcHoverview.CreateArrow(pt1, pt2); Arrow arrow2 = form1.fcHoverview.CreateArrow(pt2, anchorPointPos); arrow1.ArrowHead = ArrowHead.Triangle; arrow1.ArrowHeadSize = 2.0F; arrow1.FillColor = Color.Black; arrow2.PenColor = Color.Blue; } form1.fcHoverview.Selection.Clear(); } foreach (EditorLink link in form1.hoverviewOutgoingLinks) { Arrow arrow = state.Arrow(link.Guid); int portId = 0; (editorNode.ModelBox.Tag as EditorNode).anchorTagToInt.TryGetValue(link.ModelLink.OriginPort + link.GraphicLink.OriginPortID.ToString(CultureInfo.InvariantCulture), out portId); if (form1.hoverviewBox.AnchorPattern.Points.Count > portId) { PointF anchorPointPos = FrmFlowChart.GetRelativeAnchorPosition(new SysCAD.Protocol.Rectangle(form1.hoverviewBox.BoundingRect), form1.hoverviewBox.AnchorPattern.Points[portId].X, form1.hoverviewBox.AnchorPattern.Points[portId].Y, form1.hoverviewBox.RotationAngle).ToPointF(); PointF pt1 = Flowchart2Hoverbox(link.Arrow.Origin.BoundingRect, form1.hoverviewBox.BoundingRect, arrow.ControlPoints[1]); PointF pt2 = Flowchart2Hoverbox(link.Arrow.Origin.BoundingRect, form1.hoverviewBox.BoundingRect, arrow.ControlPoints[0]); ///Box box1 = form1.fcHoverview.CreateBox(pt1.X*2.0F, pt1.Y, 0.001F, 0.01F); //box1.Visible = false; //box1.FillColor = System.Drawing.Color.FromArgb(20, 222, 184, 136); //box1.FrameColor = System.Drawing.Color.FromArgb(25, 111, 92, 68); //Box box2 = form1.fcHoverview.CreateBox(pt2.X, pt2.Y, 0.001F, 0.01F); //box2.Visible = false; Arrow arrow1 = form1.fcHoverview.CreateArrow(pt2, pt1); Arrow arrow2 = form1.fcHoverview.CreateArrow(pt2, anchorPointPos); arrow1.ArrowHead = ArrowHead.Triangle; arrow1.ArrowHeadSize = 2.0F; arrow1.FillColor = Color.Black; arrow2.PenColor = Color.Blue; } form1.fcHoverview.Selection.Clear(); } RectangleF zoomRect = form1.hoverviewBox.BoundingRect; zoomRect.Inflate(form1.hoverviewBox.BoundingRect.Width * 0.4F, form1.hoverviewBox.BoundingRect.Height * 0.4F); form1.fcHoverview.ZoomToRect(zoomRect); } } } if ((hoverNode != null) && (hoverNode.ModelBox != null) && (hoverNode.ModelBox.AnchorPattern != null)) { int closestI = 0; Double closestDistance = Double.MaxValue; for (int i = 0; i < hoverNode.ModelBox.AnchorPattern.Points.Count; i++) { if (hoverNode.ModelBox.AnchorPattern.Points[i].AllowOutgoing) { SysCAD.Protocol.Point anchorPointPos = GetRelativeAnchorPosition(new SysCAD.Protocol.Rectangle(hoverNode.ModelBox.BoundingRect), hoverNode.ModelBox.AnchorPattern.Points[i].X, hoverNode.ModelBox.AnchorPattern.Points[i].Y, hoverNode.ModelBox.RotationAngle); Double thisDistance = Distance(new SysCAD.Protocol.Point(fcFlowChart.ClientToDoc(new System.Drawing.Point(e.X, e.Y))), anchorPointPos); if (thisDistance < closestDistance) { closestDistance = thisDistance; closestI = i; } } } String hoverTag = hoverNode.Tag; int hoverAnchor = closestI; String anchorString; hoverNode.anchorIntToTag.TryGetValue(hoverAnchor, out anchorString); if (anchorString != null) { form1.ToolStripStatusLabel.Text = "Item: " + hoverTag + " : " + " Port: " + anchorString.TrimEnd(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }); } } if (oldHoverLink != null) if (oldHoverLink != hoverLink) // we've moved on, un-hover the old one. oldHoverLink.Hovered = false; if (oldHoverNode != null) // deal with old itemBox. if (oldHoverNode != hoverNode) // we've moved on, un-hover the old one. oldHoverNode.Hovered = false; if (hoverLink != null) hoverLink.Hovered = true; if (hoverNode != null) hoverNode.Hovered = true; oldHoverLink = hoverLink; oldHoverNode = hoverNode; }