[7403] | 1 | using System;
|
---|
| 2 | using System.Windows.Forms;
|
---|
| 3 | using HeuristicLab.Clients.Hive.CloudManager.Model;
|
---|
| 4 | using HeuristicLab.Core.Views;
|
---|
| 5 | using HeuristicLab.MainForm;
|
---|
| 6 |
|
---|
| 7 | namespace HeuristicLab.Clients.Hive.CloudManager.Views {
|
---|
| 8 | [View("DeploymentView")]
|
---|
| 9 | [Content(typeof(Deployment), IsDefaultView = true)]
|
---|
| 10 | public partial class DeploymentView : ItemView {
|
---|
| 11 | public new Deployment Content {
|
---|
| 12 | get { return (Deployment)base.Content; }
|
---|
| 13 | set { base.Content = value; }
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | public DeploymentView() {
|
---|
| 17 | InitializeComponent();
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | protected override void DeregisterContentEvents() {
|
---|
| 21 | base.DeregisterContentEvents();
|
---|
| 22 | }
|
---|
| 23 | protected override void RegisterContentEvents() {
|
---|
| 24 | base.RegisterContentEvents();
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | protected override void OnContentChanged() {
|
---|
| 28 | if (Content == null) {
|
---|
| 29 | txtDeploymentName.Clear();
|
---|
| 30 | txtDeploymentSlot.Clear();
|
---|
| 31 | txtDeploymentStatus.Clear();
|
---|
| 32 | txtCoresUsed.Clear();
|
---|
| 33 | } else {
|
---|
| 34 | txtDeploymentName.Text = Content.Label;
|
---|
| 35 | txtDeploymentSlot.Text = Content.DeploymentSlot;
|
---|
| 36 | txtDeploymentStatus.Text = Content.Status;
|
---|
| 37 | txtInstanceCount.Text = Content.RoleInstanceList.Count.ToString();
|
---|
| 38 | if (Content.RoleInstanceList.Count > 0) {
|
---|
| 39 | txtInstanceSize.Text = Content.RoleInstanceList[0].InstanceSize;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | tbChangeCores.Minimum = 1;
|
---|
| 43 | tbChangeCores.Maximum = Content.Subscription.MaxCoreCount;
|
---|
| 44 | tbChangeCores.Value = Content.RoleInstanceList.Count;
|
---|
| 45 |
|
---|
| 46 | txtCoresUsed.Text = (tbChangeCores.Value * GetCoresFromInstanceSize(txtInstanceSize.Text)).ToString();
|
---|
| 47 |
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | private void tbChangeCores_Scroll(object sender, System.EventArgs e) {
|
---|
| 52 | int tbValue = tbChangeCores.Value;
|
---|
| 53 | int size = GetCoresFromInstanceSize(txtInstanceSize.Text);
|
---|
| 54 | txtInstanceCount.Text = tbValue.ToString();
|
---|
| 55 | int cores = tbValue * (int)size;
|
---|
| 56 | txtCoresUsed.Text = cores.ToString();
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | private int GetCoresFromInstanceSize(string instanceSize) {
|
---|
| 60 | HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize size =
|
---|
| 61 | (HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize)Enum.Parse(
|
---|
| 62 | typeof(HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize),
|
---|
| 63 | instanceSize,
|
---|
| 64 | true);
|
---|
| 65 | return (int)size;
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 | }
|
---|