public static CarList createListItem(Racer racer, int place, TimeInfo timeInfo) { CarList item = new CarList(); item.place.Content = place; item.timeAverage.Text = String.Format("{0:0.000}", timeInfo.AverageTime) + "s"; item.timeBest.Text = String.Format("{0:0.000}", timeInfo.BestTime) + "s"; if (timeInfo.HasAllLanesDone()) { item.timeAverageHolder.Opacity = 1; item.timeBestHolder.Opacity = 1; } if (!racer.PassedInspection) { item.disabled.Visibility = Visibility.Visible; } item.Lanes.Children.Clear(); for (int i = 0; i < DataManager.Settings.NumberOfLanes; i++) { Label lane = new Label(); lane.Content = (i + 1).ToString(); lane.HorizontalAlignment = HorizontalAlignment.Center; lane.VerticalAlignment = VerticalAlignment.Center; lane.FontSize = 30; if (timeInfo.LanesDone.Contains(i + 1)) { lane.IsEnabled = false; lane.FontWeight = FontWeights.UltraLight; lane.Opacity = 0.5; } item.Lanes.Children.Add(lane); } item.tbCarName.Text = racer.Car.Name; item.tbCreatorName.Text = racer.Maker.Name; try { item.imgCarImage.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Car.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Car's Picture. Falling Back to defalt.", ex1.Message); try { item.imgCarImage.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltCarImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Car's Picture.", ex2.Message); } } try { item.imgCreatorPicture.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Maker.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Creator's Picture. Falling Back to defalt.", ex1.Message); try { item.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltMakerImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Creator's Picture", ex2.Message); } } return(item); }
private void addCarListItem(Panel host, Racer racer, int delay) { CarList listItem = CarList.createListItem(racer); listItem.MouseUp += delegate { RacerDetails.editOldRacer(HostGrid, racer, delegate () { updateRacerList(); }, delegate () { forgetRace(); }); }; listItem.Margin = new Thickness(0, 0, 0, 8); listItem.AnimateIn(delay); host.Children.Add(listItem); }
public static CarList createListItem(Racer racer) { CarList item = new CarList(); item.place.Content = ""; item.timeAverage.Text = "-"; item.timeBest.Text = "-"; if (!racer.PassedInspection) { item.disabled.Visibility = Visibility.Visible; } item.Lanes.Children.Clear(); for (int i = 0; i < DataManager.Settings.NumberOfLanes; i++) { Label lane = new Label(); lane.Content = (i + 1).ToString(); lane.HorizontalAlignment = HorizontalAlignment.Center; lane.VerticalAlignment = VerticalAlignment.Center; lane.FontSize = 30; item.Lanes.Children.Add(lane); } item.tbCarName.Text = racer.Car.Name; item.tbCreatorName.Text = racer.Maker.Name; try { item.imgCarImage.Source = new BitmapImage(DataManager.getAbsoluteUri(racer.Car.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Car's Picture. Falling Back to defalt.", ex1.Message); try { item.imgCarImage.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltCarImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Car's Picture.", ex2.Message); } } try { item.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(racer.Maker.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Creator's Picture. Falling Back to defalt.", ex1.Message); try { item.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltMakerImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Creator's Picture", ex2.Message); } } return(item); }
public static void editOldRacer(Panel parent, Racer racer, racerUpdatedHandler returnHandler, racerDeletedHandler deleteHandler) { RacerDetails editor = new RacerDetails(WindowType.Display); editor.onUpdatedRacer += returnHandler; editor.onDeletedRacer += deleteHandler; editor._racer = racer; try { editor.imgCarPicture.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Car.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Car's Picture. Falling Back to defalt.", ex1.Message); try { editor.imgCarPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltCarImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Car's Picture.", ex2.Message); } } try { editor.imgCreatorPicture.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Maker.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Creator's Picture. Falling Back to defalt.", ex1.Message); try { editor.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltMakerImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Creator's Picture", ex2.Message); } } editor.tbCarName.Text = racer.Car.Name; editor.tbCreatorName.Text = racer.Maker.Name; editor.tbBarcode.Text = racer.Barcode; editor.cboClass.Text = racer.Class; editor.passedInspect.IsChecked = racer.PassedInspection; editor.raceData.Children.Clear(); editor.raceData.ColumnDefinitions.Clear(); if (racer.Times.Count > 0) { editor.scores.Visibility = Visibility.Visible; double totalTime = 0; int totalAmount = 0; double bestTime = 10; editor.lbNoRaceData.Visibility = Visibility.Collapsed; for (int i = 0; i < DataManager.Settings.NumberOfLanes; i++) { editor.raceData.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); //<Label Grid.Column="5" Content="6" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center"/> Label lbLaneHeader = new Label(); lbLaneHeader.Content = (i + 1).ToString(); lbLaneHeader.FontSize = 30; lbLaneHeader.HorizontalAlignment = HorizontalAlignment.Center; lbLaneHeader.VerticalAlignment = VerticalAlignment.Center; lbLaneHeader.SetValue(Grid.RowProperty, 0); lbLaneHeader.SetValue(Grid.ColumnProperty, i); editor.raceData.Children.Add(lbLaneHeader); //<Border Grid.Column="6" Grid.Row="1" Grid.RowSpan="2" BorderThickness="0.5, 0, 1, 0" BorderBrush="{DynamicResource MaterialDesignDivider}" Margin="0, 16, 0, 8"/> Border border = new Border(); border.HorizontalAlignment = HorizontalAlignment.Stretch; border.VerticalAlignment = VerticalAlignment.Stretch; border.Margin = new Thickness(0, 8, 0, 8); border.BorderBrush = editor.FindResource("MaterialDesignDivider") as Brush; border.BorderThickness = new Thickness((i == 0 ? 0 : 0.5), 0, (i == DataManager.Settings.NumberOfLanes - 1 ? 0 : 0.5), 0); border.SetValue(Grid.RowProperty, 0); border.SetValue(Grid.RowSpanProperty, 2); border.SetValue(Grid.ColumnProperty, i); editor.raceData.Children.Add(border); StackPanel stp = new StackPanel(); stp.HorizontalAlignment = HorizontalAlignment.Center; stp.VerticalAlignment = VerticalAlignment.Top; stp.Orientation = Orientation.Vertical; stp.SetValue(Grid.RowProperty, 1); stp.SetValue(Grid.ColumnProperty, i); List<double> times = new List<double>(); foreach (Time time in racer.Times) { if (time.Lane == i + 1) { times.Add(time.Speed); } } times.Sort(); for (int t = 0; t < times.Count; t++) { Label lbTime = new Label(); lbTime.Content = String.Format("{0:0.000}", times[t]) + "s"; lbTime.FontSize = 18; if (t == 0) { totalTime += times[t]; totalAmount++; if (bestTime > times[t]) { bestTime = times[t]; } } else { lbTime.Opacity = 0.5; } lbTime.HorizontalAlignment = HorizontalAlignment.Center; lbTime.VerticalAlignment = VerticalAlignment.Top; lbTime.SetValue(Grid.RowProperty, 1); lbTime.SetValue(Grid.ColumnProperty, i); stp.Children.Add(lbTime); } editor.timeAverage.Text = String.Format("{0:0.000}", (totalTime / totalAmount)) + "s"; editor.timeBest.Text = String.Format("{0:0.000}", bestTime) + "s"; editor.raceData.Children.Add(stp); } } MakeDialog(parent, editor, WindowType.Display); }
public static void editOldRacer(Panel parent, Racer racer, racerUpdatedHandler returnHandler, racerDeletedHandler deleteHandler) { RacerDetails editor = new RacerDetails(WindowType.Display); editor.onUpdatedRacer += returnHandler; editor.onDeletedRacer += deleteHandler; editor._racer = racer; try { editor.imgCarPicture.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Car.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Car's Picture. Falling Back to defalt.", ex1.Message); try { editor.imgCarPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltCarImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Car's Picture.", ex2.Message); } } try { editor.imgCreatorPicture.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Maker.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Creator's Picture. Falling Back to defalt.", ex1.Message); try { editor.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltMakerImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Creator's Picture", ex2.Message); } } editor.tbCarName.Text = racer.Car.Name; editor.tbCreatorName.Text = racer.Maker.Name; editor.tbBarcode.Text = racer.Barcode; editor.cboClass.Text = racer.Class; editor.passedInspect.IsChecked = racer.PassedInspection; editor.raceData.Children.Clear(); editor.raceData.ColumnDefinitions.Clear(); if (racer.Times.Count > 0) { editor.scores.Visibility = Visibility.Visible; double totalTime = 0; int totalAmount = 0; double bestTime = 10; editor.lbNoRaceData.Visibility = Visibility.Collapsed; for (int i = 0; i < DataManager.Settings.NumberOfLanes; i++) { editor.raceData.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); //<Label Grid.Column="5" Content="6" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center"/> Label lbLaneHeader = new Label(); lbLaneHeader.Content = (i + 1).ToString(); lbLaneHeader.FontSize = 30; lbLaneHeader.HorizontalAlignment = HorizontalAlignment.Center; lbLaneHeader.VerticalAlignment = VerticalAlignment.Center; lbLaneHeader.SetValue(Grid.RowProperty, 0); lbLaneHeader.SetValue(Grid.ColumnProperty, i); editor.raceData.Children.Add(lbLaneHeader); //<Border Grid.Column="6" Grid.Row="1" Grid.RowSpan="2" BorderThickness="0.5, 0, 1, 0" BorderBrush="{DynamicResource MaterialDesignDivider}" Margin="0, 16, 0, 8"/> Border border = new Border(); border.HorizontalAlignment = HorizontalAlignment.Stretch; border.VerticalAlignment = VerticalAlignment.Stretch; border.Margin = new Thickness(0, 8, 0, 8); border.BorderBrush = editor.FindResource("MaterialDesignDivider") as Brush; border.BorderThickness = new Thickness((i == 0 ? 0 : 0.5), 0, (i == DataManager.Settings.NumberOfLanes - 1 ? 0 : 0.5), 0); border.SetValue(Grid.RowProperty, 0); border.SetValue(Grid.RowSpanProperty, 2); border.SetValue(Grid.ColumnProperty, i); editor.raceData.Children.Add(border); StackPanel stp = new StackPanel(); stp.HorizontalAlignment = HorizontalAlignment.Center; stp.VerticalAlignment = VerticalAlignment.Top; stp.Orientation = Orientation.Vertical; stp.SetValue(Grid.RowProperty, 1); stp.SetValue(Grid.ColumnProperty, i); List <double> times = new List <double>(); foreach (Time time in racer.Times) { if (time.Lane == i + 1) { times.Add(time.Speed); } } times.Sort(); for (int t = 0; t < times.Count; t++) { Label lbTime = new Label(); lbTime.Content = String.Format("{0:0.000}", times[t]) + "s"; lbTime.FontSize = 18; if (t == 0) { totalTime += times[t]; totalAmount++; if (bestTime > times[t]) { bestTime = times[t]; } } else { lbTime.Opacity = 0.5; } lbTime.HorizontalAlignment = HorizontalAlignment.Center; lbTime.VerticalAlignment = VerticalAlignment.Top; lbTime.SetValue(Grid.RowProperty, 1); lbTime.SetValue(Grid.ColumnProperty, i); stp.Children.Add(lbTime); } editor.timeAverage.Text = String.Format("{0:0.000}", (totalTime / totalAmount)) + "s"; editor.timeBest.Text = String.Format("{0:0.000}", bestTime) + "s"; editor.raceData.Children.Add(stp); } } MakeDialog(parent, editor, WindowType.Display); }
public static CarTile createTile(Racer racer, bool keepSize) { return createTile(racer, keepSize, false, null); }
public static CarTile createTile(Racer racer, bool keepSize, addToRaceHandler addHandler) { return createTile(racer, keepSize, true, addHandler); }
private static CarTile createTile(Racer racer, bool keepSize, bool haveAdd, addToRaceHandler addHandler) { CarTile tile = new CarTile(); tile.tbCarName.Text = racer.Car.Name; tile.tbCreatorName.Text = racer.Maker.Name; tile.onAddToRace += addHandler; if (!racer.PassedInspection) { tile.disabled.Visibility = Visibility.Visible; } if (!haveAdd || !racer.PassedInspection) { tile.addHolder.Visibility = System.Windows.Visibility.Collapsed; } if (!keepSize) { //make unsized tile.MainGrid.Width = tile.MainGrid.Height = Double.NaN; } try { tile.imgCarImage.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Car.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Car's Picture. Falling Back to defalt.", ex1.Message); try { tile.imgCarImage.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltCarImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Car's Picture.", ex2.Message); } } try { tile.imgCreatorPicture.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Maker.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Creator's Picture. Falling Back to defalt.", ex1.Message); try { tile.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltMakerImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Creator's Picture", ex2.Message); } } return tile; }
public static CarList createListItem(Racer racer, int place, TimeInfo timeInfo) { CarList item = new CarList(); item.place.Content = place; item.timeAverage.Text = String.Format("{0:0.000}", timeInfo.AverageTime) + "s"; item.timeBest.Text = String.Format("{0:0.000}", timeInfo.BestTime) + "s"; if (timeInfo.HasAllLanesDone()) { item.timeAverageHolder.Opacity = 1; item.timeBestHolder.Opacity = 1; } if (!racer.PassedInspection) { item.disabled.Visibility = Visibility.Visible; } item.Lanes.Children.Clear(); for (int i = 0; i < DataManager.Settings.NumberOfLanes; i++) { Label lane = new Label(); lane.Content = (i + 1).ToString(); lane.HorizontalAlignment = HorizontalAlignment.Center; lane.VerticalAlignment = VerticalAlignment.Center; lane.FontSize = 30; if (timeInfo.LanesDone.Contains(i + 1)) { lane.IsEnabled = false; lane.FontWeight = FontWeights.UltraLight; lane.Opacity = 0.5; } item.Lanes.Children.Add(lane); } item.tbCarName.Text = racer.Car.Name; item.tbCreatorName.Text = racer.Maker.Name; try { item.imgCarImage.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Car.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Car's Picture. Falling Back to defalt.", ex1.Message); try { item.imgCarImage.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltCarImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Car's Picture.", ex2.Message); } } try { item.imgCreatorPicture.Source = DataManager.loadImage(DataManager.getAbsoluteUri(racer.Maker.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Creator's Picture. Falling Back to defalt.", ex1.Message); try { item.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltMakerImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Creator's Picture", ex2.Message); } } return item; }
public static CarList createListItem(Racer racer) { CarList item = new CarList(); item.place.Content = ""; item.timeAverage.Text = "-"; item.timeBest.Text = "-"; if (!racer.PassedInspection) { item.disabled.Visibility = Visibility.Visible; } item.Lanes.Children.Clear(); for (int i = 0; i < DataManager.Settings.NumberOfLanes; i++) { Label lane = new Label(); lane.Content = (i + 1).ToString(); lane.HorizontalAlignment = HorizontalAlignment.Center; lane.VerticalAlignment = VerticalAlignment.Center; lane.FontSize = 30; item.Lanes.Children.Add(lane); } item.tbCarName.Text = racer.Car.Name; item.tbCreatorName.Text = racer.Maker.Name; try { item.imgCarImage.Source = new BitmapImage(DataManager.getAbsoluteUri(racer.Car.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Car's Picture. Falling Back to defalt.", ex1.Message); try { item.imgCarImage.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltCarImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Car's Picture.", ex2.Message); } } try { item.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(racer.Maker.ImageUri)); } catch (Exception ex1) { DataManager.MessageProvider.showError("Could Not Load Creator's Picture. Falling Back to defalt.", ex1.Message); try { item.imgCreatorPicture.Source = new BitmapImage(DataManager.getAbsoluteUri(DataManager.Settings.DefaltMakerImageUri)); } catch (Exception ex2) { DataManager.MessageProvider.showError("Could Not Load Defalt Creator's Picture", ex2.Message); } } return item; }
public static CarTile createTile(Racer racer, bool keepSize, addToRaceHandler addHandler) { return(createTile(racer, keepSize, true, addHandler)); }
public static CarTile createTile(Racer racer, bool keepSize) { return(createTile(racer, keepSize, false, null)); }