public ValidateCommand(ElementViewModel viewModel, IUIServiceWpf uiService) : base(uiService) { this.viewModel = viewModel; this.keyGestureConverter = new KeyGestureConverter(); }
private void InitializeChangeEvents(ElementViewModel element) { element.PropertyChanged += elementPropertyChanged; element.Deleted += elementDeleted; }
public ElementProperty(IServiceProvider serviceProvider, ElementViewModel parent, PropertyDescriptor declaringProperty) : this(serviceProvider, parent, declaringProperty, new Attribute[0]) { }
/// <summary> /// Returns the <see cref="BindableProperty.BindableValue"/> for an element that is displayed in a suggested value list. /// </summary> /// <param name="element">The element to collect a value for.</param> /// <returns>A string value for the element.</returns> protected virtual string GetValueFromElement(ElementViewModel element) { return(element.NameProperty.BindableProperty.BindableValue); }
public ElementReferenceProperty(IServiceProvider serviceProvider, ElementLookup lookup, ElementViewModel parent, PropertyDescriptor declaringProperty, IEnumerable <Attribute> additionalAttributes) : base(serviceProvider, parent, declaringProperty, additionalAttributes.Union(new Attribute[] { new ValidationAttribute(typeof(ElementReferenceValidator)) })) { if (declaringProperty.PropertyType != typeof(string)) { throw new ArgumentException(Resources.ReferencePropertyInvalidType); } this.lookup = lookup; this.changeScopePropertyWatcher = new ChangeScopePropertyWatcher(); this.changeScopePropertyWatcher.ChangeScopePropertyChanged += new EventHandler(ChangeScopePropertyWatcherChangeScopePropertyChanged); referenceAttribute = base.Attributes.OfType <ReferenceAttribute>().FirstOrDefault(); Debug.Assert(referenceAttribute != null); ((INotifyCollectionChanged)ValidationResults).CollectionChanged += ValidationCollectionChanged; }
/// <summary> /// Adds any related child elements to the specified element. /// </summary> /// <param name="element">The element to find related elements for.</param> /// <param name="relatedElements">The set of related elements.</param> protected static void AddChildrenRelatedElements(ElementViewModel element, Collection <ElementViewModel> relatedElements) { relatedElements.AddRange(element.ChildElements); }
///<summary> /// Creates a delete command for the supplied <see cref="ElementViewModel"/>. ///</summary> ///<param name="elementViewModel">The element the delete command applies to.</param> ///<param name="attributes">Attributes that may override the type of delete command created.</param> ///<returns>A delete command for the element based on a <see cref="CommandAttribute"/> in <paramref name="attributes"/> or an instance of <see cref="DefaultDeleteCommandModel"/>.</returns> ///<seealso cref="CreateDeleteCommand(Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ViewModel.ElementViewModel,System.Collections.Generic.IEnumerable{System.Attribute},System.Type)"/> ///<exception>Errors in creating the underlying object may result in a <see cref="ResolutionFailedException"/></exception> public CommandModel CreateDeleteCommand(ElementViewModel elementViewModel, IEnumerable <Attribute> attributes) { return(CreateDeleteCommand(elementViewModel, attributes, typeof(DefaultDeleteCommandModel))); }
///<summary> /// Initializes a new instance of the <see cref="DefaultElementConfigurationProperty"/> class. ///</summary> ///<param name="serviceProvider">The service provider used to locate certain services for the configuration system.</param> ///<param name="parent">The parent <see cref="ElementViewModel"/> that owns the property.</param> ///<param name="declaringProperty">The description of the property.</param> ///<param name="additionalAttributes">Additional attributes made available to the property.</param> public DefaultElementConfigurationProperty(IServiceProvider serviceProvider, ElementViewModel parent, PropertyDescriptor declaringProperty, IEnumerable <Attribute> additionalAttributes) : base(serviceProvider, parent, declaringProperty, additionalAttributes) { }
/// <summary> /// Gets a value that indicates this extender provides <see cref="Property"/> /// elements to a <see cref="ElementViewModel"/>. /// </summary> /// <param name="subject">The <see cref="ElementViewModel"/> to determine properties for.</param> /// <returns> /// Should return <see langword="true"/> if this extender provides properties for the <paramref name="subject"/>. /// Otherwise, returns <see langword="false"/>. /// </returns> public bool CanExtend(ElementViewModel subject) { return(typeof(ICustomProviderData).IsAssignableFrom(subject.ConfigurationType) && TypeDescriptor.GetAttributes(subject.ConfigurationElement).OfType <OmitCustomAttributesPropertyAttribute>().Count() == 0); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultDeleteCommandModel"/> class. /// </summary> /// <param name="elementViewModel">The <see cref="ElementViewModel"/> instance this command applies to.</param> /// <param name="uiService"><see cref="IUIServiceWpf"/> for invoking messages or other windows.</param> public DefaultDeleteCommandModel(ElementViewModel elementViewModel, IUIServiceWpf uiService) : base(uiService) { this.elementViewModel = elementViewModel; }
public DefaultElementConfigurationProperty(IServiceProvider serviceProvider, ElementViewModel parent, PropertyDescriptor declaringProperty) : base(serviceProvider, parent, declaringProperty) { }
public ElementViewModel(ElementViewModel parentElementModel, PropertyDescriptor declaringProperty) : this(parentElementModel, declaringProperty, new Attribute[0]) { }
/// <summary> /// Adds an element to the <see cref="ChildElements"/> collection. /// </summary> /// <param name="element"></param> protected void AddChildToView(ElementViewModel element) { EnsureHasChildElements(); childElements.Add(element); }
/// <summary> /// Removes an element from the <see cref="ChildElements"/> collection. /// </summary> /// <param name="element"></param> protected void RemoveChildFromView(ElementViewModel element) { EnsureHasChildElements(); childElements.Remove(element); }
/// <summary> /// Adds elements that an element visually refers to in within the section. /// </summary> /// <param name="element">The element to find related elements for.</param> /// <param name="relatedElements">The set of related elements.</param> protected static void AddReferredToRelatedElements(ElementViewModel element, Collection <ElementViewModel> relatedElements) { relatedElements.AddRange(element.Properties.OfType <ElementReferenceProperty>() .Where(x => x.ReferencedElement != null) .Select(x => x.ReferencedElement)); }
private void RemoveElementPropertyMonitoring(ElementViewModel element) { this.elementsMonitored.Remove(element); element.Properties.CollectionChanged -= ElementPropertiesCollectionChangedHandler; }
/// <summary> /// Adds elements that visually refer to an element within the section. /// </summary> /// <param name="element">The element to find related elements for.</param> /// <param name="relatedElements">The set of related elements.</param> protected void AddReferredFromRelatedElements(ElementViewModel element, Collection <ElementViewModel> relatedElements) { relatedElements.AddRange(DescendentElements(x => x.Properties.OfType <ElementReferenceProperty>().Where(y => y.ReferencedElement == element).Any())); }
public ConfigurationProperty(IServiceProvider serviceProvider, ElementViewModel parent, PropertyDescriptor declaringProperty) : base(serviceProvider, parent, declaringProperty, new Attribute[] { new DesignTimeReadOnlyAttribute(false) }) { }
/// <summary> /// Adds children of any child collections related this the specified element. /// </summary> /// <param name="element">The element to find related elements for.</param> /// <param name="relatedElements">The set of related elements.</param> protected static void AddCollectionChildrenRelatedElement(ElementViewModel element, Collection <ElementViewModel> relatedElements) { relatedElements.AddRange(element.ChildElements.OfType <ElementCollectionViewModel>().SelectMany(x => x.ChildElements).OfType <CollectionElementViewModel>().Cast <ElementViewModel>()); }
/// <summary> /// Initializes a new instance of <see cref="TypeNameProperty"/>. /// </summary> /// <param name="serviceProvider">The service provider to use in locating services.</param> /// <param name="parent">The parent element.</param> /// <param name="declaringProperty">The declaring <see cref="PropertyDescriptor"/> for this property.</param> public TypeNameProperty(IServiceProvider serviceProvider, ElementViewModel parent, PropertyDescriptor declaringProperty) : base(serviceProvider, parent, declaringProperty) { }
///<summary> /// Creates a <see cref="CommandModel"/> with the specified <see cref="ElementViewModel"/> as a constructor parameter. ///</summary> ///<param name="target">The <see cref="ElementViewModel"/> to provide as constructor context for the command.</param> ///<typeparam name="TCommandModel">The <see cref="CommandModel"/> type to create.</typeparam> ///<returns>The created <see cref="CommandModel"/></returns> /// <exception>Errors in creating the underlying object may result in a <see cref="ResolutionFailedException"/></exception> public TCommandModel CreateCommand <TCommandModel>(ElementViewModel target) where TCommandModel : CommandModel { return(builder.Resolve <TCommandModel>(new DependencyOverride(typeof(ElementViewModel), target))); }
public TimeSpanElementConfigurationProperty(IServiceProvider serviceProvider, ElementViewModel parent, PropertyDescriptor declaringProperty) : base(serviceProvider, parent, declaringProperty, new Attribute[] { new TypeConverterAttribute(typeof(StrictTimeSpanTypeConverter)) }) { }
public ElementReferenceProperty(IServiceProvider serviceProvider, ElementLookup lookup, ElementViewModel parent, PropertyDescriptor declaringProperty) : this(serviceProvider, lookup, parent, declaringProperty, Enumerable.Empty <Attribute>()) { }
/// <summary> /// Initializes a new instance of the <see cref="TimeSpanElementConfigurationProperty"/> class. /// </summary> /// <param name="serviceProvider">The service provider used to locate certain services for the configuration system.</param> /// <param name="parent">The parent <see cref="ElementViewModel"/> that owns the property.</param> /// <param name="declaringProperty">The description of the property.</param> /// <param name="additionalAttributes">Additional attributes made available to the property.</param> public TimeSpanElementConfigurationProperty(IServiceProvider serviceProvider, ElementViewModel parent, PropertyDescriptor declaringProperty, IEnumerable <Attribute> additionalAttributes) : base(serviceProvider, parent, declaringProperty, additionalAttributes.Union(new Attribute[] { new TypeConverterAttribute(typeof(StrictTimeSpanTypeConverter)) })) { }
/// <summary> /// Creates a new instnace of <see cref="CollectionEditorContainedElementProperty"/> /// </summary> /// <param name="serviceProvider"></param> /// <param name="parent">The parent element view model.</param> /// <param name="declaringProperty">The declaring property descriptor.</param> public CollectionEditorContainedElementProperty(IServiceProvider serviceProvider, ElementViewModel parent, PropertyDescriptor declaringProperty) : base(serviceProvider, parent, declaringProperty, Enumerable.Empty <Attribute>()) { logicalParentElement = parent.ParentElement.ParentElement; }
/// <summary> /// Initializes a new instance of <see cref="HeaderedListLayout"/>. /// </summary> /// <param name="containingElement">The <see cref="ElementViewModel"/> instance that should be displayed as a headered list.</param> public HeaderedListLayout(ElementViewModel containingElement) : base(new HeaderLayout(containingElement.Name, containingElement.Commands), new ElementListLayout(containingElement.ChildElements)) { }
public CollectionEditorContainedElementReferenceProperty(IServiceProvider serviceProvider, ElementLookup lookup, ElementViewModel parent, PropertyDescriptor declaringProperty) : base(serviceProvider, lookup, parent, declaringProperty) { logicalParentElement = parent.ParentElement.ParentElement; }
/// <summary> /// Initializes a new instance of <see cref="HeaderedListLayout"/> with the specified contextual commands. /// </summary> /// <param name="containingElement">The <see cref="ElementViewModel"/> instance that should be displayed as a headered list.</param> /// <param name="commands">A specific list of <see cref="CommandModel"/> that should be displayed for the add (+) button in the UI.</param> public HeaderedListLayout(ElementViewModel containingElement, IEnumerable <CommandModel> commands) : base(new HeaderLayout(containingElement.Name, commands), new ElementListLayout(containingElement.ChildElements)) { }
/// <summary> /// Initializes a new instance of <see cref="HierarchicalLayout"/>. /// </summary> /// <param name="current">The <see cref="ElementViewModel"/> instance that should be displayed on the left side.</param> /// <param name="children">The set of <see cref="ElementViewModel"/> instances that should be displayed as <paramref name="current"/>'s children.</param> /// <param name="columnIndex">The 0-based column index that should be used to display and resize the <paramref name="current"/> element. </param> public HierarchicalLayout(ElementViewModel current, IEnumerable <ElementViewModel> children, int columnIndex) : base(current, new ElementListLayout(children), columnIndex) { }
public ToggleShowPropertiesCommand(ElementViewModel viewModel, IUIServiceWpf uiService) : base(uiService) { this.viewModel = viewModel; }