コード例 #1
0
 private void ImportBtn_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         int  index = 0;
         bool flag1 = true;
         List <IMControlScheme> imControlSchemeList = new List <IMControlScheme>();
         foreach (ImportSchemesWindowControl child in this.mSchemesStackPanel.Children)
         {
             bool?isChecked = child.mContent.IsChecked;
             bool flag2     = true;
             if (isChecked.GetValueOrDefault() == flag2 & isChecked.HasValue)
             {
                 imControlSchemeList.Add(this.dict.ElementAt <KeyValuePair <string, IMControlScheme> >(index).Value);
                 if (this.ParentWindow.SelectedConfig.ControlSchemesDict.Keys.Select <string, string>((Func <string, string>)(key => key.ToLower(CultureInfo.InvariantCulture).Trim())).Contains <string>(child.mContent.Content.ToString().ToLower(CultureInfo.InvariantCulture).Trim()))
                 {
                     if (!this.EditedNameIsAllowed(child.mImportName.Text, child))
                     {
                         child.mImportName.InputTextValidity = TextValidityOptions.Error;
                         if (!string.IsNullOrEmpty(child.mImportName.Text) && child.mImportName.Text.Trim().IndexOfAny(Path.GetInvalidFileNameChars()) < 0)
                         {
                             BlueStacksUIBinding.Bind(child.mWarningMsg, LocaleStrings.GetLocalizedString("STRING_DUPLICATE_SCHEME_NAME_WARNING", ""), "");
                         }
                         child.mWarningMsg.Visibility = Visibility.Visible;
                         flag1 = false;
                     }
                     else
                     {
                         child.mImportName.InputTextValidity = TextValidityOptions.Success;
                         child.mWarningMsg.Visibility        = Visibility.Collapsed;
                     }
                 }
             }
             ++index;
         }
         if (imControlSchemeList.Count == 0)
         {
             this.ParentWindow.mCommonHandler.AddToastPopup((Window)this, LocaleStrings.GetLocalizedString("STRING_NO_SCHEME_SELECTED", ""), 1.3, false);
         }
         else
         {
             if (!flag1)
             {
                 return;
             }
             foreach (IMControlScheme scheme in imControlSchemeList)
             {
                 ImportSchemesWindowControl controlFromScheme = this.GetControlFromScheme(scheme);
                 if (this.ParentWindow.SelectedConfig.ControlSchemesDict.Keys.Select <string, string>((Func <string, string>)(key => key.ToLower(CultureInfo.InvariantCulture))).Contains <string>(controlFromScheme.mContent.Content.ToString().ToLower(CultureInfo.InvariantCulture).Trim()))
                 {
                     scheme.Name = controlFromScheme.mImportName.Text.Trim();
                 }
             }
             this.mStringsToImport = KMManager.CleanupGuidanceAccordingToSchemes(imControlSchemeList, this.mStringsToImport);
             this.ImportSchemes(imControlSchemeList, this.mStringsToImport);
             KeymapCanvasWindow.sIsDirty = true;
             KMManager.SaveIMActions(this.ParentWindow, false, false);
             this.CanvasWindow.SidebarWindow.FillProfileCombo();
             this.CanvasWindow.SidebarWindow.ProfileChanged();
             KMManager.SendSchemeChangedStats(this.ParentWindow, "import_scheme");
             this.ParentWindow.mCommonHandler.AddToastPopup((Window)this.CanvasWindow.SidebarWindow, LocaleStrings.GetLocalizedString("STRING_CONTROLS_IMPORTED", ""), 1.3, false);
             this.CloseWindow();
         }
     }
     catch (Exception ex)
     {
         Logger.Error("Error while importing script. err:" + ex.ToString());
     }
 }