Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/DeploymentView.cs @ 10256

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

#1680:

  • Check if role instance list is not null (while deploying a package)
  • Remove a hosted service when it's deleted
File size: 3.3 KB
Line 
1using System;
2using System.Windows.Forms;
3using HeuristicLab.Clients.Hive.CloudManager.Model;
4using HeuristicLab.Core.Views;
5using HeuristicLab.MainForm;
6
7namespace HeuristicLab.Clients.Hive.CloudManager.Views {
8  [View("DeploymentView")]
9  [Content(typeof(Deployment), IsDefaultView = true)]
10  public partial class DeploymentView : ItemView {
11    private const string SaveChangesString = "Save changes to take effect.";
12    public new Deployment Content {
13      get { return (Deployment)base.Content; }
14      set { base.Content = value; }
15    }
16
17    public DeploymentView() {
18      InitializeComponent();
19    }
20
21    protected override void DeregisterContentEvents() {
22      base.DeregisterContentEvents();
23    }
24    protected override void RegisterContentEvents() {
25      base.RegisterContentEvents();
26    }
27
28    protected override void OnContentChanged() {
29      if (Content == null) {
30        txtDeploymentName.Clear();
31        txtDeploymentSlot.Clear();
32        txtDeploymentStatus.Clear();
33        txtCoresUsed.Clear();
34      } else {
35        txtDeploymentName.Text = Content.Label;
36        txtDeploymentSlot.Text = Content.DeploymentSlot;
37        txtDeploymentStatus.Text = Content.Status;
38        if (Content.RoleInstanceList != null) {
39          txtInstanceCount.Text = Content.RoleInstanceList.Count.ToString();
40          if (Content.RoleInstanceList.Count > 0) {
41            txtInstanceSize.Text = Content.RoleInstanceList[0].InstanceSize;
42          }
43        } else {
44          txtInstanceCount.Text = "";
45          txtInstanceSize.Text = "";
46        }
47
48
49        tbChangeCores.Minimum = 1;
50        tbChangeCores.Maximum = Content.Subscription.MaxCoreCount;
51        if (Content.Modified) {
52          tbChangeCores.Value = Content.NewInstanceCount;
53          lblChanges.Text = SaveChangesString;
54        } else {
55          if (Content.RoleInstanceList == null) {
56            tbChangeCores.Value = tbChangeCores.Minimum;
57          } else {
58            tbChangeCores.Value = Content.RoleInstanceList.Count;
59          }
60          lblChanges.Text = "";
61        }
62
63        txtCoresUsed.Text = (tbChangeCores.Value * GetCoresFromInstanceSize(txtInstanceSize.Text)).ToString();
64
65      }
66    }
67
68    private void tbChangeCores_Scroll(object sender, System.EventArgs e) {
69      int tbValue = tbChangeCores.Value;
70      int size = GetCoresFromInstanceSize(txtInstanceSize.Text);
71      txtInstanceCount.Text = tbValue.ToString();
72      int cores = tbValue * (int)size;
73      txtCoresUsed.Text = cores.ToString();
74
75      if (Content.RoleInstanceList.Count != tbValue) {
76        Content.Modified = true;
77        lblChanges.Text = SaveChangesString;
78      } else {
79        Content.Modified = false;
80        lblChanges.Text = string.Empty;
81      }
82
83      Content.NewInstanceCount = tbValue;
84    }
85
86    private int GetCoresFromInstanceSize(string instanceSize) {
87      if (instanceSize != string.Empty) {
88        HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize size =
89         (HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize)Enum.Parse(
90           typeof(HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize),
91           instanceSize,
92           true);
93        return (int)size;
94      } else {
95        return 0;
96      }
97
98    }
99  }
100}
Note: See TracBrowser for help on using the repository browser.