Esempio n. 1
0
 internal virtual DataTemplate GetPropertyValueEditor(PropertyContainerEditMode mode)
 {
     if (mode != PropertyContainerEditMode.Inline)
     {
         return((DataTemplate)null);
     }
     return(this._inlineEditorTemplate);
 }
        /// <summary>
        /// Helper class that attempts to find the DataTemplate for the requested PropertyContainerEditMode
        /// given the currently displayed PropertyEntry and the currently set default PropertyValueEditors.
        ///
        /// If the requested DataTemplate is found on the PropertyValueEditor associated with the displayed
        /// control, is it returned.
        ///
        /// Otherwise if the requested DataTemplate is found on DefaultStandardValuesPropertyValueEditor,
        /// it is returned.
        ///
        /// Otherwise if the requested DataTemplate is found on DefaultPropertyValueEditor,
        /// it is returned.
        ///
        /// Otherwise null is returned.
        /// </summary>
        /// <param name="editMode">The editMode for which the DataTemplate should be retrieved</param>
        /// <returns>Most relevant DataTemplate for the specified edit mode based on the currently
        /// displayed PropertyEntry and the current set of default PropertyValueEditors, or null if not
        /// found.</returns>
        private DataTemplate FindPropertyValueEditorTemplate(PropertyContainerEditMode editMode)
        {
            PropertyEntry       property          = this.PropertyEntry;
            PropertyValueEditor editor            = null;
            DataTemplate        requestedTemplate = null;

            // Look at property
            if (property != null)
            {
                editor = property.PropertyValueEditor;
                if (editor != null)
                {
                    requestedTemplate = editor.GetPropertyValueEditor(editMode);
                }
            }

            if (requestedTemplate != null)
            {
                return(requestedTemplate);
            }

            // Is the property of type enum and used as flags?
            if (IsFlagsProperty(property))
            {
                requestedTemplate = this.GetFlagEditorTemplate(editMode);
            }

            if (requestedTemplate != null)
            {
                return(requestedTemplate);
            }

            // Does the property have standard values?
            if (property != null && property.HasStandardValuesInternal)
            {
                editor = this.DefaultStandardValuesPropertyValueEditor;
                if (editor != null)
                {
                    requestedTemplate = editor.GetPropertyValueEditor(editMode);
                }
            }

            if (requestedTemplate != null)
            {
                return(requestedTemplate);
            }

            // Use the default
            editor = this.DefaultPropertyValueEditor;
            if (editor != null)
            {
                requestedTemplate = editor.GetPropertyValueEditor(editMode);
            }

            return(requestedTemplate);
        }
Esempio n. 3
0
        private void ChangeActiveEditMode(PropertyContainerEditMode editMode)
        {
            PropertyContainer propertyContainer = (PropertyContainer)this.GetValue(PropertyContainer.OwningPropertyContainerProperty);

            if (propertyContainer == null)
            {
                return;
            }
            propertyContainer.ActiveEditMode = editMode;
        }
Esempio n. 4
0
        private void ChangeActiveEditMode(PropertyContainerEditMode editMode)
        {
            PropertyContainer propertyContainer = (PropertyContainer)this.GetValue((DependencyProperty)PropertyContainer.OwningPropertyContainerProperty);

            if (propertyContainer == null)
            {
                return;
            }
            propertyContainer.set_ActiveEditMode(editMode);
        }
Esempio n. 5
0
        private void SwitchPropertyContainerMode(ExecutedRoutedEventArgs eventArgs, PropertyContainerEditMode newMode)
        {
            PropertyContainer propertyContainer = PropertyEditingHelper.GetPropertyContainer(eventArgs.OriginalSource);

            if (propertyContainer == null)
            {
                return;
            }
            propertyContainer.set_ActiveEditMode(newMode);
            eventArgs.Handled = true;
        }
        internal bool SupportsEditMode(PropertyContainerEditMode mode)
        {
            // special handling for dialog editor
            if (mode == PropertyContainerEditMode.Dialog)
            {
                return(FindDialogPropertyValueEditor() != null);
            }

            // for everything else
            return(FindPropertyValueEditorTemplate(mode) != null);
        }
        private static void SwitchActiveEditMode(ExecutedRoutedEventArgs e, PropertyContainerEditMode newMode)
        {
            PropertyContainer container = GetContainerFromEventArgs(e);

            if (container == null)
            {
                return;
            }

            container.ActiveEditMode = newMode;
        }
