Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1680:

  • If CloudManagerClient contains hostedservice, merge them in add-method
  • Merge methods added deployment and hostedservice
  • Update/merge treeview in CloudResourceView
  • Indicate a change of the trackbar (DeploymentView)
File size: 2.9 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        txtInstanceCount.Text = Content.RoleInstanceList.Count.ToString();
39        if (Content.RoleInstanceList.Count > 0) {
40          txtInstanceSize.Text = Content.RoleInstanceList[0].InstanceSize;
41        }
42
43        tbChangeCores.Minimum = 1;
44        tbChangeCores.Maximum = Content.Subscription.MaxCoreCount;
45        if (Content.Modified) {
46          tbChangeCores.Value = Content.NewInstanceCount;
47          lblChanges.Text = SaveChangesString;
48        } else {
49          tbChangeCores.Value = Content.RoleInstanceList.Count;
50        }
51
52        txtCoresUsed.Text = (tbChangeCores.Value * GetCoresFromInstanceSize(txtInstanceSize.Text)).ToString();
53
54      }
55    }
56
57    private void tbChangeCores_Scroll(object sender, System.EventArgs e) {
58      int tbValue = tbChangeCores.Value;
59      int size = GetCoresFromInstanceSize(txtInstanceSize.Text);
60      txtInstanceCount.Text = tbValue.ToString();
61      int cores = tbValue * (int)size;
62      txtCoresUsed.Text = cores.ToString();
63
64      if (Content.RoleInstanceList.Count != tbValue) {
65        Content.Modified = true;
66        lblChanges.Text = SaveChangesString;
67      } else {
68        Content.Modified = false;
69        lblChanges.Text = string.Empty;
70      }
71
72      Content.NewInstanceCount = tbValue;
73    }
74
75    private int GetCoresFromInstanceSize(string instanceSize) {
76      HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize size =
77       (HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize)Enum.Parse(
78         typeof(HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize),
79         instanceSize,
80         true);
81      return (int)size;
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.