Esempio n. 1
0
 protected static void MoveProjects(SolutionBase from, SolutionBase to)
 {
     for (int i = from.projects.Count - 1; i >= 0; i--)
     {
         INamedProject item = from.projects[i];
         from.RemoveProject(item);
         to.AddProject(item);
     }
 }
Esempio n. 2
0
        private bool SaveProjectItems(bool promptBeforeSaving, bool saveActiveDocument)
        {
            Func <IProjectItem, Microsoft.Expression.Framework.Documents.DocumentReference> documentReference = null;
            Func <IProjectItem, bool> func = null;
            bool flag = true;

            ErrorHandling.HandleBasicExceptions(() => {
                IEnumerable <IProjectItem> dirtyProjectItems = SolutionBase.GetDirtyProjectItems(this.Projects);
                if (!saveActiveDocument)
                {
                    IDocumentView activeView = this.Services.ViewService().ActiveView as IDocumentView;
                    if (activeView != null)
                    {
                        IDocument document = activeView.Document;
                        dirtyProjectItems  =
                            from item in dirtyProjectItems
                            where item.Document != document
                            select item;
                    }
                }
                if (dirtyProjectItems.Any <IProjectItem>())
                {
                    if (promptBeforeSaving)
                    {
                        SaveFilesDialog saveFilesDialog = new SaveFilesDialog(this.Services, dirtyProjectItems);
                        saveFilesDialog.InitializeDialog();
                        saveFilesDialog.ShowDialog();
                        if (saveFilesDialog.Result == ProjectDialog.ProjectDialogResult.Cancel)
                        {
                            flag = false;
                            return;
                        }
                        if (saveFilesDialog.Result == ProjectDialog.ProjectDialogResult.Discard)
                        {
                            flag = true;
                            return;
                        }
                    }
                    if (this.IsSourceControlActive)
                    {
                        IEnumerable <IProjectItem> projectItems = dirtyProjectItems;
                        if (documentReference == null)
                        {
                            documentReference = (IProjectItem item) => item.DocumentReference;
                        }
                        SourceControlHelper.UpdateSourceControl(projectItems.Select <IProjectItem, Microsoft.Expression.Framework.Documents.DocumentReference>(documentReference), UpdateSourceControlActions.Checkout, this.Services);
                    }
                    IEnumerable <IProjectItem> projectItems1 = dirtyProjectItems;
                    if (func == null)
                    {
                        func = (IProjectItem item) => !item.SaveDocumentFile();
                    }
                    flag = !projectItems1.Any <IProjectItem>(func);
                }
            }, (Exception exception) => this.Services.ShowErrorMessage(StringTable.SaveAllFailedDialogMessage, exception));
            return(flag);
        }
Esempio n. 3
0
        private void RefreshSolution()
        {
            MessageBoxResult messageBoxResult;

            if (this.SolutionFileInformation != null && this.SolutionFileInformation.HasChanged())
            {
                string solutionChangedDialogMessage = StringTable.SolutionChangedDialogMessage;
                string path = base.DocumentReference.Path;
                if (!SolutionBase.IsReloadPromptEnabled())
                {
                    messageBoxResult = MessageBoxResult.Yes;
                }
                else
                {
                    MessageBoxArgs messageBoxArg        = new MessageBoxArgs();
                    CultureInfo    currentCulture       = CultureInfo.CurrentCulture;
                    object[]       shortApplicationName = new object[] { path, this.Services.ExpressionInformationService().ShortApplicationName };
                    messageBoxArg.Message = string.Format(currentCulture, solutionChangedDialogMessage, shortApplicationName);
                    messageBoxArg.Button  = MessageBoxButton.YesNo;
                    messageBoxArg.Image   = MessageBoxImage.Exclamation;
                    MessageBoxArgs messageBoxArg1 = messageBoxArg;
                    messageBoxResult = this.Services.MessageDisplayService().ShowMessage(messageBoxArg1);
                }
                if (messageBoxResult == MessageBoxResult.Yes && this.Save(false))
                {
                    this.Services.ExceptionHandler(() => {
                        this.CloseAllProjects();
                        ((ProjectManager)this.Services.ProjectManager()).OnSolutionClosed(new SolutionEventArgs(this));
                        this.LoadInternal();
                        ((ProjectManager)this.Services.ProjectManager()).OnSolutionOpened(new SolutionEventArgs(this));
                        this.reloadDocuments = true;
                        if (this.IsUnderSourceControl)
                        {
                            ISourceControlProvider sourceControlProvider = this.Services.SourceControlProvider();
                            if (sourceControlProvider != null)
                            {
                                sourceControlProvider.OpenProject(base.DocumentReference.Path, false);
                            }
                        }
                        if (this.Services.ProjectManager().ItemSelectionSet.Count == 0)
                        {
                            this.Services.ProjectManager().ItemSelectionSet.SetSelection(this);
                        }
                    }, () => string.Format(CultureInfo.CurrentCulture, StringTable.DialogRefreshFailedMessage, new object[] { base.DocumentReference.Path }));
                }
                this.UpdateFileInformation();
            }
        }
