private void DodajPomiar_Click(object sender, RoutedEventArgs e) { Pomiar pomiar = new Pomiar("0.0", "0.0"); AddPomiarWindow addPomiarWindow = new AddPomiarWindow(pomiar) { Owner = this }; if (addPomiarWindow.ShowDialog() == true) { double time = Convert.ToDouble(pomiar.Time); double mass = (double)this.mass.Value; double height = (double)this.length.Value; double power = (mass * _g * height / time)/10000.0; if (time == 0.0) power = 0.0; _pomiary.Add(new Pomiar(time.ToString(), power.ToString("F2"))); this.listBox.ItemsSource = null; this.listBox.ItemsSource = _pomiary; if (_pomiary.Count > 0) { this.buttonUsunPomiar.IsEnabled = true; this.mass.IsEnabled = false; this.massError.IsEnabled = false; this.length.IsEnabled = false; this.lengthError.IsEnabled = false; this.buttonZapisz.IsEnabled = true; } else { this.buttonUsunPomiar.IsEnabled = false; this.mass.IsEnabled = true; this.massError.IsEnabled = true; this.length.IsEnabled = true; this.lengthError.IsEnabled = true; this.buttonZapisz.IsEnabled = false; } Calculate(); } }
public AddPomiarWindow(Pomiar pomiar) { InitializeComponent(); _pomiar = pomiar; }