public void timer_Tick(object sender, EventArgs e, TimeSpan span, int i, cars Car) { lock (locker) { try { spanList[i] = spanList[i].Subtract(TimeSpan.FromMinutes(1)); } catch { return; } } if (spanList[i] != span) { if (spanChange != null) { spanChange(this, null); } } if (spanList[i] <= TimeSpan.Zero) { timersList[i].Stop(); delete_or_cancel_import(i); _db.cars.Add(Car); _db.SaveChanges(); } }
public void timerClock(cars Car, TimeSpan span, int i) { spanList.Add(span); carsList.Add(Car); timersList.Add(new DispatcherTimer()); timersList[i].Interval = TimeSpan.FromSeconds(1); timersList[i].Tick += (sender, e) => { timer_Tick(sender, e, spanList[spanList.Count() - 1], i, Car); };; timersList[i].Start(); }
public DetailView(int samochod) { InitializeComponent(); ID = samochod; System.Console.WriteLine(ID); auto = (from m in _db.cars where m.id == ID select m).Single(); markamodelTextBlock.Text = auto.make + " " + auto.model; cenaTextBlock.Text = auto.price.ToString(); marzaTextBlock.Text = auto.price.ToString(); rokprodTextBlock.Text = auto.year.ToString(); pojsilTextBlock.Text = auto.displ.ToString(); paliwoTextBlock.Text = auto.fuelType; przebiegTextBlock.Text = auto.mileage.ToString(); opisTextBlock.Text = auto.desc; powerTextBlock.Text = auto.power.ToString(); tranyTextBlock.Text = auto.trany; if (auto.photo == "") { return; } else { try { autoImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(auto.photo)); } catch { TextBlock textIfImageUnavailable = new TextBlock(); textIfImageUnavailable.Text = "OBRAZEK NIEDOSTEPNY"; textIfImageUnavailable.Foreground = new SolidColorBrush(Colors.DarkRed); textIfImageUnavailable.Margin = new Thickness(150, 0, 0, 150); LayoutRoot.Children.Add(textIfImageUnavailable); Grid.SetRow(textIfImageUnavailable, 2); Grid.SetColumn(textIfImageUnavailable, 0); } } }
public SellVehicle(bool editmode, int id) { InitializeComponent(); _editMode = editmode; _id = id; if (_editMode == true) { auto = (from m in _db.cars where m.id == _id select m).Single(); markaTextBox.Text = auto.make; modelTextBox.Text = auto.model; cenaTextBox.Text = auto.price.ToString(); marzaTextBox.Text = auto.margin.ToString().Replace(',', '.'); rok_produkcjiTextBox.Text = auto.year.ToString(); poj_silnikaTextBox.Text = auto.displ.ToString(); przebiegTextBox.Text = auto.mileage.ToString(); mocTextBox.Text = auto.power.ToString(); paliwoRadioGroup_checker(); skrzyniaComboBox_checker(); opisTextBox.Text = auto.desc; zdjecieTextBox.Text = auto.photo; parkingGrid.Visibility = Visibility.Visible; } }