private void OnDecrease(object sender, RoutedEventArgs e) { string s = this.Text.Replace(',', '.'); double result1; if ((object)this.PropertyType == (object)typeof(double) && double.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, (IFormatProvider)NumberFormatInfo.InvariantInfo, out result1) && result1 > 0.0) { if (this.CanDecrease(result1, 0.05)) { this.Text = (result1 - 0.05).ToString((IFormatProvider)CultureInfo.CurrentCulture); KMManager.CheckAndCreateNewScheme(); } } else { int result2; if ((object)this.PropertyType == (object)typeof(int) && int.TryParse(s, out result2) && (result2 > 0 && this.CanDecrease((double)result2, 1.0))) { --result2; this.Text = result2.ToString((IFormatProvider)CultureInfo.CurrentCulture); KMManager.CheckAndCreateNewScheme(); } } foreach (IMActionItem imActionItem in (Collection <IMActionItem>) this.IMActionItems) { this.SetValueHandling(imActionItem); } }
private void Canvas_MouseDown(object sender, MouseButtonEventArgs e) { if (CanvasElement.sFocusedTextBox != null) { WpfUtils.FindVisualParent <CanvasElement>(CanvasElement.sFocusedTextBox as DependencyObject).TxtBox_LostFocus(CanvasElement.sFocusedTextBox, new RoutedEventArgs()); } else { if (double.IsNaN(this.CanvasWindowLeft) && double.IsNaN(this.CanvasWindowTop)) { this.CanvasWindowLeft = this.Left; this.CanvasWindowTop = this.Top; this.mMousePointForNewTap = Mouse.GetPosition((IInputElement)this.mCanvas); } KeymapCanvasWindow.sIsDirty = true; try { this.DragMove(); } catch (Exception ex) { } if (Math.Abs(this.CanvasWindowLeft - this.Left) < 2.0 && Math.Abs(this.CanvasWindowTop - this.Top) < 2.0) { if (KMManager.sIsInScriptEditingMode && this.mIsExtraSettingsPopupOpened) { return; } Tap tap = new Tap(); tap.Type = KeyActionType.Tap; IMAction imAction = (IMAction)tap; if (this.ParentWindow.SelectedConfig.ControlSchemes.Count == 0 && CanvasElement.sFocusedTextBox != null) { WpfUtils.FindVisualParent <CanvasElement>(CanvasElement.sFocusedTextBox as DependencyObject).TxtBox_LostFocus(CanvasElement.sFocusedTextBox, new RoutedEventArgs()); } else { if (this.ParentWindow.SelectedConfig.ControlSchemes.Count == 0) { KMManager.AddNewControlSchemeAndSelect(this.ParentWindow, (IMControlScheme)null, false); } else if (this.ParentWindow.SelectedConfig.SelectedControlScheme.BuiltIn) { KMManager.CheckAndCreateNewScheme(); } this.ParentWindow.SelectedConfig.SelectedControlScheme.GameControls.Add(imAction); List <CanvasElement> source = this.AddCanvasElementsForAction(imAction, false); source.First <CanvasElement>().SetMousePoint(this.mMousePointForNewTap); source.First <CanvasElement>().IsRemoveIfEmpty = true; source.First <CanvasElement>().ShowTextBox((object)source.First <CanvasElement>().dictTextElemets.First <KeyValuePair <Positions, BlueStacks.Common.Tuple <string, TextBox, TextBlock, List <IMAction> > > >().Value.Item3); } } this.CanvasWindowLeft = double.NaN; this.CanvasWindowTop = double.NaN; } }
private void ResizeIcon_PreviewMouseDown(object sender, MouseButtonEventArgs e) { KMManager.CheckAndCreateNewScheme(); this.mCanvasElement = WpfUtils.FindVisualParent <CanvasElement>(sender as DependencyObject); this.mCanvasElement.mResizeIcon.Focus(); this.startPoint = e.GetPosition((IInputElement)this); this.mCanvas.PreviewMouseMove += new MouseEventHandler(this.CanvasResizeExistingElement_MouseMove); KeymapCanvasWindow.sIsDirty = true; e.Handled = true; Mouse.Capture((IInputElement)this.mCanvas); }
private void IMapTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (this.IMActionItems != null && this.IMActionItems.Any <IMActionItem>()) { foreach (IMActionItem imActionItem in (Collection <IMActionItem>) this.IMActionItems) { this.SetValueHandling(imActionItem); } KMManager.CheckAndCreateNewScheme(); } this.SetCaretIndex(); }
private void SetStopMobaDpadValue(bool isChecked) { this.mCanvasElement.MOBASkillSettingsMoreInfoPopup.IsOpen = false; this.mCanvasElement.MOBAOtherSettingsMoreInfoPopup.IsOpen = false; KMManager.CheckAndCreateNewScheme(); this.mStopMovementCheckbox.IsChecked = new bool?(isChecked); if (this.mCanvasElement.ListActionItem.First <IMAction>().Type == KeyActionType.MOBASkill) { ((MOBASkill)this.mCanvasElement.ListActionItem.First <IMAction>()).StopMOBADpad = isChecked; } KeymapCanvasWindow.sIsDirty = true; }
private void CreateGameControlCopy(IMAction originalAction, Point point, bool isNewScheme = true) { IMAction imAction = originalAction.DeepCopy <IMAction>(); imAction.PositionX = originalAction.PositionX + 1.0; List <CanvasElement> source = this.AddCanvasElementsForAction(imAction, false); if (isNewScheme) { KMManager.CheckAndCreateNewScheme(); } this.ParentWindow.SelectedConfig.SelectedControlScheme.GameControls.Add(imAction); this.StartMoving(source.First <CanvasElement>(), point); }
protected override void OnPreviewTextInput(TextCompositionEventArgs args) { if (args != null) { string s; if (this.SelectionLength > 0) { StringBuilder stringBuilder = new StringBuilder(this.Text); stringBuilder.Remove(this.SelectionStart, this.SelectionLength); stringBuilder.Insert(this.SelectionStart, args.Text); s = stringBuilder.ToString(); } else { s = this.Text.Insert(this.SelectionStart, args.Text); } if ((object)this.PropertyType == (object)typeof(int)) { int result; args.Handled = !int.TryParse(s, out result) || (double)result <this.MinValue || (double)result> this.MaxValue; } else if ((object)this.PropertyType == (object)typeof(double)) { string str = s.Replace(',', '.'); double result; if (double.TryParse(str, NumberStyles.Float | NumberStyles.AllowThousands, (IFormatProvider)NumberFormatInfo.InvariantInfo, out result)) { args.Handled = this.MinValue > result || result > this.MaxValue; } else { if (string.Equals(str, ".", StringComparison.InvariantCultureIgnoreCase)) { this.Text = "0."; KMManager.CheckAndCreateNewScheme(); if (this.IMActionItems != null && this.IMActionItems.Any <IMActionItem>()) { foreach (IMActionItem imActionItem in (Collection <IMActionItem>) this.IMActionItems) { this.SetValueHandling(imActionItem); } } this.CaretIndex = this.Text.Length; } args.Handled = true; } } } base.OnPreviewTextInput(args); }
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); }
private void CanvasMoveExistingElement_MouseMove(object sender, MouseEventArgs e) { KMManager.CheckAndCreateNewScheme(); this.Focus(); this.MoveElement(e.GetPosition((IInputElement)this)); }
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; }
private void KeyPropertyNameTextBox_TextChanged(object sender, TextChangedEventArgs e) { KMManager.CheckAndCreateNewScheme(); KeymapCanvasWindow.sIsDirty = true; }