private void Bookmark_img_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (!this.mSchemeName.IsReadOnly)
     {
         this.HandleNameEdit(this);
     }
     if (this.ParentWindow.SelectedConfig.ControlSchemesDict.ContainsKey(this.mSchemeName.Text))
     {
         IMControlScheme imControlScheme = this.ParentWindow.SelectedConfig.ControlSchemesDict[this.mSchemeName.Text];
         if (imControlScheme.IsBookMarked)
         {
             imControlScheme.IsBookMarked = false;
             this.mBookmarkImg.ImageName  = "bookmark";
         }
         else
         {
             List <IMControlScheme> controlSchemes = this.ParentWindow.SelectedConfig.ControlSchemes;
             if ((controlSchemes != null ? (controlSchemes.Count <IMControlScheme>((Func <IMControlScheme, bool>)(scheme => scheme.IsBookMarked)) < 5 ? 1 : 0) : 0) != 0)
             {
                 imControlScheme.IsBookMarked = true;
                 this.mBookmarkImg.ImageName  = "bookmarked";
             }
             else
             {
                 this.CanvasWindow.SidebarWindow.AddToastPopup(LocaleStrings.GetLocalizedString("STRING_BOOKMARK_SCHEMES_WARNING", ""));
             }
         }
         this.CanvasWindow.SidebarWindow.FillProfileCombo();
         KeymapCanvasWindow.sIsDirty = true;
     }
     e.Handled = true;
 }
Example #2
0
 private void SaveCFGButton_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     foreach (System.Windows.Controls.ListViewItem listViewItem in (IEnumerable)this.mLoadedCFGsListView.Items)
     {
         if (listViewItem.Content.ToString().EndsWith("* (modified)", StringComparison.InvariantCulture))
         {
             try
             {
                 string   fullFilePath = listViewItem.Tag.ToString();
                 IMConfig index        = this.mLoadedCFGDict[fullFilePath];
                 List <IMControlScheme> imControlSchemeList = new List <IMControlScheme>();
                 foreach (IMControlScheme controlScheme in index.ControlSchemes)
                 {
                     IMControlScheme imControlScheme = controlScheme.DeepCopy();
                     imControlScheme.SetGameControls(this.GetFinalListOfActions(this.mSchemeTreeMapping[index][controlScheme]));
                     imControlSchemeList.Add(imControlScheme);
                 }
                 index.ControlSchemes = imControlSchemeList;
                 JsonSerializerSettings serializerSettings = Utils.GetSerializerSettings();
                 serializerSettings.Formatting = Formatting.Indented;
                 this.WriteFile(fullFilePath, JsonConvert.SerializeObject((object)index, serializerSettings));
                 listViewItem.Content = (object)listViewItem.Content.ToString().TrimEnd("* (modified)".ToCharArray());
             }
             catch (Exception ex)
             {
                 string str = string.Format("Couldn't write to file: {0}, Ex: {1}", (object)listViewItem.Tag.ToString(), (object)ex);
                 Logger.Error(str);
                 int num = (int)System.Windows.MessageBox.Show(str);
             }
         }
     }
 }
Example #3
0
    public IMControlScheme DeepCopy()
    {
        IMControlScheme imControlScheme = (IMControlScheme)this.MemberwiseClone();
        List <IMAction> gameControls    = this.GameControls;

        imControlScheme.SetGameControls(gameControls != null ? gameControls.DeepCopy <List <IMAction> >() : (List <IMAction>)null);
        imControlScheme.SetImages(this.Images.ConvertAll <JObject>((Converter <JObject, JObject>)(jt => (JObject)jt?.DeepClone())));
        return(imControlScheme);
    }
Example #4
0
 private ImportSchemesWindowControl GetControlFromScheme(
     IMControlScheme scheme)
 {
     foreach (ImportSchemesWindowControl child in this.mSchemesStackPanel.Children)
     {
         if (child.mContent.Content.ToString().Trim().ToLower(CultureInfo.InvariantCulture) == scheme.Name.ToLower(CultureInfo.InvariantCulture).Trim())
         {
             return(child);
         }
     }
     return((ImportSchemesWindowControl)null);
 }
Example #5
0
 public SchemeBookmarkControl(IMControlScheme scheme, MainWindow window, double maxWidth)
 {
     this.InitializeComponent();
     this.mParentWindow       = window;
     this.mSchemeName.Text    = scheme?.Name;
     this.mSchemeName.ToolTip = (object)this.mSchemeName.Text;
     if (scheme.Selected)
     {
         this.mPictureBox.ImageName = "radio_selected";
     }
     this.mSchemeName.MaxWidth = maxWidth - 20.0;
 }
Example #6
0
        private void SchemeItem_Drop(object sender, System.Windows.DragEventArgs e)
        {
            IMControlScheme data        = e.Data.GetData(typeof(IMControlScheme)) as IMControlScheme;
            IMControlScheme dataContext = ((FrameworkElement)sender).DataContext as IMControlScheme;
            int             sourceIndex = this.mSchemesListView.Items.IndexOf((object)data);
            int             targetIndex = this.mSchemesListView.Items.IndexOf((object)dataContext);

            if (sourceIndex == -1 || targetIndex == -1)
            {
                return;
            }
            this.MoveItem(data, sourceIndex, targetIndex);
            this.mSchemesListView.Items.Refresh();
            this.MarkCurrentCFGModified();
        }
Example #7
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;
        }
Example #8
0
        private void mSchemesListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int selectedIndex = this.mSchemesListView.SelectedIndex;

            if (selectedIndex == -1)
            {
                return;
            }
            this.mCurrentlySelectedScheme = this.mSchemesList[selectedIndex];
            this.ClearIMActionsTree();
            this.BuildIMActionsTree();
            this.GenerateTreeView();
            if (this.mIMActionsTreeView.Items.Count <= 0)
            {
                return;
            }
            this.mIMActionsTreeView.Visibility = Visibility.Visible;
        }
Example #9
0
 private void MoveItem(IMControlScheme source, int sourceIndex, int targetIndex)
 {
     if (sourceIndex < targetIndex)
     {
         this.mSchemesList.Insert(targetIndex + 1, source);
         this.mSchemesList.RemoveAt(sourceIndex);
     }
     else
     {
         int index = sourceIndex + 1;
         if (this.mSchemesList.Count + 1 <= index)
         {
             return;
         }
         this.mSchemesList.Insert(targetIndex, source);
         this.mSchemesList.RemoveAt(index);
     }
 }
 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;
 }