Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphNodeBinding{TTargetType, TContentType}"/> class.
        /// </summary>
        /// <param name="node">The graph node bound to this instance.</param>
        /// <param name="propertyName">The name of the property of the view model that is bound to this instance.</param>
        /// <param name="propertyChanging">The delegate to invoke when the node content is about to change.</param>
        /// <param name="propertyChanged">The delegate to invoke when the node content has changed.</param>
        /// <param name="converter">A converter function to convert between the content type and the property type.</param>
        /// <param name="notifyChangesOnly">If <c>True</c>, delegates will be invoked only if the content of the node has actually changed. Otherwise, they will be invoked every time the node is updated, even if the new value is equal to the previous one.</param>
        public GraphNodeBinding(IGraphNode node, string propertyName, PropertyChangeDelegate propertyChanging, PropertyChangeDelegate propertyChanged, Func <TContentType, TTargetType> converter, bool notifyChangesOnly = true)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }
            if (converter == null)
            {
                throw new ArgumentNullException(nameof(converter));
            }
            this.node      = node;
            this.converter = converter;

            changingHandler = (s, e) =>
            {
                if (!notifyChangesOnly || !Equals(e.Content.Retrieve(e.OldValue, e.Index), e.Content.Retrieve(e.NewValue, e.Index)))
                {
                    propertyChanging?.Invoke(new[] { propertyName });
                }
            };
            node.Content.Changing += changingHandler;

            changedHandler = (s, e) =>
            {
                if (!notifyChangesOnly || !Equals(e.Content.Retrieve(e.OldValue, e.Index), e.Content.Retrieve(e.NewValue, e.Index)))
                {
                    propertyChanged?.Invoke(new[] { propertyName });
                }
            };
            node.Content.Changed += changedHandler;
        }
Example #2
0
 internal GraphNodeBinding(string propertyName, PropertyChangeDelegate propertyChanging, PropertyChangeDelegate propertyChanged, [NotNull] Func <TTargetType, TContentType> converter, IUndoRedoService actionService, bool notifyChangesOnly = true)
 {
     PropertyName           = propertyName;
     this.propertyChanging  = propertyChanging;
     this.propertyChanged   = propertyChanged;
     Converter              = converter ?? throw new ArgumentNullException(nameof(converter));
     ActionService          = actionService;
     this.notifyChangesOnly = notifyChangesOnly;
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphNodeBinding{TTargetType, TContentType}"/> class.
 /// </summary>
 /// <param name="node">The graph node bound to this instance.</param>
 /// <param name="propertyName">The name of the property of the view model that is bound to this instance.</param>
 /// <param name="propertyChanging">The delegate to invoke when the node content is about to change.</param>
 /// <param name="propertyChanged">The delegate to invoke when the node content has changed.</param>
 /// <param name="converter">A converter function to convert between the content type and the property type.</param>
 /// <param name="notifyChangesOnly">If <c>True</c>, delegates will be invoked only if the content of the node has actually changed. Otherwise, they will be invoked every time the node is updated, even if the new value is equal to the previous one.</param>
 public GraphNodeBinding(IGraphNode node, string propertyName, PropertyChangeDelegate propertyChanging, PropertyChangeDelegate propertyChanged, Func <TContentType, TTargetType> converter, bool notifyChangesOnly = true)
 {
     if (node == null)
     {
         throw new ArgumentNullException(nameof(node));
     }
     if (converter == null)
     {
         throw new ArgumentNullException(nameof(converter));
     }
     this.node              = node;
     this.propertyName      = propertyName;
     this.propertyChanging  = propertyChanging;
     this.propertyChanged   = propertyChanged;
     this.converter         = converter;
     this.notifyChangesOnly = notifyChangesOnly;
     node.Content.Changing += ContentChanging;
     node.Content.Changed  += ContentChanged;
 }
Example #4
0
 public MemberGraphNodeBinding([NotNull] IMemberNode node, string propertyName, PropertyChangeDelegate propertyChanging, PropertyChangeDelegate propertyChanged, [NotNull] Func <TTargetType, TContentType> converter, IUndoRedoService actionService, bool notifyChangesOnly = true)
     : base(propertyName, propertyChanging, propertyChanged, converter, actionService, notifyChangesOnly)
 {
     Node = node;
     node.ValueChanged  += ValueChanged;
     node.ValueChanging += ValueChanging;
 }
Example #5
0
 public extern static void setPropertyChangeFP(PropertyChangeDelegate fp);
Example #6
0
 /// <summary>
 /// 移除一个事件回调函数
 /// </summary>
 public void RemoveValueChangeEvent(PropertyChangeDelegate <T> callback)
 {
     m_changeEvent -= callback;
 }
Example #7
0
 /// <summary>
 /// 增加一个事件回调函数
 /// </summary>
 public void AddValueChangeEvent(PropertyChangeDelegate <T> callback)
 {
     m_changeEvent += callback;
 }
 public extern static void setPropertyChangeFP(PropertyChangeDelegate fp);
 /// <summary>
 /// 移除一个事件回调函数
 /// </summary>
 public void RemoveValueChangeEvent(PropertyChangeDelegate callback)
 {
     m_changeEvent -= callback;
 }
Example #10
0
 /// <summary>
 /// 增加一个事件回调函数
 /// </summary>
 public void AddValueChangeEvent(PropertyChangeDelegate callback)
 {
     m_changeEvent += callback;
 }