Ejemplo 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);
        }
Ejemplo n.º 2
0
        private void OnActivateCommand()
        {
            PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.ActivateProjectItem);
            INamedProject namedProject = base.Services.ProjectManager().CurrentSolution.FindProjectContainingOpenItem(this.projectItem.DocumentReference);

            if (namedProject != null && namedProject != this.ProjectItem.Project)
            {
                base.Services.MessageDisplayService().ShowError(StringTable.ProjectItemAlreadyOpenMessage);
                return;
            }
            IView activeView = base.Services.ViewService().ActiveView;

            if (!this.projectItem.DocumentType.CanView)
            {
                if (this.projectItem is FolderStandIn || this.projectItem.DocumentType == base.Services.DocumentTypes()[DocumentTypeNamesHelper.Folder])
                {
                    this.IsExpanded = !this.IsExpanded;
                    return;
                }
                if (activeView != null && this.projectItem.DocumentType.CanInsertTo(this.projectItem, activeView))
                {
                    this.projectItem.DocumentType.AddToDocument(this.projectItem, activeView);
                    return;
                }
                if (Microsoft.Expression.Framework.Documents.PathHelper.FileExists(this.projectItem.DocumentReference.Path))
                {
                    CommandTarget commandTarget = base.Services.ProjectManager() as CommandTarget;
                    if (commandTarget != null)
                    {
                        string str = "Project_EditExternally";
                        commandTarget.SetCommandProperty(str, "TargetDocument", this.ProjectItem);
                        commandTarget.Execute(str, CommandInvocationSource.Palette);
                    }
                }
            }
            else
            {
                using (IDisposable disposable = TemporaryCursor.SetWaitCursor())
                {
                    this.projectItem.OpenView(true);
                }
            }
        }