private void KeyTextBox_MouseDown(object sender, MouseButtonEventArgs e) { if (this.ActionItemProperty.StartsWith("Key", StringComparison.InvariantCultureIgnoreCase)) { if (e.MiddleButton == MouseButtonState.Pressed) { e.Handled = true; this.mKeyTextBox.Tag = (object)"MouseMButton"; BlueStacksUIBinding.Bind(this.mKeyTextBox, Constants.ImapLocaleStringsConstant + "MouseMButton"); } else if (e.RightButton == MouseButtonState.Pressed) { e.Handled = true; this.mKeyTextBox.Tag = (object)"MouseRButton"; BlueStacksUIBinding.Bind(this.mKeyTextBox, Constants.ImapLocaleStringsConstant + "MouseRButton"); } else if (e.XButton1 == MouseButtonState.Pressed) { e.Handled = true; this.mKeyTextBox.Tag = (object)"MouseXButton1"; BlueStacksUIBinding.Bind(this.mKeyTextBox, Constants.ImapLocaleStringsConstant + "MouseXButton1"); } else if (e.XButton2 == MouseButtonState.Pressed) { e.Handled = true; this.mKeyTextBox.Tag = (object)"MouseXButton2"; BlueStacksUIBinding.Bind(this.mKeyTextBox, Constants.ImapLocaleStringsConstant + "MouseXButton2"); } } if (!this.PropertyType.Equals(typeof(bool))) { return; } 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.EdgeScroll || !this.ActionItemProperty.Equals("EdgeScrollEnabled", StringComparison.InvariantCultureIgnoreCase)) { return; } KMManager.AssignEdgeScrollMode(this.mKeyTextBox.Tag.ToString(), this.mKeyTextBox); }
protected override void OnPreviewMouseDown(MouseButtonEventArgs args) { if (args != null) { if (this.IMActionItems != null && this.IMActionItems.Any <IMActionItem>()) { foreach (IMActionItem imActionItem in (Collection <IMActionItem>) this.IMActionItems) { if (imActionItem.ActionItem.StartsWith("Key", StringComparison.InvariantCulture)) { if (args.MiddleButton == MouseButtonState.Pressed) { args.Handled = true; this.Tag = (object)"MouseMButton"; BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + "MouseMButton"); } else if (args.RightButton == MouseButtonState.Pressed) { args.Handled = true; this.Tag = (object)"MouseRButton"; BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + "MouseRButton"); } else if (args.XButton1 == MouseButtonState.Pressed) { args.Handled = true; this.Tag = (object)"MouseXButton1"; BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + "MouseXButton1"); } else if (args.XButton2 == MouseButtonState.Pressed) { args.Handled = true; this.Tag = (object)"MouseXButton2"; BlueStacksUIBinding.Bind((TextBox)this, Constants.ImapLocaleStringsConstant + "MouseXButton2"); } } 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); } } } } if (args.LeftButton == MouseButtonState.Pressed && this.IsKeyboardFocusWithin) { args.Handled = true; } this.Focus(); args.Handled = true; } if (this.PropertyType.Equals(typeof(bool))) { KMManager.CheckAndCreateNewScheme(); } this.SetCaretIndex(); base.OnPreviewMouseDown(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 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; }
internal bool AddActionItem(IMAction action) { this.PropertyType = IMAction.DictPropertyInfo[action.Type][this.ActionItemProperty].PropertyType; if (!this.PropertyType.Equals(typeof(string)) && !string.Equals(this.ActionItemProperty, "Sensitivity", StringComparison.InvariantCultureIgnoreCase) && (!string.Equals(this.ActionItemProperty, "EdgeScrollEnabled", StringComparison.InvariantCultureIgnoreCase) && !string.Equals(this.ActionItemProperty, "GamepadSensitivity", StringComparison.InvariantCultureIgnoreCase)) && (!string.Equals(this.ActionItemProperty, "MouseAcceleration", StringComparison.InvariantCultureIgnoreCase) && !string.Equals(this.ActionItemProperty, "SensitivityRatioY", StringComparison.InvariantCultureIgnoreCase) && (action.Type != KeyActionType.Scroll || !string.Equals(this.ActionItemProperty, "Speed", StringComparison.InvariantCultureIgnoreCase))) || action.Type == KeyActionType.State && (string.Equals(this.ActionItemProperty, "Name", StringComparison.InvariantCultureIgnoreCase) || string.Equals(this.ActionItemProperty, "Model", StringComparison.InvariantCultureIgnoreCase))) { this.mKeyPropertyNameTextBox.IsEnabled = false; } else { this.mKeyPropertyNameTextBox.IsEnabled = true; int length = this.mActionItemProperty.IndexOf("_alt1", StringComparison.InvariantCulture); string origKey = this.mActionItemProperty; if (length > 0) { origKey = this.mActionItemProperty.Substring(0, length); } this.AssignGuidanceText(action, origKey); } if ((action.Type == KeyActionType.Zoom || action.Type == KeyActionType.MouseZoom) && (string.Equals(this.ActionItemProperty, "Speed", StringComparison.InvariantCultureIgnoreCase) || string.Equals(this.ActionItemProperty, "Acceleration", StringComparison.InvariantCultureIgnoreCase) || string.Equals(this.ActionItemProperty, "Amplitude", StringComparison.InvariantCultureIgnoreCase))) { this.mKeyPropertyNameTextBox.IsEnabled = true; this.AssignGuidanceText(action, this.mActionItemProperty); } this.lstActionItem.Add(action); string str1 = this.mActionItemProperty; if (this.mActionItemProperty.EndsWith("_alt1", StringComparison.InvariantCulture)) { int length = this.mActionItemProperty.IndexOf("_alt1", StringComparison.InvariantCulture); if (length > 0) { str1 = this.mActionItemProperty.Substring(0, length); } } if (this.IsAddDirectionAttribute) { BlueStacksUIBinding.Bind(this.mKeyPropertyName, Constants.ImapLocaleStringsConstant + action.Type.ToString() + "_" + str1 + action.Direction.ToString()); } else { BlueStacksUIBinding.Bind(this.mKeyPropertyName, Constants.ImapLocaleStringsConstant + action.Type.ToString() + "_" + str1); } string str2 = action[this.ActionItemProperty].ToString(); if (string.Equals(this.ActionItemProperty, "SensitivityRatioY", StringComparison.InvariantCulture)) { double num1 = Convert.ToDouble(action[this.ActionItemProperty], (IFormatProvider)CultureInfo.InvariantCulture); double num2 = Convert.ToDouble(action["Sensitivity"], (IFormatProvider)CultureInfo.InvariantCulture); str2 = num1 == 0.0 || num2 == 0.0 ? (num1 == 0.0 ? 0.ToString("0.##", (IFormatProvider)CultureInfo.CurrentCulture) : num1.ToString("0.##", (IFormatProvider)CultureInfo.CurrentCulture)) : (num2 * num1).ToString("0.##", (IFormatProvider)CultureInfo.CurrentCulture); } this.mKeyTextBox.Tag = action[this.ActionItemProperty]; if (this.ActionItemProperty.StartsWith("Key", StringComparison.CurrentCultureIgnoreCase)) { BlueStacksUIBinding.Bind(this.mKeyTextBox, KMManager.GetStringsToShowInUI(str2)); } else { this.mKeyTextBox.Text = str2.ToString((IFormatProvider)CultureInfo.CurrentCulture); } if (this.ActionItemProperty.Equals("KeyWheel", StringComparison.InvariantCultureIgnoreCase)) { this.mKeyTextBox.ToolTip = (object)this.mKeyTextBox.Text; ToolTipService.SetShowOnDisabled((DependencyObject)this.mKeyTextBox, true); } if (this.lstActionItem.First <IMAction>().Type == KeyActionType.EdgeScroll && this.ActionItemProperty.Equals("EdgeScrollEnabled", StringComparison.InvariantCultureIgnoreCase)) { KMManager.AssignEdgeScrollMode(str2, this.mKeyTextBox); } if (!str2.Contains("Gamepad", StringComparison.InvariantCultureIgnoreCase) && !this.ActionItemProperty.Contains("Gamepad", StringComparison.InvariantCultureIgnoreCase)) { return(false); } BlueStacksUIBinding.Bind(this.mKeyTextBox, KMManager.GetKeyUIValue(str2)); this.mKeyTextBox.ToolTip = (object)this.mKeyTextBox.Text; return(true); }