private void OnOpenDialogWindow(object sender, ExecutedRoutedEventArgs eventArgs) { PropertyReferenceProperty referenceProperty = (PropertyReferenceProperty)PropertyEditingHelper.GetEditedProperty(eventArgs.OriginalSource, eventArgs.Parameter); DataTemplate dialogEditorTemplate = PropertyEditingHelper.GetDialogEditorTemplate((PropertyEntry)referenceProperty); if (dialogEditorTemplate == null) { return; } Dialog dialog = (Dialog) new DialogValueEditorHost(referenceProperty.get_PropertyValue(), dialogEditorTemplate); int remaining = 0; SceneEditTransaction sceneEditTransaction = (SceneEditTransaction)null; if (this.ActiveDocument != null) { this.CommitOutstandingTransactions(0); sceneEditTransaction = this.ActiveDocument.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.DialogValueEditorUndoDescription, new object[1] { (object)referenceProperty.get_DisplayName() })); this.editTransactions.Push(sceneEditTransaction); remaining = this.editTransactions.Count; } bool?nullable = dialog.ShowDialog(); if (this.ActiveDocument != null) { this.CommitOutstandingTransactions(remaining); if (nullable.HasValue && nullable.Value) { sceneEditTransaction.Commit(); } else { sceneEditTransaction.Cancel(); } this.editTransactions.Pop(); } eventArgs.Handled = true; }
public static PropertyValueEditor GetPropertyEditorTemplate(PropertyReferenceProperty property) { bool flag = false; IProjectContext projectContext = property.ObjectSet.ProjectContext; PropertyValueEditor propertyValueEditor = PropertyEditorTemplateLookup.GetPropertyEditorTemplate(projectContext, property.ObjectSet.DesignerContext, property.PropertyTypeId); if (propertyValueEditor == PropertyEditorTemplateLookup.ObjectEditorTemplate && property.get_PropertyValue().get_CanConvertFromString()) { flag = true; propertyValueEditor = (PropertyValueEditor)null; } SceneNodeProperty sceneNodeProperty = property as SceneNodeProperty; if (propertyValueEditor == null) { if (property.Converter != null && property.Converter.GetPropertiesSupported()) { return(PropertyEditorTemplateLookup.ObjectEditorTemplate); } if (sceneNodeProperty != null && UriEditor.IsPropertySupportedOnType((PropertyReferenceProperty)sceneNodeProperty, sceneNodeProperty.SceneNodeObjectSet.ObjectType)) { DataTemplate dataTemplate = new DataTemplate(); dataTemplate.VisualTree = new FrameworkElementFactory(typeof(UriEditor)); propertyValueEditor = new PropertyValueEditor(dataTemplate); } } if (propertyValueEditor == null && !flag) { IType computedValueTypeId = property.ComputedValueTypeId; if (computedValueTypeId != null) { propertyValueEditor = PropertyEditorTemplateLookup.GetPropertyEditorTemplate(projectContext, property.ObjectSet.DesignerContext, computedValueTypeId); if (propertyValueEditor is PropertyEditorTemplateLookup.CollectionDialogPropertyValueEditor) { propertyValueEditor = (PropertyValueEditor)null; } } } if (((PropertyEntry)property).get_IsReadOnly() && !(propertyValueEditor is PropertyEditorTemplateLookup.CollectionDialogPropertyValueEditor) && !ProjectNeutralTypes.LayoutPathCollection.IsAssignableFrom((ITypeId)property.PropertyTypeId)) { return((PropertyValueEditor)null); } if (sceneNodeProperty != null && propertyValueEditor is PropertyEditorTemplateLookup.CollectionDialogPropertyValueEditor) { bool isMixed; DocumentNode valueAsDocumentNode = sceneNodeProperty.GetLocalValueAsDocumentNode(true, out isMixed); if (valueAsDocumentNode != null && valueAsDocumentNode is DocumentPrimitiveNode) { return((PropertyValueEditor)null); } if (property.PropertyTypeId.IsArray && !property.PropertyTypeId.PlatformMetadata.ResolveType(PlatformTypes.ArrayExtension).IsResolvable) { return((PropertyValueEditor)null); } } return(propertyValueEditor); }