private void UserControl_Loaded(object sender, RoutedEventArgs e) { this.DataContext = Item as ResoAV.clCompetitor; this.Width = 82 * (Item as ResoAV.clCompetitor).AttemptCollection.Length; var temp = new clCompetitor(); for (int i = 0; i < temp.AttemptCollection.Length; ++i) { var v = new ColumnDefinition(); v.Width = new GridLength(82); grMain.ColumnDefinitions.Add(v); var b = new Border(); b.SetValue(Grid.ColumnProperty, i); b.BorderThickness = new Thickness(1, 1, 0, 0); //b.BorderBrush="Black"; var t = new TextBlock(); //t.FontWeight = FontWeights.Bold; t.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; t.TextAlignment = TextAlignment.Center; t.Padding = new Thickness(0, 5, 0, 0); t.MouseEnter += TimeTextBlock_MouseEnter; t.MouseLeave += TimeTextBlock_MouseLeave; t.SetBinding(TextBlock.TextProperty, new Binding("AttemptCollection") { Converter = new AttemptListConverter(), ConverterParameter = i, }); t.ContextMenu = this.ContextMenu; b.Child = t; grMain.Children.Add(b); } }
public void Init(Table.ResultCallbackDelegate callback, clCompetitor man) { lbHeader.Text = man.Number + " " + man.Name + " " + man.Class; _resultCallback = callback; _man = man; HardwareCommunicator.ReceivedData += new HardwareCommunicator.ComEventHandler(HardwareCommunicator_ReceivedData); }
//add private void Button_Click(object sender, RoutedEventArgs e) { int num; if (string.IsNullOrEmpty(edNum.Text)) { num = competitor.Select(i => i.Number).OrderByDescending(i => i).FirstOrDefault() + 1; } else if (!Int32.TryParse(edNum.Text, out num)) { //throw new Exception("Стартовый номер указан не верно. Введённое значение - не число"); MessageBox.Show("Стартовый номер указан не верно. Введённое значение - не число", "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (competitor.Any(i => i.Number == num)) { MessageBox.Show("Участник с таким номером уже существует", "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning); return; } var c = new clCompetitor { Number = num,//Int32.Parse(edNum.Text), Name = edName.Text, Model = edCar.Text, Class = (clCompetitor.carClass)(Enum.Parse(typeof(clCompetitor.carClass), cmbClass.SelectedItem.ToString(), true)), }; competitor.Add(c);//String.Format("{0} {1} {2}", edNum.Text, edName.Text, edClass.Text)); edNum.Text = ""; edName.Text = ""; edCar.Text = ""; }
public static TimeSpan OverallSum(clCompetitor c) { TimeSpan res = new TimeSpan(); foreach (var i in c.AttemptCollection) { res = res.Add(GetSpanByAttempt(i)); } return(res); }
public void ResultCallback(clCompetitor man, TimeSpan result, int penality, TextBlock targetCell) { int column = (int)(targetCell.Parent as Border).GetValue(Grid.ColumnProperty); //int row = (int)(targetCell.Parent as Border).GetValue(Grid.RowProperty); if (column >= 0) { man.AttemptModify(column, result); } (targetCell.Parent as Border).Background = new SolidColorBrush(Color.FromRgb(0, 255, 0)); }
public static TimeSpan OneFastest(clCompetitor c) { TimeSpan min = GetSpanByAttempt(c.AttemptCollection[0]), tmp; foreach (var i in c.AttemptCollection) { tmp = GetSpanByAttempt(i); if (tmp < min) { min = tmp; } } return(min); }
public static TimeSpan TwoFastest(clCompetitor c) { var list = new List <TimeSpan>(); foreach (var i in c.AttemptCollection) { list.Add(GetSpanByAttempt(i)); } list.Sort(); if (list.Count > 1) { return(list[0] + list[1]); } else { return(list[0]); } }
private void LoadCompetitorsFromFile(string filepath) { using (TextReader file = new StreamReader(filepath)) { string line = file.ReadLine(); while (!string.IsNullOrEmpty(line)) { var columns = line.Split(';'); if (columns.Count() > 0 && columns[0] == "service_information") { SetSettings(columns); } else { try { var comp = new clCompetitor() { //Number = columns[0], Name = columns[1], Model = columns[2], //Class = columns[3]; }; comp.Number = Int32.Parse(columns[0]); if (!competitor.Any(i => i.Number == comp.Number)) { comp.Class = (clCompetitor.carClass)(Enum.Parse(typeof(clCompetitor.carClass), columns[3], true)); competitor.Add(comp); } } catch (Exception ex) { System.Console.WriteLine(ex.Message); } } line = file.ReadLine(); } } lbRacingTitle.Text = RaceSettings.RS.RaceHeader; }
public static TimeSpan CalcResult(clCompetitor clCompetitor) { var foo = GetCalcType(RaceSettings.RS.ResultCalculationType); return(foo(clCompetitor)); }
//private XLS _w; public Table() { InterceptKeys.Main1(); InterceptKeys.ResoavHookKey += new EventHandler <ResoavEventArgs>(InterceptKeys_ResoavHookKey); if (!InterceptKeys.KeysUnderLook.ContainsKey(System.Windows.Forms.Keys.D1)) { InterceptKeys.KeysUnderLook.Add(System.Windows.Forms.Keys.D1, false); InterceptKeys.KeysUnderLook.Add(System.Windows.Forms.Keys.D2, false); InterceptKeys.KeysUnderLook.Add(System.Windows.Forms.Keys.D3, false); InterceptKeys.KeysUnderLook.Add(System.Windows.Forms.Keys.D4, false); InterceptKeys.KeysUnderLook.Add(System.Windows.Forms.Keys.D5, false); InterceptKeys.KeysUnderLook.Add(System.Windows.Forms.Keys.D6, false); InterceptKeys.KeysUnderLook.Add(System.Windows.Forms.Keys.D7, false); InterceptKeys.KeysUnderLook.Add(System.Windows.Forms.Keys.D8, false); InterceptKeys.KeysUnderLook.Add(System.Windows.Forms.Keys.D9, false); } competitor = new ObservableCollection <clCompetitor>(); #if DEBUG competitor.Add(new clCompetitor() { Number = 25, Name = "Иван Петров", Model = "ваз-2101", Class = clCompetitor.carClass.TUNING }); competitor.Add(new clCompetitor() { Number = 28, Name = "Филип Рот", Model = "ваз-2102", Class = clCompetitor.carClass.STANDART }); competitor.Add(new clCompetitor() { Number = 41, Name = "Барт Меткалф", Model = "ваз-21099", Class = clCompetitor.carClass.SPORT }); competitor.Add(new clCompetitor() { Number = 43, Name = "Степанов Борис", Model = "ваз-2104", Class = clCompetitor.carClass.RB_4x4 }); //competitor.Add(new clCompetitor() { Number = 44, Name = "Гленн Клоуз", Model = "ваз-2105", Class = clCompetitor.carClass.RB1600 }); //competitor.Add(new clCompetitor() { Number = 5, Name = "Валерий Леонтьев", Model = "ваз-2106", Class = clCompetitor.carClass.ABSOLUTE }); //competitor.Add(new clCompetitor() { Number = 50, Name = "Надежда Заседателева", Model = "ваз-2108", Class = clCompetitor.carClass.RB2000 }); //competitor.Add(new clCompetitor() { Number = 19, Name = "Брюс Уиллис", Model = "ваз-2108", Class = clCompetitor.carClass.RB4000 }); //competitor.Add(new clCompetitor() { Number = 125, Name = "Егор Гайдар", Model = "ваз-2112", Class = clCompetitor.carClass.RB1600 }); #endif leftButtonMenu = new ContextMenu(); var subMenu = new MenuItem(); subMenu.Header = "Отправить в гонку"; subMenu.Click += new RoutedEventHandler(menuToRace_Click); leftButtonMenu.Items.Add(subMenu); subMenu = new MenuItem(); subMenu.Header = "Присудить сход"; subMenu.Click += new RoutedEventHandler(menuShod_Click); leftButtonMenu.Items.Add(subMenu); subMenu = new MenuItem(); subMenu.Header = "Не стартовал"; subMenu.Click += new RoutedEventHandler(menuNS_Click); leftButtonMenu.Items.Add(subMenu); subMenu = new MenuItem(); subMenu.Header = "Штраф +" + RaceSettings.RS.Penality + " сек"; subMenu.Click += new RoutedEventHandler(menuPenality_Click); leftButtonMenu.Items.Add(subMenu); InitializeComponent(); var temp = new clCompetitor(); for (int i = 1; i <= temp.AttemptCollection.Length; ++i) { var v = new ColumnDefinition(); v.Width = new GridLength(82); grUnderMain.ColumnDefinitions.Add(v); var t = new TextBlock(); t.SetValue(Grid.ColumnProperty, 3 + i); t.Text = "Попытка " + i; t.FontWeight = FontWeights.Bold; t.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; t.TextAlignment = TextAlignment.Center; t.Background = new SolidColorBrush(Color.FromRgb (System.Drawing.Color.LightGray.R, System.Drawing.Color.LightGray.G, System.Drawing.Color.LightGray.B)); grUnderMain.Children.Add(t); } DataContext = this; lbRacingTitle.Text = RaceSettings.RS.RaceHeader; //HardwareCommunicator.ReInitialize(); }