private HistoryMemento ImportOneFile(DocumentWorkspace documentWorkspace, string fileName, out Rectangle lastLayerBounds) { documentWorkspace.AppWorkspace.Widgets.StatusBarProgress.ResetProgressStatusBar(); ProgressEventHandler progressCallback = delegate(object sender, ProgressEventArgs e) { documentWorkspace.AppWorkspace.Widgets.StatusBarProgress.SetProgressStatusBar(e.Percent); }; FileType fileType; Document document = DocumentWorkspace.LoadDocument(documentWorkspace, fileName, out fileType, progressCallback); documentWorkspace.AppWorkspace.Widgets.StatusBarProgress.EraseProgressStatusBar(); if (document != null) { string name = Path.ChangeExtension(Path.GetFileName(fileName), null); string newLayerNameFormat = PdnResources.GetString("ImportFromFileAction.ImportOneFile.NewLayer.Format"); foreach (Layer layer in document.Layers) { layer.Name = string.Format(newLayerNameFormat, name, layer.Name); layer.IsBackground = false; } HistoryMemento ha = ImportDocument(documentWorkspace, document, out lastLayerBounds); return(ha); } else { lastLayerBounds = Rectangle.Empty; return(null); } }
public MainPanel() { var dialog = new OpenFileDialog { CheckFileExists = true, CheckPathExists = true, FilterIndex = 0 }; dialog.ShowDialog(); var fileName = dialog.FileName; FileType type; var document = DocumentWorkspace.LoadDocument(this, fileName, out type, null); _workspace = new DocumentWorkspace { Document = document, Dock = DockStyle.Fill }; _appworkspace = new AppWorkspace(_workspace) { Dock = DockStyle.Fill }; Controls.Add(_appworkspace); }