using System; using System.Windows.Forms; using HeuristicLab.Clients.Hive.CloudManager.Model; using HeuristicLab.Core.Views; using HeuristicLab.MainForm; namespace HeuristicLab.Clients.Hive.CloudManager.Views { [View("DeploymentView")] [Content(typeof(Deployment), IsDefaultView = true)] public partial class DeploymentView : ItemView { public new Deployment Content { get { return (Deployment)base.Content; } set { base.Content = value; } } public DeploymentView() { InitializeComponent(); } protected override void DeregisterContentEvents() { base.DeregisterContentEvents(); } protected override void RegisterContentEvents() { base.RegisterContentEvents(); } protected override void OnContentChanged() { if (Content == null) { txtDeploymentName.Clear(); txtDeploymentSlot.Clear(); txtDeploymentStatus.Clear(); txtCoresUsed.Clear(); } else { txtDeploymentName.Text = Content.Label; txtDeploymentSlot.Text = Content.DeploymentSlot; txtDeploymentStatus.Text = Content.Status; txtInstanceCount.Text = Content.RoleInstanceList.Count.ToString(); if (Content.RoleInstanceList.Count > 0) { txtInstanceSize.Text = Content.RoleInstanceList[0].InstanceSize; } tbChangeCores.Minimum = 1; tbChangeCores.Maximum = Content.Subscription.MaxCoreCount; tbChangeCores.Value = Content.RoleInstanceList.Count; txtCoresUsed.Text = (tbChangeCores.Value * GetCoresFromInstanceSize(txtInstanceSize.Text)).ToString(); } } private void tbChangeCores_Scroll(object sender, System.EventArgs e) { int tbValue = tbChangeCores.Value; int size = GetCoresFromInstanceSize(txtInstanceSize.Text); txtInstanceCount.Text = tbValue.ToString(); int cores = tbValue * (int)size; txtCoresUsed.Text = cores.ToString(); } private int GetCoresFromInstanceSize(string instanceSize) { HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize size = (HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize)Enum.Parse( typeof(HeuristicLab.Clients.Hive.CloudManager.Azure.Constants.InstanceSize), instanceSize, true); return (int)size; } } }