public static SvgDocument FromStream(Stream stream) { using (var wrapper = new SvgDocumentOpener(stream)) { return(SvgDocument.Open <SvgDocument>(wrapper.InnerStream)); } }
protected override Document OnLoad(Stream input) { pdnDocument = null; svg = SvgDocumentOpener.FromStream(input); GetInitialValues(out int viewportW, out int viewportH, out int ppi, out int viewBoxX, out int viewBoxY, out int viewBoxW, out int viewBoxH); using (cts = new CancellationTokenSource()) using (dialog = new SvgImportDialog()) { dialog.Title = WindowTitle; dialog.SourceDpi = ppi; dialog.ViewportW = viewportW; dialog.ViewportH = viewportH; dialog.ViewBoxX = viewBoxX; dialog.ViewBoxY = viewBoxY; dialog.ViewBoxW = viewBoxW; dialog.ViewBoxH = viewBoxH; //MessageBox.Show("SIZEHINT_INIT CALL FROM SVGFILETYPE.CS"); dialog.InitSizeHint(); dialog.SetMins(); dialog.FormClosing += Dialog_FormClosing; dialog.FormClosed += Dialog_FormClosed; dialog.OkClick += Dialog_OkClick; Form mainForm = Utils.GetMainForm(); Func <DialogResult> callback = () => dialog.ShowDialog(mainForm); DialogResult dialogResult = mainForm?.InvokeRequired == true ? (DialogResult)mainForm.Invoke(callback) : callback.Invoke(); svg = null; if (dialogResult != DialogResult.OK) { pdnDocument?.Dispose(); throw new OperationCanceledException("Cancelled by user"); } return(pdnDocument); } }