예제 #1
0
 public void AddWindGenerator(WindGenerator generator)
 {
     this.WindGenerators.Add(generator);
     context.WindGenerators.Add(generator);
     context.SaveChanges();
     WindGenerators = new ObservableCollection <WindGenerator>(context.WindGenerators.AsEnumerable());
 }
예제 #2
0
 private void WindGenList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     selectedWindGen = vm.WindGenerators.Where(x => x.Id == vm.WindGenerators.ToList()[WindGenList.SelectedIndex].Id).FirstOrDefault();
     if (selectedWindGen != null)
     {
         nameLbl.Content           = selectedWindGen.Name;
         ratedPowerLbl.Content     = selectedWindGen.RatedPower;
         ratedWindSpeedLbl.Content = selectedWindGen.RatedWindSpeed;
         minWindSpeedLbl.Content   = selectedWindGen.MinWindSpeed;
         maxWindSpeedLbl.Content   = selectedWindGen.MaxWindSpeed;
         if (selectedWindGen.Radius == 0)
         {
             selectedWindGen.Radius = Math.Sqrt((double)selectedWindGen.SweptArea / Math.PI);
             vm.Modify(selectedWindGen);
         }
         rotorLbl.Content = ((double)selectedWindGen.Radius).ToString("0.00");
         if (selectedWindGen.SweptArea == 0)
         {
             selectedWindGen.SweptArea = Math.PI * selectedWindGen.Radius * selectedWindGen.Radius;
             vm.Modify(selectedWindGen);
         }
         sweptAreaLbl.Content = ((double)selectedWindGen.SweptArea).ToString("0.0");
         heightLbl.Content    = selectedWindGen.Height == null ? "N/A" : selectedWindGen.Height.ToString();
         if (chartWindow != null)
         {
             chartWindow.GetPowerValues();
         }
         priceLabel.Content = selectedWindGen.Price.ToString();
     }
 }
예제 #3
0
 public MainWindow()
 {
     InitializeComponent();
     startDateDP.SelectedDate = startDate;
     this.DataContext         = new ViewModel();
     vm                        = this.DataContext as ViewModel;
     weather                   = new WeatherAPI();
     weatherListDaily          = new List <Weather>();
     weatherListHourly         = new List <Weather>();
     firstWeatherToCompare     = new List <Weather>();
     secondWeatherToCompare    = new List <Weather>();
     WindGenList.SelectedIndex = 0;
     RefreshWindList();
     selectedWindGen = vm.WindGenerators.Where(x => x.Id == vm.WindGenerators.ToList()[WindGenList.SelectedIndex].Id).FirstOrDefault();
 }
예제 #4
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     CheckValues();
     if (correct)
     {
         WindGenerator generator = new WindGenerator()
         {
             IsWorking      = true,
             MaxWindSpeed   = maxWindSpeed,
             MinWindSpeed   = minWindSpeed,
             Name           = name,
             Radius         = rotorRadius,
             RatedPower     = ratedPower,
             RatedWindSpeed = ratedWindSpeed,
             SweptArea      = sweptArea,
             Height         = height == 0 ? 10 : height,
             Price          = price
         };
         main.vm.AddWindGenerator(generator);
         main.RefreshWindList();
         this.Close();
     }
 }
예제 #5
0
 internal void Modify(WindGenerator selected)
 {
     context.Entry(selected).State = System.Data.Entity.EntityState.Modified;
     context.SaveChanges();
 }