/// <summary> /// Executes the Add To Favorites Form for the specified character. /// </summary> /// <param name="charCode">Character code.</param> /// <param name="owner">Owner window.</param> /// <returns></returns> public static int? Execute(ushort charCode, Control owner) { int? result = null; using (AddToFavoritesForm frmAddToFavorites = new AddToFavoritesForm()) { frmAddToFavorites.CharacterCode = charCode; DialogResult dialogResult = frmAddToFavorites.ShowDialog(owner); if (dialogResult == DialogResult.OK) { result = frmAddToFavorites.SelectedIndex; } } return result; }
/// <summary> /// Executes the Add To Favorites Form for the specified character. /// </summary> /// <param name="charCode">Character code.</param> /// <param name="owner">Owner window.</param> /// <returns></returns> public static int?Execute(ushort charCode, Control owner) { int?result = null; using (AddToFavoritesForm frmAddToFavorites = new AddToFavoritesForm()) { frmAddToFavorites.CharacterCode = charCode; DialogResult dialogResult = frmAddToFavorites.ShowDialog(owner); if (dialogResult == DialogResult.OK) { result = frmAddToFavorites.SelectedIndex; } } return(result); }
private void frmCharacterLookup_ResultSubmitted(object sender, CharacterSearchResultEventArgs e) { switch (e.Result.Action) { case CharacterSearchAction.Cancel: break; case CharacterSearchAction.InsertCharacter: if (!e.Result.KeepApplicationActive) { HideApplication(); } try { UnicodeCharSender.Send(hTargetWindow, e.Result.CharacterCode); } catch (Exception ex) { ShowErrorMessage(LocalizationHelper.GetResource(this, "msgSendCharFailed"), ex); } if (e.Result.KeepApplicationActive) { NativeMethods.SetForegroundWindow(Handle); } break; case CharacterSearchAction.CopyCharacterToClipboard: Clipboard.SetText(((char)e.Result.CharacterCode).ToString()); HideApplication(); break; case CharacterSearchAction.AddCharacterToFavorites: int?selectedIndex = AddToFavoritesForm.Execute(e.Result.CharacterCode, this); if (selectedIndex.HasValue) { UserSettings.Instance.Favorites[selectedIndex.Value] = e.Result.CharacterCode; UserSettings.Instance.Save(false); LoadFavorites(); } break; } }