예제 #1
0
        private static IPropertySource CreatePropertySource(object instance)
        {
            if (instance == null)
            {
                return(null);
            }

            return(instance as IPropertySource ?? PropertyGridHelper.CreatePropertySource(instance));
        }
예제 #2
0
        private void OnInspect(object sender, RoutedEventArgs eventArgs)
        {
            if (MyPropertyGrid.SelectedProperty == null)
            {
                return;
            }

            // Push old source to history stack.
            _history.Push(MyPropertyGrid.PropertySource);
            MyPropertyGrid.PropertySource =
                PropertyGridHelper.CreatePropertySource(MyPropertyGrid.SelectedProperty.Value);

            eventArgs.Handled = true;
        }
예제 #3
0
        private void InspectEditor()
        {
            Logger.Debug("Inspecting editor.");

            var inspectionService = Editor.Services.GetInstance <IPropertiesService>().WarnIfMissing();

            if (inspectionService != null)
            {
                // Important: The order of ActivateItem and PropertySource.set matters.
                // Make Properties window active before changing the property source. Otherwise,
                // document may think they are still in control of the properties window and change
                // the content.
                Editor.ActivateItem(inspectionService.PropertiesViewModel);

                inspectionService.PropertySource = PropertyGridHelper.CreatePropertySource(Editor);
            }
        }
예제 #4
0
        public PropertyGridTest()
        {
            InitializeComponent();

            MyPropertyGrid.PropertySource = PropertyGridHelper.CreatePropertySource(MyButton);

            MyPropertyGrid2.PropertySource = new PropertySource()
            {
                Name       = "Custom Name",
                TypeName   = "Custom Type",
                Properties =
                {
                    new CustomProperty("Name", "StringValue dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd")
                    {
                        Description  = "Description of Property0",
                        Category     = null,
                        DefaultValue = "Default",
                        CanReset     = true,
                    },
                    new CustomProperty("Property 2", true)
                    {
                        Description  = "Description of Property 2",
                        PropertyType = typeof(bool),
                        DefaultValue = false,
                        CanReset     = true,
                    },
                    new CustomProperty("Float", 666.666f)
                    {
                        PropertyType = typeof(float),
                    },
                    new CustomProperty("Long", 1234567L)
                    {
                        Name         = "Long",
                        PropertyType = typeof(long),
                        DefaultValue = 666L,
                        CanReset     = true,
                    },
                    new CustomProperty("WpfColor", Colors.BlueViolet)
                    {
                        PropertyType = typeof(Color),
                        DefaultValue = Colors.Black,
                        CanReset     = true,
                    },
                },
            };
        }
예제 #5
0
        private void OnOutlineSelectedItemsChanged(object sender, NotifyCollectionChangedEventArgs eventArgs)
        {
            // The selection has changed. --> Update Properties window.

            if (_propertiesService == null)
            {
                return;
            }
            if (_outlineService == null)
            {
                return;
            }

            // Do nothing if the Outline window is displaying a different outline.
            if (_outlineService.Outline != Outline)
            {
                return;
            }

            // Per default, we show the general model info.
            _currentPropertySource = _modelPropertySource;

            // If something in the Outline window is selected, we show the selected item.
            if (Outline.SelectedItems.Count > 0)
            {
                var selectedItem = Outline.SelectedItems[0];
                var userData     = selectedItem.UserData;
                if (userData != null)
                {
                    _currentPropertySource = PropertyGridHelper.CreatePropertySource(
                        selectedItem.UserData,
                        selectedItem.Text);
                }
            }

            _propertiesService.PropertySource = _currentPropertySource;
        }