public XNode(Node node, string category = null) { Node = node; _category = category; Border b = new Border(); double size = node.Label.Text.Length * 9; b.Width = size + 12; b.Height = size * 2 / 3 + 4; _visualObject = b; Brush strokeBrush = CommonX.BrushFromMsaglColor(Node.Attr.Color); if (category != null) { Brush brush = Categories.GetBrush(_category); if (brush != null) { strokeBrush = brush; } } BoundaryPath = new Path { //Data = CreatePathFromNodeBoundary(), Stroke = strokeBrush, Fill = CommonX.BrushFromMsaglColor(Node.Attr.FillColor), StrokeThickness = Node.Attr.LineWidth }; Node.Attr.LineWidthHasChanged += AttrLineWidthHasChanged; //Node.Attr.GeometryNode.LayoutChangeEvent += GeometryNodeBeforeLayoutChangeEvent; }
void CreateBackgroundRectangle(GeometryGraph geomGraph) { rectToFillGraphBackground = new System.Windows.Shapes.Rectangle(); SetBackgroundRectanglePositionAndSize(geomGraph); rectToFillGraphBackground.Fill = CommonX.BrushFromMsaglColor(drawingGraph.Attr.BackgroundColor); Panel.SetZIndex(rectToFillGraphBackground, -1); graphCanvas.Children.Add(rectToFillGraphBackground); }
public XEdge(Edge edge, string category = null) { Edge = edge; _category = category; _strokePathThickness = edge.Attr.LineWidth; if (edge.Label != null) { XLabel label = new XLabel(edge); this.XLabel = label; _visualObject = label.VisualObject; } Path = new Path { Stroke = CommonX.BrushFromMsaglColor(edge.Attr.Color), StrokeThickness = _strokePathThickness, StrokeDashArray = EdgeCategories.GetDashArray(category), Tag = this }; }
public XNode(Node node, GraphNode gnode = null) { Node = node; _vsGraphNodeInfo = gnode; _visualObject = new LevelOfDetailsContainer(); Brush strokeBrush = CommonX.BrushFromMsaglColor(Node.Attr.Color); _fill = CommonX.BrushFromMsaglColor(Node.Attr.FillColor); if (gnode != null) { if (gnode.Categories.Count() > 0) { _category = gnode.Categories.ElementAt(0).ToString().Replace("CodeSchema_", ""); _fill = NodeCategories.GetFill(_category); Brush brush = NodeCategories.GetStroke(_category); if (brush != null) { strokeBrush = brush; } } } BoundaryPath = new Path { //Data = CreatePathFromNodeBoundary(), Stroke = strokeBrush, Fill = _fill, StrokeThickness = Node.Attr.LineWidth, Tag = this }; BoundaryCurveIsDirty = true; Node.Attr.VisualsChanged += AttrLineWidthHasChanged; //Node.Attr.GeometryNode.LayoutChangeEvent += GeometryNodeBeforeLayoutChangeEvent; }
public void Invalidate(double scale = 1) { if (BoundaryCurveIsDirty) { BoundaryPath.Data = CreatePathFromNodeBoundary(); BoundaryCurveIsDirty = false; } PositionPath(Node.BoundingBox); var node_scale = Scale(); if (_visualObject != null) { if (node_scale < 0.5) { if (_visualObject.Visibility != Visibility.Hidden) { _visualObject.Visibility = Visibility.Hidden; BoundaryPath.Fill = BoundaryPath.Stroke; } } else { if (_visualObject.Visibility != Visibility.Visible) { _visualObject.Visibility = Visibility.Visible; BoundaryPath.Fill = CommonX.BrushFromMsaglColor(Node.Attr.FillColor); } if (_vTitle == null) { Grid g = new Grid(); ((Border)_visualObject).Child = g; g.Margin = new Thickness(4); g.VerticalAlignment = VerticalAlignment.Center; g.HorizontalAlignment = HorizontalAlignment.Center; g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); _vTitle = new TextBlock { Text = Node.Label.Text, Name = "Title" }; _vTitle.VerticalAlignment = VerticalAlignment.Center; g.Children.Add(_vTitle); Grid.SetColumn(_vTitle, 1); if (_category != null) { ImageSource src = Categories.GetIcon(_category); if (src != null) { _vIcon = new Image { Source = src }; _vIcon.VerticalAlignment = VerticalAlignment.Center; RenderOptions.SetBitmapScalingMode(_vIcon, BitmapScalingMode.HighQuality); g.Children.Add(_vIcon); } } } double fontSize = Math.Min(12 / (node_scale * scale), 12); _vTitle.FontSize = fontSize; if (_vIcon != null) { _vIcon.Width = fontSize * 2; } CommonX.PositionElement(_visualObject, Node.BoundingBox.Center, node_scale); } } }