private void CreateSource(object sender, RoutedEventArgs e)
        {
            var type = (sender as MenuItem).Tag as string;
            IInstanceSource source;
            switch (type)
            {
                case "Amazon":
                    source = new AmazonInstanceSource();
                    break;
                case "Chef":
                    source = new ChefInstanceSource();
                    break;
                default:
                    return;
            }

            App.Settings.InstanceSources.Add(source);
            App.InstanceCollection.InstanceSources.Add(source);
            source.SettingsControl.Background = new SolidColorBrush(Colors.Transparent);
            var tab = new TabItem { Header = source.Name, Content = source.SettingsControl, Tag = source, DataContext = source.Settings };
            tabControl.Items.Add(tab);
            tabControl.SelectedItem = tab;
            if (MainWindowViewModel.instance != null)
                MainWindowViewModel.instance.DoRefreshList();
        }
 private void TestConnection_Click(object sender, RoutedEventArgs e)
 {
     var src = new AmazonInstanceSource { Settings = DataContext as AmazonSettings };
     testConnectionButton.IsEnabled = false;
     (Parent as Control).Cursor = Cursors.Wait;
     Task.Factory.StartNew(() => src.GetInstanceList())
         .ContinueWith(t =>
         {
             testConnectionButton.IsEnabled = true;
             (Parent as Control).Cursor = Cursors.Arrow;
             if (t.Exception != null)
                 ExceptionDialog.Show(t.Exception);
             else
                 MessageBox.Show("Connection Successful");
         }, TaskScheduler.FromCurrentSynchronizationContext());
 }