CP-24707: Add license status information to the title bar for pool and hosts (#1783)

* CP-24707: Add license status information to the title bar for pool and hosts

Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>

* CP-24707: Add license status information to the title bar for pool and hosts

Show expired licenses as Unlicensed in the Header

Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>

* CP-24707: Add license status information to the title bar for pool and hosts

Improvements, fixes following the code review

Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>

* CP-24707: Add license status information to the title bar for pool and hosts

More code to make it nicer

Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>

* CP-24707: Add license status information to the title bar for pool and hosts

More code to make it even more nicer

Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
This commit is contained in:
Gabor Apati-Nagy 2017-09-28 16:10:41 +01:00 committed by Mihaela Stoica
parent 21b941c20a
commit 39026f300e
6 changed files with 187 additions and 40 deletions

View File

@ -96,9 +96,10 @@ namespace XenAdmin
this.TitleBackPanel = new XenAdmin.Controls.GradientPanel.GradientPanel();
this.TitleIcon = new System.Windows.Forms.PictureBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.TitleLabel = new System.Windows.Forms.Label();
this.LicenseStatusTitleLabel = new System.Windows.Forms.Label();
this.toolTipContainer1 = new XenAdmin.Controls.ToolTipContainer();
this.loggedInLabel1 = new XenAdmin.Controls.LoggedInLabel();
this.TitleLabel = new System.Windows.Forms.Label();
this.ToolStrip = new XenAdmin.Controls.ToolStripEx();
this.backButton = new System.Windows.Forms.ToolStripSplitButton();
this.forwardButton = new System.Windows.Forms.ToolStripSplitButton();
@ -556,10 +557,26 @@ namespace XenAdmin
// tableLayoutPanel1
//
resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1");
this.tableLayoutPanel1.Controls.Add(this.toolTipContainer1, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.TitleLabel, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.LicenseStatusTitleLabel, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.toolTipContainer1, 3, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
//
// TitleLabel
//
resources.ApplyResources(this.TitleLabel, "TitleLabel");
this.TitleLabel.AutoEllipsis = true;
this.TitleLabel.ForeColor = System.Drawing.SystemColors.HighlightText;
this.TitleLabel.Name = "TitleLabel";
this.TitleLabel.UseMnemonic = false;
//
// LicenseStatusTitleLabel
//
resources.ApplyResources(this.LicenseStatusTitleLabel, "LicenseStatusTitleLabel");
this.LicenseStatusTitleLabel.ForeColor = System.Drawing.SystemColors.HighlightText;
this.LicenseStatusTitleLabel.Name = "LicenseStatusTitleLabel";
this.LicenseStatusTitleLabel.UseMnemonic = false;
//
// toolTipContainer1
//
resources.ApplyResources(this.toolTipContainer1, "toolTipContainer1");
@ -573,14 +590,6 @@ namespace XenAdmin
this.loggedInLabel1.Connection = null;
this.loggedInLabel1.Name = "loggedInLabel1";
//
// TitleLabel
//
resources.ApplyResources(this.TitleLabel, "TitleLabel");
this.TitleLabel.AutoEllipsis = true;
this.TitleLabel.ForeColor = System.Drawing.SystemColors.HighlightText;
this.TitleLabel.Name = "TitleLabel";
this.TitleLabel.UseMnemonic = false;
//
// ToolStrip
//
resources.ApplyResources(this.ToolStrip, "ToolStrip");
@ -2146,6 +2155,7 @@ namespace XenAdmin
private CommandToolStripMenuItem controlDomainMemoryToolStripMenuItem;
private CommandToolStripMenuItem enablePVSReadcachingToolStripMenuItem;
private CommandToolStripMenuItem disablePVSReadcachingToolStripMenuItem;
private Label LicenseStatusTitleLabel;
}
}

View File

@ -1124,6 +1124,9 @@ namespace XenAdmin
case "edition":
case "license_server":
case "license_params":
UpdateHeader();
UpdateToolbars();
break;
case "other_config":
// other_config may contain HideFromXenCenter
UpdateToolbars();
@ -2846,6 +2849,8 @@ namespace XenAdmin
/// </summary>
private void UpdateHeader()
{
ResetLicenseStatusTitleLabel();
if (navigationPane.currentMode == NavigationPane.NavigationMode.Notifications)
return;
@ -2858,6 +2863,9 @@ namespace XenAdmin
{
IXenObject xenObject = SelectionManager.Selection[0].XenObject;
TitleLabel.Text = xenObject.NameWithLocation();
UpdateLicenseStatusTitleLabel(xenObject);
TitleIcon.Image = Images.GetImage16For(xenObject);
// When in folder view only show the logged in label if it is clear to which connection the object belongs (most likely pools and hosts)
@ -2872,6 +2880,57 @@ namespace XenAdmin
TitleIcon.Image = Properties.Resources.Logo;
loggedInLabel1.Connection = null;
}
SetTitleLabelMaxWidth();
}
private void UpdateLicenseStatusTitleLabel(IXenObject xenObject)
{
if (xenObject is Pool)
{
var pool = xenObject as Pool;
if (pool.Connection != null && pool.Connection.CacheIsPopulated)
{
if (pool.IsFreeLicenseOrExpired)
{
LicenseStatusTitleLabel.Text = Messages.MAINWINDOW_HEADER_UNLICENSED;
LicenseStatusTitleLabel.ForeColor = Color.Red;
}
else
{
LicenseStatusTitleLabel.Text = string.Format(Messages.MAINWINDOW_HEADER_LICENSED_WITH, pool.LicenseString());
}
}
}
else if (xenObject is Host)
{
var host = xenObject as Host;
if (host.Connection != null && host.Connection.CacheIsPopulated)
{
if (host.IsFreeLicenseOrExpired())
{
LicenseStatusTitleLabel.Text = Messages.MAINWINDOW_HEADER_UNLICENSED;
LicenseStatusTitleLabel.ForeColor = Color.Red;
}
else
{
LicenseStatusTitleLabel.Text = string.Format(Messages.MAINWINDOW_HEADER_LICENSED_WITH, Helpers.GetFriendlyLicenseName(host));
}
}
}
}
private void ResetLicenseStatusTitleLabel()
{
LicenseStatusTitleLabel.Text = string.Empty;
LicenseStatusTitleLabel.ForeColor = Program.TitleBarForeColor;
}
private void SetTitleLabelMaxWidth()
{
TitleLabel.MaximumSize = new Size(tableLayoutPanel1.Width - loggedInLabel1.Width - LicenseStatusTitleLabel.Width - 6, TitleLabel.Height);
}
private void UpdateViewMenu(NavigationPane.NavigationMode mode)
@ -2962,6 +3021,7 @@ namespace XenAdmin
{
if (mode == NavigationPane.NavigationMode.Notifications)
{
ResetLicenseStatusTitleLabel();
TheTabControl.Visible = false;
}
else
@ -3352,6 +3412,7 @@ namespace XenAdmin
mainWindowResized = true;
}
SetSplitterDistance();
SetTitleLabelMaxWidth();
}
private void SetSplitterDistance()
@ -3388,6 +3449,8 @@ namespace XenAdmin
TabPage t = TheTabControl.SelectedTab;
if (t == TabPageConsole)
ConsolePanel.UpdateRDPResolution();
SetTitleLabelMaxWidth();
}
}
}

