public DecoratedSetter(IValueSetter setter, GetInstanceDelegate <TInnerSubject> getTargetHandler, SetInstanceDelegate <TInnerSubject> newInstanceSetter, Func <TInnerSubject, TInnerSubject> cloner)
 {
     this.setter            = setter;
     this.cloner            = cloner;
     this.getTargetHandler  = getTargetHandler;
     this.newInstanceSetter = newInstanceSetter;
 }
Example #2
0
        /// <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 <IEdge> context)
        {
            IEdge edge = context.CurrentInstance;

            if (edge != null)
            {
                IEdgeStyle style = edge.Style;
                if (style != null)
                {
                    IPropertyMapBuilder propertyBuilder = GetStylePropertyMapBuilder(context, style);
                    if (propertyBuilder != null)
                    {
                        GetInstanceDelegate <IEdgeStyle> styleGetter = delegate { return(context.CurrentInstance.Style); };
                        SetInstanceDelegate <IEdgeStyle> styleSetter = delegate(IEdgeStyle newInstance) {
                            IGraph graph       = context.Lookup(typeof(IGraph)) as IGraph;
                            IEdge  currentEdge = context.CurrentInstance;
                            if (graph != null)
                            {
                                graph.SetStyle(currentEdge, newInstance);
                            }
                        };
                        propertyBuilder.BuildPropertyMap(context.CreateChildContext(DefaultEdgeOptionBuilder.StylePropertyName, styleGetter, styleSetter, styleAssignmentPolicy));
                    }
                }
            }
        }
 internal DefaultPropertyBuildContext(ILookup innerLookup, IContextLookup contextLookup, IPropertyMap map, TSubject subject)
 {
     this.innerLookup   = innerLookup;
     this.contextLookup = contextLookup;
     this.map           = map;
     this.getInstance   = delegate() { return(subject); };
     this.setInstance   = delegate { };
 }
 protected DefaultPropertyBuildContext(ILookup innerLookup, IContextLookup contextLookup, string prefix, IPropertyMap map, GetInstanceDelegate <TSubject> getInstance, SetInstanceDelegate <TSubject> setInstance, AssignmentPolicy policy)
 {
     this.innerLookup   = innerLookup;
     this.map           = map;
     this.prefix        = prefix;
     this.getInstance   = getInstance;
     this.setInstance   = setInstance;
     this.policy        = policy;
     this.contextLookup = contextLookup;
 }
        /// <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));
                    }
                }
            }
        }
 public IPropertyBuildContext <TInnerChild> CreateChildContext <TInnerChild>(string name, GetInstanceDelegate <TInnerChild> getHandler, SetInstanceDelegate <TInnerChild> setHandler, AssignmentPolicy policy) where TInnerChild : class
 {
     return(new OuterWrappingBuildContext <T1, T2, TInnerChild>(wrapper, childContext.CreateChildContext(name, getHandler, setHandler, policy)));
 }
 /// <summary>
 /// Recursively applies the cloning logic to the registered setters.
 /// </summary>
 public IPropertyBuildContext <TChild> CreateChildContext <TChild>(string name, GetInstanceDelegate <TChild> getHandler, SetInstanceDelegate <TChild> setHandler, AssignmentPolicy policy) where TChild : class
 {
     if (parent.useClone)
     {
         return(new OuterWrappingBuildContext <T1, T2, TChild>(this,
                                                               context.CreateChildContext(name, getHandler, setHandler, policy)));
     }
     else
     {
         return(context.CreateChildContext(name, getHandler, setHandler, policy));
     }
 }
Example #8
0
        /// <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);
                    styleContext.AddEntry("Shadow",
                                          new DelegateGetter <bool>(
                                              delegate { return(context.CurrentInstance.Style is ShadowNodeStyleDecorator); },
                                              delegate {
                        //show item only for !PanelNodeStyle...
                        return(!(context.CurrentInstance.Style is PanelNodeStyle));
                    }),
                                          new DelegateSetter <bool>(delegate(bool isShadow) {
                        INodeStyle currentStyle = context.CurrentInstance.Style;
                        if (isShadow && !(currentStyle is ShadowNodeStyleDecorator))
                        {
                            //don't decorate if already decorated...
                            INodeStyle newStyle =
                                new ShadowNodeStyleDecorator(currentStyle);
                            styleContext.SetNewInstance(newStyle);
                        }
                        else
                        {
                            if (!isShadow && currentStyle is ShadowNodeStyleDecorator)
                            {
                                //remove decoration
                                styleContext.SetNewInstance(
                                    ((ShadowNodeStyleDecorator)currentStyle).Wrapped);
                            }
                        }
                    },
                                                                    delegate { return(!(context.CurrentInstance.Style is PanelNodeStyle)); }
                                                                    ));

                    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));
                    }
                }
            }
        }
 internal DecoratedBuildContext(ILookup lookup, IContextLookup innerLookup, string prefix, IPropertyMap map, GetInstanceDelegate <TInnerSubject> getHandler, SetInstanceDelegate <TInnerSubject> setHandler, AssignmentPolicy policy)
     : base(lookup, innerLookup, prefix, map, getHandler, setHandler, policy)
 {
 }
 public IPropertyBuildContext <TChild> CreateChildContext <TChild>(string name, GetInstanceDelegate <TChild> getHandler,
                                                                   SetInstanceDelegate <TChild> setHandler,
                                                                   AssignmentPolicy policy) where TChild : class
 {
     return(new DecoratedBuildContext <TChild>(innerLookup, contextLookup, DefaultOptionBuilderContext <object> .CreatePrefix(this.prefix, name), map, getHandler, setHandler, policy));
 }