mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
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:
parent
21b941c20a
commit
39026f300e
30
XenAdmin/MainWindow.Designer.cs
generated
30
XenAdmin/MainWindow.Designer.cs
generated
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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=">>TitleLabel.Name" xml:space="preserve">
|
||||
<value>TitleLabel</value>
|
||||
</data>
|
||||
<data name=">>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=">>TitleLabel.Parent" xml:space="preserve">
|
||||
<value>tableLayoutPanel1</value>
|
||||
</data>
|
||||
<data name=">>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=">>LicenseStatusTitleLabel.Name" xml:space="preserve">
|
||||
<value>LicenseStatusTitleLabel</value>
|
||||
</data>
|
||||
<data name=">>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=">>LicenseStatusTitleLabel.Parent" xml:space="preserve">
|
||||
<value>tableLayoutPanel1</value>
|
||||
</data>
|
||||
<data name=">>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=">>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=">>TitleLabel.Name" xml:space="preserve">
|
||||
<value>TitleLabel</value>
|
||||
</data>
|
||||
<data name=">>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=">>TitleLabel.Parent" xml:space="preserve">
|
||||
<value>tableLayoutPanel1</value>
|
||||
</data>
|
||||
<data name=">>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><?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="toolTipContainer1" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="TitleLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100,AutoSize,0" /><Rows Styles="Percent,100" /></TableLayoutSettings></value>
|
||||
<value><?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="TitleLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="LicenseStatusTitleLabel" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="toolTipContainer1" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,Percent,100,AutoSize,0" /><Rows Styles="Percent,100" /></TableLayoutSettings></value>
|
||||
</data>
|
||||
<data name="TitleBackPanel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>0, 0</value>
|
||||
|
18
XenModel/Messages.Designer.cs
generated
18
XenModel/Messages.Designer.cs
generated
@ -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 &High Availability....
|
||||
/// </summary>
|
||||
|
@ -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>&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>&High Availability...</value>
|
||||
</data>
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user