Exemplo n.º 1
0
        public static void OnIsAutoChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            IntValueWithAutoEditor control = d as IntValueWithAutoEditor;

            bool newValue           = (bool)(e.NewValue);
            var  bindInsType        = control.BindInstance.GetType();
            var  enumrableInterface = bindInsType.GetInterface(typeof(System.Collections.IEnumerable).FullName, false);

            if (enumrableInterface != null)
            {
                foreach (var objIns in (System.Collections.IEnumerable)control.BindInstance)
                {
                    var property = objIns.GetType().GetProperty(control.BindProperty.Name + "_Auto");
                    if (property != null && newValue != (bool)(property.GetValue(objIns, null)))
                    {
                        property.SetValue(objIns, newValue, null);
                    }
                }
            }
            else
            {
                var property = control.BindInstance.GetType().GetProperty(control.BindProperty.Name + "_Auto");
                if (property != null && newValue != (bool)(property.GetValue(control.BindInstance, null)))
                {
                    property.SetValue(control.BindInstance, newValue, null);
                }
            }
        }
Exemplo n.º 2
0
 public static void OnBindInstanceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     IntValueWithAutoEditor control = d as IntValueWithAutoEditor;
 }
Exemplo n.º 3
0
        public static void OnBindPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            IntValueWithAutoEditor control = d as IntValueWithAutoEditor;

            control.Pro_Auto.Content = "Auto";
            var newValue           = e.NewValue as EditorCommon.CustomPropertyDescriptor;
            var bindInsType        = control.BindInstance.GetType();
            var enumrableInterface = bindInsType.GetInterface(typeof(System.Collections.IEnumerable).FullName, false);

            if (enumrableInterface != null)
            {
                bool hasProperty = false;
                bool hasDiff     = false;
                bool autoValue   = false;
                int  index       = 0;
                foreach (var objIns in (System.Collections.IEnumerable)control.BindInstance)
                {
                    var property = objIns.GetType().GetProperty(newValue.Name + "_Auto");
                    if (index == 0)
                    {
                        if (property == null)
                        {
                            hasProperty = false;
                        }
                        else
                        {
                            autoValue = (bool)(property.GetValue(objIns, null));
                        }
                    }
                    else
                    {
                        if (property == null)
                        {
                            if (hasProperty)
                            {
                                hasDiff = true;
                                break;
                            }
                        }
                        else
                        {
                            if (!hasProperty)
                            {
                                hasDiff = true;
                                break;
                            }
                            var tempVal = (bool)(property.GetValue(objIns, null));
                            if (autoValue != tempVal)
                            {
                                hasDiff = true;
                                break;
                            }
                        }
                    }
                    index++;
                }

                if (hasDiff)
                {
                    control.Pro_Auto.Content = "Multi";
                }
                else
                {
                    foreach (var objIns in (System.Collections.IEnumerable)control.BindInstance)
                    {
                        var property = objIns.GetType().GetProperty(newValue.Name + "_Auto");
                        if (property == null)
                        {
                            control.AutoButtonVisible = Visibility.Collapsed;
                        }
                        else
                        {
                            control.AutoButtonVisible = Visibility.Visible;
                            control.IsAuto            = (bool)(property.GetValue(objIns, null));
                        }
                    }
                }
            }
            else
            {
                var property = control.BindInstance.GetType().GetProperty(newValue.Name + "_Auto");
                if (property == null)
                {
                    control.AutoButtonVisible = Visibility.Collapsed;
                }
                else
                {
                    control.AutoButtonVisible = Visibility.Visible;
                    control.IsAuto            = (bool)(property.GetValue(control.BindInstance, null));
                }
            }
        }