public ShortcutKeyControlElement(MainWindow window, SettingsWindow settingsWindow) { this.InitializeComponent(); this.ParentWindow = window; this.ParentSettingsWindow = settingsWindow; InputMethod.SetIsInputMethodEnabled((DependencyObject)this.mShortcutKeyTextBox, false); MainWindow parentWindow = this.ParentWindow; string[] strArray; if (parentWindow == null) { strArray = (string[])null; } else { strArray = parentWindow.mCommonHandler.mShortcutsConfigInstance.DefaultModifier.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); } foreach (string str in strArray) { Key key = (Key)Enum.Parse(typeof(Key), str); this.mDefaultModifierForUI = this.mDefaultModifierForUI + IMAPKeys.GetStringForUI(key) + " + "; this.mDefaultModifierForFile = this.mDefaultModifierForFile + IMAPKeys.GetStringForFile(key) + " + "; } }
private bool Valid(Key key) { if (key == Key.Escape || key == Key.LeftAlt || (key == Key.RightAlt || key == Key.LeftCtrl) || (key == Key.RightCtrl || key == Key.RightShift || (key == Key.LeftShift || key == Key.Capital)) || (key == Key.Return || key == Key.Space || key == Key.Delete)) { return(false); } if (this.ParentWindow.mCommonHandler.mShortcutsConfigInstance != null) { string b = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0} + {1} + {2}", (object)IMAPKeys.GetStringForFile(Key.LeftCtrl), (object)IMAPKeys.GetStringForFile(Key.LeftAlt), (object)IMAPKeys.GetStringForFile(key)); foreach (ShortcutKeys shortcutKeys in this.ParentWindow.mCommonHandler.mShortcutsConfigInstance.Shortcut) { if (string.Equals(shortcutKeys.ShortcutKey, b, StringComparison.InvariantCulture)) { this.ParentWindow.mCommonHandler.AddToastPopup((Window)this.ParentWindow.MacroRecorderWindow, LocaleStrings.GetLocalizedString("STRING_ALREADY_IN_USE_MESSAGE", ""), 4.0, true); return(false); } } } if (!MainWindow.sMacroMapping.ContainsKey(IMAPKeys.GetStringForFile(key)) || !(MainWindow.sMacroMapping[IMAPKeys.GetStringForFile(key)] != this.mRecording.Name)) { return(true); } this.ParentWindow.mCommonHandler.AddToastPopup((Window)this.ParentWindow.MacroRecorderWindow, LocaleStrings.GetLocalizedString("STRING_ALREADY_IN_USE_MESSAGE", ""), 4.0, true); return(false); }
private void KeyTextBox_KeyUp(object sender, KeyEventArgs e) { if (this.lstActionItem[0].Type != KeyActionType.Tap && this.lstActionItem[0].Type != KeyActionType.TapRepeat && this.lstActionItem[0].Type != KeyActionType.Script) { return; } if (this.mKeyList.Count >= 2) { string str1 = IMAPKeys.GetStringForUI(this.mKeyList.ElementAt <Key>(this.mKeyList.Count - 2)) + " + " + IMAPKeys.GetStringForUI(this.mKeyList.ElementAt <Key>(this.mKeyList.Count - 1)); string str2 = IMAPKeys.GetStringForFile(this.mKeyList.ElementAt <Key>(this.mKeyList.Count - 2)) + " + " + IMAPKeys.GetStringForFile(this.mKeyList.ElementAt <Key>(this.mKeyList.Count - 1)); this.mKeyTextBox.Text = str1; this.mKeyTextBox.Tag = (object)str2; this.SetValueHandling(); } else if (this.mKeyList.Count == 1) { string stringForUi = IMAPKeys.GetStringForUI(this.mKeyList.ElementAt <Key>(0)); string stringForFile = IMAPKeys.GetStringForFile(this.mKeyList.ElementAt <Key>(0)); this.mKeyTextBox.Text = stringForUi; this.mKeyTextBox.Tag = (object)stringForFile; this.SetValueHandling(); } if (!this.ActionItemProperty.Equals("EnableCondition", StringComparison.InvariantCultureIgnoreCase) && !this.ActionItemProperty.Equals("StartCondition", StringComparison.InvariantCultureIgnoreCase) && !this.ActionItemProperty.Equals("Note", StringComparison.InvariantCultureIgnoreCase)) { this.mKeyTextBox.CaretIndex = this.mKeyTextBox.Text.Length; } this.mKeyList.Clear(); }
public static string GetStringForUI(string key) { if (!string.IsNullOrEmpty(key)) { Key key1 = EnumHelper.Parse <Key>(key, Key.NoName); if (key1 != Key.NoName) { key = IMAPKeys.GetStringForUI(key1); } } return(key); }
public static string GetStringForUI(Key key) { string str = key.ToString(); if (IMAPKeys.mDictKeys.ContainsKey(key)) { str = IMAPKeys.mDictKeys[key]; if (str.StartsWith("Oem", StringComparison.OrdinalIgnoreCase)) { str = IMAPKeys.KeyCodeToUnicode(key); } } return(str); }
private void MacroShortcutPreviewKeyDown(object sender, KeyEventArgs e) { this.mMacroShortcutTextBox.Text = ""; this.mMacroShortcutTextBox.Tag = (object)""; Key key = e.Key == Key.System ? e.SystemKey : e.Key; if (IMAPKeys.mDictKeys.ContainsKey(key) && this.Valid(key)) { this.mMacroShortcutTextBox.Text = IMAPKeys.GetStringForUI(key); this.mMacroShortcutTextBox.Tag = (object)IMAPKeys.GetStringForFile(key); } else { this.mMacroShortcutTextBox.Text = ""; this.mMacroShortcutTextBox.Tag = (object)""; } e.Handled = true; this.SaveScriptSettings(); }
internal SingleMacroControl( MainWindow parentWindow, MacroRecording record, MacroRecorderWindow recorderWindow) { this.InitializeComponent(); this.mRecording = record; this.ParentWindow = parentWindow; this.mMacroRecorderWindow = recorderWindow; InputMethod.SetIsInputMethodEnabled((DependencyObject)this.mMacroShortcutTextBox, false); this.mTimestamp.Text = DateTime.ParseExact(this.mRecording.TimeCreated, "yyyyMMddTHHmmss", (IFormatProvider)CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal).ToString("yyyy.MM.dd HH.mm.ss", (IFormatProvider)CultureInfo.InvariantCulture); this.mScriptName.Text = this.mRecording.Name; this.mMacroShortcutTextBox.Text = IMAPKeys.GetStringForUI(this.mRecording.Shortcut); this.mScriptName.ToolTip = (object)this.mScriptName.Text; if (record.RecordingType == RecordingTypes.MultiRecording) { this.mScriptSettingsImg.Visibility = Visibility.Collapsed; this.mMergeScriptSettingsImg.Visibility = Visibility.Visible; } if (!string.IsNullOrEmpty(this.mRecording.Shortcut)) { this.mMacroShortcutTextBox.Tag = (object)IMAPKeys.GetStringForFile(IMAPKeys.mDictKeys.FirstOrDefault <KeyValuePair <Key, string> >((Func <KeyValuePair <Key, string>, bool>)(x => x.Value == this.mRecording.Shortcut)).Key); MainWindow.sMacroMapping[this.mMacroShortcutTextBox.Tag.ToString()] = this.mScriptName.Text; } else { this.mMacroShortcutTextBox.Tag = (object)""; } this.IsBookmarked = BlueStacksUIUtils.CheckIfMacroScriptBookmarked(this.mRecording.Name); if (record.PlayOnStart) { this.mAutorunImage.Visibility = Visibility.Visible; } if (this.ParentWindow.mIsMacroPlaying && string.Equals(this.mRecording.Name, this.ParentWindow.mMacroPlaying, StringComparison.InvariantCulture)) { this.ToggleScriptPlayPauseUi(true); } else { this.ToggleScriptPlayPauseUi(false); } }
protected override void OnKeyUp(KeyEventArgs args) { if (args != null) { if (this.IMActionItems != null && this.IMActionItems.Any <IMActionItem>()) { foreach (IMActionItem imActionItem in (Collection <IMActionItem>) this.IMActionItems) { if (imActionItem.IMAction.Type == KeyActionType.Tap || imActionItem.IMAction.Type == KeyActionType.TapRepeat || imActionItem.IMAction.Type == KeyActionType.Script) { if (this.mKeyList.Count >= 2) { string str = IMAPKeys.GetStringForUI(this.mKeyList.ElementAt <Key>(this.mKeyList.Count - 2)) + " + " + IMAPKeys.GetStringForUI(this.mKeyList.ElementAt <Key>(this.mKeyList.Count - 1)); this.Tag = (object)(IMAPKeys.GetStringForFile(this.mKeyList.ElementAt <Key>(this.mKeyList.Count - 2)) + " + " + IMAPKeys.GetStringForFile(this.mKeyList.ElementAt <Key>(this.mKeyList.Count - 1))); this.Text = str; this.SetValueHandling(imActionItem); } else if (this.mKeyList.Count == 1) { string stringForUi = IMAPKeys.GetStringForUI(this.mKeyList.ElementAt <Key>(0)); this.Tag = (object)IMAPKeys.GetStringForFile(this.mKeyList.ElementAt <Key>(0)); this.Text = stringForUi; this.SetValueHandling(imActionItem); } this.mKeyList.Clear(); } } } args.Handled = true; } if (this.PropertyType.Equals(typeof(bool))) { KMManager.CheckAndCreateNewScheme(); } this.SetCaretIndex(); base.OnKeyUp(args); }
protected override void OnPreviewKeyDown(KeyEventArgs args) { if (args != null && args.Key != Key.Escape) { if (this.IMActionItems != null && this.IMActionItems.Any <IMActionItem>()) { foreach (IMActionItem imActionItem in (Collection <IMActionItem>) this.IMActionItems) { if (imActionItem.ActionItem.StartsWith("Key", StringComparison.InvariantCulture)) { if (imActionItem.IMAction.Type == KeyActionType.Tap || imActionItem.IMAction.Type == KeyActionType.TapRepeat || imActionItem.IMAction.Type == KeyActionType.Script) { if (args.Key == Key.Back || args.SystemKey == Key.Back) { this.Tag = (object)string.Empty; BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + this.Tag?.ToString()); } else if (IMAPKeys.mDictKeys.ContainsKey(args.SystemKey) || IMAPKeys.mDictKeys.ContainsKey(args.Key)) { if (args.SystemKey == Key.LeftAlt || args.SystemKey == Key.RightAlt || args.SystemKey == Key.F10) { this.mKeyList.AddIfNotContain <Key>(args.SystemKey); } else if (args.KeyboardDevice.Modifiers != ModifierKeys.None) { if (args.KeyboardDevice.Modifiers == ModifierKeys.Alt) { this.mKeyList.AddIfNotContain <Key>(args.SystemKey); } else if (args.KeyboardDevice.Modifiers == (ModifierKeys.Alt | ModifierKeys.Shift)) { this.mKeyList.AddIfNotContain <Key>(args.SystemKey); } else { this.mKeyList.AddIfNotContain <Key>(args.Key); } } else { this.mKeyList.AddIfNotContain <Key>(args.Key); } } } else { if (args.Key == Key.System && IMAPKeys.mDictKeys.ContainsKey(args.SystemKey)) { this.Tag = (object)IMAPKeys.GetStringForFile(args.SystemKey); BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + IMAPKeys.GetStringForUI(args.SystemKey)); } else if (IMAPKeys.mDictKeys.ContainsKey(args.Key)) { this.Tag = (object)IMAPKeys.GetStringForFile(args.Key); BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + IMAPKeys.GetStringForUI(args.Key)); } else if (args.Key == Key.Back) { this.Tag = (object)string.Empty; BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + string.Empty); } args.Handled = true; } } if (string.Equals(imActionItem.ActionItem, "GamepadStick", StringComparison.InvariantCulture)) { if (args.Key == Key.Back || args.Key == Key.Delete) { this.Tag = (object)string.Empty; BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + string.Empty); } args.Handled = true; } if (this.PropertyType.Equals(typeof(bool))) { bool flag = !Convert.ToBoolean(imActionItem.IMAction[imActionItem.ActionItem], (IFormatProvider)CultureInfo.InvariantCulture); this.Tag = (object)flag; IMapTextBox.Setvalue(imActionItem, flag.ToString((IFormatProvider)CultureInfo.InvariantCulture)); BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + this.Tag?.ToString()); if (imActionItem.IMAction.Type == KeyActionType.EdgeScroll && imActionItem.ActionItem.Equals("EdgeScrollEnabled", StringComparison.InvariantCultureIgnoreCase)) { KMManager.AssignEdgeScrollMode(flag.ToString((IFormatProvider)CultureInfo.InvariantCulture), (TextBox)this); } args.Handled = true; } } } this.Focus(); args.Handled = true; } if (this.PropertyType.Equals(typeof(bool))) { KMManager.CheckAndCreateNewScheme(); } this.SetCaretIndex(); base.OnPreviewKeyDown(args); }
private void IMapTextBox_PreviewMouseWheel(object sender, MouseWheelEventArgs args) { if (args != null && args.Delta != 0 && (this.IMActionItems != null && this.IMActionItems.Any <IMActionItem>())) { foreach (IMActionItem imActionItem in (Collection <IMActionItem>) this.IMActionItems) { if (imActionItem.ActionItem.StartsWith("Key", StringComparison.InvariantCulture)) { this.Tag = args.Delta < 0 ? (object)"MouseWheelDown" : (object)"MouseWheelUp"; this.SetValueHandling(imActionItem); BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + IMAPKeys.GetStringForUI(this.Tag.ToString())); } if (this.PropertyType.Equals(typeof(bool))) { bool flag = !Convert.ToBoolean(imActionItem.IMAction[imActionItem.ActionItem], (IFormatProvider)CultureInfo.InvariantCulture); this.Tag = (object)flag; IMapTextBox.Setvalue(imActionItem, flag.ToString((IFormatProvider)CultureInfo.InvariantCulture)); BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + this.Tag?.ToString()); args.Handled = true; } } args.Handled = true; } this.SetCaretIndex(); }
private void IMapTextBox_Loaded(object sender, RoutedEventArgs e) { if (this.TextBlock != null) { this.TextBlock.TextTrimming = TextTrimming.None; this.TextBlock.TextWrapping = TextWrapping.Wrap; } if (string.IsNullOrEmpty(this.Tag.ToString())) { return; } string[] strArray = this.Tag.ToString().Split('+'); if (strArray.Length == 0) { return; } if (this.IMActionItems[0].ActionItem.Contains("_alt1", StringComparison.InvariantCultureIgnoreCase) || this.IMActionItems[0].ActionItem.Contains("Gamepad", StringComparison.InvariantCultureIgnoreCase)) { this.Text = string.Join(" + ", ((IEnumerable <string>)strArray).ToList <string>().Select <string, string>((Func <string, string>)(x => LocaleStrings.GetLocalizedString(Constants.ImapLocaleStringsConstant + IMAPKeys.GetStringForUI(KMManager.CheckForGamepadSuffix(x.Trim())), ""))).ToArray <string>()); } else { this.Text = string.Join(" + ", ((IEnumerable <string>)strArray).ToList <string>().Select <string, string>((Func <string, string>)(x => LocaleStrings.GetLocalizedString(KMManager.GetStringsToShowInUI(x.Trim()), ""))).ToArray <string>()); } }
private static IntPtr KeyboardHookCallback(int nCode, IntPtr wParam, IntPtr lParam) { try { if (GlobalKeyBoardMouseHooks.sIsEnableKeyboardHookLogging) { Logger.Info("Keyboard hook .." + nCode.ToString() + ".." + wParam.ToString() + ".." + lParam.ToString()); } MainWindow window = BlueStacksUIUtils.ActivatedWindow; if (nCode >= 0) { if (!(wParam == (IntPtr)256) && !(wParam == (IntPtr)260)) { if (!(wParam == (IntPtr)257)) { goto label_19; } } int virtualKey = Marshal.ReadInt32(lParam); Logger.Debug("Keyboard hook .." + virtualKey.ToString() + ".." + GlobalKeyBoardMouseHooks.sKey); if (!(wParam == (IntPtr)256)) { if (!(wParam == (IntPtr)260)) { goto label_19; } } if (!string.IsNullOrEmpty(GlobalKeyBoardMouseHooks.sKey) && (Keys)virtualKey == (Keys)Enum.Parse(typeof(Keys), GlobalKeyBoardMouseHooks.sKey, false) && (GlobalKeyBoardMouseHooks.sIsControlUsedInBossKey ? 1 : 0) == (Keyboard.IsKeyDown(Key.LeftCtrl) ? 1 : (Keyboard.IsKeyDown(Key.RightCtrl) ? 1 : 0)) && ((GlobalKeyBoardMouseHooks.sIsAltUsedInBossKey ? 1 : 0) == (Keyboard.IsKeyDown(Key.LeftAlt) ? 1 : (Keyboard.IsKeyDown(Key.RightAlt) ? 1 : 0)) && (GlobalKeyBoardMouseHooks.sIsShiftUsedInBossKey ? 1 : 0) == (Keyboard.IsKeyDown(Key.LeftShift) ? 1 : (Keyboard.IsKeyDown(Key.RightShift) ? 1 : 0)))) { ThreadPool.QueueUserWorkItem((WaitCallback)(obj => { if (BlueStacksUIUtils.DictWindows.Values.Count <= 0) { return; } MainWindow mainWindow = BlueStacksUIUtils.DictWindows.Values.ToList <MainWindow>()[0]; mainWindow.Dispatcher.Invoke((Delegate)(() => { try { if (mainWindow.OwnedWindows.OfType <OnBoardingPopupWindow>().Any <OnBoardingPopupWindow>() || mainWindow.OwnedWindows.OfType <GameOnboardingControl>().Any <GameOnboardingControl>()) { return; } GlobalKeyBoardMouseHooks.mIsHidden = !GlobalKeyBoardMouseHooks.mIsHidden; BlueStacksUIUtils.HideUnhideBlueStacks(GlobalKeyBoardMouseHooks.mIsHidden); } catch { } })); })); return((IntPtr)1); } if (window != null) { if (!Keyboard.IsKeyDown(Key.LeftCtrl)) { if (!Keyboard.IsKeyDown(Key.RightCtrl)) { goto label_19; } } if (!Keyboard.IsKeyDown(Key.LeftAlt)) { if (!Keyboard.IsKeyDown(Key.RightAlt)) { goto label_19; } } if (virtualKey >= 96 && virtualKey <= 105) { virtualKey -= 48; } string vkString = IMAPKeys.GetStringForFile(KeyInterop.KeyFromVirtualKey(virtualKey)); if (MainWindow.sMacroMapping.Keys.Contains <string>(vkString)) { ThreadPool.QueueUserWorkItem((WaitCallback)(obj => { try { window.Dispatcher.Invoke((Delegate)(() => { if (window.mSidebar.GetElementFromTag("sidebar_macro") != null && window.mSidebar.GetElementFromTag("sidebar_macro").Visibility == Visibility.Visible && window.mSidebar.GetElementFromTag("sidebar_macro").IsEnabled) { if (window.mIsMacroRecorderActive) { window.ShowToast(LocaleStrings.GetLocalizedString("STRING_STOP_RECORDING_FIRST", ""), "", "", false); } else if (window.mIsMacroPlaying) { CustomMessageWindow customMessageWindow = new CustomMessageWindow(); BlueStacksUIBinding.Bind(customMessageWindow.TitleTextBlock, "STRING_CANNOT_RUN_MACRO", ""); BlueStacksUIBinding.Bind(customMessageWindow.BodyTextBlock, "STRING_STOP_MACRO_SCRIPT", ""); customMessageWindow.AddButton(ButtonColors.Blue, "STRING_OK", (EventHandler)null, (string)null, false, (object)null, true); customMessageWindow.Owner = (Window)window; customMessageWindow.ShowDialog(); } else { try { string path = Path.Combine(RegistryStrings.MacroRecordingsFolderPath, MainWindow.sMacroMapping[vkString] + ".json"); if (!File.Exists(path)) { return; } MacroRecording record = JsonConvert.DeserializeObject <MacroRecording>(File.ReadAllText(path), Utils.GetSerializerSettings()); record.Name = MainWindow.sMacroMapping[vkString]; window.mCommonHandler.FullMacroScriptPlayHandler(record); ClientStats.SendMiscellaneousStatsAsync("MacroOperations", RegistryManager.Instance.UserGuid, RegistryManager.Instance.ClientVersion, "macro_play", "shortcut_keys", record.RecordingType.ToString(), string.IsNullOrEmpty(record.MacroId) ? "local" : "community", (string)null, (string)null, "Android"); } catch (Exception ex) { Logger.Error("Exception in macro play with shortcut: " + ex.ToString()); } } } else { Logger.Info("Macro not enabled for the current package: " + window.StaticComponents.mSelectedTabButton.PackageName); } })); } catch { } })); } } } } catch { } label_19: return(NativeMethods.CallNextHookEx(GlobalKeyBoardMouseHooks.mKeyboardHookID, nCode, wParam, lParam)); }
private void HandleShortcutKeyDown(KeyEventArgs e) { Logger.Debug("SHORTCUT: PrintKey............" + e.Key.ToString()); Logger.Debug("SHORTCUT: PrintSystemKey............" + e.SystemKey.ToString()); if ((!IMAPKeys.mDictKeys.ContainsKey(e.Key) && !IMAPKeys.mDictKeys.ContainsKey(e.SystemKey) || !ShortcutKeyControlElement.IsValid(e.Key) && !ShortcutKeyControlElement.IsValid(e.SystemKey)) && (e.Key != Key.Back && e.Key != Key.Delete)) { return; } string str1 = string.Empty; string str2 = string.Empty; string str3 = string.Empty; this.mShortcutKeyTextBox.Tag = (object)string.Empty; if (e.KeyboardDevice.Modifiers != ModifierKeys.None) { if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { str1 = IMAPKeys.GetStringForUI(Key.LeftCtrl) + " + "; this.mShortcutKeyTextBox.Tag = (object)(IMAPKeys.GetStringForFile(Key.LeftCtrl) + " + "); } if (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt)) { str2 = IMAPKeys.GetStringForUI(Key.LeftAlt) + " + "; CustomTextBox shortcutKeyTextBox = this.mShortcutKeyTextBox; shortcutKeyTextBox.Tag = (object)(shortcutKeyTextBox.Tag?.ToString() + IMAPKeys.GetStringForFile(Key.LeftAlt) + " + "); } if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { str3 = IMAPKeys.GetStringForUI(Key.LeftShift) + " + "; CustomTextBox shortcutKeyTextBox = this.mShortcutKeyTextBox; shortcutKeyTextBox.Tag = (object)(shortcutKeyTextBox.Tag?.ToString() + IMAPKeys.GetStringForFile(Key.LeftShift) + " + "); } if (string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2) || e.SystemKey == Key.F10) { this.mShortcutKeyTextBox.Text = str1 + str2 + str3 + IMAPKeys.GetStringForUI(e.SystemKey); CustomTextBox shortcutKeyTextBox = this.mShortcutKeyTextBox; shortcutKeyTextBox.Tag = (object)(shortcutKeyTextBox.Tag?.ToString() + IMAPKeys.GetStringForFile(e.SystemKey)); } else { this.mShortcutKeyTextBox.Text = str1 + str2 + str3 + IMAPKeys.GetStringForUI(e.Key); CustomTextBox shortcutKeyTextBox = this.mShortcutKeyTextBox; shortcutKeyTextBox.Tag = (object)(shortcutKeyTextBox.Tag?.ToString() + IMAPKeys.GetStringForFile(e.Key)); } } else if (e.Key == Key.Back || e.Key == Key.Delete) { this.mShortcutKeyTextBox.Text = string.Empty; this.mShortcutKeyTextBox.Tag = (object)string.Empty; if (this.ParentSettingsWindow.mDuplicateShortcutsList.Contains(this.mShortcutNameTextBlock.Text)) { this.ParentSettingsWindow.mDuplicateShortcutsList.Remove(this.mShortcutNameTextBlock.Text); } this.SetSaveButtonState(this.ParentSettingsWindow.mIsShortcutEdited); } else if (e.Key == Key.Escape) { if (string.Equals(this.mDefaultModifierForFile, "Shift + ", StringComparison.InvariantCulture)) { this.mShortcutKeyTextBox.Text = this.mDefaultModifierForUI + IMAPKeys.GetStringForUI(e.Key); this.mShortcutKeyTextBox.Tag = (object)(this.mDefaultModifierForFile + IMAPKeys.GetStringForFile(e.Key)); } } else if ((e.Key == Key.D0 || e.SystemKey == Key.D0) && string.Equals(this.mDefaultModifierForUI, "Ctrl + Shift + ", StringComparison.InvariantCulture)) { this.mShortcutKeyTextBox.Text = string.Empty; this.mShortcutKeyTextBox.Tag = (object)string.Empty; this.AddToastPopup(LocaleStrings.GetLocalizedString("STRING_WINDOW_ACTION_ERROR", "")); } else if (e.Key == Key.System) { this.mShortcutKeyTextBox.Text = this.mDefaultModifierForUI + IMAPKeys.GetStringForUI(e.SystemKey); this.mShortcutKeyTextBox.Tag = (object)(this.mDefaultModifierForFile + IMAPKeys.GetStringForFile(e.SystemKey)); } else { this.mShortcutKeyTextBox.Text = this.mDefaultModifierForUI + IMAPKeys.GetStringForUI(e.Key); this.mShortcutKeyTextBox.Tag = (object)(this.mDefaultModifierForFile + IMAPKeys.GetStringForFile(e.Key)); } e.Handled = true; this.mShortcutKeyTextBox.CaretIndex = this.mShortcutKeyTextBox.Text.Length; this.mIsShortcutSameAsMacroShortcut = false; if ((MainWindow.sMacroMapping.ContainsKey(IMAPKeys.GetStringForUI(e.Key)) || MainWindow.sMacroMapping.ContainsKey(IMAPKeys.GetStringForUI(e.SystemKey))) && (string.Equals(this.mShortcutKeyTextBox.Text, str1 + str2 + IMAPKeys.GetStringForUI(e.Key), StringComparison.InvariantCulture) || string.Equals(this.mShortcutKeyTextBox.Text, str1 + str2 + IMAPKeys.GetStringForUI(e.SystemKey), StringComparison.InvariantCulture))) { this.mIsShortcutSameAsMacroShortcut = true; } if (string.Equals(this.mShortcutKeyTextBox.Text, "Alt + F4", StringComparison.InvariantCulture)) { this.mShortcutKeyTextBox.Text = string.Empty; this.mShortcutKeyTextBox.Tag = (object)string.Empty; this.AddToastPopup(LocaleStrings.GetLocalizedString("STRING_WINDOW_ACTION_ERROR", "")); } foreach (ShortcutKeys userDefinedConfig in this.mUserDefinedConfigList) { this.mShortcutKeyTextBox.InputTextValidity = TextValidityOptions.Success; this.mKeyInfoPopup.IsOpen = false; this.ParentSettingsWindow.mIsShortcutEdited = true; this.CheckIfShortcutAlreadyUsed(); this.ParentWindow.mCommonHandler.OnShortcutKeysRefresh(); if (string.Equals(LocaleStrings.GetLocalizedString(userDefinedConfig.ShortcutName, ""), this.mShortcutNameTextBlock.Text, StringComparison.InvariantCulture) && !string.Equals(userDefinedConfig.ShortcutKey, this.mShortcutKeyTextBox.Text, StringComparison.InvariantCulture)) { userDefinedConfig.ShortcutKey = this.mShortcutKeyTextBox.Tag.ToString(); BlueStacks.Common.Stats.SendMiscellaneousStatsAsync("KeyboardShortcuts", RegistryManager.Instance.UserGuid, RegistryManager.Instance.ClientVersion, "shortcut_edit", this.mShortcutNameTextBlock.Text, (string)null, (string)null, (string)null, (string)null, "Android", 0); } } }
private void AddElement(ShortcutKeys ele) { ShortcutKeyControlElement keyControlElement = new ShortcutKeyControlElement(this.ParentWindow, this.ParentSettingsWindow); BlueStacksUIBinding.Bind(keyControlElement.mShortcutNameTextBlock, ele.ShortcutName, ""); string[] strArray = ele.ShortcutKey.Split(new char[2] { '+', ' ' }, StringSplitOptions.RemoveEmptyEntries); string str = string.Empty; foreach (string key in strArray) { str = str + LocaleStrings.GetLocalizedString(Constants.ImapLocaleStringsConstant + IMAPKeys.GetStringForUI(key), "") + " + "; } this.mShortcutUIElements[ele.ShortcutCategory].Item2.Add(keyControlElement); if (!string.IsNullOrEmpty(str)) { keyControlElement.mShortcutKeyTextBox.Text = str.Substring(0, str.Length - 3); } keyControlElement.mUserDefinedConfigList = new List <ShortcutKeys>() { ele }; if (!ele.ReadOnlyTextbox) { return; } keyControlElement.mShortcutKeyTextBox.IsEnabled = false; }
private void KeyTextBox_KeyDown(object sender, KeyEventArgs e) { KMManager.CheckAndCreateNewScheme(); KeymapCanvasWindow.sIsDirty = true; if (e.Key == Key.Escape) { return; } if (this.ActionItemProperty.StartsWith("Key", StringComparison.InvariantCultureIgnoreCase)) { if (this.lstActionItem[0].Type == KeyActionType.Tap || this.lstActionItem[0].Type == KeyActionType.TapRepeat || this.lstActionItem[0].Type == KeyActionType.Script) { if (e.Key == Key.Back || e.SystemKey == Key.Back) { this.mKeyTextBox.Tag = (object)string.Empty; BlueStacksUIBinding.Bind(this.mKeyTextBox, Constants.ImapLocaleStringsConstant + this.mKeyTextBox.Tag?.ToString()); } else if (IMAPKeys.mDictKeys.ContainsKey(e.SystemKey) || IMAPKeys.mDictKeys.ContainsKey(e.Key)) { if (e.SystemKey == Key.LeftAlt || e.SystemKey == Key.RightAlt || e.SystemKey == Key.F10) { this.mKeyList.AddIfNotContain <Key>(e.SystemKey); } else if (e.KeyboardDevice.Modifiers != ModifierKeys.None) { if (e.KeyboardDevice.Modifiers == ModifierKeys.Alt) { this.mKeyList.AddIfNotContain <Key>(e.SystemKey); } else if (e.KeyboardDevice.Modifiers == (ModifierKeys.Alt | ModifierKeys.Shift)) { this.mKeyList.AddIfNotContain <Key>(e.SystemKey); } else { this.mKeyList.AddIfNotContain <Key>(e.Key); } } else { this.mKeyList.AddIfNotContain <Key>(e.Key); } } } else { if (e.Key == Key.System && IMAPKeys.mDictKeys.ContainsKey(e.SystemKey)) { this.mKeyTextBox.Tag = (object)IMAPKeys.GetStringForFile(e.SystemKey); BlueStacksUIBinding.Bind(this.mKeyTextBox, Constants.ImapLocaleStringsConstant + IMAPKeys.GetStringForUI(e.SystemKey)); } else if (IMAPKeys.mDictKeys.ContainsKey(e.Key)) { this.mKeyTextBox.Tag = (object)IMAPKeys.GetStringForFile(e.Key); BlueStacksUIBinding.Bind(this.mKeyTextBox, Constants.ImapLocaleStringsConstant + IMAPKeys.GetStringForUI(e.Key)); } else if (e.Key == Key.Back) { this.mKeyTextBox.Tag = (object)string.Empty; BlueStacksUIBinding.Bind(this.mKeyTextBox, Constants.ImapLocaleStringsConstant + string.Empty); } e.Handled = true; } } if (this.PropertyType.Equals(typeof(bool))) { this.mKeyTextBox.Tag = (object)!Convert.ToBoolean(this.lstActionItem.First <IMAction>()[this.ActionItemProperty], (IFormatProvider)CultureInfo.InvariantCulture); BlueStacksUIBinding.Bind(this.mKeyTextBox, Constants.ImapLocaleStringsConstant + this.mKeyTextBox.Tag?.ToString()); if (this.lstActionItem.First <IMAction>().Type == KeyActionType.TapRepeat && KMManager.CanvasWindow.mCanvasElement != null) { KMManager.CanvasWindow.mCanvasElement.SetToggleModeValues(this.lstActionItem.First <IMAction>(), false); } if (this.lstActionItem.First <IMAction>().Type == KeyActionType.EdgeScroll && this.ActionItemProperty.Equals("EdgeScrollEnabled", StringComparison.InvariantCultureIgnoreCase)) { KMManager.AssignEdgeScrollMode(this.mKeyTextBox.Tag.ToString(), this.mKeyTextBox); } e.Handled = true; } if (this.PropertyType.Equals(typeof(int)) && this.lstActionItem.First <IMAction>().Type == KeyActionType.FreeLook && KMManager.CanvasWindow.mCanvasElement != null) { KMManager.CanvasWindow.mCanvasElement.SetToggleModeValues(this.lstActionItem.First <IMAction>(), false); } if (string.Equals(this.ActionItemProperty, "GamepadStick", StringComparison.InvariantCultureIgnoreCase) && (e.Key == Key.Back || e.SystemKey == Key.Back)) { this.mKeyTextBox.Tag = (object)string.Empty; BlueStacksUIBinding.Bind(this.mKeyTextBox, Constants.ImapLocaleStringsConstant + this.mKeyTextBox.Tag?.ToString()); } if (!this.ActionItemProperty.StartsWith("Key", StringComparison.InvariantCultureIgnoreCase) || this.lstActionItem[0].Type != KeyActionType.Tap && this.lstActionItem[0].Type != KeyActionType.TapRepeat && this.lstActionItem[0].Type != KeyActionType.Script || e.Key != Key.Tab) { return; } e.Handled = true; }