Beispiel #1
0
        public Stream WriteToStream(Drawing drawing)
        {
            var ms           = new MemoryStream();
            var fileSettings = FileHandler.GetFileSettingsFromDrawing(drawing);

            Assert.True(FileHandler.WriteDrawing("filename", ms, drawing, ViewPort.CreateDefaultViewPort(), fileSettings));
            ms.Seek(0, SeekOrigin.Begin);
            return(ms);
        }
Beispiel #2
0
        public async Task <bool> Execute(IWorkspace workspace, object arg)
        {
            var unsaved = await workspace.PromptForUnsavedChanges();

            if (unsaved == UnsavedChangesResult.Cancel)
            {
                return(false);
            }

            workspace.Update(drawing: new Drawing(), activeViewPort: ViewPort.CreateDefaultViewPort(), isDirty: false);
            workspace.UndoRedoService.ClearHistory();
            return(true);
        }
Beispiel #3
0
        public async void VerifyNonDefaultVersionIsPreservedInWriteTest()
        {
            using (var ms1 = new MemoryStream())
            {
                var drawing = new Drawing();

                // write file as R13
                using (new DxfFileSettingsProvider(new DxfFileSettings()
                {
                    FileVersion = DxfFileVersion.R13
                }))
                {
                    Assert.True(await Workspace.ReaderWriterService.TryWriteDrawing("filename.dxf", drawing, ViewPort.CreateDefaultViewPort(), ms1, preserveSettings: false));
                }

                // verify that it was written as such
                ms1.Seek(0, SeekOrigin.Begin);
                var file = DxfFile.Load(ms1);
                Assert.Equal(DxfAcadVersion.R13, file.Header.Version);

                using (var ms2 = new MemoryStream())
                {
                    // write it again
                    Assert.True(await Workspace.ReaderWriterService.TryWriteDrawing("filename.dxf", drawing, ViewPort.CreateDefaultViewPort(), ms2, preserveSettings: true));

                    // verify again that it was written correctly without specifying drawing settings
                    ms2.Seek(0, SeekOrigin.Begin);
                    file = DxfFile.Load(ms2);
                    Assert.Equal(DxfAcadVersion.R13, file.Header.Version);
                }
            }
        }
Beispiel #4
0
        public async void VerifyDefaultDxfVersionInWriteTest()
        {
            using (var ms = new MemoryStream())
            {
                var drawing = new Drawing();

                // write file with defaults
                Assert.True(await Workspace.ReaderWriterService.TryWriteDrawing("filename.dxf", drawing, ViewPort.CreateDefaultViewPort(), ms, preserveSettings: false));

                // verify that the written default is correct
                ms.Seek(0, SeekOrigin.Begin);
                var file = DxfFile.Load(ms);
                Assert.Equal(DxfAcadVersion.R12, file.Header.Version);
            }
        }