/// <summary> /// Converts the property value (in respect to multiple source elements) and returns the converted value. /// </summary> /// <returns>Converted property value.</returns> /// <remarks> /// Converter: All equal --> use value. One differs --> empty value. /// </remarks> public override object GetPropertyValue() { Html value = PropertyGridEditorViewModel.GetPropertyValue(this.Elements[0], this.PropertyName) as Html; if (value == null && this.ViewModelStore != null) { IParentModelElement parent = this.ViewModelStore.GetDomainModelServices(this.Elements[0] as ModelElement).ElementParentProvider.GetParentModelElement(this.Elements[0] as ModelElement); if (parent == null) { throw new ArgumentNullException("Parent of element " + this.Elements[0].ToString() + " can not be null"); } string path = parent.DomainFilePath; string dirName = new System.IO.FileInfo(path).DirectoryName; value = new Html("", dirName); //value = new Html("", this.ViewModelStore.GetDomainModelServices(this.Elements[0] as ModelElement).ElementParentProvider.GetDomainModelDirectory(this.Elements[0] as ModelElement)); } return(value); }
/// <summary> /// Assigns the property value to the property of every source element. /// </summary> /// <param name="value">Property value to be assigned.</param> public override void SetPropertyValue(object value) { // empty string values are treated as null... Html html = value as Html; if (html != null) { if (html.HtmlData.Trim() == string.Empty) { html = null; } } using (Transaction transaction = this.Store.TransactionManager.BeginTransaction("Update property value - " + this.PropertyName)) { PropertyGridEditorViewModel.SetPropertyValues(this.Elements, this.PropertyName, value); transaction.Commit(); } // handle errors if (html != null) { if (html.ValidationResult.Count() > 0) { // clear current error list this.EventManager.GetEvent <ErrorListClearItems>().Publish(this); // add serialization result items List <BaseErrorListItemViewModel> items = new List <BaseErrorListItemViewModel>(); foreach (IValidationMessage validationmessage in html.ValidationResult) { StringErrorListItemViewModel item = new StringErrorListItemViewModel(this.ViewModelStore, validationmessage.MessageId, ModelErrorListItemViewModel.ConvertCategory(validationmessage.Type), validationmessage.Description); items.Add(item); } // notify of change this.EventManager.GetEvent <ErrorListAddItems>().Publish(items); } } }
/// <summary> /// Compares two view models by comparing their property display names. /// </summary> /// <param name="x">IPropertyGridEditorViewModel to be compared.</param> /// <param name="y">IPropertyGridEditorViewModel to be compared.</param> /// <returns>Int from Compare.To</returns> private static int CompareViewModels(PropertyGridEditorViewModel x, PropertyGridEditorViewModel y) { return(x.PropertyDisplayName.CompareTo(y.PropertyDisplayName)); }
/// <summary> /// Called whenever the selected editor is changed. /// </summary> public virtual void SelectedEditorChanged(PropertyGridEditorViewModel selectedEditor) { }