Example #1
0
        private void OnChanged(IPropertyChanged changed)
        {
            lock (locker)
            {
                if (isSuppressingChange)
                {
                    return;
                }
                isSuppressingChange = true;
            }

            var value = changed.NewValue;

            if (value == null)
            {
                Object = null;
                Directory.DeleteTree();
                Directory.Refresh();
            }
            else
            {
                Object = new DbObjectNode(Database, (IRxObject)changed.NewValue, Directory);
            }

            lock (locker)
            {
                isSuppressingChange = false;
            }
        }
Example #2
0
        /// <summary>
        /// 验证属性值变更状态是否满足要求
        /// </summary>
        /// <param name="propertyChanged"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public static bool IsCondition(IPropertyChanged propertyChanged, AbstractRequestContext context)
        {
            if (propertyChanged.PropertyChanged == PropertyChangedState.Ignore)
            {
                return(true);
            }

            var changedVersion = context.GetPropertyVersion(propertyChanged.Property);

            switch (changedVersion)
            {
            case -1:
            {
                return(true);
            }

            case 0:
            {
                return(propertyChanged.PropertyChanged == PropertyChangedState.Unchanged);
            }

            case int version when version > 0:
            {
                return(propertyChanged.PropertyChanged == PropertyChangedState.Changed);
            }

            default:
            {
                return(false);
            }
            }
        }
Example #3
0
        private void GetPropertyInfo(object src, object dest, string srcProperty, string destProperty)
        {
            var lastObj = GetObjectFromString(srcProperty, src, out srcPropertyLast);

            if (lastObj != null && lastObj is IPropertyChanged)
            {
                foreach (PropertyInfo propertyInfo in lastObj.GetType().GetProperties())
                {
                    if (propertyInfo.Name == srcPropertyLast)
                    {
                        srcPropertyInfo = propertyInfo;
                        break;
                    }
                }
                srcObject = lastObj as IPropertyChanged;
                srcObject.PropertyChanged += Binding_PropertyChanged;
            }

            lastObj = GetObjectFromString(destProperty, dest, out destPropertyLast);
            if (lastObj != null)
            {
                foreach (PropertyInfo propertyInfo in lastObj.GetType().GetProperties())
                {
                    if (propertyInfo.Name == destPropertyLast)
                    {
                        destPropertyInfo = propertyInfo;
                        break;
                    }
                }
                destObject = lastObj;
            }
        }
Example #4
0
 public SudokuController(IPropertyChanged propertyChanged)
 {
     _propertyChanged = propertyChanged;
     _game = new Sudoku.Game();
     _game.create();
     _propertyChanged.NotifyPropertyChanged();
 }
        /// <summary>Performs the logical operation "target.PropertyChanged += handler",
        /// where 'target' is located in another AppDomain, using this helper as an
        /// intermediary so that the subscription works correctly.</summary>
        public CrossDomainPropertyChangeHelper(IPropertyChanged target, PropertyChangedDelegate handler)
        {
            Debug.Assert(RemotingServices.IsTransparentProxy(target));
            _handler = handler;
            target.PropertyChanged += Intermediary;

            // Honestly I don't know what I am doing. Tried to figure it out, failed.
            ((ILease)RemotingServices.GetLifetimeService(this)).Register(this);             // register self as sponsor
        }
		/// <summary>Performs the logical operation "target.PropertyChanged += handler",
		/// where 'target' is located in another AppDomain, using this helper as an
		/// intermediary so that the subscription works correctly.</summary>
		public CrossDomainPropertyChangeHelper(IPropertyChanged target, PropertyChangedDelegate handler)
		{
			Debug.Assert(RemotingServices.IsTransparentProxy(target));
			_handler = handler;
			target.PropertyChanged += Intermediary;
			
			// Honestly I don't know what I am doing. Tried to figure it out, failed.
			((ILease)RemotingServices.GetLifetimeService(this)).Register(this); // register self as sponsor
		}
