예제 #1
0
        private async void Button_AddButtonColor_Click(object sender, RoutedEventArgs e)
        {
            var view = new AddButton(guids[combo_joysticks.SelectedIndex], joystickHelper, JoystickButtonToColor.ButtonTypeEnum.Color);
            JoystickButtonToColor newButton = (JoystickButtonToColor)await DialogHost.Show(view);

            if (newButton == null)
            {
                return;
            }

            newButton.ButtonType = JoystickButtonToColor.ButtonTypeEnum.Color; //TODO: REMOVE POG
            buttonsToColors.Add(newButton);
            var panel = new ButtonColorPicker(buttonsToColors[buttonsToColors.Count - 1]);

            panel.colorPanel.ColorChanged += ColorPanel_ColorChanged;
            panel.colorPanel.MouseLeave   += ColorPanel_MouseLeave;

            ContextMenu context = new ContextMenu();
            MenuItem    menu    = new MenuItem();

            menu.Header = "Remove";
            menu.Click += Item_Click;
            menu.Uid    = (buttonsToColors.Count - 1).ToString();
            context.Items.Add(menu);
            panel.ContextMenu = context;

            StackColors.Children.Add(panel);

            joystickHelper.SaveJoystickButtons(buttonsToColors.ToList(), guids[combo_joysticks.SelectedIndex]);
        }
예제 #2
0
        private void combo_joysticks_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (guids.Count <= 0 || combo_joysticks.SelectedIndex < 0)
            {
                return;
            }

            Stop();

            buttonsToColors = new ObservableCollection <JoystickButtonToColor>();

            App.settings.JoystickSelected = guids[combo_joysticks.SelectedIndex].ToString();
            App.settings.Save();

            foreach (var item in joystickHelper.LoadJoystickButtons(guids[combo_joysticks.SelectedIndex]))
            {
                buttonsToColors.Add(item);
            }

            for (int i = 0; i < buttonsToColors.Count; i++)
            {
                var item = buttonsToColors[i];
                if (item.ButtonType == JoystickButtonToColor.ButtonTypeEnum.Color)
                {
                    var panel = new ButtonColorPicker(item);
                    panel.colorPanel.ColorChanged += ColorPanel_ColorChanged;
                    ContextMenu context = new ContextMenu();
                    MenuItem    menu    = new MenuItem();
                    menu.Header = "Remove";
                    menu.Click += Item_Click;
                    context.Items.Add(menu);
                    menu.Uid          = i.ToString();
                    panel.ContextMenu = context;

                    StackColors.Children.Add(panel);
                }
                else
                {
                    var panel = new ButtonBrightnessPicker(item);

                    ContextMenu context = new ContextMenu();
                    MenuItem    menu    = new MenuItem();
                    menu.Header = "Remove";
                    menu.Click += Item_Click;
                    context.Items.Add(menu);
                    menu.Uid          = i.ToString();
                    panel.ContextMenu = context;
                    StackColors.Children.Add(panel);
                }
            }

            Start();
        }