/// <summary>
 /// Initializes the styles to use for the graph.
 /// </summary>
 private void InitializeStyles()
 {
     defaultNodeStyle = new ShinyPlateNodeStyle {
         Brush = Brushes.DarkOrange
     };
     sourceNodeStyle = new ShinyPlateNodeStyle {
         Brush = Brushes.LimeGreen
     };
     targetNodeStyle = new ShinyPlateNodeStyle {
         Brush = Brushes.OrangeRed
     };
     sourceAndTargetNodeStyle = new ShinyPlateNodeStyle
     {
         Brush = new LinearGradientBrush
         {
             GradientStops = new GradientStopCollection
             {
                 new GradientStop {
                     Color = Colors.Green, Offset = 0.49
                 },
                 new GradientStop {
                     Color = Colors.Red, Offset = 0.51
                 }
             },
             SpreadMethod = GradientSpreadMethod.Pad,
         }
     };
     defaultEdgeStyle = new PolylineEdgeStyle {
         TargetArrow = directed ? Arrows.Default : Arrows.None
     };
     pathEdgeStyle = new PolylineEdgeStyle {
         Pen = new Pen(Brushes.Red, 4.0f), TargetArrow = directed ? Arrows.Default : Arrows.None
     };
 }
Esempio n. 2
0
        private INode CreateNode(PointD location, INodeStyle nodeStyle, string label)
        {
            var node = Graph.CreateNode(location, nodeStyle);

            Graph.AddLabel(node, label);
            return(node);
        }
            /// <inheritdoc/>
            public IHitTestable GetHitTestable(INode item, INodeStyle style)
            {
                var geometry = shapeNodeStyle.Renderer.GetShapeGeometry(item, shapeNodeStyle);
                var outline  = geometry.GetOutline();

                return(HitTestables.Create((context, location) => outline.PathContains(location, context.HitTestRadius)));
            }
        /// <summary>
        /// Called by the various node creation callbacks to create a node in the resulting graph view
        /// that corresponds to the provided <paramref name="layoutNode"/>.
        /// </summary>
        /// <remarks>
        /// If a model node is provided, the ports of the original node will be copied to the created view node.
        /// Also, a clone of the original node style will be used as the style of the created node.
        /// </remarks>
        /// <param name="pageLayoutGraph">The layout graph representing the current page</param>
        /// <param name="pageView">The <see cref="IGraph"/> that is built to show the multi-page layout in a graph canvas</param>
        /// <param name="layoutNode">The node of the layout graph that should be copied</param>
        /// <param name="modelNode">The node of the original input graph that corresponds to the <paramref name="layoutNode"/> (may be <see langword="null"/>)</param>
        /// <param name="isReferenceNode"></param>
        /// <param name="nodeDefaults"></param>
        /// <returns>the created node</returns>
        /// <seealso cref="CreateConnectorNode"/>
        /// <seealso cref="CreateNormalNode"/>
        /// <seealso cref="CreateGroupNode"/>
        /// <seealso cref="CreateProxyNode"/>
        /// <seealso cref="CreateProxyReferenceNode"/>
        protected INode CreateNodeCore(LayoutGraph pageLayoutGraph, IGraph pageView, Node layoutNode, INode modelNode, bool isReferenceNode, INodeDefaults nodeDefaults)
        {
            // get the layout from the layout graph
            INodeLayout nodeLayout = pageLayoutGraph.GetLayout(layoutNode);
            // get the style from the node defaults or the model node (or the default style if none is provided)
            INodeStyle style = (INodeStyle)(nodeDefaults.Style != NullNodeStyle
                                         ? nodeDefaults.GetStyleInstance()
                                         : (modelNode != null
                                              ? modelNode.Style.Clone()
                                              : pageView.NodeDefaults.Style.Clone()));
            var tag = modelNode != null ? modelNode.Tag : null;
            // create the copied node
            INode viewNode = pageView.CreateNode(new RectD(nodeLayout.X, nodeLayout.Y, nodeLayout.Width, nodeLayout.Height), style, tag);

            // copy the ports of the model node
            if (modelNode != null)
            {
                CopyPorts(pageView, layoutNode, viewNode, modelNode);
            }

            viewToLayoutNode[viewNode] = layoutNode;
            IMapper <INode, NodeData> referencingMapper = pageView.MapperRegistry.GetMapper <INode, NodeData>(MapperKeyNodeData);
            NodeData data = new NodeData {
                IsReferenceNode = isReferenceNode
            };

            referencingMapper[viewNode] = data;

            return(viewNode);
        }
 public void SetNodeStyle(DoubleRange range, INodeStyle style)
 {
     nodeStyles[range] = style;
     if (maxValue == null || range.Max > maxValue.Max)
     {
         maxValue = range;
     }
 }
 public GrowShrinkButtonNodeStyleDecorator(INodeStyle wrappedStyle)
 {
     if (wrappedStyle == null)
     {
         throw new ArgumentNullException("wrappedStyle");
     }
     WrappedStyle = wrappedStyle;
 }
        protected override PointD?GetIntersection(INode node, PointD inner, PointD outer)
        {
            INodeStyle maxDetailStyle = GetMaxDetailNodeStyle();

            if (maxDetailStyle != null)
            {
                return(maxDetailStyle.Renderer.GetShapeGeometry(node, maxDetailStyle).GetIntersection(inner, outer));
            }
            return(base.GetIntersection(node, inner, outer));
        }
        protected override GeneralPath GetOutline(INode node)
        {
            INodeStyle maxDetailStyle = nodeStyles[maxValue];

            if (maxDetailStyle != null)
            {
                return(maxDetailStyle.Renderer.GetShapeGeometry(node, maxDetailStyle).GetOutline());
            }
            return(base.GetOutline(node));
        }
        protected override bool IsInside(INode node, PointD point)
        {
            INodeStyle maxDetailStyle = nodeStyles[maxValue];

            if (maxDetailStyle != null)
            {
                return(maxDetailStyle.Renderer.GetShapeGeometry(node, maxDetailStyle).IsInside(point));
            }
            return(base.IsInside(node, point));
        }
            public bool IsHit(IInputModeContext context, PointD location)
            {
                INodeStyle nodeStyle = orgChartNodeStyle.GetNodeStyle(context.Zoom);

                if (nodeStyle != null)
                {
                    var clickHandler = nodeStyle.Renderer.GetContext(node, nodeStyle).Lookup <IClickHandler>();
                    return(clickHandler != null && clickHandler.HitTestable.IsHit(context, location));
                }
                return(false);
            }
            /// <summary>
            /// Use the node style's outline as obstacle.
            /// </summary>
            /// <remarks>For node style renderers that don't provide a <see cref="IShapeGeometry"/>, no bridges will be created.</remarks>
            /// <returns></returns>
            private GeneralPath CreatePath()
            {
                INodeStyle     style    = groupNode.Style;
                IShapeGeometry geometry = style.Renderer.GetShapeGeometry(groupNode, style);

                if (geometry != null)
                {
                    GeneralPath outline = geometry.GetOutline();
                    return(outline);
                }
                return(null);
            }
