public RaceFactoryPanel(Action <RaceDetails> raceOutputRcvr) { InitializeComponent(); raceRcvr = raceOutputRcvr; if (AntPlusRacerConfig.getInstance().autoLoadAvailableRaceSourcesForRace) { AntPlusDevMgr antMgr = AntConfigPanel.accessInstance().antMgr; for (int i = 0; i < antMgr.deviceList.Count; ++i) { AntPlusDevMgr.AntPlus_Connection dev = antMgr.deviceList[i]; //Skip devices in use if (dev.dataSource.isInUse || dev.getConnStatus() != AntPlusDevMgr.AntPlus_Connection.ConnState.Connected || isDataSourceReserved(dev.dataSource)) { continue; } else { configureRacer(0xFF, dev.dataSource, AntPlusRacerConfig.getInstance().getDefaultRaceTrack(dev.dataSource.getSportType()).distance); } } if (configuredRacers.Count == 0) { DisplayRacerList(); } } else { DisplayRacerList(); } ComboBox_RaceLength.SizeChanged += new SizeChangedEventHandler((sender, args) => comboBoxAutoLblFontSize(sender as ComboBox)); }
public void refreshView() { Dispatcher.Invoke(new Action(() => { DataSourcePacket lastSeenData = antPlusConnection.dataSource.getLastDataRcvd(); Label_Description2.Content = antPlusConnection.dataSource.getSportType(); Label_DevID.Content = antPlusConnection.dataSource.searchProfile.deviceNumber; Label_Status.Content = antPlusConnection.getConnStatus().ToString(); if (lastSeenData == null) { Label_Dist.Content = "---"; Label_Speed.Content = "---"; Label_Cadence.Content = "---"; } else { Label_Dist.Content = Math.Round(lastSeenData.distance).ToString(); Label_Speed.Content = Math.Round(lastSeenData.speed_ms, 2).ToString(); Label_Cadence.Content = Math.Round(lastSeenData.cadence).ToString(); } })); }
private void DisplayRacerConfig() { inRacerConfigScreen = true; //TODOb this only shows ant plus sources ListBox_RacerOrSources.Items.Clear(); Button_AddRacer.Visibility = System.Windows.Visibility.Hidden; ComboBox_RaceLength.Visibility = System.Windows.Visibility.Visible; Button_Start.Visibility = System.Windows.Visibility.Hidden; Label_DisplayTitle.Content = "Configure New Racer - Source and Track Length:"; ComboBox_RaceLength.Items.Clear(); AntPlusDevMgr antMgr = AntConfigPanel.accessInstance().antMgr; Binding widthBind = new Binding("ActualWidth"); widthBind.Source = ListBox_RacerOrSources; bool select0 = false; dsOnDisplay = new List <DataSourceBase>(); //Add current source if (racerIndexUnderConfig >= 0) { dsOnDisplay.Add(configuredRacers[racerIndexUnderConfig].dataSource); select0 = true; } for (int i = 0; i < antMgr.deviceList.Count; ++i) { AntPlusDevMgr.AntPlus_Connection dev = antMgr.deviceList[i]; //Skip devices in use if (dev.dataSource.isInUse || dev.getConnStatus() != AntPlusDevMgr.AntPlus_Connection.ConnState.Connected || isDataSourceReserved(dev.dataSource)) { continue; } else { dsOnDisplay.Add(dev.dataSource); } } if (dsOnDisplay.Count > 0) { foreach (DataSourceBase i in dsOnDisplay) { //Show as option in list Label name = new Label(); name.Content = i.getSportType() + "-" + i.getSourceName(); Viewbox vb = new Viewbox(); vb.SetBinding(Viewbox.WidthProperty, widthBind); vb.Margin = new Thickness(0, 1, 20, 1); vb.Child = name; ListBox_RacerOrSources.Items.Add(vb); if (select0) { ListBox_RacerOrSources.SelectedIndex = 0; } Button_RacerAddOrFinish.IsEnabled = true; Button_RacerRemoveOrCancel.IsEnabled = true; } } else { Label_DisplayTitle.Content = "...No Data Sources Available"; Button_RacerAddOrFinish.IsEnabled = false; Button_RacerRemoveOrCancel.IsEnabled = true; } Label lbl2 = new Label() { Content = "Save" }; Viewbox vb2 = new Viewbox() { Child = lbl2 }; Button_RacerAddOrFinish.Content = vb2; Label lbl3 = new Label() { Content = "Cancel" }; Viewbox vb3 = new Viewbox() { Child = lbl3 }; Button_RacerRemoveOrCancel.Content = vb3; }