private void KeyPairComb_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox cb = (ComboBox)sender; if (cb != null) { if (cb.SelectedItem != null) { string keyFile = CAwsConfig.Instance.getKeyFilePath(cb.SelectedItem.ToString()); if (string.IsNullOrEmpty(keyFile) == true || File.Exists(keyFile) == false) { KeyFileInputDlg kfInput = new KeyFileInputDlg(cb.SelectedItem.ToString()); kfInput.ShowDialog(); } } } }
private void launchButton_Click(object sender, RoutedEventArgs e) { //other thread will access these _amiId = AmiIdLb.Text; if (KeyPairComb.SelectedValue != null) { _selectedKeyPair = KeyPairComb.SelectedValue.ToString(); if (string.IsNullOrEmpty(_selectedKeyPair) == false) { string keyFile = CAwsConfig.Instance.getKeyFilePath(_selectedKeyPair); if (string.IsNullOrEmpty(keyFile) == true || File.Exists(keyFile) == false) { KeyFileInputDlg kfInput = new KeyFileInputDlg(_selectedKeyPair); kfInput.ShowDialog(); } keyFile = CAwsConfig.Instance.getKeyFilePath(_selectedKeyPair); if (string.IsNullOrEmpty(keyFile) == true || File.Exists(keyFile) == false) { //cannot continue. we need the key path return; } } } if (SecurityGroupComb.SelectedValue != null) { _selectedSecurityGroups = SecurityGroupComb.SelectedValue.ToString(); } if (ZoneComb.SelectedValue != null) { _selectedZone = ZoneComb.SelectedValue.ToString(); } ; enableProgressBar(); _launchThread = new Thread(new ThreadStart(launch)); _launchThread.SetApartmentState(ApartmentState.STA); _launchThread.Start(); }
void password_Click(object sender, RoutedEventArgs e) { try { ContextMenu cm = (ContextMenu)ContextMenu.ItemsControlFromItemContainer((MenuItem)e.OriginalSource); CEc2Instance ins = (CEc2Instance)((FrameworkElement)(((Panel)(cm.PlacementTarget)).Children[0])).DataContext; if (ins != null) { //check key file string keyFile = CAwsConfig.Instance.getKeyFilePath(ins.keyPairName); if (string.IsNullOrEmpty(keyFile) == true || File.Exists(keyFile) == false) { KeyFileInputDlg kfInput = new KeyFileInputDlg(ins.keyPairName); kfInput.ShowDialog(); keyFile = CAwsConfig.Instance.getKeyFilePath(ins.keyPairName); if (string.IsNullOrEmpty(keyFile) == true || File.Exists(keyFile) == false) { MessageBox.Show("Cannot find the key file.", "Get Password", MessageBoxButton.OK, MessageBoxImage.Warning); return; } } FetchPassword pw = new FetchPassword(ins); pw.ShowDialog(); } else { MessageBox.Show("Cannot fetch the password for this instance."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }