//List<UnitsContainer> unitsContainers; //public MainWindow(IStatisticsRepository repo, UnitManager manager) public MainWindow(ContainersApi containers) { InitializeComponent(); //this.repo = repo; //this.unitsContainers = manager.GetContainers(); //this.UnitTypeComboBox.ItemsSource = this.unitsContainers; //UsageStatisticsGrid.ItemsSource = this.repo.GetAllStatistics(); this.containers = containers; this.UnitTypeComboBox.ItemsSource = containers.GetContainers(); this.AddUnitTypeComboBox.ItemsSource = containers.GetContainers(); UsageStatisticsGrid.ItemsSource = containers.GetAllStatistics(); }
private void AddUnitButtonClicked(object sender, RoutedEventArgs e) { //var selected = (UnitsContainer)AddUnitTypeComboBox.SelectedValue; //var containersList = this.containers.GetContainers(); //var current = containersList.Find(x => x.Name == selected.Name) as UnitsContainer; //if (current != null) //{ // current.AddUnit(RatioTextBox.Text, NewUnitTextBox.Text); // this.UnitTypeComboBox.ItemsSource = containers.GetContainers(); //} var selected = (UnitsContainer)AddUnitTypeComboBox.SelectedValue; containers.AddUnit(selected.Name, RatioTextBox.Text, NewUnitTextBox.Text); this.UnitTypeComboBox.ItemsSource = containers.GetContainers(); }