Exemplo n.º 1
0
 private void DeleteSelectedBatteries(object sender, RoutedEventArgs e)
 {
     foreach (Battery battery in batteryListView.SelectedItems)
     {
         ((ObservableCollection <Battery>)batteryListView.ItemsSource).Remove(battery);
     }
     BatteryController.updateBatteryList((ObservableCollection <Battery>)batteryListView.ItemsSource);
 }
Exemplo n.º 2
0
 private void EmptySelectedBatteries(object sender, RoutedEventArgs e)
 {
     foreach (Battery battery in batteryListView.SelectedItems)
     {
         battery.batteryLevel = 0;
     }
     BatteryController.updateBatteryList((ObservableCollection <Battery>)batteryListView.ItemsSource);
     refreshBatteryList();
 }
Exemplo n.º 3
0
        private async void EditBattery(object sender, RoutedEventArgs e)
        {
            var batteryFlyout  = new ContentDialog();
            var batteryContent = new AddBattery((Battery)((HyperlinkButton)sender).DataContext);

            batteryContent.BatterySaved += delegate(object battery, EventArgs eDelegate)
            {
                batteryFlyout.Hide();
                //TODO: use ID to index instead of label
                var existingBattery = ((ObservableCollection <Battery>)batteryListView.ItemsSource).FirstOrDefault <Battery>(n => n.label == ((Battery)battery).label);
                existingBattery.batteryLevel = ((Battery)battery).batteryLevel;
                BatteryController.updateBatteryList((ObservableCollection <Battery>)batteryListView.ItemsSource);
                refreshBatteryList();
            };
            batteryFlyout.Content = batteryContent;
            await batteryFlyout.ShowAsync();
        }
Exemplo n.º 4
0
 private void refreshBatteryList()
 {
     //TODO: use binding so we don't need this method
     batteryListView.ItemsSource = BatteryController.GetBatteries();
 }