Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddSubscriptionDialog.cs @ 7362

Last change on this file since 7362 was 7362, checked in by spimming, 13 years ago

#1680:

  • Check if password is valid for pfx file
  • progress bar is now marquee style
  • control flow refactored
File size: 1.9 KB
Line 
1using System.ComponentModel;
2using System.Windows.Forms;
3using HeuristicLab.Clients.Hive.CloudManager.Model;
4
5namespace HeuristicLab.Clients.Hive.CloudManager.Views {
6  public partial class AddSubscriptionDialog : Form {
7    public bool ErrorOccured { get; set; }
8    public Subscription Subscription { get; set; }
9
10    private BackgroundWorker worker = new BackgroundWorker();
11
12    public AddSubscriptionDialog() {
13      InitializeComponent();
14
15      txtCertThumbprint.Text = "EFFD1808EF2F0658C52997CF00F7A86680F9FA62";
16      txtSubscriptionId.Text = "271e67e2-3132-4429-b0e7-ab94d3a95554";
17      cbSaveSubscription.Checked = false;
18      cbDiscoverServices.Checked = true;
19
20      worker.DoWork += new DoWorkEventHandler(LoadSubscription);
21      worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerCompleted);
22
23      ErrorOccured = true;
24    }
25
26    private void btnOk_Click(object sender, System.EventArgs e) {
27      this.progressBar.Visible = true;
28      worker.RunWorkerAsync();
29    }
30
31    private void btnCancel_Click(object sender, System.EventArgs e) {
32      this.Close();
33    }
34
35    private void LoadSubscription(object sender, DoWorkEventArgs e) {
36      e.Result = CloudManagerClient.Instance.AzureProvider.GetSubscriptionInfo(txtSubscriptionId.Text, txtCertThumbprint.Text);
37    }
38
39    private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
40      progressBar.Visible = false;
41      if (e.Error == null) {
42        ErrorOccured = false;
43        Subscription = (Subscription)e.Result;
44        Subscription.SaveToConfig = cbSaveSubscription.Checked;
45        Subscription.DiscoverServices = cbDiscoverServices.Checked;
46        this.Close();
47      } else {
48        MessageBox.Show(e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
49        ErrorOccured = true;
50        Subscription = null;
51        this.Show();
52      }
53    }
54  }
55}
Note: See TracBrowser for help on using the repository browser.