private void EditVerse_Cliked(object sender, System.Windows.RoutedEventArgs e) { if (this.SelectedNote == null) { MessageDisplay.Show("Please select a Verse Note"); return; } try { if (TextEditing.ShowDialog(this.SelectedNote.Verse, this.uxVerseNotes.Text).IsFalse()) { return; } if (TextEditing.Text.IsNullEmptyOrWhiteSpace()) { this.DeleteSelectedVerse(); return; } BiblesData.Database.InsertVerseNote(new VerseNotesModel { BibleVerseKey = this.SelectedNote.BibleVerseKey, FootNote = TextEditing.Text.ZipFile() }); this.uxVerseNotes.Text = TextEditing.Text; } catch (Exception err) { ErrorLog.ShowError(err); } }
private void Delete_Cliked(object sender, RoutedEventArgs e) { if (this.SelectedHighlight == null) { MessageDisplay.Show("Please select a Verse."); return; } try { string message = $"{TranslationDictionary.Translate("Are you sure you would like to delete?")} {this.SelectedHighlight.Verse}"; if (MessageDisplay.Show(message, "Warning", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } BiblesData.Database.DeleteHighlight(this.SelectedHighlight.BibleVerseKeyId); this.uxPager.ItemsSource.Remove(this.SelectedHighlight); this.uxVerseText.Text = string.Empty; } catch (Exception err) { ErrorLog.ShowError(err); } }
private void DeleteVerse_Cliked(object sender, RoutedEventArgs e) { if (this.SelectedBookmark == null) { MessageDisplay.Show("Please select a Bookmark"); return; } try { string message = $"Are you sure you would like to delete Bookmark {this.SelectedBookmark.SelectedVerse}."; if (MessageDisplay.Show(message, "Warning", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } string studyVerseKey = $"{this.StudyId}||{this.SelectedBookmark.VerseKey}"; BiblesData.Database.DeleteStudyBookmark(studyVerseKey); this.Bookmarks = this.Bookmarks.Remove(this.SelectedBookmark); } catch (Exception err) { ErrorLog.ShowError(err); } }
private void OpenVers_Cliked(object sender, RoutedEventArgs e) { if (this.SelectedBookmark == null) { MessageDisplay.Show("Please select a Bookmark"); return; } try { int bibleKey = Formatters.GetBibleFromKey(this.SelectedBookmark.VerseKey); object[] args = new object[] { bibleKey, this.SelectedBookmark.VerseKey }; this.InvokeMethod(Application.Current.MainWindow, "LoadReader", args); Application.Current.MainWindow.Focus(); } catch (Exception err) { ErrorLog.ShowError(err); } }
private void EditVerse_Cliked(object sender, RoutedEventArgs e) { if (this.SelectedBookmark == null) { MessageDisplay.Show("Please select a Bookmark"); return; } try { ModelsBookmark bookmark = this.SelectedBookmark.CopyTo(new ModelsBookmark()); ModelView.OnItemBrowse += this.BookmarkModel_Browse; if (ModelView.ShowDialog(this.GetParentWindow(), true, "Bookmark", bookmark).IsFalse()) { return; } this.SelectedBookmark = bookmark.CopyTo(this.SelectedBookmark); StudyBookmarkModel dbModel = this.SelectedBookmark.CopyToObject(new StudyBookmarkModel()).To <StudyBookmarkModel>(); dbModel.StudyVerseKey = $"{this.StudyId}||{this.SelectedBookmark.VerseKey}"; BiblesData.Database.InsertStudyBookmarkModel(dbModel); } catch (Exception err) { ErrorLog.ShowError(err); } }
public static void Show(string windowTitle, UserControlBase control, string boolUpdateMethod, Window owner = null, bool isTopMost = false, bool autoSize = true, bool showOkButton = true, bool showCancelButton = true) { try { ControlDialog.window = new ControlWindow(windowTitle, control, boolUpdateMethod, false, autoSize, showOkButton, showCancelButton); if (owner != null) { ControlDialog.window.Owner = owner; } ControlDialog.window.Topmost = isTopMost; ControlDialog.window.Show(); } catch (Exception err) { MessageDisplay.Show(err.InnerExceptionMessage()); } finally { ControlDialog.window = null; } }
private void DeleteVerse_Cliked(object sender, System.Windows.RoutedEventArgs e) { if (this.SelectedBookmark == null) { MessageDisplay.Show("Please select a Bookmark"); return; } try { string message = $"{TranslationDictionary.Translate("Are you sure you would like to delete?")} {this.SelectedBookmark.SelectedVerse}."; if (MessageDisplay.Show(message, "Warning", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } BiblesData.Database.DeleteBookmark(this.SelectedBookmark.VerseKey); this.uxPager.ItemsSource.Remove(this.SelectedBookmark); } catch (Exception err) { ErrorLog.ShowError(err); } }
public static bool?ShowDialog( string windowTitle, UserControlBase control, string boolUpdateMethod, bool autoSize = true, bool showOkButton = true, bool showCancelButton = true) { try { ControlDialog.window = new ControlWindow(windowTitle, control, boolUpdateMethod, true, autoSize, showOkButton, showCancelButton); return(ControlDialog.window.ShowDialog()); } catch (Exception err) { MessageDisplay.Show(err.InnerExceptionMessage()); return(false); } finally { ControlDialog.window = null; } }
private async void DisplayMouseHover() { try { RESLEEP: await Task.Factory.StartNew(() => { Sleep.ThreadWaitSeconds(this.sleepSeconds); }); bool[] isMouseOver = new bool[] { this.uxPopupContent.IsMouseOver, this.uxPopupContent.IsMouseOver, this.selectedTabHeader.IsMouseOver }; if (this.uxPopupContent.IsOpen && isMouseOver.All(m => !m)) { this.uxPopupContent.IsOpen = false; } else { goto RESLEEP; } } catch (Exception err) { #if DEBUG MessageDisplay.Show(TranslationDictionary.Translate(err.InnerExceptionMessage())); #endif // DO NOTHING } }
public static void Show(string windowTitle, UserControlBase control, string boolUpdateMethod, Window owner = null, bool isTopMost = false, bool autoSize = true, bool showOkButton = true, bool showCancelButton = true, double desiredSize = 0) { try { ControlDialog.window = new ControlWindow(windowTitle, control, boolUpdateMethod, false, autoSize, showOkButton, showCancelButton); if (owner != null) { ControlDialog.window.Owner = owner; } ControlDialog.window.Topmost = isTopMost; ControlDialog.window.Closing += ControlDialog.ControlWindow_Closing; if (desiredSize > ControlDialog.window.ScreenWidth().ToDouble()) { ControlDialog.FitToScreen(); } ControlDialog.window.Show(); } catch (Exception err) { MessageDisplay.Show(err.InnerExceptionMessage()); } }
public override void AddAditionalPanels() { if (ProTONEConfig.IsPlayer) { AddPanel(typeof(FileTypesPanel), AppConfig.CurrentUserIsAdministrator); } else if (ProTONEConfig.IsMediaLibrary) { AddPanel(typeof(AddonCfgPanel)); AddPanel(typeof(AddonSettingsPanel)); } AddPanel(typeof(SubtitleSettingsPanel)); if (ProTONEConfig.IsPlayer) { if (!AppConfig.CurrentUserIsAdministrator) { MessageDisplay.Show(Translator.Translate("TXT_PANELSHIDDEN_NOADMIN"), Translator.Translate("TXT_CAUTION"), MessageBoxIcon.Exclamation); } AddPanel(typeof(MiscellaneousSettingsPanel)); } AddPanel(typeof(ControlAppPanel)); }
private void CategoryItem_Delete(object sender, RoutedEventArgs e) { try { if (MessageDisplay.Show($"Are you sure you would like to delete {this.SelectedCategory.CategoryName}", "Warning", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } BiblesData.Database.DeleteCategory(this.SelectedCategory.StudyCategoryId); TreeViewItemTool category = this.uxCategoryTree.SelectedItem.To <TreeViewItemTool>(); if (category.Parent.GetType() == typeof(TreeViewItemTool)) { TreeViewItemTool parent = category.Parent.To <TreeViewItemTool>(); parent.Items.Remove(category); } else { this.uxCategoryTree.Items.Remove(category); } } catch (Exception err) { ErrorLog.ShowError(err); } }
private void btnOpenDvdFolder_Click(object sender, EventArgs e) { OPMFolderBrowserDialog dlg = new OPMFolderBrowserDialog(); dlg.ShowNewFolderButton = false; dlg.Description = Translator.Translate("TXT_LOAD_DVD_FOLDER"); dlg.PerformPathValidation += new PerformPathValidationHandler(dlg_PerformPathValidation); dlg.InheritAppIcon = false; dlg.Icon = this.Icon; if (dlg.ShowDialog() == DialogResult.OK) { try { _selectedMedia = DvdMedia.FromPath(dlg.SelectedPath); } catch { _selectedMedia = null; } if (_selectedMedia != null) { DialogResult = DialogResult.OK; Close(); } else { MessageDisplay.Show(Translator.Translate("TXT_INVALIDDVDVOLUME"), Translator.Translate("TXT_ERROR"), MessageBoxIcon.Warning); } } }
private void btnOk_Click(object sender, EventArgs e) { bool valid = false; Uri uri = null; try { valid = System.Uri.IsWellFormedUriString(txtUri.Text, UriKind.Absolute); if (valid) { uri = new Uri(txtUri.Text); } UriBuilder builder = new UriBuilder(txtUri.Text); } catch { valid = false; } if (!valid) { MessageDisplay.Show(Translator.Translate("TXT_TCPIPINVALIDFORMAT"), Translator.Translate("TXT_CAUTION"), MessageBoxIcon.Warning); } else { this.Uri = txtUri.Text; DialogResult = DialogResult.OK; } }
private void ClearBackColour_Clicked(object sender, RoutedEventArgs e) { if (this.selectedKey.IsNullEmptyOrWhiteSpace() || Formatters.GetVerseFromKey(this.selectedKey) <= 0) { MessageDisplay.Show("Please select a verse."); return; } try { int verseNumber = Formatters.GetVerseFromKey(this.selectedKey); HighlightRitchTextBox textBox = this.loadedTextBoxDictionary[verseNumber]; int start = textBox.GetSelectionStartIndex(); int length = textBox.GetSelectedTextLength(); textBox.Text = this.versesDictionary[verseNumber].VerseText; string bibleVerseKey = Formatters.IsBiblesKey(this.selectedKey) ? this.selectedKey : $"{this.Bible.BibleId}||{this.selectedKey}"; BiblesData.Database.DeleteVerseColours(bibleVerseKey); } catch (Exception err) { ErrorLog.ShowError(err); } }
private void Delete_Cliked(object sender, System.Windows.RoutedEventArgs e) { if (this.SelectedMapping == null) { MessageDisplay.Show("Please select a mapping"); return; } try { string message = $"{TranslationDictionary.Translate("Are you sure you would like to delete?")} {this.SelectedMapping.EnglishLanguage} -> {this.SelectedMapping.OtherLanguage}?"; if (MessageDisplay.Show(message, "Warning", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } this.deletedMappings.Add(this.SelectedMapping.TranslationMappingId); this.TranslationMappings = this.TranslationMappings.Remove(this.SelectedMapping); } catch (Exception err) { ErrorLog.ShowError(err); } }
private void ExportTranslation_Cliked(object sender, RoutedEventArgs e) { if (this.SelectedLanguage.LanguageId <= 0) { MessageDisplay.Show("Please select a Language"); return; } try { StringBuilder result = new StringBuilder(); foreach (TranslationMapping mapping in this.TranslationMappings) { result.AppendLine(JsonConvert.SerializeObject(mapping)); } string path = Path.Combine(Paths.KnownFolder(KnownFolder.Downloads), $"{this.SelectedLanguage.Language}_Translation_File.txt"); File.WriteAllText(path, result.ToString()); Process.Start(Paths.KnownFolder(KnownFolder.Downloads)); } catch (Exception err) { ErrorLog.ShowError(err); } }
private void Add_Cliked(object sender, System.Windows.RoutedEventArgs e) { if (this.SelectedLanguage.LanguageId <= 0) { MessageDisplay.Show("Please select a Language"); return; } try { TranslationMapping mapping = new TranslationMapping(); if (ModelView.ShowDialog("New Mapping", mapping).IsFalse()) { return; } this.TranslationMappings = this.TranslationMappings.Add(mapping); } catch (Exception err) { ErrorLog.ShowError(err); } }
private void Edit_Cliked(object sender, System.Windows.RoutedEventArgs e) { if (this.SelectedMapping == null) { MessageDisplay.Show("Please select a mapping"); return; } try { TranslationMapping mapping = this.SelectedMapping.CopyTo(new TranslationMapping()); if (ModelView.ShowDialog("Edit Mapping", mapping).IsFalse()) { return; } this.SelectedMapping = mapping.CopyTo(this.SelectedMapping); } catch (Exception err) { ErrorLog.ShowError(err); } }
private void OkButton_Clicked(object sender, RoutedEventArgs e) { try { if (!this.boolUpdateMethodName.IsNullEmptyOrWhiteSpace()) { bool updateResult = this.InvokeMethod(this.uxContent.Content, this.boolUpdateMethodName, new object[] { }).TryToBool(); if (!updateResult) { return; } } if (this.isAsDialog) { this.DialogResult = true; } else { this.Close(); } } catch (Exception err) { MessageDisplay.Show(err.InnerExceptionMessage()); } }
private void ImportStudy_Click(object sender, RoutedEventArgs e) { try { OpenFileDialog openDlg = new OpenFileDialog(); openDlg.Title = "Import Study"; openDlg.DefaultExt = ".study"; openDlg.Filter = "Bible Study (.study)|*.study"; if (openDlg.ShowDialog(this.GetParentWindow()).IsFalse()) { return; } this.InvokeMethod("Bibles.Downloads.ImportBibleStudy,Bibles.Downloads", "ImportStudy", new object[] { openDlg.FileName }); this.uxStudyCategories.Initialize(); MessageDisplay.Show("Import Completed."); } catch (Exception err) { ErrorLog.ShowError(err); } }
void ApplicationNotifier_ApplicationMessageBoxMessage(string message, string title, MessageBoxIcon icon) { MessageBoxIcon msgIcon = MessageBoxIcon.None; switch (icon) { case MessageBoxIcon.Information: msgIcon = MessageBoxIcon.Information; break; case MessageBoxIcon.Warning: msgIcon = MessageBoxIcon.Warning; break; case MessageBoxIcon.Error: msgIcon = MessageBoxIcon.Error; break; case MessageBoxIcon.None: default: msgIcon = MessageBoxIcon.None; break; } MessageDisplay.Show(message, title, msgIcon); }
public static bool?ShowDialog(Window owner, bool topMost, string windowTitle, object model) { try { ModelView.viewer = new ViewerWindow(windowTitle, model); ModelView.viewer.OnItemBrowse += ModelView.OnItem_Browse; ModelView.viewer.Owner = owner; ModelView.viewer.Topmost = topMost; return(ModelView.viewer.ShowDialog()); } catch (Exception err) { MessageDisplay.Show(err.InnerExceptionMessage()); } finally { ModelView.viewer.OnItemBrowse -= ModelView.OnItem_Browse; ModelView.viewer = null; } return(null); }
public static bool?ShowDialog( string windowTitle, UserControlBase control, string boolUpdateMethod, bool autoSize = true, bool showOkButton = true, bool showCancelButton = true, double desiredSize = 0) { try { ControlDialog.window = new ControlWindow(windowTitle, control, boolUpdateMethod, true, autoSize, showOkButton, showCancelButton); ControlDialog.window.Closing += ControlDialog.ControlWindow_Closing; ControlDialog.window.Owner = Application.Current.MainWindow; if (desiredSize > ControlDialog.window.ScreenWidth().ToDouble()) { ControlDialog.FitToScreen(); } return(ControlDialog.window.ShowDialog()); } catch (Exception err) { MessageDisplay.Show(err.InnerExceptionMessage()); return(false); } }
private void Hyperlink_Clicked(object sender, RoutedEventArgs e) { try { HyperlinkEdit linker = new HyperlinkEdit(); if (linker.ShowDialog().IsFalse()) { return; } Run run = new Run(linker.Hyperlink.DisplayName); TextPointer textPoint = this.uxHtmlText.CaretPosition.GetInsertionPosition(LogicalDirection.Forward); Hyperlink hyperLink = new Hyperlink(run, textPoint); hyperLink.NavigateUri = new Uri(linker.Hyperlink.Url); hyperLink.IsEnabled = true; hyperLink.RequestNavigate += (hyperlinkSender, args) => Process.Start(args.Uri.ToString()); } catch (Exception err) { MessageDisplay.Show(TranslationDictionary.Translate(err.InnerExceptionMessage())); } }
public static bool?ShowDialog(Window owner, bool topMost, string windowTitle, string fieldCaption) { try { InputBox.InputModel = new InputBoxModel(); InputBox.viewer = new ViewerWindow(windowTitle, fieldCaption, InputBox.InputModel); InputBox.viewer.Owner = owner; InputBox.viewer.Topmost = topMost; return(InputBox.viewer.ShowDialog()); } catch (Exception err) { MessageDisplay.Show(err.InnerExceptionMessage()); } finally { InputBox.viewer = null; } return(null); }
private void LinkVerse_Cliked(object sender, RoutedEventArgs e) { if (this.SelectedVerseKey.IsNullEmptyOrWhiteSpace() || Formatters.GetVerseFromKey(this.SelectedVerseKey) <= 0 || this.SelectedSide == ParalelleSideEnum.None) { MessageDisplay.Show("Please select a Verse."); return; } try { Type linkType = Type.GetType("Bibles.Link.LinkEditor,Bibles.Link"); object[] args = new object[] { this.selectedBibleId, this.SelectedSide == ParalelleSideEnum.Left ? this.versesDictionaryLeft[Formatters.GetVerseFromKey(this.SelectedVerseKey)] : this.versesDictionaryRight[Formatters.GetVerseFromKey(this.SelectedVerseKey)] }; UserControlBase linkEditor = Activator.CreateInstance(linkType, args) as UserControlBase; string title = $"Link - {GlobalStaticData.Intance.GetKeyDescription(this.SelectedVerseKey)}"; linkEditor.Height = this.Height; if (ControlDialog.ShowDialog(title, linkEditor, "AcceptLink", false).IsFalse()) { return; } int selectedVerse = Formatters.GetVerseFromKey(this.selectedKey); BibleLoader.RefreshVerseNumberPanel ( this.loadedVerseStackDictionaryLeft[selectedVerse], this.BibleLeft.BibleId, this.versesDictionaryLeft[selectedVerse] ); BibleLoader.RefreshVerseNumberPanel ( this.loadedVerseStackDictionaryRight[selectedVerse], this.BibleRight.BibleId, this.versesDictionaryRight[selectedVerse] ); } catch (Exception err) { ErrorLog.ShowError(err); } }
private bool VerifyShortcut(KeyEventArgs args) { OPMShortcut cmd = ShortcutMapper.MapCommand(args.KeyData); if (cmd == OPMShortcut.CmdOutOfRange) { // Key combination currently not assigned so it's OK to use it. return(true); } if (cmd == _cmd) { // Same command => ok to reassign. return(true); } string cmdOld = cmd.ToString().Replace("Cmd", string.Empty); string cmdNew = _cmd.ToString().Replace("Cmd", string.Empty); KeysConverter kc = new KeysConverter(); string key = kc.ConvertToInvariantString(args.KeyData); if ((args.KeyData == Keys.Space && ShortcutMapper.IsPlayer) || !ShortcutMapper.IsConfigurableShortcut(cmd)) { // Key combination currently assigned // to a non-configurable command (e.g. F1 = help) MessageDisplay.Show(Translator.Translate("TXT_DUP_SHORTCUT_FIXED", key, cmdOld), Translator.Translate("TXT_DUPPLICATE_SHORTCUT"), MessageBoxIcon.Warning); return(false); } if (MessageDisplay.Query(Translator.Translate("TXT_DUP_SHORTCUT_CONFIRM", key, cmdOld, cmdNew), Translator.Translate("TXT_DUPPLICATE_SHORTCUT"), MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes) { // Key combination already assigned and the user did not want to change it use it. return(false); } // Unassign old shortcut if (ShortcutMapper.KeyCommands[(int)cmd].KeyData == args.KeyData) { // Was used for primary shortcut ShortcutMapper.KeyCommands[(int)cmd] = new KeyEventArgs(Keys.None); } else if (ShortcutMapper.AltKeyCommands[(int)cmd].KeyData == args.KeyData) { // Was used for alternate shortcut ShortcutMapper.AltKeyCommands[(int)cmd] = new KeyEventArgs(Keys.None); } return(true); }
private void EditStudy_Click(object sender, System.Windows.RoutedEventArgs e) { if (this.SelectedStudyHeader == null) { MessageDisplay.Show("Please select a Study."); return; } try { #region CHECK FOR OPEN STUDIES foreach (Window window in Application.Current.Windows) { if (window.GetType() != typeof(ControlWindow)) { continue; } UserControlBase controlBase = window.GetPropertyValue("ControlContent").To <UserControlBase>(); if (controlBase.GetType() != typeof(EditStudy)) { continue; } StudyHeader studyHeader = controlBase.GetPropertyValue("SubjectHeader").To <StudyHeader>(); if (studyHeader.StudyHeaderId <= 0) { continue; } window.Focus(); this.CloseIfNotMainWindow(true); return; } #endregion EditStudy edit = new EditStudy(this.SelectedStudyHeader); ControlDialog.Show(this.SelectedStudyHeader.StudyName, edit, "SaveStudy", autoSize: false); this.CloseIfNotMainWindow(true); } catch (Exception err) { ErrorLog.ShowError(err); } }
private void Collapse_Clicked(object sender, System.Windows.RoutedEventArgs e) { try { this.ToggelCollaps(this.uxCollapse.Direction != Specialized.DirectionsEnum.Right); } catch (Exception err) { MessageDisplay.Show(err.Message); } }