Esempio n. 1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            slider           = GetTemplateChild("Slider") as DoubleSlider;
            LowerLabel       = GetTemplateChild("LowerValue") as Label;
            UpperLabel       = GetTemplateChild("UpperValue") as Label;
            ThresholdWarning = GetTemplateChild("ThresholdWarning") as Image;
            SensorDisplay    = GetTemplateChild("PlatformSensorDisplay") as PlatformSensorDisplay;

            slider.ValueChanged += delegate(DoubleSlider slider) { SaveToConfig(); };

            // Show the edit button for the custom-sensors slider.
            Button EditCustomSensorsButton = GetTemplateChild("EditCustomSensorsButton") as Button;

            EditCustomSensorsButton.Visibility = Type == "custom-sensors"? Visibility.Visible:Visibility.Hidden;
            EditCustomSensorsButton.Click     += delegate(object sender, RoutedEventArgs e)
            {
                SetCustomSensors dialog = new SetCustomSensors();
                dialog.Owner = Window.GetWindow(this);
                dialog.ShowDialog();
            };

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                LoadUIFromConfig(ActivePad.GetFirstActivePadConfig(args));
            });
        }
Esempio n. 2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            int[] PanelToIndex = new int[] {
                7, 8, 9,
                4, 5, 6,
                1, 2, 3,
            };

            EnabledPanelButtons = new PanelButton[9];
            for (int i = 0; i < 9; ++i)
            {
                EnabledPanelButtons[i] = GetTemplateChild("EnablePanel" + PanelToIndex[i]) as PanelButton;
            }

            foreach (PanelButton button in EnabledPanelButtons)
            {
                button.Click += EnabledPanelButtonClicked;
            }

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                LoadUIFromConfig(ActivePad.GetFirstActivePadConfig(args));
            });
        }
Esempio n. 3
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            HueSlider = GetTemplateChild("HueSlider") as ColorPickerSlider;
            HueSlider.ValueChanged += delegate(object sender, RoutedPropertyChangedEventArgs <double> e) {
                SaveToConfig();
            };

            HueSlider.StartedDragging += delegate() { StartedDragging?.Invoke(); };
            HueSlider.StoppedDragging += delegate() { StoppedDragging?.Invoke(); };

            DoubleCollection ticks = new DoubleCollection();

            // Add a tick at the minimum value, which is a negative value.  This is the
            // tick for white.
            ticks.Add(HueSlider.Minimum);

            // Add a tick for 0-359.  Don't add 360, since that's the same as 0.
            for (int i = 0; i < 360; ++i)
            {
                ticks.Add(i);
            }
            HueSlider.Ticks = ticks;

            OnConfigChange onConfigChange;

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                int pad = SelectedPanel < 9? 0:1;
                LoadUIFromConfig(args.controller[pad].config);
            });
        }
Esempio n. 4
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                LoadUIFromConfig(ActivePad.GetFirstActivePadConfig(args));
            });
        }
Esempio n. 5
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                LoadUIFromConfig(args.controller[args.FirstController].config);
            });
        }
Esempio n. 6
0
        public MainWindow()
        {
            InitializeComponent();

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                LoadUIFromConfig(args);
            });
        }
Esempio n. 7
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            OnConfigChange onConfigChange;

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                LoadUIFromConfig(args);
            });
        }
Esempio n. 8
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            OnConfigChange onConfigChange;

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                int pad = Panel < 9? 0:1;
                LoadUIFromConfig(args.controller[pad].config);
            });
        }
Esempio n. 9
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            Button button = GetTemplateChild("PART_Button") as Button;

            button.Click += delegate(object sender, RoutedEventArgs e) { Select(); };

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                string CurrentPreset = ConfigPresets.GetPreset(args.controller[args.FirstController].config);
                Selected             = CurrentPreset == Type;
            });
        }
