Esempio n. 1
0
        private void OnAddItem(object sender, EventArgs e)
        {
            if (this.editingValue == null)
            {
                return;
            }
            SceneNodeProperty sceneNodeProperty = this.editingProperty as SceneNodeProperty;

            if (sceneNodeProperty == null)
            {
                return;
            }
            SceneNodeObjectSet sceneNodeObjectSet = sceneNodeProperty.SceneNodeObjectSet;

            if (sceneNodeObjectSet == null)
            {
                return;
            }
            CommandTarget commandTarget = sceneNodeObjectSet.DesignerContext.ProjectManager as CommandTarget;

            if (commandTarget == null)
            {
                return;
            }
            string   commandName    = "Project_AddExistingItemOfType";
            IProject currentProject = this.GetCurrentProject();

            if (currentProject == null)
            {
                return;
            }
            IDocumentType[] documentTypeArray = this.GetSupportedDocumentTypesFromSelection();
            if (documentTypeArray == UriEditor.multiScaleDocuments)
            {
                List <IDocumentType> list = Enumerable.ToList <IDocumentType>((IEnumerable <IDocumentType>)documentTypeArray);
                list.Remove(sceneNodeObjectSet.DesignerContext.DocumentTypeManager.DocumentTypes[DocumentTypeNamesHelper.DeepZoom]);
                documentTypeArray = list.ToArray();
            }
            commandTarget.SetCommandProperty(commandName, "DocumentTypes", (object)documentTypeArray);
            commandTarget.SetCommandProperty(commandName, "Project", (object)currentProject);
            commandTarget.SetCommandProperty(commandName, "SelectAddedItems", (object)false);
            commandTarget.SetCommandProperty(commandName, "TargetFolder", (object)Microsoft.Expression.Framework.Documents.PathHelper.GetDirectory(sceneNodeObjectSet.ViewModel.Document.DocumentReference.Path));
            commandTarget.SetCommandProperty(commandName, "TemporarilyStopProjectPaneActivation", (object)true);
            using (WorkaroundPopup.LockOpen((DependencyObject)this))
                commandTarget.Execute(commandName, CommandInvocationSource.Palette);
            IProjectItem projectItem = EnumerableExtensions.SingleOrNull <IProjectItem>((IEnumerable <IProjectItem>)commandTarget.GetCommandProperty(commandName, "AddedProjectItems"));

            if (projectItem == null)
            {
                return;
            }
            this.ProjectItemSource = new ProjectItemModel(projectItem, this.DocumentContext, 0);
        }