private void OpenFile(string fileName, bool mustExist, bool showCoverPage) { try { string initialPath = ObjectMain.GetSetting(OptionSetting.DefaultPath); DialogResult result = DialogResult.OK; if (fileName.Length == 0) { result = OpenFileForm.GetFileToOpen(initialPath); fileName = OpenFileForm.FileSelected; showCoverPage = OpenFileForm.ShowCoverPage; } bool isPdf = fileName.ToUpper().EndsWith(".PDF"); if (mustExist & !File.Exists(fileName)) MessageBox.Show("File not found\n" + fileName, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else if (result != DialogResult.Cancel) { if (_documents.ContainsKey(fileName)) { _documents[fileName].BringToFront(); } else { DocumentWindow w = WindowFactory.CreateDocumentWindowForFile(fileName); if (w == null) MessageBox.Show("Couldn't create document window for file\n" + fileName, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else { if (isPdf) { IPdfViewer p = (IPdfViewer)w; p.ShowCoverPage = showCoverPage; w.OpenFile(fileName, uxMainToolStrip, FormWindowState.Maximized); } else { w.OpenFile(fileName, uxMainToolStrip, uxDockPanel); } _documents.Add(w.Key, w); w.FormClosed += new FormClosedEventHandler(DocumentWindow_FormClosed); } } } } catch (Exception ex) { LibSystem.Diagnostics.ExceptionHandler.Show(ex); } }