コード例 #1
0
ファイル: PaintWorkspace.cs プロジェクト: dtzxporter/DarkNet
        /// <summary>
        /// Get the workspace from the given main instance
        /// </summary>
        /// <param name="Instance">The main form instance</param>
        /// <returns>A workspace object</returns>
        public static PaintWorkspace GetWorkspaceFromInstance(Form Instance)
        {
            var Result = new PaintWorkspace();

            Result.WorkspaceInstance = Instance.GetMemberValue("appWorkspace");

            return(Result);
        }
コード例 #2
0
        /// <summary>
        /// Save the given layer as a new file
        /// </summary>
        /// <param name="PaintLayer">The layer to save</param>
        public void SaveLayerAs(PaintWorkspace Workspace, Layer PaintLayer)
        {
            // We need to make a new workspace for saving...
            var NewWorkspace = Workspace.CreateNewDocumentWorkspace();

            // Make a new document, and clone the layer to the document.
            var NewDoc = new Document(PaintLayer.Width, PaintLayer.Height);

            NewDoc.Layers.Clear();
            NewDoc.Layers.Add(PaintLayer.CloneT <Layer>());

            // Setup document
            NewWorkspace.SetDocument(ref NewDoc);

            // Invoke save
            this.DoSaveAs();

            // Remove the document from the workspace
            Workspace.RemoveDocumentWorkspace(NewWorkspace);
        }