Beispiel #1
0
        /// <summary>
        /// Prevents a default instance of the <see cref="Workspace"/> class from being created.
        /// </summary>
        //private Workspace()
        //    : this(new WorkspaceSettings { DocumentAuthor = null, DocumentTitle = null, Version = new Version(1, 0, 0, 0) })
        //{
        //}

        /// <summary>
        /// Initializes a new instance of the <see cref="Workspace"/> class.
        /// </summary>
        /// <param name="settings">The <see cref="WorkspaceSettings"/> instance.</param>
        private Workspace(WorkspaceSettings settings)
            : this(
                string.Empty,
                Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()),
                new Document(settings.DocumentTitle, settings.Version, settings.DocumentAuthor, settings.TemplateId))
        {
        }
Beispiel #2
0
        public static Workspace New(EventHandler <WorkspaceModifiedEventArgs> onModifiedHandler, EventHandler onSavedHandler, WorkspaceSettings settings)
        {
            var newWorkspace = new Workspace(settings);

            if (onModifiedHandler != null)
            {
                newWorkspace.Modified += onModifiedHandler;
            }
            if (onSavedHandler != null)
            {
                newWorkspace.Saved += onSavedHandler;
            }
            newWorkspace.OnModified(newWorkspace.Document, string.Empty);
            if (!Directory.Exists(newWorkspace.WorkingDirectory))
            {
                Directory.CreateDirectory(newWorkspace.WorkingDirectory);
            }
            if (settings.TemplateId != Guid.Empty)
            {
                newWorkspace.ExtractTemplateResources();
            }
            return(newWorkspace);
        }