internal static bool SaveAllFiles(Form1 form, bool saveNewRecentFile = true) { CustomXtraTabControl pagesTabControl = form.pagesTabControl; XtraTabPage startTabPage = pagesTabControl.SelectedTabPage; bool fullSuccess = true; try { pagesTabControl.BeginUpdate(); foreach (XtraTabPage tabPage in pagesTabControl.TabPages) { if (!TabUtil.IsTabPageModified(tabPage)) { continue; } pagesTabControl.SelectedTabPage = tabPage; if (!SaveFile(saveNewRecentFile, form, false, false, true)) { fullSuccess = false; } } } finally { pagesTabControl.SelectedTabPage = startTabPage; pagesTabControl.EndUpdate(); } return(fullSuccess); }
internal static void OpenDictionaryWindow(Form1 form, CustomXtraTabControl pagesTabControl) { CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); if (!pageTextBox.SelectedText.TrimStart().TrimEnd().Contains(" ")) { WindowManager.ShowDictionary(form, pageTextBox.SelectedText); } else { WindowManager.ShowDictionary(form); } }
internal static bool AreAllTabsEmptyAndWithoutFiles(Form1 form) { CustomXtraTabControl pagesTabControl = form.pagesTabControl; foreach (XtraTabPage tabPage in pagesTabControl.TabPages) { if (!String.IsNullOrEmpty(ProgramUtil.GetPageTextBox(tabPage).Text) || !String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(tabPage))) { return(false); } } return(true); }
internal static void MouseUpOnTab(Form1 form, MouseEventArgs e) { CustomXtraTabControl pagesTabControl = form.pagesTabControl; PropertyInfo tabProperties = pagesTabControl.GetType().GetProperty("ViewInfo", BindingFlags.Instance | BindingFlags.NonPublic); BaseTabControlViewInfo tabViewInfo = tabProperties.GetValue(pagesTabControl, null) as BaseTabControlViewInfo; if (tabViewInfo != null && !tabViewInfo.SelectedTabPageViewInfo.Bounds.Contains(e.Location)) { return; } switch (e.Button) { case MouseButtons.Middle: ClosePage(form); break; } }
internal static int OpenFile(Form1 form, int tabIdentity, String[] specificFileNames, bool showMessages, bool saveNewRecentFile, out List <String> errors) { CustomXtraTabControl pagesTabControl = form.pagesTabControl; ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel; ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar; OpenFileDialog openFileDialog = form.openFileDialog; bool isWindowsHostsFile = false; int localTabIdentity = tabIdentity; errors = new List <String>(); openFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form); openFileDialog.Multiselect = true; SetFileDialogFilter(openFileDialog); TrayManager.RestoreFormIfIsInTray(form); try { String[] fileNames; if (specificFileNames == null || specificFileNames.Length <= 0) { if (openFileDialog.ShowDialog() != DialogResult.OK) { return(tabIdentity); } fileNames = openFileDialog.FileNames; } else { fileNames = specificFileNames; } //Verify if file is a DtPad session if (fileNames.Length == 1 && fileNames[0].EndsWith(".dps")) { SessionManager.OpenSession(form, fileNames[0]); return(form.TabIdentity); } Application.DoEvents(); toolStripProgressBar.Value = 0; foreach (String fileName in fileNames) { //Verify if file is Windows hosts file if (fileName.Contains(@"drivers\etc\hosts")) { if (!SystemUtil.IsUserAdministrator()) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("UserNotAdmin", className)); } isWindowsHostsFile = true; } if (!showMessages) { if (!File.Exists(fileName)) { errors.Add(String.Format(LanguageUtil.GetCurrentLanguageString("NoMessageFileNotExists", className), fileName)); continue; } if (FileUtil.IsFileInUse(fileName)) { errors.Add(String.Format(LanguageUtil.GetCurrentLanguageString("NoMessageFileInUse", className), fileName)); continue; } if (FileUtil.IsFileTooLargeForDtPad(fileName)) { errors.Add(String.Format(LanguageUtil.GetCurrentLanguageString("NoMessageFileTooHeavy", className), fileName)); continue; } } else if (!File.Exists(fileName)) { WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("FileNotExisting", className), fileName)); continue; } else if (FileUtil.IsFileInUse(fileName)) { WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("FileInUse", className), fileName)); continue; } if (FileUtil.IsFileTooLargeForDtPad(fileName)) { WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("FileTooHeavy", className), fileName)); continue; } //Cycle and check if the file is already open, in which case I select its tab and continue with the next one XtraTabPage tabPage; if (FileUtil.IsFileAlreadyOpen(form, fileName, out tabPage)) { pagesTabControl.SelectedTabPage = tabPage; toolStripProgressBar.PerformStep(); toolStripProgressBar.PerformStep(); toolStripProgressBar.PerformStep(); toolStripProgressBar.PerformStep(); toolStripProgressBar.Visible = false; continue; } //Verify if file is an archive try { ZipFile file = null; bool isZipFile; try { file = new ZipFile(fileName); isZipFile = file.TestArchive(false, TestStrategy.FindFirstError, form.Zip_Errors); } finally { if (file != null) { file.Close(); } } if (isZipFile) { WindowManager.ShowZipExtract(form, fileName); continue; } } catch (ZipException) { } toolStripProgressBar.Visible = true; toolStripProgressBar.PerformStep(); String fileContents; Encoding fileEncoding; bool anonymousFile = false; //Verify if file is a PDF if (fileName.EndsWith(".pdf")) { bool success; fileContents = PdfUtil.ExtractText(fileName, out success); if (!success) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("InvalidPdf", className)); return(tabIdentity); } fileEncoding = EncodingUtil.GetDefaultEncoding(); anonymousFile = true; } else { fileContents = FileUtil.ReadToEndWithEncoding(fileName, out fileEncoding); } bool favouriteFile = FavouriteManager.IsFileFavourite(fileName); if (!favouriteFile && saveNewRecentFile) { ConfigUtil.UpdateParameter("LastUserFolder", Path.GetDirectoryName(fileName)); FileListManager.SetNewRecentFile(form, fileName); } toolStripProgressBar.PerformStep(); CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); if (!String.IsNullOrEmpty(pageTextBox.Text) || !String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.SelectedTabPage))) { localTabIdentity = TabManager.AddNewPage(form, localTabIdentity); } toolStripProgressBar.PerformStep(); //Row number check WindowManager.CheckLineNumbersForTextLenght(form, fileContents); FileInfo fileInfo = new FileInfo(fileName); pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); //Verify if file is a tweet file if (fileName.EndsWith(".tweet") && !ColumnRulerManager.IsPanelOpen(form)) { ColumnRulerManager.TogglePanel(form); } pageTextBox.Text = fileContents.Replace(Environment.NewLine, ConstantUtil.newLine); pageTextBox.CustomOriginal = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage).Text.GetHashCode().ToString(); pageTextBox.CustomEncoding = fileEncoding.CodePage.ToString(); if (!anonymousFile) { String fileNameWithoutPath = Path.GetFileName(fileName); pageTextBox.CustomModified = false; ProgramUtil.SetFilenameTabPage(pagesTabControl.SelectedTabPage, fileName); pagesTabControl.SelectedTabPage.ImageIndex = fileInfo.IsReadOnly ? 2 : 0; pagesTabControl.SelectedTabPage.Text = fileNameWithoutPath; pagesTabControl.SelectedTabPage.Tooltip = fileName; pagesTabControl.SelectedTabPage.TooltipTitle = fileNameWithoutPath; form.Text = String.Format("DtPad - {0}", fileNameWithoutPath); TabManager.ToggleTabFileTools(form, true); } else { pageTextBox.CustomModified = true; } toolStripStatusLabel.Text = String.Format("{0} \"{1}\" {2}", LanguageUtil.GetCurrentLanguageString("File", className), Path.GetFileName(fileName), LanguageUtil.GetCurrentLanguageString("Opened", className)); toolStripProgressBar.PerformStep(); tabIdentity = localTabIdentity; if (!String.IsNullOrEmpty(fileInfo.Extension) && ConfigUtil.GetStringParameter("AutoFormatFiles").Contains(fileInfo.Extension)) { FormatManager.FormatXml(form); } if (ConfigUtil.GetBoolParameter("AutoOpenHostsConfigurator") && isWindowsHostsFile) { pagesTabControl.SelectedTabPage.Appearance.Header.ForeColor = ConfigUtil.GetColorParameter("ColorHostsConfigurator"); CustomFilesManager.OpenHostsSectionPanel(form); isWindowsHostsFile = false; } } } catch (Exception exception) { TabManager.ToggleTabFileTools(form, false); toolStripProgressBar.Visible = false; toolStripProgressBar.Value = 0; if (showMessages) { WindowManager.ShowErrorBox(form, exception.Message, exception); } } finally { toolStripProgressBar.Visible = false; toolStripProgressBar.Value = 0; } return(tabIdentity); }
internal static void CheckTextCorrectness(Form1 form, String languageSign) { if (!ExistsDictionary(languageSign)) { WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("NoDictionary", className) + ConstantUtil.dtPadURL + "wikipage?title=Dictionaries"); return; } CustomXtraTabControl pagesTabControl = form.pagesTabControl; CustomRichTextBox pageTextBox = ProgramUtil.GetPageTextBox(pagesTabControl.SelectedTabPage); if (RichTextBoxUtil.ContainsUnderlineText(pageTextBox)) { ClearTextCorrectness(pageTextBox); } bool textCorrectness = true; RichTextBox tempRichTextBox = new RichTextBox { BackColor = pageTextBox.BackColor }; //Temporary RichTextBox to avoid too much undo/redo into buffer pageTextBox.SuspendPainting(); tempRichTextBox.Rtf = pageTextBox.Rtf; //Method 1: char parse (more accurate, slower) using (Hunspell hunspell = new Hunspell(ConstantUtil.ApplicationExecutionPath() + "\\Languages\\" + languageSign + ".aff", ConstantUtil.ApplicationExecutionPath() + "\\Languages\\" + languageSign + ".dic")) { int wordStart = 0; StringBuilder word = new StringBuilder(String.Empty); StringBuilder text = new StringBuilder(pageTextBox.Text); for (int i = 0; i < text.Length; i++) { if (text[i] == '\'' || (!Char.IsWhiteSpace(text[i]) && !Char.IsPunctuation(text[i]) && !Char.IsSymbol(text[i]) && !Char.IsSeparator(text[i]))) { word.Append(text[i]); if (i < text.Length - 1) { continue; } } if (!hunspell.Spell(word.ToString()) && !String.IsNullOrEmpty(word.ToString().Trim())) { tempRichTextBox.Select(wordStart, word.Length); tempRichTextBox.SelectionFont = new Font(pageTextBox.Font, FontStyle.Underline); tempRichTextBox.SelectionColor = (pageTextBox.BackColor == Color.Red) ? Color.Yellow : Color.Red; textCorrectness = false; } word = new StringBuilder(String.Empty); wordStart = i + 1; } } //Method 2: word parse (less accurate, faster) //String[] wordsList = pageTextBox.Text.Split(new[] { ' ', Convert.ToChar(ConstantUtil.newLine), '\t', '/', '\\', '.', '?', ';', ',', ':', '(', ')', '[', ']', '{', '}', '\\', '|', '/', '!', '"', '\'', '=' }, StringSplitOptions.RemoveEmptyEntries); //List<String> wordsAlreadySeen = new List<String>(); //using (Hunspell hunspell = new Hunspell(ConstantUtil.ApplicationExecutionPath() + "\\Languages\\" + languageSign + ".aff", ConstantUtil.ApplicationExecutionPath() + "\\Languages\\" + languageSign + ".dic")) //{ // foreach (String word in wordsList) // { // if (wordsAlreadySeen.Contains(word)) // { // continue; // } // wordsAlreadySeen.Add(word); // if (hunspell.Spell(word)) // { // continue; // } // int i = 0; // while (i != -1 && (i = pageTextBox.Text.IndexOf(word, i)) != -1) // { // tempRichTextBox.Select(i, word.Length); // tempRichTextBox.SelectionFont = new Font(pageTextBox.Font, FontStyle.Underline); // tempRichTextBox.SelectionColor = (pageTextBox.BackColor == Color.Red) ? Color.Yellow : Color.Red; // i += word.Length; // } // } //} pageTextBox.IsUnderlining = true; RichTextBoxUtil.ReplaceRTFContent(pageTextBox, tempRichTextBox); pageTextBox.ResumePainting(); tempRichTextBox.Dispose(); TextManager.RefreshUndoRedoExternal(form); if (textCorrectness) { WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("TextCorrect", className)); } }
internal static bool SaveAllFilesAsZip(Form1 form) { SaveFileDialog saveFileDialog = form.saveFileDialog; CustomXtraTabControl pagesTabControl = form.pagesTabControl; ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel; ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar; if (TabManager.AreAllTabsEmptyAndWithoutFiles(form)) { WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("NoContent", className)); return(false); } //Save all files before to proceed foreach (XtraTabPage tabPage in pagesTabControl.TabPages) { if (!String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(tabPage)) && !tabPage.Text.StartsWith("*")) { continue; } if (WindowManager.ShowQuestionBox(form, LanguageUtil.GetCurrentLanguageString("SaveAllFiles", className)) != DialogResult.Yes) { return(false); } if (!FileManager.SaveAllFiles(form)) { WindowManager.ShowInfoBox(form, LanguageUtil.GetCurrentLanguageString("FilesNotSaved", className)); return(false); } break; } toolStripProgressBar.Value = 0; toolStripProgressBar.Visible = true; toolStripProgressBar.PerformStep(); //Save file dialog saveFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form); saveFileDialog.Filter = LanguageUtil.GetCurrentLanguageString("FileDialog", className); saveFileDialog.FilterIndex = 0; saveFileDialog.FileName = "*.zip"; try { if (saveFileDialog.ShowDialog() != DialogResult.OK) { toolStripProgressBar.Visible = false; return(false); } toolStripProgressBar.PerformStep(); String fileName = saveFileDialog.FileName; if (!fileName.EndsWith(".zip")) { fileName += ".zip"; } toolStripProgressBar.PerformStep(); WriteZipFile(fileName, pagesTabControl.TabPages); toolStripProgressBar.PerformStep(); toolStripStatusLabel.Text = String.Format(LanguageUtil.GetCurrentLanguageString("Saved", className), fileName); } catch (Exception exception) { WindowManager.ShowErrorBox(form, exception.Message, exception); return(false); } finally { toolStripProgressBar.Visible = false; } return(true); }
private static String ReadSessionXML(Form1 form, String fileName, out bool loadTotallyFailed) { CustomXtraTabControl pagesTabControl = form.pagesTabControl; ToolStripDropDownButton sessionImageToolStripButton = form.sessionImageToolStripButton; ToolStripMenuItem useDefaultToolStripMenuItem = form.useDefaultToolStripMenuItem; ToolStripMenuItem closeButtonToolStripMenuItem = form.closeButtonToolStripMenuItem; ToolStripMenuItem tabPositionToolStripMenuItem = form.tabPositionToolStripMenuItem; ToolStripMenuItem tabOrientationToolStripMenuItem = form.tabOrientationToolStripMenuItem; loadTotallyFailed = false; int selectedTab = 0; int existingTabs = 0; if (pagesTabControl.TabPages.Count > 1 || !String.IsNullOrEmpty(ProgramUtil.GetPageTextBox(pagesTabControl.TabPages[0]).Text) || !String.IsNullOrEmpty(ProgramUtil.GetFilenameTabPage(pagesTabControl.TabPages[0]))) { existingTabs = pagesTabControl.TabPages.Count; } sessionImageToolStripButton.DropDownItems.Clear(); sessionImageToolStripButton.DropDownItems.Add(fileName); sessionImageToolStripButton.DropDownItems[0].Image = ToolbarResource.diagram; sessionImageToolStripButton.DropDownItems[0].Click += form.sessionPropertiesToolStripMenuItem_Click; sessionImageToolStripButton.DropDownItems.Add(new ToolStripSeparator()); XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(fileName); XmlNodeList nodeFileList = xmldoc.GetElementsByTagName("file"); if (nodeFileList.Count == 0) { throw new SessionException(LanguageUtil.GetCurrentLanguageString("Empty", className)); } String[] fileNames = new String[nodeFileList.Count]; KnownColor[] tabColors = new KnownColor[nodeFileList.Count]; for (int i = 0; i < nodeFileList.Count; i++) { XmlNode nodeFile = nodeFileList[i]; String path = nodeFile.Attributes["path"].Value; path = FileUtil.EvaluateAbsolutePath(Path.GetDirectoryName(fileName), path); fileNames[i] = Path.Combine(path, nodeFile.Attributes["name"].Value); sessionImageToolStripButton.DropDownItems.Add(fileNames[i]); sessionImageToolStripButton.DropDownItems[sessionImageToolStripButton.DropDownItems.Count - 1].Click += form.sessionImageToolStripButton_Click; if (!File.Exists(fileNames[i])) { sessionImageToolStripButton.DropDownItems[sessionImageToolStripButton.DropDownItems.Count - 1].Enabled = false; } try { if (Convert.ToBoolean(nodeFile.Attributes["open"].Value)) { selectedTab = i; } } catch (Exception) { } try { tabColors[i] = (KnownColor)Enum.Parse(typeof(KnownColor), nodeFile.Attributes["tabcolor"].Value, true); } catch (Exception) { tabColors[i] = KnownColor.Black; } } List <String> errors; form.TabIdentity = FileManager.OpenFile(form, form.TabIdentity, fileNames, false, false, out errors); if (errors.Count == 0) { pagesTabControl.SelectedTabPageIndex = selectedTab; for (int j = 0; j < pagesTabControl.TabPages.Count - existingTabs; j++) { TabManager.SetTabColor(pagesTabControl.TabPages[j + existingTabs], Color.FromKnownColor(tabColors[j])); //pagesTabControl.TabPages[j].Appearance.Header.ForeColor = Color.FromKnownColor(tabColors[j]); } } else { String errorMessage = LanguageUtil.GetCurrentLanguageString("openingErrors", className) + Environment.NewLine; for (int i = 0; i < errors.Count; i++) { if (i == errors.Count - 1) { errorMessage += errors[i]; continue; } errorMessage += errors[i] + Environment.NewLine; } WindowManager.ShowContent(form, errorMessage); if (errors.Count == fileNames.Length) { loadTotallyFailed = true; } } if (xmldoc.GetElementsByTagName("session")[0].Attributes["aspect"].Value == "default") { useDefaultToolStripMenuItem.Checked = true; } else { useDefaultToolStripMenuItem.Checked = false; CheckDropDownIndex(closeButtonToolStripMenuItem, Convert.ToInt32(xmldoc.GetElementsByTagName("session")[0].Attributes["button"].Value)); CheckDropDownIndex(tabPositionToolStripMenuItem, Convert.ToInt32(xmldoc.GetElementsByTagName("session")[0].Attributes["position"].Value)); CheckDropDownIndex(tabOrientationToolStripMenuItem, Convert.ToInt32(xmldoc.GetElementsByTagName("session")[0].Attributes["orientation"].Value)); } return(xmldoc.GetElementsByTagName("session")[0].Attributes["name"].Value); }
internal static void ExportSessionAsZip(Form1 form) { SaveFileDialog saveFileDialog = form.saveFileDialog; CustomXtraTabControl pagesTabControl = form.pagesTabControl; ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel; ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar; ToolStripButton sessionToolStripButton = form.sessionToolStripButton; ToolStripDropDownButton sessionImageToolStripButton = form.sessionImageToolStripButton; if (IsOpenedSessionModified(form)) { if (WindowManager.ShowQuestionBox(form, LanguageUtil.GetCurrentLanguageString("SaveSessionForExport", className)) != DialogResult.Yes) { return; } if (!SaveSession(form, false)) { return; } } if (!SessionContainsOnlySubFiles(form)) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("NoExport", className)); return; } toolStripProgressBar.Value = 0; toolStripProgressBar.Visible = true; toolStripProgressBar.PerformStep(); //Save file dialog saveFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form); saveFileDialog.Filter = LanguageUtil.GetCurrentLanguageString("ExportFileDialog", className); saveFileDialog.FilterIndex = 0; saveFileDialog.FileName = sessionToolStripButton + ".zip"; try { if (saveFileDialog.ShowDialog() != DialogResult.OK) { toolStripProgressBar.Visible = false; return; } toolStripProgressBar.PerformStep(); String fileName = saveFileDialog.FileName; if (!fileName.EndsWith(".zip")) { fileName += ".zip"; } toolStripProgressBar.PerformStep(); ZipManager.WriteZipFile(fileName, pagesTabControl.TabPages, new FileInfo(sessionImageToolStripButton.DropDownItems[0].Text).DirectoryName, new List <String> { sessionImageToolStripButton.DropDownItems[0].Text }); toolStripProgressBar.PerformStep(); toolStripStatusLabel.Text = String.Format(LanguageUtil.GetCurrentLanguageString("ExportSaved", className), fileName); } catch (Exception exception) { WindowManager.ShowErrorBox(form, exception.Message, exception); } finally { toolStripProgressBar.Visible = false; } }
internal static void OpenSession(Form1 form, String fileName = null) { CustomXtraTabControl pagesTabControl = form.pagesTabControl; ToolStrip sessionToolStrip = form.sessionToolStrip; ToolStripButton sessionToolStripButton = form.sessionToolStripButton; ToolStripMenuItem closeToolStripMenuItem3 = form.closeToolStripMenuItem3; ToolStripMenuItem saveToolStripMenuItem2 = form.saveToolStripMenuItem2; ToolStripMenuItem exportAsZipToolStripMenuItem = form.exportAsZipToolStripMenuItem; ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel; OpenFileDialog openFileDialog = form.openFileDialog; ToolStripProgressBar toolStripProgressBar = form.toolStripProgressBar; //SplitContainer verticalSplitContainer = form.verticalSplitContainer; ToolStripMenuItem renameSessionToolStripMenuItem = form.renameSessionToolStripMenuItem; ToolStripMenuItem favouriteSessionToolStripMenuItem = form.favouriteSessionToolStripMenuItem; ToolStripMenuItem listFilesToolStripMenuItem = form.listFilesToolStripMenuItem; ToolStripMenuItem aspectToolStripMenuItem = form.aspectToolStripMenuItem; ToolStripMenuItem useDefaultToolStripMenuItem = form.useDefaultToolStripMenuItem; ToolStripMenuItem closeButtonToolStripMenuItem = form.closeButtonToolStripMenuItem; ToolStripMenuItem tabPositionToolStripMenuItem = form.tabPositionToolStripMenuItem; ToolStripMenuItem tabOrientationToolStripMenuItem = form.tabOrientationToolStripMenuItem; ToolStripMenuItem sessionPropertiesToolStripMenuItem = form.sessionPropertiesToolStripMenuItem; try { bool isASessionOpened = IsASessionOpened(form); if (isASessionOpened && WindowManager.ShowQuestionBox(form, LanguageUtil.GetCurrentLanguageString("AlreadyOpen", className)) != DialogResult.Yes) { return; } if (isASessionOpened) { CloseSession(form); } if (String.IsNullOrEmpty(fileName)) { openFileDialog.InitialDirectory = FileUtil.GetInitialFolder(form); openFileDialog.Multiselect = false; openFileDialog.Filter = LanguageUtil.GetCurrentLanguageString("FileDialog", className); openFileDialog.FilterIndex = 0; openFileDialog.FileName = "*.dps"; if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } fileName = openFileDialog.FileName; } if (!File.Exists(fileName)) { WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("FileNotExisting", className), fileName)); return; } if (FileUtil.IsFileInUse(fileName)) { WindowManager.ShowAlertBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("FileInUse", className), fileName)); return; } if (pagesTabControl.TabPages.Count > 1 && TabManager.AreAllTabsEmpty(form)) { if (!TabManager.CloseAllPages(form)) { return; } } bool loadTotallyFailed; String sessionName = ReadSessionXML(form, fileName, out loadTotallyFailed); toolStripProgressBar.Visible = false; if (loadTotallyFailed) { return; } sessionToolStrip.Visible = true; sessionToolStripButton.Text = sessionName; closeToolStripMenuItem3.Enabled = true; saveToolStripMenuItem2.Enabled = true; exportAsZipToolStripMenuItem.Enabled = true; renameSessionToolStripMenuItem.Enabled = true; favouriteSessionToolStripMenuItem.Enabled = true; listFilesToolStripMenuItem.Enabled = true; aspectToolStripMenuItem.Enabled = true; useDefaultToolStripMenuItem.Enabled = true; sessionPropertiesToolStripMenuItem.Enabled = true; if (!useDefaultToolStripMenuItem.Checked) { closeButtonToolStripMenuItem.Enabled = true; tabPositionToolStripMenuItem.Enabled = true; tabOrientationToolStripMenuItem.Enabled = true; OptionManager.CheckTabCloseButton(form, GetDropDownIndexChecked(closeButtonToolStripMenuItem)); OptionManager.CheckTabPosition(form, GetDropDownIndexChecked(tabPositionToolStripMenuItem)); OptionManager.CheckTabOrientation(form, GetDropDownIndexChecked(tabOrientationToolStripMenuItem)); } else { closeButtonToolStripMenuItem.Enabled = false; tabPositionToolStripMenuItem.Enabled = false; tabOrientationToolStripMenuItem.Enabled = false; } ConfigUtil.UpdateParameter("LastUserFolder", Path.GetDirectoryName(fileName)); FileListManager.SetNewRecentSession(form, fileName); //verticalSplitContainer.Panel1.Padding = new Padding(0); toolStripStatusLabel.Text = String.Format(LanguageUtil.GetCurrentLanguageString("Opened", className), sessionToolStripButton.Text); } catch (Exception exception) { OptionManager.CheckTabCloseButton(form, ConfigUtil.GetIntParameter("TabCloseButtonMode")); OptionManager.CheckTabPosition(form, ConfigUtil.GetIntParameter("TabPosition")); OptionManager.CheckTabOrientation(form, ConfigUtil.GetIntParameter("TabOrientation")); WindowManager.ShowErrorBox(form, exception.Message, exception); } }