Esempio n. 12
0
 /// <summary>
 /// Initializes an instance of this style.
 /// </summary>
 /// <param name="wrapped">the wrapped style</param>
 /// <param name="imageUrl">the url of the decorator image</param>
 public NodeStyleDecorator(INodeStyle wrapped, string imageUrl)
 {
     this.wrapped  = wrapped;
     this.imageUrl = imageUrl;
     if (imageUrl != null)
     {
         var image = Image.FromFile(imageUrl);
         imageStyle = new MemoryImageNodeStyle {
             Image = image
         };
     }
 }
            public void OnClicked(IInputModeContext context, PointD location)
            {
                INodeStyle nodeStyle = orgChartNodeStyle.GetNodeStyle(context.CanvasControl.Zoom);

                if (nodeStyle != null)
                {
                    var clickHandler = nodeStyle.Renderer.GetContext(node, nodeStyle).Lookup <IClickHandler>();
                    if (clickHandler != null && clickHandler.HitTestable.IsHit(context, location))
                    {
                        clickHandler.OnClicked(context, location);
                    }
                }
            }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConstraintsNodeStyle"/> class.
 /// </summary>
 public ConstraintsNodeStyle()
 {
     buttons        = new List <Button>();
     DecoratedStyle = new ShapeNodeStyle
     {
         Brush =
             new LinearGradientBrush(new Point(0, 0), new Point(1, 1), Color.White,
                                     Color.FromArgb(255, 221, 221, 255)),
         Shape = ShapeNodeShape.Rectangle,
         Pen   = new Pen(Color.Gray, 2)
     };
     AddDecoratorButtons();
     node = new SimpleNode();
 }
        /// <summary>
        /// Method that populates the <see cref="IPropertyMap"/> for edge styles in a given context.
        /// </summary>
        /// <remarks>
        /// This implementation uses <see cref="GetStylePropertyMapBuilder"/> to retrieve the builder for the style.
        /// </remarks>
        /// <param name="context">The context to use for queries.</param>
        protected virtual void BuildStyleProperties(IPropertyBuildContext <INode> context)
        {
            INode node = context.CurrentInstance;

            if (node != null)
            {
                INodeStyle style = node.Style;
                if (style != null)
                {
                    GetInstanceDelegate <INodeStyle> styleGetter = delegate { return(context.CurrentInstance.Style); };
                    SetInstanceDelegate <INodeStyle> styleSetter = delegate(INodeStyle newValue) {
                        IGraph graph       = context.Lookup(typeof(IGraph)) as IGraph;
                        INode  currentNode = context.CurrentInstance;
                        if (graph != null)
                        {
                            graph.SetStyle(currentNode, newValue);
                            var foldingView = graph.Lookup(typeof(IFoldingView)) as IFoldingView;
                            if (foldingView != null)
                            {
                                var masterNode = foldingView.GetMasterItem(currentNode);
                                if (foldingView.IsInFoldingState(currentNode))
                                {
                                    // update non-dummy node
                                    foldingView.Manager.MasterGraph.SetStyle(masterNode, newValue);
                                }
                                else if (foldingView.IsExpanded(currentNode))
                                {
                                    // update dummy node
                                    if (foldingView.Manager.HasFolderNodeState(masterNode))
                                    {
                                        foldingView.Manager.GetFolderNodeState(masterNode).Style = newValue;
                                    }
                                }
                            }
                        }
                    };
                    IPropertyBuildContext <INodeStyle> styleContext =
                        context.CreateChildContext(StylePropertyName, styleGetter, styleSetter, styleAssignmentPolicy);

                    IPropertyMapBuilder propertyBuilder = GetStylePropertyMapBuilder(context, style);
                    if (propertyBuilder != null)
                    {
                        GetInstanceDelegate <INodeStyle> innerStyleGetter = delegate { return(styleContext.CurrentInstance); };
                        SetInstanceDelegate <INodeStyle> innerStyleSetter = delegate(INodeStyle newValue) { styleContext.SetNewInstance(newValue); };
                        propertyBuilder.BuildPropertyMap(styleContext.CreateChildContext(string.Empty, innerStyleGetter, innerStyleSetter, styleAssignmentPolicy));
                    }
                }
            }
        }
            /// <summary>
            /// Return an obstacle for the node style's outline.
            /// </summary>
            /// <param name="context"></param>
            /// <returns></returns>
            public GeneralPath GetObstacles(IRenderContext context)
            {
                INodeStyle style   = groupNode.Style;
                bool       visible = style.Renderer.GetVisibilityTestable(groupNode, style).IsVisible(context, context.Clip);

                if (!visible)
                {
                    //If the node is invisible, don't return anything (won't be painted anyway...)
                    return(null);
                }
                else
                {
                    //Otherwise, creta an obstacle
                    return(CreatePath());
                }
            }
        /// <summary>
        /// Builds the options for the style of the node instance.
        /// </summary>
        /// <param name="context">The context to use for building.</param>
        /// <param name="node">The current node instance.</param>
        protected virtual void BuildStyleOptions(IOptionBuilderContext context, INode node)
        {
            context = context.CreateChildContext(DefaultNodePropertyMapBuilder.StylePropertyName);
            //style group...
            //retrieve current style...
            INodeStyle style = node.Style;

            if (style != null)
            {
                //retrieve OptionBuilder from style
                IOptionBuilder builder = GetStyleOptionBuilder(context, style);
                if (builder != null)
                {
                    builder.AddItems(context, style.GetType(), style);
                }
            }
        }
 /// <summary>
 /// Initializes the styles to use for the graph.
 /// </summary>
 private void InitializeStyles()
 {
     defaultNodeStyle = new ShinyPlateNodeStyle {
         Brush = Brushes.DarkOrange
     };
     sourceNodeStyle = new ShinyPlateNodeStyle {
         Brush = Brushes.LimeGreen
     };
     targetNodeStyle = new ShinyPlateNodeStyle {
         Brush = Brushes.OrangeRed
     };
     sourceAndTargetNodeStyle = new ShinyPlateNodeStyle {
         Brush = new HatchBrush(HatchStyle.LargeCheckerBoard, Color.LimeGreen, Color.OrangeRed)
     };
     defaultEdgeStyle = new PolylineEdgeStyle {
         Pen = Pens.Black, TargetArrow = directed ? Arrows.Default : Arrows.None
     };
     pathEdgeStyle = new PolylineEdgeStyle {
         Pen = new Pen(Color.Red, 4.0f), TargetArrow = directed ? Arrows.Default : Arrows.None
     };
 }
 /// <summary>
 /// Initializes an instance of this style.
 /// </summary>
 /// <param name="wrapped">the wrapped style</param>
 /// <param name="imageUrl">the url of the decorator image</param>
 public NodeStyleDecorator(INodeStyle wrapped, string imageUrl)
 {
     this.wrapped  = wrapped;
     this.imageUrl = imageUrl;
 }
