public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            FlowDirection returnValue = FlowDirection.LeftToRight;

            Fx.Assert(values.Length == 3, "Incorrect values in the MultiValueConverter!");
            if (values.Length == 3)
            {
                ModelPropertyEntry propertyEntry = values[1] as ModelPropertyEntry;
                if (propertyEntry != null)
                {
                    if (!propertyEntry.DisplayName.Equals("Name"))
                    {
                        if (targetType == typeof(FlowDirection))
                        {
                            object propertyValue = values[0];
                            if (propertyValue == null || propertyValue.GetType() == typeof(string))
                            {
                                //customize it to controls FlowDirection Property
                                returnValue = (FlowDirection)PropertyInspectorResources.GetResources()["SelectedControlFlowDirectionRTL"];
                            }
                        }
                    }
                }
            }
            return(returnValue);
        }
        // <summary>
        // Basic ctor
        // </summary>
        // <param name="property">Property to display</param>
        // <param name="valueDialogTemplate">Template to use</param>
        public PropertyValueDialogControl(PropertyEntry property, DataTemplate valueDialogTemplate)
        {
            Fx.Assert(property != null, "property parameter is null");
            Fx.Assert(valueDialogTemplate != null, "valueDialogTemplate parameter is null");

            ModelPropertyEntry modelPropertyValue = property as ModelPropertyEntry;

            if (modelPropertyValue != null)
            {
                _rootTransaction = modelPropertyValue.FirstModelProperty.Value.BeginEdit();
            }

            InitializeComponent();

            // Make sure we use PI-specific resources within this control
            this.Resources.MergedDictionaries.Add(PropertyInspectorResources.GetResources());

            // Hook into an opening of nested dialogs.  PropertyInspector class takes care of this for us.
            // However, we are using Blend's collection editor which doesn't do the same thing, so
            // we need to reproduce that behavior manually.
            PropertyValueDialogHost.AttachOpenDialogHandlers(this);

            // Hook into the standard set of Commands
            _defaultCommandHandler = new PropertyValueEditorCommandHandler(this);


            _OKButton.Click                += new RoutedEventHandler(OnOkButtonClicked);
            _cancelButton.Click            += new RoutedEventHandler(OnCancelButtonClicked);
            _contentControl.Content         = property.PropertyValue;
            _contentControl.ContentTemplate = valueDialogTemplate;

            //Handle the commit and cancel keys within the property inspector, that is hosted in the collection editor
            ValueEditorUtils.SetHandlesCommitKeys(this, true);
        }
 // <summary>
 // Apply the FlowDirection to the resource.
 // </summary>
 private void CheckAndSetFlowDirectionResource()
 {
     // Check if the value being edited is FlowDirection
     // and if so, reset the resource to the current value that the user is setting.
     // This will refresh the property inspector and all the string editors, showing "string" properties,
     // would have their FlowDirection set to the current value.
     if (ParentModelPropertyEntry.PropertyName.Equals(FrameworkElement.FlowDirectionProperty.Name))
     {
         object value = Value;
         if (value != null)
         {
             PropertyInspectorResources.GetResources()["SelectedControlFlowDirectionRTL"] = value;
         }
     }
 }
        // Updates PI when the application becomes Idle (perf optimization)
        private void OnSelectionChangedIdle()
        {
            if (DesignerPerfEventProvider != null)
            {
                DesignerPerfEventProvider.PropertyInspectorUpdatePropertyListStart();
            }

            if (AreSelectionsEquivalent(_lastNotifiedSelection, _displayedSelection))
            {
                return;
            }

            if (!VisualTreeUtils.IsVisible(this))
            {
                return;
            }

            // Change the SelectedControlFlowDirectionRTL resource property
            // This will allow the 3rd party editors to look at this property
            // and change to RTL for controls that support RTL.
            // We set the resource to the primary selections RTL property.
            FlowDirection commmonFD = this.FlowDirection;

            if (_lastNotifiedSelection != null && _lastNotifiedSelection.PrimarySelection != null)
            {
                FrameworkElement selectedElement = _lastNotifiedSelection.PrimarySelection.View as FrameworkElement;
                if (selectedElement != null)
                {
                    commmonFD = selectedElement.FlowDirection;
                }

                // In case of mulitislection,
                // if the FlowDirection is different then always set it to LTR.
                // else set it to common FD.
                if (_lastNotifiedSelection.SelectionCount > 1)
                {
                    foreach (ModelItem item in _lastNotifiedSelection.SelectedObjects)
                    {
                        FrameworkElement curElm = item.View as FrameworkElement;
                        if (curElm != null && curElm.FlowDirection != commmonFD)
                        {
                            //reset to LTR (since the FD's are different within multiselect)
                            commmonFD = FlowDirection.LeftToRight;
                            break;
                        }
                    }
                }
            }

            PropertyInspectorResources.GetResources()["SelectedControlFlowDirectionRTL"] = commmonFD;

            RefreshPropertyList(false);

            UpdateSelectionPropertyChangedEventHooks(_displayedSelection, _lastNotifiedSelection);
            _displayedSelection = _lastNotifiedSelection;
            _lastParent         = GetCommonParent(_lastNotifiedSelection);

            // Handle dangling transactions
            _defaultCommandHandler.CommitOpenTransactions();

            OnPropertyChanged("IsInfoBarNameReadOnly");
            OnPropertyChanged("SelectionName");
            OnPropertyChanged("SelectionIcon");
            OnPropertyChanged("SelectionTypeName");
        }
 // This class can have a private ctor because we instantiate it through code,
 // not through XAML or attributes
 private SubPropertyViewEditor()
     : base(
         PropertyInspectorResources.GetResources()["MarkerSubPropertyTemplate"] as DataTemplate,
         PropertyInspectorResources.GetResources()["MarkerSubPropertyTemplate"] as DataTemplate)
 {
 }
Exemple #6
0
 public BoolViewEditor()
     :
     base(PropertyInspectorResources.GetResources()["BoolViewTemplate"] as DataTemplate)
 {
 }
 void InitializePropertyInspectorResources()
 {
     this.propertyInspector.Resources.MergedDictionaries.Add(PropertyInspectorResources.GetResources());
 }