public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is IEnumerable <string> strings))
            {
                return((object)string.Empty);
            }
            List <string> stringList = new List <string>();

            foreach (string text in strings)
            {
                stringList.Add(KMManager.GetKeyUIValue(text));
            }
            return((object)string.Join(" / ", stringList.ToArray()));
        }
Beispiel #2
0
        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);
        }