public ObiConfiguration(ObiForm form, ProjectView.ProjectView projectView, Settings settings) : this() { m_Settings = settings; m_ProjectView = projectView; m_Form = form; this.Text = this.Text + " " + Application.ProductVersion; if (m_Settings.ObiFont != this.Font.Name) { this.Font = new Font(m_Settings.ObiFont, this.Font.Size, FontStyle.Regular); //@fontconfig } InitializeInputDevices(); LoadProfilesToComboboxes(); if (m_cb_SelectProfile.Items.Count > 0) { m_cb_SelectProfile.SelectedIndex = 0; } if (m_cb_SelectShortcutsProfile.Items.Count > 0) { m_cb_SelectShortcutsProfile.SelectedIndex = 0; } m_tb_ObiConfigInstructions.Text = Localizer.Message("ConfigureObi"); string path = "C:\\Obi Projects"; m_ProjectDirectoryPath = path; m_DirectoryTextbox.Text = m_ProjectDirectoryPath; }
private void mSelectButton_Click(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.SelectedPath = mPathTextBox.Text; dialog.ShowNewFolderButton = true; if (dialog.ShowDialog() == DialogResult.OK && ObiForm.CheckProjectDirectory_Safe(dialog.SelectedPath, true)) { mPathTextBox.Text = dialog.SelectedPath; } }
// Validate the chosen location before closing private void mOKButton_Click(object sender, EventArgs e) { if (m_ProjectNameTextBox.Text.Trim() == string.Empty) { MessageBox.Show(Localizer.Message("SaveAsEmptyProjectFileName"), Localizer.Message("Caption_Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); mCanClose = false; } else { string newPath = Path.Combine(mLocationTextBox.Text, m_ProjectNameTextBox.Text + ".obi"); try { string[] logicalDrives = System.IO.Directory.GetLogicalDrives(); foreach (string drive in logicalDrives) { if ((mLocationTextBox.Text == drive) || (mLocationTextBox.Text == Environment.GetFolderPath(Environment.SpecialFolder.Desktop)) || (mLocationTextBox.Text == Environment.GetFolderPath(Environment.SpecialFolder.MyComputer) || (mLocationTextBox.Text == Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)))) { MessageBox.Show(string.Format(Localizer.Message("SaveAs_cannot_save_in_root"), mLocationTextBox.Text)); mCanClose = false; return; } // Must not save in same directory } if (Path.GetFullPath(Path.GetDirectoryName(newPath)) == Path.GetFullPath(Path.GetDirectoryName(mOriginalProjectPath))) { MessageBox.Show(Localizer.Message("save_as_error_same_directory")); mCanClose = false; } // The selected location must be suitable else if (!m_PathChecked && !ObiForm.CheckProjectPath(newPath, true)) { mCanClose = false; } else { mNewProjectPath = newPath; mCanClose = true; } } catch (Exception x) { MessageBox.Show(string.Format(Localizer.Message("cannot_use_project_path"), newPath, x.Message), Localizer.Message("cannot_use_project_path_caption"), MessageBoxButtons.OK, MessageBoxIcon.Error); mCanClose = false; } } }
// Browse to a new location. private void mSelectButton_Click(object sender, EventArgs e) { // SaveFileDialog dialog = new SaveFileDialog(); FolderBrowserDialog dialog = new FolderBrowserDialog(); string[] logicalDrives = System.IO.Directory.GetLogicalDrives(); // dialog.AddExtension = true; try { // dialog.FileName = Path.GetFullPath(mLocationTextBox.Text); dialog.SelectedPath = Path.GetFullPath(mLocationTextBox.Text); } catch (Exception) {} // dialog.DefaultExt = Localizer.Message("obi_filter"); if (dialog.ShowDialog() == DialogResult.OK) { if (Path.GetFullPath(Path.GetDirectoryName(Path.Combine(dialog.SelectedPath, m_ProjectNameTextBox.Text + ".obi"))) == Path.GetFullPath(Path.GetDirectoryName(mOriginalProjectPath))) { MessageBox.Show(Localizer.Message("save_as_error_same_directory")); return; } foreach (string drive in logicalDrives) { if ((dialog.SelectedPath == drive) || (dialog.SelectedPath == Environment.GetFolderPath(Environment.SpecialFolder.Desktop)) || (dialog.SelectedPath == Environment.GetFolderPath(Environment.SpecialFolder.MyComputer) || (dialog.SelectedPath == Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)))) { MessageBox.Show(string.Format(Localizer.Message("SaveAs_cannot_save_in_root"), dialog.SelectedPath)); return; } } if (ObiForm.CheckProjectPath_Safe(Path.Combine(dialog.SelectedPath, m_ProjectNameTextBox.Text + ".obi"), true)) { m_PathChecked = true; mLocationTextBox.Text = dialog.SelectedPath; mUserSetLocation = true; // mLocationTextBox.Text = Path.GetDirectoryName(dialog.FileName); // mLocationTextBox.Text = dialog.FileName; // mNewDirectoryTextBox.TextChanged -= new EventHandler ( mNewDirectoryTextBox_TextChanged ); // mNewDirectoryTextBox.Text = Directory.GetParent ( mLocationTextBox.Text ).FullName; // mNewDirectoryTextBox.TextChanged += new EventHandler ( mNewDirectoryTextBox_TextChanged ); // mNewDirectoryTextBox.ReadOnly = true; // mLocationTextBox.Text = Path.GetFullPath(string.Format(Localizer.Message("save_as_new_directory_name"), mDir)); // m_ProjectNameTextBox.Text = "project.obi"; } } }
private void mOKButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(mPathTextBox.Text)) { MessageBox.Show(Localizer.Message("ExportDirectoryPathEmpty"), Localizer.Message("Caption_Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); mCanClose = false; return; } if (!m_IsMegaVoiceConnect) { mCanClose = ObiForm.CheckProjectDirectory_Safe(DirectoryPath, true); } else { if (!string.IsNullOrEmpty(mPathTextBox.Text) && !string.IsNullOrEmpty(m_MegaVoiceExportFileName)) { string MegaVoiceExportFinalPath = mPathTextBox.Text + "\\" + m_MegaVoiceExportFileName; if (Directory.Exists(MegaVoiceExportFinalPath)) { DialogResult tempResult = MessageBox.Show(Localizer.Message("ExportFolderExistsMegavoice"), Localizer.Message("Caption_Warning"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (tempResult == DialogResult.No) { mCanClose = false; return; } } mCanClose = ObiForm.CheckProjectDirectory_Safe(m_TemprorayPathOfMegavoiceExport, true, false); } } if (mCanClose && m_chkBoxCreateMediaOverlays.Enabled) { mSettings.Export_EpubCreateMediaOverlays = m_chkBoxCreateMediaOverlays.Checked; } if (m_chkBoxAddCuePointsInAudio.Checked) { DialogResult result = MessageBox.Show(string.Format(Localizer.Message("ExportInsertCuePointOrCopy"), "\n"), Localizer.Message("Caption_Information"), MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { m_IsInsertCuePoints = true; } } }
private void mSelectButton_Click(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.SelectedPath = mPathTextBox.Text; dialog.ShowNewFolderButton = true; if (dialog.ShowDialog() == DialogResult.OK && (m_IsMegaVoiceConnect || ObiForm.CheckProjectDirectory_Safe(dialog.SelectedPath, true))) { if (m_IsMegaVoiceConnect) { var drives = DriveInfo.GetDrives(); bool isRemovableDrive = false; //List<string> temp = new List<string>(); foreach (var drive in drives) { if (drive.DriveType == DriveType.Removable) { Console.WriteLine(drive.Name); //temp.Add(drive.Name); if (dialog.SelectedPath.Contains(drive.Name)) { if (dialog.SelectedPath == drive.Name) { isRemovableDrive = true; } } } } if (!isRemovableDrive) { DialogResult tempResult = MessageBox.Show(Localizer.Message("USBDriveCheck"), Localizer.Message("Caption_Information"), MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2); if (tempResult == DialogResult.No) { return; } } } mPathTextBox.Text = dialog.SelectedPath; } }
/// <summary> /// Before closing, make sure that the directory chosen works. /// </summary> private void mOKButton_Click(object sender, EventArgs e) { mCanClose = false; try { if (mTitleBox.Text.Trim() == "") { MessageBox.Show(Localizer.Message("NewProject_EmptyTitle"), Localizer.Message("EmptyProjectTitle_error_Caption"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } bool tempCheckPath = ObiForm.CheckProjectPath(mFileBox.Text, true); if (tempCheckPath) { m_AudioSettingsDialog.ShowDialog(); mCanClose = true; } } catch (Exception x) { MessageBox.Show(x.Message, Localizer.Message("location_error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void mOKButton_Click(object sender, EventArgs e) { mCanClose = ObiForm.CheckProjectDirectory_Safe(DirectoryPath, true); }
public void AssignShotcutToContextMenu() { KeyboardShortcuts_Settings keyboardShortcuts = mProjectView.ObiForm.KeyboardShortcuts; Context_ShowContentsMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mFocusOnTOCViewToolStripMenuItem"].Value.ToString())); Context_ShowContentsMenuItem.AccessibleName = Context_ShowContentsMenuItem.Text.Replace("&", "") + " " + Context_ShowContentsMenuItem.ShortcutKeyDisplayString; Context_AddSectionMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mAddSectionToolStripMenuItem"].Value.ToString())); Context_AddSectionMenuItem.AccessibleName = Context_AddSectionMenuItem.Text.Replace("&", "") + " " + Context_AddSectionMenuItem.ShortcutKeyDisplayString; Context_AddSubsectionMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mAddSubsectionToolStripMenuItem"].Value.ToString())); Context_AddSubsectionMenuItem.AccessibleName = Context_AddSubsectionMenuItem.Text.Replace("&", "") + " " + Context_AddSubsectionMenuItem.ShortcutKeyDisplayString; Context_InsertSectionMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mInsertSectionToolStripMenuItem"].Value.ToString())); Context_InsertSectionMenuItem.AccessibleName = Context_InsertSectionMenuItem.Text.Replace("&", "") + " " + Context_InsertSectionMenuItem.ShortcutKeyDisplayString; Context_MergeWithNextMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mMergeWithNextSectionToolStripMenuItem"].Value.ToString())); Context_MergeWithNextMenuItem.AccessibleName = Context_MergeWithNextMenuItem.Text.Replace("&", "") + " " + Context_MergeWithNextMenuItem.ShortcutKeyDisplayString; Context_MultipleOperationsMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mMultiSectionOperations"].Value.ToString())); Context_MultipleOperationsMenuItem.AccessibleName = Context_MultipleOperationsMenuItem.Text.Replace("&", "") + " " + Context_MultipleOperationsMenuItem.ShortcutKeyDisplayString; Context_RenameSectionMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mRenameSectionToolStripMenuItem"].Value.ToString())); Context_RenameSectionMenuItem.AccessibleName = Context_RenameSectionMenuItem.Text.Replace("&", "") + " " + Context_RenameSectionMenuItem.ShortcutKeyDisplayString; Context_DecreaseSectionLevelMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mDecreaseSectionLevelToolStripMenuItem"].Value.ToString())); Context_DecreaseSectionLevelMenuItem.AccessibleName = Context_DecreaseSectionLevelMenuItem.Text.Replace("&", "") + " " + Context_DecreaseSectionLevelMenuItem.ShortcutKeyDisplayString; Context_IncreaseSectionLevelMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mIncreaseSectionLevelToolStripMenuItem"].Value.ToString())); Context_IncreaseSectionLevelMenuItem.AccessibleName = Context_IncreaseSectionLevelMenuItem.Text.Replace("&", "") + " " + Context_IncreaseSectionLevelMenuItem.ShortcutKeyDisplayString; Context_SectionIsUsedMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mSectionIsUsedToolStripMenuItem"].Value.ToString())); Context_SectionIsUsedMenuItem.AccessibleName = Context_SectionIsUsedMenuItem.Text.Replace("&", "") + " " + Context_SectionIsUsedMenuItem.ShortcutKeyDisplayString; Context_AddBlankPhraseMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mAddBlankPhraseToolStripMenuItem"].Value.ToString())); Context_AddBlankPhraseMenuItem.AccessibleName = Context_AddBlankPhraseMenuItem.Text.Replace("&", "") + " " + Context_AddBlankPhraseMenuItem.ShortcutKeyDisplayString; Context_AddEmptyPagesMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mAddEmptyPagesToolStripMenuItem"].Value.ToString())); Context_AddEmptyPagesMenuItem.AccessibleName = Context_AddEmptyPagesMenuItem.Text.Replace("&", "") + " " + Context_AddEmptyPagesMenuItem.ShortcutKeyDisplayString; Context_CutMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mCutToolStripMenuItem"].Value.ToString())); Context_CutMenuItem.AccessibleName = Context_CutMenuItem.Text.Replace("&", "") + " " + Context_CutMenuItem.ShortcutKeyDisplayString; Context_CopyMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mCopyToolStripMenuItem"].Value.ToString())); Context_CopyMenuItem.AccessibleName = Context_CopyMenuItem.Text.Replace("&", "") + " " + Context_CopyMenuItem.ShortcutKeyDisplayString; Context_PasteMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mPasteToolStripMenuItem"].Value.ToString())); Context_PasteMenuItem.AccessibleName = Context_PasteMenuItem.Text.Replace("&", "") + " " + Context_PasteMenuItem.ShortcutKeyDisplayString; Context_PasteBeforeMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mPasteBeforeToolStripMenuItem"].Value.ToString())); Context_PasteBeforeMenuItem.AccessibleName = Context_PasteBeforeMenuItem.Text.Replace("&", "") + " " + Context_PasteBeforeMenuItem.ShortcutKeyDisplayString; Context_PasteInsideMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mPasteInsideToolStripMenuItem"].Value.ToString())); Context_PasteInsideMenuItem.AccessibleName = Context_PasteInsideMenuItem.Text.Replace("&", "") + " " + Context_PasteInsideMenuItem.ShortcutKeyDisplayString; Context_DeleteMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mDeleteToolStripMenuItem"].Value.ToString())); Context_DeleteMenuItem.AccessibleName = Context_DeleteMenuItem.Text.Replace("&", "") + " " + Context_DeleteMenuItem.ShortcutKeyDisplayString; Context_PropertiesMenuItem.ShortcutKeyDisplayString = ObiForm.RefineKeyboardShortcutStringForAccessibleName(keyboardShortcuts.FormatKeyboardShorcut(keyboardShortcuts.MenuNameDictionary["mView_SectionPropertiesMenuItem"].Value.ToString())); Context_PropertiesMenuItem.AccessibleName = Context_PropertiesMenuItem.Text.Replace("&", "") + " " + Context_PropertiesMenuItem.ShortcutKeyDisplayString; }