예제 #1
0
        /// <summary>
        /// Opens a workspace based on a .cshell file.
        /// </summary>
        /// <param name="cshellFile">The file path to the .cshell file.</param>
        /// <returns>A task that completes once the workspace is opened.</returns>
        public static Task OpenWorkspace(string cshellFile)
        {
            var eventAggregator = IoC.Get<IEventAggregator>();

            lock (instanceLock)
            {
                if (!File.Exists(cshellFile))
                    Workspace.CreateWorkspaceFile(cshellFile);
                workspace = new Workspace(cshellFile);
            }
            //send the opening event
            if (eventAggregator != null)
                eventAggregator.Publish(new WorkspaceOpeningEventArgs(Workspace));

            return Workspace.Open()
                .ContinueWith(t =>
                {
                    //send the opened event
                    if (eventAggregator != null)
                        eventAggregator.Publish(new WorkspaceOpenedEventArgs(Workspace));
                });
        }
예제 #2
0
        /// <summary>
        /// Closes the current workspace.
        /// </summary>
        /// <returns>A task that completes once the workspace is closed.</returns>
        public static Task CloseWorkspace()
        {
            if (Workspace == null)
            {
                var t = new TaskCompletionSource<object>();
                t.SetResult(null);
                return t.Task;
            }

            //send the closing event
            var eventAggregator = IoC.Get<IEventAggregator>();
            if (eventAggregator != null)
                eventAggregator.Publish(new WorkspaceClosingEventArgs(Workspace));

            return Workspace.Close()
                 .ContinueWith(t =>
                 {
                     lock (instanceLock)
                     {
                         workspace = null;
                     }
                     if (eventAggregator != null)
                         eventAggregator.Publish(new WorkspaceClosedEventArgs());
                 });
        }
예제 #3
0
 public WorkspaceClosingEventArgs(Workspace ws)
 {
     Workspace = ws;
 }
예제 #4
0
 public WorkspaceOpenedEventArgs(Workspace ws)
 {
     Workspace = ws;
 }