public ChatWindowViewModel(ChatWindowViewModelSettings settings, List <TranslationEngine> translationEngines, List <ChatMsgType> allChatCodes, HotKeyManager hotKeyManager) { this._AsyncPropertyChanged = new AsyncEvent <AsyncPropertyChangedEventArgs>(this.EventErrorHandler, "ChatWindowViewModel \n AsyncPropertyChanged"); this._RequestChatClear = new AsyncEvent <TatruEventArgs>(this.EventErrorHandler, "ChatWindowViewModel \n RequsetChatClear"); ShowChatWindowCommand = new TataruUICommand(ShowChatWindow); RestChatWindowPositionCommand = new TataruUICommand(ResetChatWindowPosition); _IsWindowVisible = true; Name = settings.Name; _WinId = settings.WinId; ChatFontSize = settings.ChatFontSize; LineBreakHeight = settings.LineBreakHeight; SpacingCount = settings.SpacingCount; IsAlwaysOnTop = settings.IsAlwaysOnTop; IsClickThrough = settings.IsClickThrough; IsAutoHide = settings.IsAutoHide; AutoHideTimeout = settings.AutoHideTimeout; IsHiddenByUser = false; BackGroundColor = settings.BackGroundColor; TranslationEngines = new CollectionView(translationEngines); var tmpEngine = translationEngines.FirstOrDefault(x => x.EngineName == settings.TranslationEngineName); TranslationEngines.MoveCurrentToFirst(); if (tmpEngine != null) { if (TranslationEngines.Contains(tmpEngine)) { TranslationEngines.MoveCurrentTo(tmpEngine); } else { TranslationEngines.MoveCurrentToFirst(); } } OnTranslationEngineChange(this, null); TrySetLangugue(_TranslateFromLanguagues, settings.FromLanguague); TrySetLangugue(_TranslateToLanguagues, settings.ToLanguague); ChatWindowRectangle = settings.ChatWindowRectangle; ChatCodes = LoadChatCodes(settings.ChatCodes, allChatCodes); _HotKeyManager = hotKeyManager; ShowHideChatKeys = new HotKeyCombination(settings.ShowHideChatKeys); ClickThoughtChatKeys = new HotKeyCombination(settings.ClickThoughtChatKeys); ClearChatKeys = new HotKeyCombination(settings.ClearChatKeys); _HotKeyManager.GlobalHotKeyPressed += OnGlobalHotKeyPressed; }
public UserSettings() { BackgroundColor = (Color)ColorConverter.ConvertFromString("#4B000000"); Font1Color = (Color)ColorConverter.ConvertFromString("#FFFFFFFF"); Font2Color = (Color)ColorConverter.ConvertFromString("#FFFFFFFF"); IsClickThrough = false; IsAlwaysOnTop = true; IsHideToTray = false; IsAutoHide = false; IsDirecMemoryReading = true; AutoHideTimeout = new TimeSpan(0, 5, 0); FontSize = 14; RecentBackgroundColors = new List <Color>(new Color[] { (Color)ColorConverter.ConvertFromString("#4B000000") }); LineBreakHeight = 0; InsertSpaceCount = 0; CurrentTranslationEngine = 0; CurrentFFXIVLanguage = "English"; CurrentTranslateToLanguage = "English"; CurentUILanguague = (int)LanguagueWrapper.Languages.English; SettingsWindowSize = new System.Drawing.PointD(0.0, 0.0); ChatWindowLocation = new System.Drawing.RectangleD(0.0, 0.0, 0.0, 0.0); ShowHideChatKeys = new HotKeyCombination("ShowHideChatWin"); ClickThoughtChatKeys = new HotKeyCombination("ClickThoughtChatWin"); ClearChatKeys = new HotKeyCombination("ClearChatWin"); ChatCodes = new Dictionary <string, ChatMsgType>() { { "003D", new ChatMsgType("003D", MsgType.Translate, "NPCD", (Color)ColorConverter.ConvertFromString("#FFABD647")) }, { "0044", new ChatMsgType("0044", MsgType.Translate, "NPCA", (Color)ColorConverter.ConvertFromString("#FFABD647")) }, }; //ChatWindows = new List<ChatWindowViewModelSettings>(new ChatWindowViewModelSettings[] { new ChatWindowViewModelSettings() }); ChatWindows = new List <ChatWindowViewModelSettings>(); IsFirstTime = 0; }
private void RegisterHotKeyUp(ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination, TextBox textBox, KeyEventArgs e) { try { var pressedKeys = Keys.GetPressdKeys(); pressedKeys = Keys.ClearRepeatedKeys(pressedKeys); pressedKeys = Keys.ClearMousKeys(pressedKeys); string str = _EmptyHKString; if (pressedKeys.Length == 0) { Keyboard.ClearFocus(); if (hotKeyCombination.IsInitialized) { str = hotKeyCombination.CombinationKeysName(); if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } else { int t = 0; t++; } var k = Keys.ConvertFromWpfKey(hotKeyCombination.NormalKey); globalHotKey = new GlobalHotKey(hotKeyCombination.Name, hotKeyCombination.ModifierKey, k); _HotKeyManager.AddGlobalHotKey(globalHotKey); textBox.Text = str; } else { if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } } } } catch (Exception ex) { Logger.WriteLog(ex); } }
public UserSettings(UserSettings userSettings) { Color BackgroundColor = userSettings.BackgroundColor; Font1Color = userSettings.Font1Color; Font2Color = userSettings.Font2Color; IsClickThrough = userSettings.IsClickThrough; IsAlwaysOnTop = userSettings.IsAlwaysOnTop; IsHideToTray = userSettings.IsHideToTray; IsAutoHide = userSettings.IsAutoHide; IsDirecMemoryReading = userSettings.IsDirecMemoryReading; AutoHideTimeout = userSettings.AutoHideTimeout; FontSize = userSettings.FontSize; RecentBackgroundColors = userSettings.RecentBackgroundColors.ToList(); LineBreakHeight = userSettings.LineBreakHeight; InsertSpaceCount = userSettings.InsertSpaceCount; CurrentTranslationEngine = userSettings.CurrentTranslationEngine; CurrentFFXIVLanguage = userSettings.CurrentFFXIVLanguage; CurrentTranslateToLanguage = userSettings.CurrentTranslateToLanguage; CurentUILanguague = userSettings.CurentUILanguague; ShowHideChatKeys = new HotKeyCombination(userSettings.ShowHideChatKeys); ClickThoughtChatKeys = new HotKeyCombination(userSettings.ClickThoughtChatKeys); SettingsWindowSize = userSettings.SettingsWindowSize; ChatWindowLocation = userSettings.ChatWindowLocation; ChatCodes = userSettings.ChatCodes.ToDictionary(entry => entry.Key, entry => new ChatMsgType(entry.Value)); ChatWindows = userSettings.ChatWindows.Select(element => new ChatWindowViewModelSettings(element)).ToList(); IsFirstTime = userSettings.IsFirstTime; }
private void RemoveHotKey(HotKeyCombination combination, ref GlobalHotKey globalHotKey) { try { combination.ClearKeys(); if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } } catch (Exception e) { Logger.WriteLog(e); } }
private void RegisterHotKeyUp(ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination, KeyEventArgs e) { if (_disposed) { return; } try { var pressedKeys = Keys.GetPressdKeys(); pressedKeys = Keys.ClearRepeatedKeys(pressedKeys); pressedKeys = Keys.ClearMousKeys(pressedKeys); if (pressedKeys.Length == 0) { Keyboard.ClearFocus(); if (hotKeyCombination.IsInitialized) { if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } var k = Keys.ConvertFromWpfKey(hotKeyCombination.NormalKey); globalHotKey = new GlobalHotKey(hotKeyCombination.Name, hotKeyCombination.ModifierKey, k); _HotKeyManager.AddGlobalHotKey(globalHotKey); } else { if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } } } } catch (Exception ex) { Logger.WriteLog(ex); } }
public TataruUIModel(ReadOnlyCollection <ReadOnlyCollection <TranslatorLanguague> > translatorsLanguages) { _TranslatorsLanguages = translatorsLanguages; this._ChatFontSizeChanged = new AsyncEvent <IntegerValueChangeEventArgs>(this.EventErrorHandler, "ChatFontSizeChanged"); this._BackgroundColorChanged = new AsyncEvent <ColorChangeEventArgs>(this.EventErrorHandler, "BackgroundColorChanged"); this._ColorListChanged = new AsyncEvent <ColorListChangeEventArgs>(this.EventErrorHandler, "ColorListChanged"); this._ParagraphSpaceCountChanged = new AsyncEvent <IntegerValueChangeEventArgs>(this.EventErrorHandler, "ParagraphSpaceCountChanged"); this._LineBreakeHeightChanged = new AsyncEvent <IntegerValueChangeEventArgs>(this.EventErrorHandler, "LineBreakeHeightChanged"); this._TranslationEngineChanged = new AsyncEvent <TranslationEngineChangeEventArgs>(this.EventErrorHandler, "TranslationEngineChanged"); this._FFLanguageChanged = new AsyncEvent <StringValueChangeEventArgs>(this.EventErrorHandler, "FFLanguageChanged"); this._TranslateToLanguageChanged = new AsyncEvent <StringValueChangeEventArgs>(this.EventErrorHandler, "TranslateToLanguageChanged"); this._ShowHideChatCombinationChanged = new AsyncEvent <HotKeyCombinationChangeEventArgs>(this.EventErrorHandler, "ShowHideChatCombinationChanged"); this._ClickThoughtChatCombinationChanged = new AsyncEvent <HotKeyCombinationChangeEventArgs>(this.EventErrorHandler, "ClickThoughtChatCombinationChanged"); this._ClearChatCombinationChanged = new AsyncEvent <HotKeyCombinationChangeEventArgs>(this.EventErrorHandler, "ClearChatCombinationChanged"); this._IsChatClickThroughChanged = new AsyncEvent <BooleanChangeEventArgs>(this.EventErrorHandler, "IsChatClickThroughChanged"); this._IsChatAlwaysOnTopChanged = new AsyncEvent <BooleanChangeEventArgs>(this.EventErrorHandler, "IsChatAlwaysOnTopChanged"); this._IsHideSettingsToTrayChanged = new AsyncEvent <BooleanChangeEventArgs>(this.EventErrorHandler, "IsHideSettingsToTrayChanged"); this._IsAutoHideChanged = new AsyncEvent <BooleanChangeEventArgs>(this.EventErrorHandler, "IsAutoHideChanged"); this._IsDirecMemoryReadingChanged = new AsyncEvent <BooleanChangeEventArgs>(this.EventErrorHandler, "IsDirecMemoryReadingChanged"); this._AutoHideTimeoutChanged = new AsyncEvent <TimeSpanChangeEventArgs>(this.EventErrorHandler, "AutoHideTimeoutChanged"); this._SettingsWindowSizeChanged = new AsyncEvent <PointDValueChangeEventArgs>(this.EventErrorHandler, "SettingsWindowSizeChanged"); this._ChatWindowRectangleChanged = new AsyncEvent <RectangleDValueChangeEventArgs>(this.EventErrorHandler, "ChatWindowRectangleChanged"); this._ChatCodesChanged = new AsyncEvent <ChatMsgTypeChangeEventArgs>(this.EventErrorHandler, "ChatCodesChanged"); this._UiLanguageChanged = new AsyncEvent <IntegerValueChangeEventArgs>(this.EventErrorHandler, "UiLanguageChanged"); _RecentBackgroundColors = new List <Color>(); _ShowHideChatKeys = new HotKeyCombination("ShowHideChatWin"); _ClickThoughtChatKeys = new HotKeyCombination("ClickThoughtChatWin"); _IsHiddenByUser = false; }
private void RegisterHotKeyDown(ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination, TextBox textBox, KeyEventArgs e) { try { var _key = Helper.RealKey(e); var pressedKeys = Keys.GetPressdKeys(); pressedKeys = Keys.ClearRepeatedKeys(pressedKeys); pressedKeys = Keys.ClearMousKeys(pressedKeys); if (pressedKeys.Length <= 1) { hotKeyCombination.ClearKeys(); } hotKeyCombination.AddKey(_key); string str = _EmptyHKString; if (hotKeyCombination.IsInitialized) { str = hotKeyCombination.CombinationKeysName(); textBox.Text = str; } else { if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } } textBox.Text = str; } catch (Exception ex) { Logger.WriteLog(ex); } }
private void RegisterHotkey(HotKeyCombination combination, ref GlobalHotKey globalHotKey) { try { if (combination.IsInitialized) { if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } var k = Keys.ConvertFromWpfKey(combination.NormalKey); globalHotKey = new GlobalHotKey(combination.Name, combination.ModifierKey, k); _HotKeyManager.AddGlobalHotKey(globalHotKey); } } catch (Exception e) { Logger.WriteLog(e); } }
private void RegisterHotKeyDown(ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination, KeyEventArgs e) { if (_disposed) { return; } try { var _key = Helper.RealKey(e); var pressedKeys = Keys.GetPressdKeys(); pressedKeys = Keys.ClearRepeatedKeys(pressedKeys); pressedKeys = Keys.ClearMousKeys(pressedKeys); if (pressedKeys.Length <= 1) { hotKeyCombination.ClearKeys(); } hotKeyCombination.AddKey(_key); if (!hotKeyCombination.IsInitialized) { if (globalHotKey != null) { _HotKeyManager.RemoveGlobalHotKey(globalHotKey); } } } catch (Exception ex) { Logger.WriteLog(ex); } }
public void SetSettings(UserSettings userSettings) { UserSettings tmpSettings = new UserSettings(); UiLanguage = userSettings.CurentUILanguague; ChatFontSize = userSettings.FontSize; BackgroundColor = userSettings.BackgroundColor; ParagraphSpaceCount = userSettings.InsertSpaceCount; LineBreakeHeight = userSettings.LineBreakHeight; TranslationEngine = (TranslationEngine)userSettings.CurrentTranslationEngine; FFLanguage = userSettings.CurrentFFXIVLanguage; TranslateToLanguage = userSettings.CurrentTranslateToLanguage; IsChatClickThrough = userSettings.IsClickThrough; IsChatAlwaysOnTop = userSettings.IsAlwaysOnTop; IsHideSettingsToTray = userSettings.IsHideToTray; IsAutoHide = userSettings.IsAutoHide; IsDirecMemoryReading = userSettings.IsDirecMemoryReading; AutoHideTimeout = userSettings.AutoHideTimeout; if (userSettings.ShowHideChatKeys != null) { ShowHideChatKeys = new HotKeyCombination(userSettings.ShowHideChatKeys); } else { ShowHideChatKeys = new HotKeyCombination(tmpSettings.ShowHideChatKeys); } if (userSettings.ClickThoughtChatKeys != null) { ClickThoughtChatKeys = new HotKeyCombination(userSettings.ClickThoughtChatKeys); } else { ClickThoughtChatKeys = new HotKeyCombination(tmpSettings.ClickThoughtChatKeys); } if (userSettings.ClearChatKeys != null) { ClearChatKeys = new HotKeyCombination(userSettings.ClearChatKeys); } else { ClearChatKeys = new HotKeyCombination(tmpSettings.ClearChatKeys); } SettingsWindowSize = userSettings.SettingsWindowSize; ChatWindowRectangle = userSettings.ChatWindowLocation; if (userSettings.RecentBackgroundColors != null) { RecentBackgroundColors = userSettings.RecentBackgroundColors.Distinct().ToList(); } else { RecentBackgroundColors = tmpSettings.RecentBackgroundColors.Distinct().ToList(); } var tmpChatList = Helper.LoadJsonData <List <ChatMsgType> >(GlobalSettings.ChatCodesFilePath); var tmpChatCodes = new Dictionary <string, ChatMsgType>(); for (int i = 0; i < tmpChatList.Count; i++) { tmpChatCodes.TryAdd(tmpChatList[i].ChatCode, tmpChatList[i]); } var userCodes = userSettings.ChatCodes.Values.ToList(); for (int i = 0; i < userCodes.Count; i++) { if (tmpChatCodes.ContainsKey(userCodes[i].ChatCode)) { tmpChatCodes[userCodes[i].ChatCode] = userCodes[i]; } } ChatCodes = tmpChatCodes; IsFirstTime = userSettings.IsFirstTime; }
private void ReRegisterGlobalHotekey(HotKeyManager hotKeyManager, ref GlobalHotKey globalHotKey, HotKeyCombination hotKeyCombination) { if (_disposed) { return; } if (globalHotKey != null) { hotKeyManager.RemoveGlobalHotKey(globalHotKey); globalHotKey = null; } if (hotKeyCombination.IsInitialized) { var k = Keys.ConvertFromWpfKey(hotKeyCombination.NormalKey); globalHotKey = new GlobalHotKey(hotKeyCombination.Name, hotKeyCombination.ModifierKey, k); hotKeyManager.AddGlobalHotKey(globalHotKey); } }