Esempio n. 10
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            slider     = GetTemplateChild("Slider") as DoubleSlider;
            LowerLabel = GetTemplateChild("LowerValue") as Label;
            UpperLabel = GetTemplateChild("UpperValue") as Label;

            slider.ValueChanged += delegate(DoubleSlider slider) { SaveToConfig(); };

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                LoadUIFromConfig(ActivePad.GetFirstActivePadConfig(args));
            });
        }
Esempio n. 11
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            if (Type != "inner-sensors" && Type != "outer-sensors")
            {
                Visibility = Visibility.Hidden;
                IsChecked  = true;
                return;
            }

            OnConfigChange onConfigChange;

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                LoadFromSettings();
            });
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            OnConfigChange onConfigChange;

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                int SelectedPad = Panel < 9? 0:1;
                int PanelIndex  = Panel % 9;
                Pressed         = args.controller[SelectedPad].inputs[PanelIndex];

                Warning = !args.controller[SelectedPad].test_data.bHaveDataFromPanel[PanelIndex] ||
                          args.controller[SelectedPad].test_data.AnySensorsOnPanelNotResponding(PanelIndex);
            });
            onConfigChange.RefreshOnInputChange    = true;
            onConfigChange.RefreshOnTestDataChange = true;
        }
Esempio n. 13
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            Button button = GetTemplateChild("PART_Button") as Button;

            button.Click += delegate(object sender, RoutedEventArgs e) { Select(); };

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                foreach (Tuple <int, SMX.SMXConfig> activePad in ActivePad.ActivePads())
                {
                    SMX.SMXConfig config = activePad.Item2;
                    string CurrentPreset = ConfigPresets.GetPreset(config);
                    Selected             = CurrentPreset == Type;
                    break;
                }
            });
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            OnConfigChange onConfigChange;

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                int SelectedPad = Panel < 9? 0:1;
                int PanelIndex  = Panel % 9;
                Pressed         = args.controller[SelectedPad].inputs[PanelIndex];

                Warning = !args.controller[SelectedPad].test_data.bHaveDataFromPanel[PanelIndex] ||
                          args.controller[SelectedPad].test_data.AnySensorsOnPanelNotResponding(PanelIndex) ||
                          args.controller[SelectedPad].test_data.AnyBadJumpersOnPanel(PanelIndex);

                // Only show this panel button if the panel's input is enabled.
                SMX.SMXConfig config = ActivePad.GetFirstActivePadConfig(args);
                Visibility           = ShouldBeDisplayed(config)? Visibility.Visible:Visibility.Collapsed;
            });
            onConfigChange.RefreshOnInputChange    = true;
            onConfigChange.RefreshOnTestDataChange = true;
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            for (int sensor = 0; sensor < 4; ++sensor)
            {
                int ThisSensor = sensor; // bind
                SensorSelectionButtons[sensor]        = GetTemplateChild("Sensor" + sensor) as ToggleButton;
                SensorSelectionButtons[sensor].Click += delegate(object sender, RoutedEventArgs e)
                {
                    ClickedSensorButton(ThisSensor);
                };
            }

            // These settings are stored in the application settings, not on the pad.  However,
            // we treat changes to this as config changes, so we can use the same OnConfigChange
            // method for updating.
            OnConfigChange onConfigChange;

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                LoadUIFromConfig(args);
            });
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            LevelBars    = new LevelBar[4];
            LevelBars[0] = Template.FindName("SensorBar1", this) as LevelBar;
            LevelBars[1] = Template.FindName("SensorBar2", this) as LevelBar;
            LevelBars[2] = Template.FindName("SensorBar3", this) as LevelBar;
            LevelBars[3] = Template.FindName("SensorBar4", this) as LevelBar;

            LevelBarText    = new Label[4];
            LevelBarText[0] = Template.FindName("SensorBarLevel1", this) as Label;
            LevelBarText[1] = Template.FindName("SensorBarLevel2", this) as Label;
            LevelBarText[2] = Template.FindName("SensorBarLevel3", this) as Label;
            LevelBarText[3] = Template.FindName("SensorBarLevel4", this) as Label;

            DiagnosticMode        = Template.FindName("DiagnosticMode", this) as ComboBox;
            CurrentDIPGroup       = Template.FindName("CurrentDIPGroup", this) as Panel;
            CurrentDIP            = Template.FindName("CurrentDIP", this) as FrameImage;
            ExpectedDIP           = Template.FindName("ExpectedDIP", this) as FrameImage;
            NoResponseFromPanel   = Template.FindName("NoResponseFromPanel", this) as FrameworkElement;
            NoResponseFromSensors = Template.FindName("NoResponseFromSensors", this) as FrameworkElement;
            BadSensorDIPSwitches  = Template.FindName("BadSensorDIPSwitches", this) as FrameworkElement;
            P1Diagnostics         = Template.FindName("P1Diagnostics", this) as FrameworkElement;
            P2Diagnostics         = Template.FindName("P2Diagnostics", this) as FrameworkElement;

            DIPLabelRight = Template.FindName("DIPLabelRight", this) as FrameworkElement;
            DIPLabelLeft  = Template.FindName("DIPLabelLeft", this) as FrameworkElement;

            Button Recalibrate = Template.FindName("Recalibrate", this) as Button;

            Recalibrate.Click += delegate(object sender, RoutedEventArgs e)
            {
                for (int pad = 0; pad < 2; ++pad)
                {
                    SMX.SMX.ForceRecalibration(pad);
                }
            };

            // Note that we won't get a MouseUp if the display is hidden due to a controller
            // disconnection while the mouse is held.  We handle this in Refresh().
            Button LightAll = Template.FindName("LightAll", this) as Button;

            LightAll.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e)
            {
                SetShowAllLights?.Invoke(true);
            };
            LightAll.PreviewMouseUp += delegate(object sender, MouseButtonEventArgs e)
            {
                SetShowAllLights?.Invoke(false);
            };

            // Update the test mode when the dropdown is changed.
            DiagnosticMode.AddHandler(ComboBox.SelectionChangedEvent, new RoutedEventHandler(delegate(object sender, RoutedEventArgs e)
            {
                for (int pad = 0; pad < 2; ++pad)
                {
                    SMX.SMX.SetSensorTestMode(pad, GetTestMode());
                }
            }));

            OnConfigChange onConfigChange;

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                Refresh(args);
            });
            onConfigChange.RefreshOnTestDataChange = true;

            Loaded += delegate(object sender, RoutedEventArgs e)
            {
                for (int pad = 0; pad < 2; ++pad)
                {
                    SMX.SMX.SetSensorTestMode(pad, GetTestMode());
                }
            };

            Unloaded += delegate(object sender, RoutedEventArgs e)
            {
                for (int pad = 0; pad < 2; ++pad)
                {
                    SMX.SMX.SetSensorTestMode(pad, SMX.SMX.SensorTestMode.Off);
                }
            };
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            LevelBars    = new LevelBar[4];
            LevelBars[0] = Template.FindName("SensorBar1", this) as LevelBar;
            LevelBars[1] = Template.FindName("SensorBar2", this) as LevelBar;
            LevelBars[2] = Template.FindName("SensorBar3", this) as LevelBar;
            LevelBars[3] = Template.FindName("SensorBar4", this) as LevelBar;

            LevelBarText    = new Label[4];
            LevelBarText[0] = Template.FindName("SensorBarLevel1", this) as Label;
            LevelBarText[1] = Template.FindName("SensorBarLevel2", this) as Label;
            LevelBarText[2] = Template.FindName("SensorBarLevel3", this) as Label;
            LevelBarText[3] = Template.FindName("SensorBarLevel4", this) as Label;

            DiagnosticMode        = Template.FindName("DiagnosticMode", this) as ComboBox;
            CurrentDIP            = Template.FindName("CurrentDIP", this) as FrameImage;
            ExpectedDIP           = Template.FindName("ExpectedDIP", this) as FrameImage;
            NoResponseFromPanel   = Template.FindName("NoResponseFromPanel", this) as FrameworkElement;
            NoResponseFromSensors = Template.FindName("NoResponseFromSensors", this) as FrameworkElement;
            P1Diagnostics         = Template.FindName("P1Diagnostics", this) as FrameworkElement;
            P2Diagnostics         = Template.FindName("P2Diagnostics", this) as FrameworkElement;

            // Only show the mode dropdown in debug mode.  In regular use, just show calibrated values.
            DiagnosticMode.Visibility = Helpers.GetDebug()? Visibility.Visible:Visibility.Collapsed;

            Button Recalibrate = Template.FindName("Recalibrate", this) as Button;

            Recalibrate.Click += delegate(object sender, RoutedEventArgs e)
            {
                for (int pad = 0; pad < 2; ++pad)
                {
                    SMX.SMX.ForceRecalibration(pad);
                }
            };

            Button LightAll = Template.FindName("LightAll", this) as Button;

            LightAll.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e)
            {
                SetShowAllLights?.Invoke(true);
            };
            LightAll.PreviewMouseUp += delegate(object sender, MouseButtonEventArgs e)
            {
                SetShowAllLights?.Invoke(false);
            };

            // Update the test mode when the dropdown is changed.
            DiagnosticMode.AddHandler(ComboBox.SelectionChangedEvent, new RoutedEventHandler(delegate(object sender, RoutedEventArgs e)
            {
                for (int pad = 0; pad < 2; ++pad)
                {
                    SMX.SMX.SetTestMode(pad, GetTestMode());
                }
            }));

            OnConfigChange onConfigChange;

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                Refresh(args);
            });
            onConfigChange.RefreshOnTestDataChange = true;

            Loaded += delegate(object sender, RoutedEventArgs e)
            {
                for (int pad = 0; pad < 2; ++pad)
                {
                    SMX.SMX.SetTestMode(pad, GetTestMode());
                }
            };

            Unloaded += delegate(object sender, RoutedEventArgs e)
            {
                for (int pad = 0; pad < 2; ++pad)
                {
                    SMX.SMX.SetTestMode(pad, SMX.SMX.SensorTestMode.Off);
                }
            };
        }
        public MainWindow()
        {
            InitializeComponent();

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args)
            {
                LoadUIFromConfig(args);
            });

            // If we're controlling GIF animations and the firmware doesn't support
            // doing animations internally, confirm exiting, since you can minimize
            // to tray to keep playing animations.  If we're not controlling animations,
            // or the firmware supports doing them automatically, don't bug the user
            // with a prompt.
            Closing += delegate(object sender, System.ComponentModel.CancelEventArgs e)
            {
                LoadFromConfigDelegateArgs args = CurrentSMXDevice.singleton.GetState();

                // Don't use ActivePads here.  Even if P1 is selected for configuration,
                // we can still be controlling animations for P2, so check both connected
                // pads.
                bool shouldConfirmExit = false;
                for (int pad = 0; pad < 2; ++pad)
                {
                    SMX.SMXConfig config;
                    if (!SMX.SMX.GetConfig(pad, out config))
                    {
                        continue;
                    }

                    // If the firmware is version 4 or higher, it supports animations directly.
                    // The user can upload GIF animations and doesn't need to leave us running
                    // for them to work.  You can still use this tool to drive animations, but
                    // don't confirm exiting.
                    if (config.masterVersion >= 4)
                    {
                        continue;
                    }

                    // If AutoLightingUsePressedAnimations isn't set, the panel is using step
                    // coloring instead of pressed animations.  All firmwares support this.
                    // Don't confirm exiting for this mode.
                    if ((config.configFlags & SMX.SMXConfigFlags.AutoLightingUsePressedAnimations) == 0)
                    {
                        continue;
                    }

                    shouldConfirmExit = true;
                }

                if (!shouldConfirmExit)
                {
                    return;
                }

                MessageBoxResult result = MessageBox.Show(
                    "Close StepManiaX configuration?\n\n" +
                    "GIF animations will keep playing if the application is minimized.",
                    "StepManiaX", System.Windows.MessageBoxButton.YesNo);
                if (result == MessageBoxResult.No)
                {
                    e.Cancel = true;
                }
            };
        }