Esempio n. 1
0
        internal void ImportSchemes(
            List <IMControlScheme> toCopyFromSchemes,
            Dictionary <string, Dictionary <string, string> > stringsToImport)
        {
            bool flag1 = false;
            bool flag2 = false;

            KMManager.MergeConflictingGuidanceStrings(this.ParentWindow.SelectedConfig, toCopyFromSchemes, stringsToImport);
            if (this.ParentWindow.SelectedConfig.ControlSchemes.Count > 0)
            {
                flag1 = true;
            }
            foreach (IMControlScheme toCopyFromScheme in toCopyFromSchemes)
            {
                IMControlScheme imControlScheme = toCopyFromScheme.DeepCopy();
                if (flag1)
                {
                    imControlScheme.Selected = false;
                }
                imControlScheme.BuiltIn      = false;
                imControlScheme.IsBookMarked = false;
                this.CanvasWindow.SidebarWindow.mSchemeComboBox.mName.Text = imControlScheme.Name;
                this.ParentWindow.SelectedConfig.ControlSchemes.Add(imControlScheme);
                this.ParentWindow.SelectedConfig.ControlSchemesDict.Add(imControlScheme.Name, imControlScheme);
                ComboBoxSchemeControl boxSchemeControl = new ComboBoxSchemeControl(this.CanvasWindow, this.ParentWindow);
                boxSchemeControl.mSchemeName.Text = LocaleStrings.GetLocalizedString(imControlScheme.Name, "");
                boxSchemeControl.IsEnabled        = true;
                BlueStacksUIBinding.BindColor((DependencyObject)boxSchemeControl, Control.BackgroundProperty, "ComboBoxBackgroundColor");
                this.CanvasWindow.SidebarWindow.mSchemeComboBox.Items.Children.Add((UIElement)boxSchemeControl);
            }
            if (flag1)
            {
                return;
            }
            foreach (IMControlScheme controlScheme in this.ParentWindow.SelectedConfig.ControlSchemes)
            {
                if (controlScheme.Selected)
                {
                    flag2 = true;
                    break;
                }
            }
            if (flag2)
            {
                return;
            }
            this.ParentWindow.SelectedConfig.ControlSchemes[0].Selected = true;
        }
 private bool EditedNameIsAllowed(string text, ComboBoxSchemeControl toBeRenamedControl)
 {
     if (string.IsNullOrEmpty(text.Trim()))
     {
         this.ParentWindow.mCommonHandler.AddToastPopup((Window)this.CanvasWindow.SidebarWindow, LocaleStrings.GetLocalizedString("STRING_INVALID_SCHEME_NAME", ""), 1.3, false);
         return(false);
     }
     foreach (ComboBoxSchemeControl child in this.CanvasWindow.SidebarWindow.mSchemeComboBox.Items.Children)
     {
         if (child.mSchemeName.Text.ToLower(CultureInfo.InvariantCulture).Trim() == text.ToLower(CultureInfo.InvariantCulture).Trim() && child != toBeRenamedControl)
         {
             this.ParentWindow.mCommonHandler.AddToastPopup((Window)this.CanvasWindow.SidebarWindow, LocaleStrings.GetLocalizedString("STRING_INVALID_SCHEME_NAME", ""), 1.3, false);
             return(false);
         }
         if (child.mSchemeName.Text.Trim().IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
         {
             this.ParentWindow.mCommonHandler.AddToastPopup((Window)this.CanvasWindow.SidebarWindow, string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0} {1} {2}", (object)LocaleStrings.GetLocalizedString("STRING_SCHEME_INVALID_CHARACTERS", ""), (object)Environment.NewLine, (object)"\\ / : * ? \" < > |"), 3.0, false);
             return(false);
         }
     }
     return(true);
 }
        private void DeleteControlScheme()
        {
            if (!this.ParentWindow.SelectedConfig.ControlSchemesDict.ContainsKey(this.mSchemeName.Text) || this.ParentWindow.SelectedConfig.ControlSchemesDict[this.mSchemeName.Text].BuiltIn)
            {
                return;
            }
            if (this.ParentWindow.SelectedConfig.ControlSchemesDict[this.mSchemeName.Text].Selected)
            {
                this.ParentWindow.SelectedConfig.ControlSchemesDict[this.mSchemeName.Text].Selected = false;
                if (this.ParentWindow.SelectedConfig.ControlSchemes.Count > 1)
                {
                    this.CanvasWindow.SidebarWindow.mSchemeComboBox.SelectedItem = !(this.CanvasWindow.SidebarWindow.mSchemeComboBox.SelectedItem == (this.CanvasWindow.SidebarWindow.mSchemeComboBox.Items.Children[0] as ComboBoxSchemeControl).mSchemeName.Text.ToString((IFormatProvider)CultureInfo.InvariantCulture)) ? (this.CanvasWindow.SidebarWindow.mSchemeComboBox.Items.Children[0] as ComboBoxSchemeControl).mSchemeName.Text.ToString((IFormatProvider)CultureInfo.InvariantCulture) : (this.CanvasWindow.SidebarWindow.mSchemeComboBox.Items.Children[1] as ComboBoxSchemeControl).mSchemeName.Text.ToString((IFormatProvider)CultureInfo.InvariantCulture);
                    this.ParentWindow.SelectedConfig.ControlSchemesDict[this.CanvasWindow.SidebarWindow.mSchemeComboBox.SelectedItem].Selected = true;
                    this.CanvasWindow.SidebarWindow.mSchemeComboBox.mName.Text = this.CanvasWindow.SidebarWindow.mSchemeComboBox.SelectedItem;
                    this.ParentWindow.SelectedConfig.SelectedControlScheme     = this.ParentWindow.SelectedConfig.ControlSchemesDict[this.CanvasWindow.SidebarWindow.mSchemeComboBox.SelectedItem];
                    this.CanvasWindow.SidebarWindow.ProfileChanged();
                }
                else
                {
                    this.CanvasWindow.SidebarWindow.mSchemeComboBox.SelectedItem = (string)null;
                    BlueStacksUIBinding.Bind(this.CanvasWindow.SidebarWindow.mSchemeComboBox.mName, "Custom", "");
                }
            }
            this.ParentWindow.SelectedConfig.ControlSchemes.Remove(this.ParentWindow.SelectedConfig.ControlSchemesDict[this.mSchemeName.Text]);
            this.ParentWindow.SelectedConfig.ControlSchemesDict.Remove(this.mSchemeName.Text);
            ComboBoxSchemeControl schemeControlFromName = KMManager.GetComboBoxSchemeControlFromName(this.mSchemeName.Text);

            if (schemeControlFromName != null)
            {
                this.CanvasWindow.SidebarWindow.mSchemeComboBox.Items.Children.Remove((UIElement)schemeControlFromName);
            }
            KeymapCanvasWindow.sIsDirty = true;
            this.CanvasWindow.SidebarWindow.FillProfileCombo();
            if (this.ParentWindow.SelectedConfig.ControlSchemes.Count != 0)
            {
                return;
            }
            this.CanvasWindow.ClearWindow();
        }
 private void HandleNameEdit(ComboBoxSchemeControl control)
 {
     control.mEditImg.Visibility = Visibility.Visible;
     control.mSaveImg.Visibility = Visibility.Collapsed;
     if (this.EditedNameIsAllowed(control.mSchemeName.Text, control))
     {
         if (this.ParentWindow.SelectedConfig.ControlSchemesDict.ContainsKey(control.mOldSchemeName))
         {
             IMControlScheme imControlScheme = this.ParentWindow.SelectedConfig.ControlSchemesDict[control.mOldSchemeName];
             imControlScheme.Name = control.mSchemeName.Text.Trim();
             this.ParentWindow.SelectedConfig.ControlSchemesDict.Remove(control.mOldSchemeName);
             this.ParentWindow.SelectedConfig.ControlSchemesDict.Add(imControlScheme.Name, imControlScheme);
             this.CanvasWindow.SidebarWindow.FillProfileCombo();
             KeymapCanvasWindow.sIsDirty = true;
         }
     }
     else
     {
         control.mSchemeName.Text = control.mOldSchemeName;
     }
     control.mSchemeName.Focusable  = false;
     control.mSchemeName.IsReadOnly = true;
 }