private void RemoveBattery_Click(object sender, RoutedEventArgs e) { var b = SelectedBattery; SelectedBattery = null; BatteryList.Remove(b); }
private void Load_Click(object sender, RoutedEventArgs e) { using (System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog()) { ofd.FileName = SavePath; ofd.Filter = SaveFilter; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { XmlSerializer s = new XmlSerializer(typeof(SObservableCollection <Battery>)); SObservableCollection <Battery> loadedBatteries = s.Deserialize(new StreamReader(ofd.FileName)) as SObservableCollection <Battery>; if (((sender as System.Windows.Controls.Control).Tag as string) == "New") { SelectedBattery = null; BatteryList.Clear(); } foreach (var b in loadedBatteries) { b.ReInitialize(); b.PropertyChanged += Battery_PropertyChanged; BatteryList.Add(b); } } } }
public void TestBatteryThreadConsuming() { ISHESToComponentsQueues queues = new SHESToComponentsQueueMock(); BatteryList batteryList = new BatteryList(ref queues); Thread.Sleep(100); Assert.IsTrue(batteryList.IsConsumig); }
private void NewBattery_Click(object sender, RoutedEventArgs e) { Battery b = new Battery("New Battery", "", Weapon.DefinedWeapons[0], new Coordinate("0000", 0), BaseAngle.Create <MilAngle>(0), "pre", 0); b.PropertyChanged += Battery_PropertyChanged; BatteryList.Add(b); SelectedBattery = b; }
private void EBattDeSerialize_Click(object sender, RoutedEventArgs e) { StreamReader rr = new StreamReader(@"D:/batterytest.xml"); Battery b = Battery.Load(rr); System.Console.WriteLine("Selected weapon: " + b.BWeapon.Designation); BatteryList.Add(b); SelectedBattery = b; }
public void TestConsumeBattery() { BatteryList batteryList = new BatteryList(); Battery b = new Battery(100, 100, "test"); batteryList.List.Add(b); var consumption = batteryList.Consume(); Assert.IsTrue(consumption < 0); }
public SHES(ISHESToComponentsQueues queues) { CurrentPower = 0; Batteries = new BatteryList(ref queues); Consumers = new ConsumersList(ref queues); SolarPanels = new SolarPanelList(ref queues); Utility = new Utility(15); isConsuming = false; this.queues = queues; }
public void TestBatteryThreadGenerating() { ISHESToComponentsQueues queues = new SHESToComponentsQueueMock(); Response response; queues.BatteryResponses.TryDequeue(out response); queues.BatteryResponses.Enqueue(new Response(0, "test")); BatteryList batteryList = new BatteryList(ref queues); Assert.IsFalse(batteryList.IsConsumig); }
public void TestGenerateBattery() { BatteryList batteryList = new BatteryList(); Battery b = new Battery(100, 100, "test"); batteryList.List.Add(b); var generating = batteryList.Generate(); //double expected = 0.0166666666666667; Assert.IsTrue(generating > 0); }
public SHES() { CurrentPower = 0; Batteries = new BatteryList(); Consumers = new ConsumersList(); SolarPanels = new SolarPanelList(); ShesDbContext context = new ShesDbContext(); Batteries.List.AddRange(context.Battery.ToList()); Consumers.List.AddRange(context.Consumers.ToList()); SolarPanels.List.AddRange(context.SolarPanels.ToList()); Utility = new Utility(15); }
private void ClearBattery_Click(object sender, RoutedEventArgs e) { SelectedBattery = null; BatteryList.Clear(); }