Esempio n. 8
0
        internal override DataTemplate GetPropertyValueEditor(PropertyContainerEditMode mode)
        {
            DataTemplate propertyValueEditor = base.GetPropertyValueEditor(mode);

            if (propertyValueEditor != null)
            {
                return(propertyValueEditor);
            }
            if (mode != PropertyContainerEditMode.Dialog)
            {
                return((DataTemplate)null);
            }
            return(this._dialogEditorTemplate);
        }
        internal override DataTemplate GetPropertyValueEditor(PropertyContainerEditMode mode)
        {
            DataTemplate propertyValueEditor = base.GetPropertyValueEditor(mode);

            if (propertyValueEditor != null)
            {
                return(propertyValueEditor);
            }
            if (mode != PropertyContainerEditMode.ExtendedPinned && mode != PropertyContainerEditMode.ExtendedPopup)
            {
                return((DataTemplate)null);
            }
            return(this._extendedEditorTemplate);
        }
        // <summary>
        // Stores the current ActiveEditMode for the specified property
        // </summary>
        // <param name="property">Property to key off of</param>
        // <param name="editMode">ActiveEditMode value to store</param>
        public void StoreActiveEditMode(PropertyEntry property, PropertyContainerEditMode editMode) 
        {
            string path = ModelUtilities.GetCachedSubPropertyHierarchyPath(property);

            // We only care about storing the ExtendedPinned state.  Everything
            // else is transitory and shouldn't be persisted.
            //
            if (editMode == PropertyContainerEditMode.ExtendedPinned)
            {
                _expandedPropertyEditors[path] = null;
            }
            else
            {
                _expandedPropertyEditors.Remove(path);
            }
        }
        // <summary>
        // Stores the current ActiveEditMode for the specified property
        // </summary>
        // <param name="property">Property to key off of</param>
        // <param name="editMode">ActiveEditMode value to store</param>
        public void StoreActiveEditMode(PropertyEntry property, PropertyContainerEditMode editMode)
        {
            string path = ModelUtilities.GetCachedSubPropertyHierarchyPath(property);

            // We only care about storing the ExtendedPinned state.  Everything
            // else is transitory and shouldn't be persisted.
            //
            if (editMode == PropertyContainerEditMode.ExtendedPinned)
            {
                _expandedPropertyEditors[path] = null;
            }
            else
            {
                _expandedPropertyEditors.Remove(path);
            }
        }
        // Updates the ControlTemplate of this control based on the currently ActiveEditMode
        private static void UpdateControlTemplate(PropertyContainer container)
        {
            PropertyContainerEditMode editMode    = container.ActiveEditMode;
            ControlTemplate           newTemplate = null;

            switch (editMode)
            {
            case PropertyContainerEditMode.Inline:
                newTemplate = container.InlineRowTemplate;
                break;

            case PropertyContainerEditMode.ExtendedPopup:
                newTemplate = container.ExtendedPopupRowTemplate;
                break;

            case PropertyContainerEditMode.ExtendedPinned:
                newTemplate = container.ExtendedPinnedRowTemplate;
                break;

            case PropertyContainerEditMode.Dialog:
                // In dialog case, just keep the same value
                return;

            default:
                Debug.Fail(
                    string.Format(
                        System.Globalization.CultureInfo.CurrentCulture,
                        "PropertyContainerEditMode does not yet support PropertyContainerEditMode '{0}'.",
                        editMode.ToString()));
                newTemplate = container.Template;
                break;
            }

            if (newTemplate != container.Template)
            {
                container.Template = newTemplate;
            }
        }