Esempio n. 20
0
 /// <summary>
 /// Creates a new instance with a wrapped node style and an angle.
 /// </summary>
 public RotatableNodeStyleDecorator(INodeStyle wrapped = null, double angle = 0)
 {
     Wrapped = wrapped ?? new ShapeNodeStyle();
     Angle   = angle;
 }
Esempio n. 21
0
 public RotatableNodeStyleVisual(INodeStyle wrappedStyle, double angle, PointD center)
 {
     WrappedStyle = wrappedStyle;
     Angle        = angle;
     Center       = center;
 }
 public RotateRenderData(INodeStyle wrapped, double angle, PointD center) : this()
 {
     WrappedStyle = wrapped;
     Angle        = angle;
     Center       = center;
 }
Esempio n. 23
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="VirtualizationNodeStyleDecorator" /> class with the given virtualization
 ///   threshold and wrapped style.
 /// </summary>
 /// <param name="threshold">The zoom level below which virtualization is turned off.</param>
 /// <param name="style">The wrapped style.</param>
 public VirtualizationNodeStyleDecorator(double threshold, INodeStyle style)
 {
     Style     = style;
     Threshold = threshold;
 }
Esempio n. 24
0
 /// <inheritdoc />
 public IHitTestable GetHitTestable(INode node, INodeStyle style)
 {
     return(Style.Renderer.GetHitTestable(node, Style));
 }
