internal VNode(Node node, FrameworkElement frameworkElementOfNodeForLabelOfLabel, Func <Edge, VEdge> funcFromDrawingEdgeToVEdge, Func <double> pathStrokeThicknessFunc) { PathStrokeThicknessFunc = pathStrokeThicknessFunc; Node = node; FrameworkElementOfNodeForLabel = frameworkElementOfNodeForLabelOfLabel; _funcFromDrawingEdgeToVEdge = funcFromDrawingEdgeToVEdge; CreateNodeBoundaryPath(); if (FrameworkElementOfNodeForLabel != null) { FrameworkElementOfNodeForLabel.Tag = this; //get a backpointer to the VNode Common.PositionFrameworkElement(FrameworkElementOfNodeForLabel, node.GeometryNode.Center, 1); Panel.SetZIndex(FrameworkElementOfNodeForLabel, Panel.GetZIndex(BoundaryPath) + 1); } SetupSubgraphDrawing(); Node.Attr.VisualsChanged += (a, b) => Invalidate(); Node.IsVisibleChanged += obj => { foreach (var frameworkElement in FrameworkElements) { frameworkElement.Opacity = Node.IsVisible ? 1 : 0; } }; }
void SetupCollapseSymbol() { var collapseBorderSize = GetCollapseBorderSymbolSize(); Debug.Assert(collapseBorderSize > 0); _collapseButtonBorder = new Border { Background = Common.BrushFromMsaglColor(_subgraph.CollapseButtonColorInactive), Width = collapseBorderSize, Height = collapseBorderSize, CornerRadius = new CornerRadius(collapseBorderSize / 2) }; Panel.SetZIndex(_collapseButtonBorder, Panel.GetZIndex(BoundaryPath) + 1); var collapseButtonCenter = GetCollapseButtonCenter(collapseBorderSize); Common.PositionFrameworkElement(_collapseButtonBorder, collapseButtonCenter, 1); double w = collapseBorderSize * 0.4; _collapseSymbolPath = new Path { Data = CreateCollapseSymbolPath(collapseButtonCenter + new Point(0, -w / 2), w), Stroke = _collapseSymbolPathInactive, StrokeThickness = 1 }; Panel.SetZIndex(_collapseSymbolPath, Panel.GetZIndex(_collapseButtonBorder) + 1); _topMarginRect.PointerPressed += (s, e) => TopMarginRectMouseLeftButtonDown(e); }
internal void CreateNodeBoundaryPath() { if (FrameworkElementOfNodeForLabel != null) { var center = Node.GeometryNode.Center; var margin = 2 * Node.Attr.LabelMargin; var bc = NodeBoundaryCurves.GetNodeBoundaryCurve(Node, FrameworkElementOfNodeForLabel .Width + margin, FrameworkElementOfNodeForLabel .Height + margin); bc.Translate(center); } BoundaryPath = new Path { Data = CreatePathFromNodeBoundary(), Tag = this }; Panel.SetZIndex(BoundaryPath, ZIndex); SetFillAndStroke(); if (Node.Label != null) { ToolTipService.SetToolTip(BoundaryPath, Node.LabelText); if (FrameworkElementOfNodeForLabel != null) { ToolTipService.SetToolTip(FrameworkElementOfNodeForLabel, Node.LabelText); } } }
void SetZIndexAndMouseInteractionsForTopMarginRect() { _topMarginRect.PointerEntered += (a, b) => { _collapseButtonBorder.Background = Common.BrushFromMsaglColor(_subgraph.CollapseButtonColorActive); _collapseSymbolPath.Stroke = new SolidColorBrush(Colors.Black); }; _topMarginRect.PointerReleased += (a, b) => { _collapseButtonBorder.Background = Common.BrushFromMsaglColor(_subgraph.CollapseButtonColorInactive); _collapseSymbolPath.Stroke = new SolidColorBrush(Colors.Silver); }; Panel.SetZIndex(_topMarginRect, int.MaxValue); }