Beispiel #1
0
 public bool ResetActiveWorkspace()
 {
     if (!this.OnActiveWorkspaceChanging())
     {
         return(false);
     }
     using (PerformanceUtility.PerformanceSequence(PerformanceEvent.ResetWorkspace))
     {
         Workspace workspace = new Workspace(this.activeWorkspace.Name, this.Content);
         WorkspaceService.WorkspaceOperationResult workspaceOperationResult = this.LoadWorkspaceConfiguration((IWorkspace)workspace, true);
         if (!workspaceOperationResult.Success)
         {
             if (this.messageDisplayService != null)
             {
                 int num = (int)this.messageDisplayService.ShowMessage(new MessageBoxArgs()
                 {
                     Message = workspaceOperationResult.Message,
                     Button  = MessageBoxButton.OK,
                     Image   = MessageBoxImage.Hand
                 });
             }
             this.OnActiveWorkspaceChangingCanceled();
             return(false);
         }
         this.ActiveWorkspace = (IWorkspace)workspace;
     }
     return(true);
 }
Beispiel #2
0
        public void SaveConfiguration(bool displayErrorMessages)
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool          flag          = false;

            for (int index = 0; index < this.customWorkspaceNames.Count; ++index)
            {
                if (flag)
                {
                    stringBuilder.Append('|');
                }
                stringBuilder.Append(this.customWorkspaceNames[index]);
                flag = true;
            }
            this.configurationObject.SetProperty("UserWorkspaces", (object)stringBuilder.ToString(), (object)string.Empty);
            this.configurationObject.SetProperty("ActiveWorkspace", (object)this.activeWorkspace.Name);
            WorkspaceService.WorkspaceOperationResult workspaceOperationResult = this.SaveWorkspaceConfiguration(this.activeWorkspace, true);
            if (workspaceOperationResult.Success || !displayErrorMessages || this.messageDisplayService == null)
            {
                return;
            }
            int num = (int)this.messageDisplayService.ShowMessage(new MessageBoxArgs()
            {
                Message = workspaceOperationResult.Message,
                Button  = MessageBoxButton.OK,
                Image   = MessageBoxImage.Hand
            });
        }
Beispiel #3
0
 public bool SwitchToWorkspace(string workspaceName)
 {
     using (PerformanceUtility.PerformanceSequence(PerformanceEvent.SwitchWorkspaces))
     {
         if (!this.factoryWorkspaceNames.Contains(workspaceName) && !this.customWorkspaceNames.Contains(workspaceName) || this.activeWorkspace.Name == workspaceName || !this.OnActiveWorkspaceChanging())
         {
             return(false);
         }
         WorkspaceService.WorkspaceOperationResult workspaceOperationResult1 = this.SaveWorkspaceConfiguration(this.activeWorkspace, true);
         if (!workspaceOperationResult1.Success)
         {
             if (this.messageDisplayService != null)
             {
                 if (this.messageDisplayService.ShowMessage(new MessageBoxArgs()
                 {
                     Message = workspaceOperationResult1.Message + " " + StringTable.WorkspaceConfigurationProceedSwitching,
                     Button = MessageBoxButton.OKCancel,
                     Image = MessageBoxImage.Exclamation
                 }) != MessageBoxResult.OK)
                 {
                     this.OnActiveWorkspaceChangingCanceled();
                     return(false);
                 }
             }
             else
             {
                 this.OnActiveWorkspaceChangingCanceled();
                 return(false);
             }
         }
         Workspace workspace = new Workspace(workspaceName, this.Content);
         WorkspaceService.WorkspaceOperationResult workspaceOperationResult2 = this.LoadWorkspaceConfiguration((IWorkspace)workspace, false);
         if (!workspaceOperationResult2.Success)
         {
             if (this.messageDisplayService != null)
             {
                 int num = (int)this.messageDisplayService.ShowMessage(new MessageBoxArgs()
                 {
                     Message = workspaceOperationResult2.Message,
                     Button  = MessageBoxButton.OK,
                     Image   = MessageBoxImage.Hand
                 });
             }
             if (this.customWorkspaceNames.Contains(workspaceName))
             {
                 this.customWorkspaceNames.Remove(workspaceName);
             }
             this.OnActiveWorkspaceChangingCanceled();
             return(false);
         }
         this.ActiveWorkspace = (IWorkspace)workspace;
     }
     return(true);
 }
Beispiel #4
0
 public bool SaveAsNewWorkspace(string workspaceName)
 {
     using (PerformanceUtility.PerformanceSequence(PerformanceEvent.SaveWorkspace))
     {
         if (this.factoryWorkspaceNames.Contains(workspaceName))
         {
             throw new InvalidOperationException("Cannot overwrite factory workspace configuration.");
         }
         if (!this.OnActiveWorkspaceChanging())
         {
             return(false);
         }
         Workspace workspace = new Workspace(workspaceName, this.Content);
         workspace.CopyConfiguration(this.activeWorkspace);
         WorkspaceService.WorkspaceOperationResult workspaceOperationResult = this.SaveWorkspaceConfiguration((IWorkspace)workspace, false);
         if (!workspaceOperationResult.Success)
         {
             if (this.messageDisplayService != null)
             {
                 int num = (int)this.messageDisplayService.ShowMessage(new MessageBoxArgs()
                 {
                     Message = workspaceOperationResult.Message,
                     Button  = MessageBoxButton.OK,
                     Image   = MessageBoxImage.Hand
                 });
             }
             this.OnActiveWorkspaceChangingCanceled();
             return(false);
         }
         if (!this.customWorkspaceNames.Contains(workspaceName))
         {
             this.customWorkspaceNames.Add(workspaceName);
         }
         this.ActiveWorkspace = (IWorkspace)workspace;
     }
     return(true);
 }
Beispiel #5
0
        public void LoadConfiguration(bool useDefaultWorkspace)
        {
            string str = (string)this.configurationObject.GetProperty("UserWorkspaces", (object)string.Empty);

            if (!string.IsNullOrEmpty(str))
            {
                this.customWorkspaceNames.AddRange((IEnumerable <string>)str.Split('|'));
            }
            string name;

            if (useDefaultWorkspace)
            {
                name = this.factoryWorkspaceNames[0];
            }
            else
            {
                name = (string)this.configurationObject.GetProperty("ActiveWorkspace", (object)this.factoryWorkspaceNames[0]);
                if (!this.factoryWorkspaceNames.Contains(name) && !this.customWorkspaceNames.Contains(name))
                {
                    name = this.factoryWorkspaceNames[0];
                }
            }
            Workspace workspace = new Workspace(name, this.Content);

            WorkspaceService.WorkspaceOperationResult workspaceOperationResult = this.LoadWorkspaceConfiguration((IWorkspace)workspace, useDefaultWorkspace);
            if (!workspaceOperationResult.Success && name != this.factoryWorkspaceNames[0])
            {
                workspace = new Workspace(this.factoryWorkspaceNames[0], this.Content);
                workspaceOperationResult = this.LoadWorkspaceConfiguration((IWorkspace)workspace, false);
            }
            if (!workspaceOperationResult.Success)
            {
                throw new InvalidOperationException("There is no workspace configuration on the machine that could be loaded.");
            }
            this.ActiveWorkspace = (IWorkspace)workspace;
        }