Beispiel #1
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 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);
                }
            }
        }