Esempio n. 4
0
        private void Project_ProjectChanged(object o, ProjectEventArgs e)
        {
            MessageBoxResult messageBoxResult;

            if (this.IsDisposed)
            {
                return;
            }
            if (e.Project == null)
            {
                return;
            }
            string projectChangedDialogMessage = StringTable.ProjectChangedDialogMessage;
            string path = e.Project.DocumentReference.Path;

            if (!SolutionBase.IsReloadPromptEnabled())
            {
                messageBoxResult = MessageBoxResult.Yes;
            }
            else
            {
                MessageBoxArgs messageBoxArg        = new MessageBoxArgs();
                CultureInfo    currentCulture       = CultureInfo.CurrentCulture;
                object[]       shortApplicationName = new object[] { path, this.Services.ExpressionInformationService().ShortApplicationName };
                messageBoxArg.Message = string.Format(currentCulture, projectChangedDialogMessage, shortApplicationName);
                messageBoxArg.Button  = MessageBoxButton.YesNo;
                messageBoxArg.Image   = MessageBoxImage.Exclamation;
                MessageBoxArgs messageBoxArg1 = messageBoxArg;
                messageBoxResult = this.Services.MessageDisplayService().ShowMessage(messageBoxArg1);
            }
            if (messageBoxResult == MessageBoxResult.Yes)
            {
                IProject project = e.Project;
                if (project != null && this.Save(false) && this.RefreshProject(project) && this.Services.ProjectManager().ItemSelectionSet.Count == 0)
                {
                    this.Services.ProjectManager().ItemSelectionSet.SetSelection(this);
                }
            }
        }
Esempio n. 5
0
        protected INamedProject InitializeProject(IProjectStore projectStore)
        {
            INamedProject namedProject;
            INamedProject unlicensedProject = null;

            try
            {
                IProjectType projectTypeForProject = this.Services.ProjectTypeManager().GetProjectTypeForProject(projectStore);
                if (projectTypeForProject != null)
                {
                    IProjectCreateError projectCreateError = projectTypeForProject.CanCreateProject(projectStore);
                    if (projectCreateError != null)
                    {
                        projectTypeForProject = this.Services.ProjectTypeManager().UnknownProjectType;
                    }
                    if (projectTypeForProject is UnknownProjectType && SolutionBase.IsReloadPromptEnabled())
                    {
                        InvalidProjectStore invalidProjectStore = projectStore as InvalidProjectStore;
                        if (invalidProjectStore == null || string.IsNullOrEmpty(invalidProjectStore.InvalidStateDescription))
                        {
                            this.PromptWithUnsupportedProjectDetails(projectStore, projectCreateError);
                        }
                        else
                        {
                            IMessageDisplayService messageDisplayService = this.Services.MessageDisplayService();
                            ErrorArgs   errorArg         = new ErrorArgs();
                            CultureInfo currentUICulture = CultureInfo.CurrentUICulture;
                            string      unsupportedProjectWithDescription = StringTable.UnsupportedProjectWithDescription;
                            object[]    displayName = new object[] { projectStore.DocumentReference.DisplayName, invalidProjectStore.InvalidStateDescription };
                            errorArg.Message      = string.Format(currentUICulture, unsupportedProjectWithDescription, displayName);
                            errorArg.AutomationId = "OpenProjectErrorDialog";
                            messageDisplayService.ShowError(errorArg);
                        }
                    }
                    LicenseState licenseState = LicensingHelper.IsProjectLicensed(projectStore, this.serviceProvider);
                    if (!licenseState.IsExpired)
                    {
                        if (!licenseState.FullyLicensed)
                        {
                            LicensingHelper.UnlicensedProjectLoadAttempted();
                        }
                        unlicensedProject = projectTypeForProject.CreateProject(projectStore, this.GetCodeDocumentTypeFromProject(projectStore), this.serviceProvider);
                    }
                    else
                    {
                        LicensingHelper.UnlicensedProjectLoadAttempted();
                        unlicensedProject = new UnlicensedProject(projectStore, this.serviceProvider);
                    }
                    return(unlicensedProject);
                }
                else
                {
                    namedProject = null;
                }
            }
            catch (Exception exception)
            {
                if (unlicensedProject != null)
                {
                    projectStore.Dispose();
                    unlicensedProject.Dispose();
                    unlicensedProject = null;
                }
                throw;
            }
            return(namedProject);
        }
Esempio n. 6
0
 public SolutionWatcher(SolutionBase solution)
 {
     this.solution = solution;
     base.CreateFileWatcher(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectory(solution.DocumentReference.Path));
     base.Watcher.IncludeSubdirectories = false;
 }
Esempio n. 7
0
 protected static bool IsReloadPromptEnabled()
 {
     return(SolutionBase.IsReloadPromptEnabled());
 }