コード例 #1
0
        public void ShouldReturnParentValue()
        {
            PropertyItemValue value    = new PropertyItemValue(new PropertyItemMock());
            PropertyItem      property = new PropertyItemMock(value);

            Assert.AreEqual(value, property.ParentValue);
        }
コード例 #2
0
        public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
        {
            if (propertyValue == null)
            {
                return;
            }
            if (propertyValue.ParentProperty.IsReadOnly)
            {
                return;
            }

            var ofd = new OpenFileDialog();

            ofd.Multiselect = false;

            var property = propertyValue.ParentProperty;

            if (property != null)
            {
                var optionsAttribute = (OpenFileDialogOptionsAttribute)property.Attributes[typeof(OpenFileDialogOptionsAttribute)];
                if (optionsAttribute != null)
                {
                    optionsAttribute.ConfigureDialog(ofd);
                }
            }

            if (ofd.ShowDialog() == true)
            {
                propertyValue.StringValue = ofd.FileName;
            }
        }
コード例 #3
0
 public override void ClearValue(PropertyItemValue propertyValue, IInputElement commandSource)
 {
     if (propertyValue == null || propertyValue.IsReadOnly)
     {
         return;
     }
     propertyValue.StringValue = string.Empty;
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueExceptionEventArgs"/> class.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="value">The value.</param>
 /// <param name="source">The source.</param>
 /// <param name="exception">The exception.</param>
 public ValueExceptionEventArgs(string message, PropertyItemValue value, ValueExceptionSource source, Exception exception)
 {
     if (message == null) throw new ArgumentNullException("message");
       if (value == null) throw new ArgumentNullException("value");
       if (exception == null) throw new ArgumentNullException("exception");
       _message = message;
       _value = value;
       _source = source;
       _exception = exception;
 }
コード例 #5
0
        public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
        {
            if (propertyValue == null)
            {
                return;
            }
            if (!propertyValue.IsCollection)
            {
                return;
            }

            MessageBox.Show("Collection!");
        }
コード例 #6
0
        private void WrapEventHandlers(PropertyItemValue target)
        {
            if (target == null)
            {
                return;
            }
            if (_wrappedEvents)
            {
                return;
            }

            target.PropertyChanged += ValuePropertyChanged;
            _wrappedEvents          = true;
        }
コード例 #7
0
        private void UnwrapEventHandlers(PropertyItemValue target)
        {
            if (target == null)
            {
                return;
            }
            if (!_wrappedEvents)
            {
                return;
            }

            target.PropertyChanged -= ValuePropertyChanged;
            _wrappedEvents          = false;
        }
コード例 #8
0
        public CollectionItemValue(PropertyItemValue propertyItemValue, int index)
        {
            _propertyItemValue = propertyItemValue;
            _index             = index;

            var expandable = PropertyGridUtils.GetAttributes <ExpandableObjectAttribute>(Value);

            if (expandable.Any())
            {
                var descriptors = MetadataRepository.GetProperties(Value).Select(prop => prop.Descriptor);

                if (descriptors.Any())
                {
                    object objectValue;
                    if (Value is ICloneable valueToClone)
                    {
                        objectValue = valueToClone.Clone();
                    }
                    else
                    {
                        objectValue = Value;
                    }


                    HasSubProperties = true;

                    var properties = new GridEntryCollection <PropertyItem>();
                    foreach (PropertyDescriptor d in descriptors)
                    {
                        var item = new PropertyItem(_propertyItemValue.ParentProperty.Owner, objectValue, d);
                        item.IsBrowsable   = ShouldDisplayProperty(d);
                        item.ValueChanged += ItemOnValueChanged;
                        properties.Add(item);
                    }

                    if (_propertyItemValue.ParentProperty.Owner.PropertyComparer != null)
                    {
                        properties.Sort(_propertyItemValue.ParentProperty.Owner.PropertyComparer);
                    }

                    SubProperties = properties;
                }

                MetadataRepository.Remove(Value);
            }
        }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueExceptionEventArgs"/> class.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="value">The value.</param>
 /// <param name="source">The source.</param>
 /// <param name="exception">The exception.</param>
 public ValueExceptionEventArgs(string message, PropertyItemValue value, ValueExceptionSource source, Exception exception)
 {
     if (message == null)
     {
         throw new ArgumentNullException("message");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (exception == null)
     {
         throw new ArgumentNullException("exception");
     }
     _message   = message;
     _value     = value;
     _source    = source;
     _exception = exception;
 }
コード例 #10
0
        public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
        {
            if (propertyValue == null)
            {
                return;
            }
            if (propertyValue.ParentProperty.IsReadOnly)
            {
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.AllowMultiple = false;

            openFileDialog.Filters = new List <FileDialogFilter>
            {
                new FileDialogFilter()
                {
                    Name         = "Image Files (*.jpg, *.png, *.bmp)"
                    , Extensions = new List <string>()
                    {
                        "jpg", "png", "bmp"
                    }
                }
            };

            var mainWindow = ApplicationExtension.GetMainWindow();

            openFileDialog.ShowAsync(mainWindow).ContinueWith(x =>
            {
                if (x.IsFaulted == false)
                {
                    string result = x.Result.FirstOrDefault();

                    if (string.IsNullOrEmpty(result) == false)
                    {
                        propertyValue.StringValue = result;
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
コード例 #11
0
        public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
        {
            PropertyGrid propGrid = commandSource as PropertyGrid;
            string       lastPath = propertyValue.StringValue;

            if (propGrid == null)
            {
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "All files (*.*)|*.*";
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            openFileDialog.ShowDialog();

            propertyValue.StringValue = openFileDialog.FileName != String.Empty ? openFileDialog.FileName : lastPath;             // change this string and compile, the ui does not see this change
            propGrid.DoReload();
            propGrid.RaiseEvent(new PropertyValueChangedEventArgs(PropertyGrid.PropertyValueChangedEvent, propertyValue.ParentProperty, ""));
        }
コード例 #12
0
        public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
        {
            if (propertyValue == null)
            {
                return;
            }
            if (propertyValue.ParentProperty.IsReadOnly)
            {
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.AllowMultiple = false;

            var property = propertyValue.ParentProperty;

            if (property != null)
            {
                var optionsAttribute = (OpenFileDialogOptionsAttribute)property.Attributes[typeof(OpenFileDialogOptionsAttribute)];
                if (optionsAttribute != null)
                {
                    optionsAttribute.ConfigureDialog(openFileDialog);
                }
            }

            var mainWindow = ApplicationExtension.GetMainWindow();

            openFileDialog.ShowAsync(mainWindow).ContinueWith(x =>
            {
                if (x.IsFaulted == false)
                {
                    string result = x.Result.FirstOrDefault();

                    if (string.IsNullOrEmpty(result) == false)
                    {
                        propertyValue.StringValue = result;
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
コード例 #13
0
        public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
        {
            if (propertyValue == null)
            {
                return;
            }
            if (propertyValue.ParentProperty.IsReadOnly)
            {
                return;
            }

            OpenFileDialog ofd = new OpenFileDialog
            {
                Filter      = "Image Files (*.jpg, *.png, *.bmp)|*.jpg;*.png;*.bmp",
                Multiselect = false
            };

            if (ofd.ShowDialog() == true)
            {
                propertyValue.StringValue = ofd.FileName;
            }
        }
コード例 #14
0
ファイル: MainWindow.xaml.cs プロジェクト: tihilv/Pat
        private void OnShowDialogEditor(object sender, ExecutedRoutedEventArgs e)
        {
            PropertyItemValue parameter = e.Parameter as PropertyItemValue;

            parameter?.ParentProperty?.Editor?.ShowDialog(parameter, this);
        }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyItem"/> class.
 /// </summary>
 /// <param name="parentValue">The parent value.</param>
 protected PropertyItem(PropertyItemValue parentValue)
 {
     _parentValue = parentValue;
 }
コード例 #16
0
ファイル: EnumDropdown.cs プロジェクト: denkhaus/WPG
        private void UnwrapEventHandlers(PropertyItemValue target)
        {
            if (target == null) return;
            if (!wrappedEvents) return;

            target.PropertyChanged -= ValuePropertyChanged;
            wrappedEvents = false;
        }
コード例 #17
0
ファイル: EnumDropdown.cs プロジェクト: denkhaus/WPG
        private void WrapEventHandlers(PropertyItemValue target)
        {
            if (target == null) return;
            if (wrappedEvents) return;

            target.PropertyChanged += ValuePropertyChanged;
            wrappedEvents = true;
        }
コード例 #18
0
 public PropertyItemMock(PropertyItemValue value) : base(value)
 {
 }
コード例 #19
0
ファイル: Editor.cs プロジェクト: denkhaus/WPG
 /// <summary>
 /// Shows the dialog for editing property value.
 /// </summary>
 /// <param name="propertyValue">The property value.</param>
 /// <param name="commandSource">The command source.</param>
 public virtual void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
 {
 }
コード例 #20
0
 public CollectionItemValue(PropertyItemValue propertyItemValue, int index)
 {
     _propertyItemValue = propertyItemValue;
     _index             = index;
 }
コード例 #21
0
 /// <summary>
 /// Shows the dialog for editing property value.
 /// </summary>
 /// <param name="propertyValue">The property value.</param>
 /// <param name="commandSource">The command source.</param>
 public virtual void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
 {
 }
コード例 #22
0
ファイル: CollectionItemValue.cs プロジェクト: stewmc/vixen
		public CollectionItemValue(PropertyItemValue propertyItemValue, int index)
		{
			_propertyItemValue = propertyItemValue;
			_index = index;
		}