Example #7
0
        public static bool Change <T>(this IPropertyChanged input, ref T field, T value, [CallerMemberName] string propertyName = "")
        {
            if (EqualityComparer <T> .Default.Equals(field, value))
            {
                return(false);
            }

            field = value;
            input.Changed(propertyName);
            return(true);
        }
Example #8
0
        public static bool Change <T>(this IPropertyChanged input, ref T field, T value, Expression <Func <T> > propertyName)
        {
            if (EqualityComparer <T> .Default.Equals(field, value))
            {
                return(false);
            }

            field = value;
            input.Changed(propertyName);
            return(true);
        }
Example #9
0
        public static void Changed <T>(this IPropertyChanged input, Expression <Func <T> > propertyName)
        {
            if (propertyName == null)
            {
                throw new ArgumentNullException(nameof(propertyName));
            }

            var body = propertyName.Body as MemberExpression;

            if (body == null)
            {
                throw new ArgumentNullException($"{nameof(propertyName)}.{nameof(propertyName.Body)}");
            }

            input.OnPropertyChanged(body.Member.Name);
        }
Example #10
0
        private void OnChanged(IPropertyChanged changed)
        {
            lock (locker)
            {
                if (isSuppressingChange)
                {
                    return;
                }
            }

            var value = changed.NewValue;

            if (value == null)
            {
                File.Delete();
            }
            else
            {
                System.IO.File.WriteAllText(File.FullName, (string)TypeConverter.Convert(changed.NewValue, typeof(string)));
            }
            Database.NotifyGlobalChanged(changed);
        }
Example #11
0
        public Binding(IPropertyChanged source, string sourcePropertyName, IPropertyChanged target, string targetPropertyName, BindingType type = BindingType.TwoWay, IValueConverter converter = null)
        {
            this.source             = source;
            this.sourcePropertyName = sourcePropertyName;
            this.target             = target;
            this.targetPropertyName = targetPropertyName;
            this.type = type;

            this.converter = converter == null ? new NoOpCoverter() : converter;

            if (type == BindingType.TwoWay || type == BindingType.OneWay)
            {
                sourceToTarget          = true;
                source.PropertyChanged += SourceChanged;
            }

            if (type == BindingType.TwoWay || type == BindingType.OneWayToSource)
            {
                targetToSource          = true;
                target.PropertyChanged += TargetChanged;
            }

            ValidateBinding();
        }
Example #12
0
        public Binding(IPropertyChanged source, string sourcePropertyName, IPropertyChanged target, string targetPropertyName, BindingType type = BindingType.TwoWay, IValueConverter converter = null)
        {
            this.source = source;
            this.sourcePropertyName = sourcePropertyName;
            this.target = target;
            this.targetPropertyName = targetPropertyName;
            this.type = type;

            this.converter = converter == null ? new NoOpCoverter() : converter;

            if (type == BindingType.TwoWay || type == BindingType.OneWay)
            {
                sourceToTarget = true;
                source.PropertyChanged += SourceChanged;
            }

            if (type == BindingType.TwoWay || type == BindingType.OneWayToSource)
            {
                targetToSource = true;
                target.PropertyChanged += TargetChanged;
            }

            ValidateBinding();
        }
 public void SetParent(object parent, PropertyInfo propertyInfo)
 {
     _parent       = parent as IPropertyChanged;
     _propertyInfo = propertyInfo;
 }
Example #14
0
 protected void OnGlobalChanged(IPropertyChanged changed)
 {
     GlobalChanged?.Invoke(changed);
 }
Example #15
0
		public void SetParent(object parent, PropertyInfo propertyInfo)
		{
			_parent       = parent as IPropertyChanged;
			_propertyInfo = propertyInfo;
		}
Example #16
0
 public static void Changed(this IPropertyChanged input, [CallerMemberName] string propertyName = "") => input.OnPropertyChanged(propertyName);
Example #17
0
 internal void NotifyGlobalChanged(IPropertyChanged changed)
 {
     OnGlobalChanged(changed);
 }