public static SceneNode CreateValueConverter(SceneViewModel viewModel) { AddValueConverterDialog valueConverterDialog = new AddValueConverterDialog(viewModel); bool?nullable = valueConverterDialog.ShowDialog(); if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? true : false)) != 0) { Type objectType = valueConverterDialog.ObjectType; string name = valueConverterDialog.ValueConverterResourceKey; if (objectType != (Type)null) { viewModel.ProjectContext.GetType(objectType); SceneNode sceneNode = viewModel.CreateSceneNode(objectType); SceneNode rootNode = viewModel.RootNode; if (rootNode != null) { Microsoft.Expression.DesignSurface.Utility.ResourceHelper.EnsureResourceDictionaryNode(rootNode); ResourceDictionaryNode resourceDictionaryNode = ResourceManager.ProvideResourcesForElement(rootNode); if (resourceDictionaryNode != null) { if (string.IsNullOrEmpty(name)) { name = objectType.Name; } string uniqueResourceKey = resourceDictionaryNode.GetUniqueResourceKey(name); DictionaryEntryNode dictionaryEntryNode = DictionaryEntryNode.Factory.Instantiate((object)uniqueResourceKey, sceneNode); resourceDictionaryNode.Insert(0, dictionaryEntryNode); return((SceneNode)dictionaryEntryNode); } } } } return((SceneNode)null); }
internal static void AddResource(DictionaryEntryNode resourceToAdd, ResourceDictionaryNode destinationDictionary, int insertionIndex) { if (insertionIndex >= 0 && insertionIndex < destinationDictionary.Count) { destinationDictionary.Insert(insertionIndex, resourceToAdd); } else { destinationDictionary.Add(resourceToAdd); } }