Esempio n. 13
0
        private DataTemplate FindPropertyValueEditorTemplate(PropertyContainerEditMode editMode)
        {
            PropertyEntry propertyEntry = this.PropertyEntry;
            DataTemplate  dataTemplate  = (DataTemplate)null;

            if (propertyEntry != null && dataTemplate == null)
            {
                PropertyValueEditor propertyValueEditor = propertyEntry.PropertyValueEditor;
                if (propertyValueEditor != null)
                {
                    dataTemplate = propertyValueEditor.GetPropertyValueEditor(editMode);
                }
            }
            if (dataTemplate != null)
            {
                return(dataTemplate);
            }
            if (propertyEntry != null && propertyEntry.HasStandardValuesInternal)
            {
                PropertyValueEditor propertyValueEditor = this.DefaultStandardValuesPropertyValueEditor;
                if (propertyValueEditor != null)
                {
                    dataTemplate = propertyValueEditor.GetPropertyValueEditor(editMode);
                }
            }
            if (dataTemplate != null)
            {
                return(dataTemplate);
            }
            PropertyValueEditor propertyValueEditor1 = this.DefaultPropertyValueEditor;

            if (propertyValueEditor1 != null)
            {
                dataTemplate = propertyValueEditor1.GetPropertyValueEditor(editMode);
            }
            return(dataTemplate);
        }
        DataTemplate GetFlagEditorTemplate(PropertyContainerEditMode editMode)
        {
            Type propertyType = this.PropertyEntry.PropertyType;

            if (editMode == PropertyContainerEditMode.Inline)
            {
                if (this.flagEditorTemplate == null)
                {
                    this.flagEditorTemplate            = new DataTemplate();
                    this.flagEditorTemplate.VisualTree = new FrameworkElementFactory(typeof(FlagEditor));
                    this.flagEditorTemplate.VisualTree.SetValue(FlagEditor.FlagTypeProperty, propertyType);
                    Binding binding = new Binding("Value");
                    binding.Converter           = new FlagStringConverter();
                    binding.ConverterParameter  = propertyType;
                    binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
                    this.flagEditorTemplate.VisualTree.SetBinding(FlagEditor.TextProperty, binding);
                }
                return(this.flagEditorTemplate);
            }
            else
            {
                return(null);
            }
        }
 internal override DataTemplate GetPropertyValueEditor(PropertyContainerEditMode mode) {
     return base.GetPropertyValueEditor(mode) ??
         (mode == PropertyContainerEditMode.Dialog ? _dialogEditorTemplate : (DataTemplate)null);
 }
 internal override DataTemplate GetPropertyValueEditor(PropertyContainerEditMode mode)
 {
     return(base.GetPropertyValueEditor(mode) ??
            (mode == PropertyContainerEditMode.Dialog ? _dialogEditorTemplate : (DataTemplate)null));
 }
        /// <summary>
        /// Helper class that attempts to find the DataTemplate for the requested PropertyContainerEditMode
        /// given the currently displayed PropertyEntry and the currently set default PropertyValueEditors.
        /// 
        /// If the requested DataTemplate is found on the PropertyValueEditor associated with the displayed
        /// control, is it returned.
        /// 
        /// Otherwise if the requested DataTemplate is found on DefaultStandardValuesPropertyValueEditor,
        /// it is returned.
        /// 
        /// Otherwise if the requested DataTemplate is found on DefaultPropertyValueEditor,
        /// it is returned.
        /// 
        /// Otherwise null is returned.
        /// </summary>
        /// <param name="editMode">The editMode for which the DataTemplate should be retrieved</param>
        /// <returns>Most relevant DataTemplate for the specified edit mode based on the currently
        /// displayed PropertyEntry and the current set of default PropertyValueEditors, or null if not
        /// found.</returns>
        private DataTemplate FindPropertyValueEditorTemplate(PropertyContainerEditMode editMode)
        {
            PropertyEntry property = this.PropertyEntry;
            PropertyValueEditor editor = null;
            DataTemplate requestedTemplate = null;

            // Look at property
            if (property != null)
            {
                editor = property.PropertyValueEditor;
                if (editor != null)
                {
                    requestedTemplate = editor.GetPropertyValueEditor(editMode);
                }
            }

            if (requestedTemplate != null)
                return requestedTemplate;

            // Is the property of type enum and used as flags?
            if (IsFlagsProperty(property))
            {
                requestedTemplate = this.GetFlagEditorTemplate(editMode);
            }

            if (requestedTemplate != null)
            {
                return requestedTemplate;
            }

            // Does the property have standard values?
            if (property != null && property.HasStandardValuesInternal)
            {
                editor = this.DefaultStandardValuesPropertyValueEditor;
                if (editor != null)
                {
                    requestedTemplate = editor.GetPropertyValueEditor(editMode);
                }
            }

            if (requestedTemplate != null)
                return requestedTemplate;

            // Use the default
            editor = this.DefaultPropertyValueEditor;
            if (editor != null)
            {
                requestedTemplate = editor.GetPropertyValueEditor(editMode);
            }

            return requestedTemplate;
        }
 DataTemplate GetFlagEditorTemplate(PropertyContainerEditMode editMode)
 {
     Type propertyType = this.PropertyEntry.PropertyType;
     if (editMode == PropertyContainerEditMode.Inline)
     {
         if (this.flagEditorTemplate == null)
         {
             this.flagEditorTemplate = new DataTemplate();
             this.flagEditorTemplate.VisualTree = new FrameworkElementFactory(typeof(FlagEditor));
             this.flagEditorTemplate.VisualTree.SetValue(FlagEditor.FlagTypeProperty, propertyType);
             Binding binding = new Binding("Value");
             binding.Converter = new FlagStringConverter();
             binding.ConverterParameter = propertyType;
             binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
             this.flagEditorTemplate.VisualTree.SetBinding(FlagEditor.TextProperty, binding);
         }
         return this.flagEditorTemplate;
     }
     else
     {
         return null;
     }
 }
        private static void SwitchActiveEditMode(ExecutedRoutedEventArgs e, PropertyContainerEditMode newMode) 
        {
            PropertyContainer container = GetContainerFromEventArgs(e);
            if (container == null)
            {
                return;
            }

            container.ActiveEditMode = newMode;
        }
 internal virtual DataTemplate GetPropertyValueEditor(PropertyContainerEditMode mode) {
     return (mode == PropertyContainerEditMode.Inline) ? _inlineEditorTemplate : null;
 }
        internal bool SupportsEditMode(PropertyContainerEditMode mode)
        {
            // special handling for dialog editor
            if (mode == PropertyContainerEditMode.Dialog)
                return FindDialogPropertyValueEditor() != null;

            // for everything else
            return FindPropertyValueEditorTemplate(mode) != null;
        }
 internal override DataTemplate GetPropertyValueEditor(PropertyContainerEditMode mode)
 {
     return(base.GetPropertyValueEditor(mode) ??
            ((mode == PropertyContainerEditMode.ExtendedPinned ||
              mode == PropertyContainerEditMode.ExtendedPopup) ? _extendedEditorTemplate : (DataTemplate)null));
 }
Esempio n. 23
0
 internal virtual DataTemplate GetPropertyValueEditor(PropertyContainerEditMode mode)
 {
     return((mode == PropertyContainerEditMode.Inline) ? _inlineEditorTemplate : null);
 }
 internal override DataTemplate GetPropertyValueEditor(PropertyContainerEditMode mode) {
     return base.GetPropertyValueEditor(mode) ??
         ((mode == PropertyContainerEditMode.ExtendedPinned ||
           mode == PropertyContainerEditMode.ExtendedPopup) ? _extendedEditorTemplate : (DataTemplate)null);
 }