// Nova.Studio - a GUI test framework for the Nova.CodeDOM C# object model library.
// Copyright (C) 2007-2012 Inevitable Software, all rights reserved.
// Released under the Common Development and Distribution License, CDDL-1.0: http://opensource.org/licenses/cddl1.php
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using Nova.CodeDOM;
namespace Nova.Studio
{
/// <summary>
/// Interaction logic for ConfigurationManager.xaml
/// </summary>
public partial class ConfigurationManager : Window
{
private readonly Solution _solution;
public ConfigurationManager(Solution solution)
{
InitializeComponent();
_solution = solution;
List<string> configurations;
List<string> platforms;
_solution.GetConfigurationsAndPlatforms(out configurations, out platforms);
comboBoxConfiguration.ItemsSource = configurations;
comboBoxConfiguration.SelectedItem = _solution.ActiveConfiguration;
comboBoxPlatform.ItemsSource = platforms;
comboBoxPlatform.SelectedItem = _solution.ActivePlatform;
listViewProjectContexts.ItemsSource = GetProjectConfigurations();
}
private List<Tuple<string, string, string>> GetProjectConfigurations()
{
List<Tuple<string, string, string>> results = new List<Tuple<string, string, string>>();
IOrderedEnumerable<Project> projects = Enumerable.OrderBy<Project, string>(_solution.Projects, delegate(Project project) { return project.Name; });
string solutionConfiguration = comboBoxConfiguration.SelectedItem as string;
string solutionPlatform = comboBoxPlatform.SelectedItem as string;
foreach (Project project in projects)
{
string projectConfiguration, projectPlatform;
_solution.GetProjectConfiguration(solutionConfiguration, solutionPlatform, project, out projectConfiguration, out projectPlatform);
results.Add(new Tuple<string, string, string>(project.Name, projectConfiguration, projectPlatform));
}
return results;
}
private void comboBoxConfiguration_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
listViewProjectContexts.ItemsSource = GetProjectConfigurations();
}
private void comboBoxPlatform_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
listViewProjectContexts.ItemsSource = GetProjectConfigurations();
}
private void buttonSave_Click(object sender, RoutedEventArgs e)
{
// Save the modified configuration and platform
_solution.ActiveConfiguration = comboBoxConfiguration.SelectedItem as string;
_solution.ActivePlatform = comboBoxPlatform.SelectedItem as string;
DialogResult = true;
}
}
}