示例#1
0
        private Rectangle CreateIcon(Point origin, out Visual visual)
        {
            if (_category != null)
            {
                ImageSource src = NodeCategories.GetIcon(_category);
                if (src != null)
                {
                    DrawingVisual icon = new DrawingVisual();
                    icon.CacheMode = new BitmapCache(1);
                    DrawingContext context = icon.RenderOpen();
                    context.DrawImage(src, new Rect(origin.X, origin.Y, _fontSize, _fontSize));
                    context.Close();

                    visual = icon;
                    return(new Rectangle(origin.X, origin.Y, _fontSize, _fontSize));
                }
            }
            visual = null;
            return(new Rectangle());
        }
示例#2
0
        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;
        }