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); } }; }
private static void FrameChangedCallback(DependencyObject target, DependencyPropertyChangedEventArgs args) { FrameImage self = target as FrameImage; self.Refresh(); }
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); } }; }