Пример #1
0
        void OpenFile(string filename)
        {
            filepath = filename;

            IStorageGraph newgraph;
            bool          isnewfile = false;

            if (string.IsNullOrEmpty(filename))
            {
                newgraph  = new MemoryStorageGraph();
                isnewfile = true;
            }
            else
            {
                switch (Path.GetExtension(filename))
                {
                case ".musicwriter":
                    var stream =
                        File.Open(
                            path: filepath,
                            mode: FileMode.OpenOrCreate,
                            access: FileAccess.ReadWrite,
                            share: FileShare.Read
                            );

                    var archive =
                        new ZipArchive(
                            stream: stream,
                            mode: ZipArchiveMode.Update | ZipArchiveMode.Read
                            );

                    newgraph = new ZipStorageGraph(archive);

                    break;

                case ".musicwriter-dir":
                    throw new NotImplementedException();

                default:
                    throw new NotSupportedException();
                }
            }

            tabScreens.Controls.Clear();

            file = new EditorFile(newgraph, containerfactoryset, isnewfile);
            Setup();

            RecentFiles.AddRecent(filepath);
        }
Пример #2
0
        private void diagSaveFile_FileOk(object sender, CancelEventArgs e)
        {
            IStorageGraph newgraph;

            switch (diagSaveFile.FilterIndex)
            {
            case 1:
                // zip file
                var stream  = diagSaveFile.OpenFile();
                var archive = new ZipArchive(stream, ZipArchiveMode.Update);
                newgraph = new ZipStorageGraph(archive);

                break;

            default:
                throw new NotSupportedException();
            }

            file.Storage.Transfer(newgraph);
            newgraph.Flush();

            OpenFile(diagSaveFile.FileName);
        }