Example #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (vms == null || vms.Count == 0)
            {
                return;
            }

            // If !firstPaint, don't re-intialize, because it will pull the rug from under our own edits.
            if (!firstPaint)
            {
                return;
            }

            // Layout because of different fonts. I tried putting this in the constructor but it didn't take effect that early.
            memorySpinnerFixed.Left = radioOff.Right + radioOff.Margin.Right;

            // Calculate the maximum legal value of dynamic minimum
            CalcMaxDynMin();

            // Shiny bar
            vmShinyBar.Initialize(vm0, vms.Count > 1, CalcMemoryUsed(), true);

            // Radio buttons and "DMC Unavailable" warning
            if (ballooning)
            {
                if (vm0.memory_dynamic_min == vm0.memory_static_max)
                {
                    radioOff.Checked = true;
                }
                else
                {
                    radioOn.Checked = true;
                }
                iconDMCUnavailable.Visible = labelDMCUnavailable.Visible = linkInstallTools.Visible = false;
            }
            else
            {
                radioOff.Checked   = true;
                radioOn.Enabled    = false;
                groupBoxOn.Enabled = false;

                if (vms.Count > 1)
                {
                    // If all the Virtualisation Statuses are the same, report that reason.
                    // Otherwise give a generic message.
                    VM.VirtualisationStatus vs0 = vm0.GetVirtualisationStatus;
                    bool identical = true;
                    foreach (VM vm in vms)
                    {
                        if (vm.GetVirtualisationStatus != vs0)
                        {
                            identical = false;
                            break;
                        }
                    }
                    if (identical)
                    {
                        var status = vm0.GetVirtualisationStatus;
                        if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED_PLURAL;
                        }
                        else if (!status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                        {
                            labelDMCUnavailable.Text = vm0.HasNewVirtualisationStates ? Messages.DMC_UNAVAILABLE_NO_IO_NO_MGMNT_PLURAL : Messages.DMC_UNAVAILABLE_NOTOOLS_PLURAL;
                        }
                        else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE))
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_OLDTOOLS_PLURAL;
                        }
                        else
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VMS;
                        }
                    }
                    else
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VMS;
                    }
                    linkInstallTools.Visible = InstallToolsCommand.CanExecuteAll(vms);
                }
                else if (vm0.is_a_template)
                {
                    labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_TEMPLATE;
                    linkInstallTools.Visible = false;
                }
                else
                {
                    var status = vm0.GetVirtualisationStatus;

                    if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED;
                    }
                    else if (!status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                    {
                        labelDMCUnavailable.Text = vm0.HasNewVirtualisationStates ? Messages.DMC_UNAVAILABLE_NO_IO_NO_MGMNT : Messages.DMC_UNAVAILABLE_NOTOOLS;
                    }
                    else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE))
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_OLDTOOLS;
                    }
                    else
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VM;
                    }

                    linkInstallTools.Visible = InstallToolsCommand.CanExecute(vm0);
                }
            }

            // Spinners
            FreeSpinnerRanges();
            static_min = vm0.memory_static_min;
            memorySpinnerDynMin.Initialize(Messages.DYNAMIC_MIN_AMP, ballooning ? XenAdmin.Properties.Resources.memory_dynmin_slider_small : null, vm0.memory_dynamic_min, vm0.memory_static_max);
            memorySpinnerDynMax.Initialize(Messages.DYNAMIC_MAX_AMP, ballooning ? XenAdmin.Properties.Resources.memory_dynmax_slider_small : null, vm0.memory_dynamic_max, vm0.memory_static_max);
            memorySpinnerFixed.Initialize("", null, vm0.memory_static_max, vm0.memory_static_max);
            SetIncrements();
            SetSpinnerRanges();
            firstPaint = false;
        }
Example #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (vms == null || vms.Count == 0)
            {
                return;
            }

            // If !firstPaint, don't re-intialize, because it will pull the rug from under our own edits.
            if (!firstPaint)
            {
                return;
            }

            // Calculate the maximum legal value of dynamic minimum
            CalcMaxDynMin();

            vmShinyBar.Populate(vms, true);

            bool licenseRestriction = Helpers.FeatureForbidden(vm0.Connection, Host.RestrictDMC);

            // Radio buttons and "DMC Unavailable" warning
            if (ballooning && !licenseRestriction)
            {
                if (vm0.memory_dynamic_min == vm0.memory_static_max)
                {
                    radioFixed.Checked = true;
                }
                else
                {
                    radioDynamic.Checked = true;
                }
                iconDMCUnavailable.Visible = labelDMCUnavailable.Visible = linkInstallTools.Visible = false;
            }
            else
            {
                radioFixed.Checked   = true;
                radioDynamic.Enabled = false;
                groupBoxOn.Enabled   = false;

                if (licenseRestriction)
                {
                    labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_LICENSE_RESTRICTION;
                    linkInstallTools.Visible = false;
                }
                else if (vms.Count > 1)
                {
                    // If all the Virtualisation Statuses are the same, report that reason.
                    // Otherwise give a generic message.
                    VM.VirtualisationStatus vs0 = vm0.GetVirtualisationStatus();
                    bool identical = true;
                    foreach (VM vm in vms)
                    {
                        if (vm.GetVirtualisationStatus() != vs0)
                        {
                            identical = false;
                            break;
                        }
                    }
                    if (identical)
                    {
                        var status = vm0.GetVirtualisationStatus();
                        if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED_PLURAL;
                        }
                        else if (!status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                        {
                            labelDMCUnavailable.Text = vm0.HasNewVirtualisationStates()
                                ? Messages.DMC_UNAVAILABLE_NO_IO_NO_MGMNT_PLURAL
                                : Messages.DMC_UNAVAILABLE_NOTOOLS_PLURAL;
                        }
                        else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE))
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_OLDTOOLS_PLURAL;
                        }
                        else
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VMS;
                        }
                    }
                    else
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VMS;
                    }
                    linkInstallTools.Visible = InstallToolsCommand.CanExecuteAll(vms);
                }
                else if (vm0.is_a_template)
                {
                    labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_TEMPLATE;
                    linkInstallTools.Visible = false;
                }
                else
                {
                    var status = vm0.GetVirtualisationStatus();

                    if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED;
                    }
                    else if (!status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                    {
                        labelDMCUnavailable.Text = vm0.HasNewVirtualisationStates()
                            ? Messages.DMC_UNAVAILABLE_NO_IO_NO_MGMNT
                            : Messages.DMC_UNAVAILABLE_NOTOOLS;
                    }
                    else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE))
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_OLDTOOLS;
                    }
                    else
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VM;
                    }

                    linkInstallTools.Visible = InstallToolsCommand.CanExecute(vm0);
                }
            }

            // Spinners
            FreeSpinnerRanges();
            memorySpinnerDynMin.Initialize(vm0.memory_dynamic_min, vm0.memory_static_max);
            memorySpinnerDynMax.Initialize(vm0.memory_dynamic_max, vm0.memory_static_max);
            memorySpinnerFixed.Initialize(vm0.memory_static_max, vm0.memory_static_max);
            SetIncrements();
            SetSpinnerRanges();
            firstPaint = false;
        }