View File

@ -1027,7 +1027,76 @@
<value>Top, Bottom, Left, Right</value>
</data>
<data name="tableLayoutPanel1.ColumnCount" type="System.Int32, mscorlib">
<value>2</value>
<value>4</value>
</data>
<data name="TitleLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="TitleLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="TitleLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 9.75pt, style=Bold</value>
</data>
<data name="TitleLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="TitleLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
</data>
<data name="TitleLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>0, 16</value>
</data>
<data name="TitleLabel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;TitleLabel.Name" xml:space="preserve">
<value>TitleLabel</value>
</data>
<data name="&gt;&gt;TitleLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;TitleLabel.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;TitleLabel.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="LicenseStatusTitleLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Left</value>
</data>
<data name="LicenseStatusTitleLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="LicenseStatusTitleLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 9.75pt, style=Bold</value>
</data>
<data name="LicenseStatusTitleLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="LicenseStatusTitleLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 3</value>
</data>
<data name="LicenseStatusTitleLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="LicenseStatusTitleLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>0, 16</value>
</data>
<data name="LicenseStatusTitleLabel.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;LicenseStatusTitleLabel.Name" xml:space="preserve">
<value>LicenseStatusTitleLabel</value>
</data>
<data name="&gt;&gt;LicenseStatusTitleLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;LicenseStatusTitleLabel.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;LicenseStatusTitleLabel.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="toolTipContainer1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -1093,34 +1162,7 @@
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;toolTipContainer1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="TitleLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Left, Right</value>
</data>
<data name="TitleLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 9.75pt, style=Bold</value>
</data>
<data name="TitleLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
</data>
<data name="TitleLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>719, 20</value>
</data>
<data name="TitleLabel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;TitleLabel.Name" xml:space="preserve">
<value>TitleLabel</value>
</data>
<data name="&gt;&gt;TitleLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;TitleLabel.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value>
</data>
<data name="&gt;&gt;TitleLabel.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="tableLayoutPanel1.Location" type="System.Drawing.Point, System.Drawing">
<value>28, 0</value>
@ -1147,7 +1189,7 @@
<value>1</value>
</data>
<data name="tableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="toolTipContainer1" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="TitleLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100,AutoSize,0" /&gt;&lt;Rows Styles="Percent,100" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="TitleLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="LicenseStatusTitleLabel" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="toolTipContainer1" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,AutoSize,0,Percent,100,AutoSize,0" /&gt;&lt;Rows Styles="Percent,100" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="TitleBackPanel.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>

View File

@ -20730,6 +20730,24 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to (Licensed with {0}).
/// </summary>
public static string MAINWINDOW_HEADER_LICENSED_WITH {
get {
return ResourceManager.GetString("MAINWINDOW_HEADER_LICENSED_WITH", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to (Unlicensed).
/// </summary>
public static string MAINWINDOW_HEADER_UNLICENSED {
get {
return ResourceManager.GetString("MAINWINDOW_HEADER_UNLICENSED", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &amp;High Availability....
/// </summary>

View File

@ -7219,6 +7219,12 @@ This will permanently delete and reinitialize all local storage on the servers.
<data name="MAINWINDOW_FORGET_SR" xml:space="preserve">
<value>&amp;Forget</value>
</data>
<data name="MAINWINDOW_HEADER_LICENSED_WITH" xml:space="preserve">
<value>(Licensed with {0})</value>
</data>
<data name="MAINWINDOW_HEADER_UNLICENSED" xml:space="preserve">
<value>(Unlicensed)</value>
</data>
<data name="MAINWINDOW_HIGH_AVAILABILITY" xml:space="preserve">
<value>&amp;High Availability...</value>
</data>

View File

@ -95,6 +95,14 @@ namespace XenAPI
return false;
}
public bool IsFreeLicenseOrExpired
{
get
{
return Connection.Cache.Hosts.Any(h => h.IsFreeLicenseOrExpired());
}
}
public string LicenseString()
{
var hosts = new List<Host>(Connection.Cache.Hosts);