Esempio n. 25
0
 /// <inheritdoc />
 public IVisibilityTestable GetVisibilityTestable(INode node, INodeStyle style)
 {
     return(Style.Renderer.GetVisibilityTestable(node, Style));
 }
Esempio n. 26
0
 /// <inheritdoc />
 public IBoundsProvider GetBoundsProvider(INode node, INodeStyle style)
 {
     return(Style.Renderer.GetBoundsProvider(node, Style));
 }
Esempio n. 27
0
 /// <inheritdoc />
 public IVisualCreator GetVisualCreator(INode node, INodeStyle style)
 {
     return(Style.Renderer.GetVisualCreator(node, Style));
 }
Esempio n. 28
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="WrapperNodeStyle" /> class, wrapping the given
 ///   <see cref="INodeStyle" />.
 /// </summary>
 /// <param name="style">The style to wrap.</param>
 public WrapperNodeStyle(INodeStyle style)
 {
     Style = style;
 }
Esempio n. 29
0
 /// <inheritdoc />
 public IShapeGeometry GetShapeGeometry(INode node, INodeStyle style)
 {
     return(Style.Renderer.GetShapeGeometry(node, Style));
 }
Esempio n. 30
0
 /// <inheritdoc />
 public ILookup GetContext(INode node, INodeStyle style)
 {
     return(Style.Renderer.GetContext(node, Style));
 }