diff --git a/XenAdmin/Dialogs/AboutDialog.Designer.cs b/XenAdmin/Dialogs/AboutDialog.Designer.cs index e10784eb9..21dc75bab 100644 --- a/XenAdmin/Dialogs/AboutDialog.Designer.cs +++ b/XenAdmin/Dialogs/AboutDialog.Designer.cs @@ -29,35 +29,19 @@ namespace XenAdmin.Dialogs private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutDialog)); - this.label2 = new System.Windows.Forms.Label(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.VersionLabel = new System.Windows.Forms.Label(); this.OkButton = new System.Windows.Forms.Button(); - this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.LicenseDetailsTextBox = new System.Windows.Forms.TextBox(); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); + this.label2 = new System.Windows.Forms.Label(); + this.licenseDetailsLabel = new System.Windows.Forms.Label(); + this.VersionLabel = new System.Windows.Forms.Label(); + this.showAgainCheckBox = new System.Windows.Forms.CheckBox(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.tableLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // - // label2 - // - resources.ApplyResources(this.label2, "label2"); - this.label2.BackColor = System.Drawing.Color.Transparent; - this.label2.Name = "label2"; - // - // pictureBox1 - // - resources.ApplyResources(this.pictureBox1, "pictureBox1"); - this.pictureBox1.Image = global::XenAdmin.Properties.Resources.about_box_graphic_423x79; - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.TabStop = false; - // - // VersionLabel - // - resources.ApplyResources(this.VersionLabel, "VersionLabel"); - this.VersionLabel.BackColor = System.Drawing.Color.Transparent; - this.VersionLabel.Name = "VersionLabel"; - // // OkButton // resources.ApplyResources(this.OkButton, "OkButton"); @@ -67,6 +51,28 @@ namespace XenAdmin.Dialogs this.OkButton.UseVisualStyleBackColor = true; this.OkButton.Click += new System.EventHandler(this.OkButton_Click); // + // tableLayoutPanel1 + // + resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); + this.tableLayoutPanel1.BackColor = System.Drawing.Color.White; + this.tableLayoutPanel1.Controls.Add(this.LicenseDetailsTextBox, 0, 5); + this.tableLayoutPanel1.Controls.Add(this.OkButton, 1, 6); + this.tableLayoutPanel1.Controls.Add(this.linkLabel1, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.licenseDetailsLabel, 0, 4); + this.tableLayoutPanel1.Controls.Add(this.VersionLabel, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.showAgainCheckBox, 0, 6); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + // + // LicenseDetailsTextBox + // + this.LicenseDetailsTextBox.BackColor = System.Drawing.SystemColors.Window; + this.tableLayoutPanel1.SetColumnSpan(this.LicenseDetailsTextBox, 2); + this.LicenseDetailsTextBox.Cursor = System.Windows.Forms.Cursors.Default; + resources.ApplyResources(this.LicenseDetailsTextBox, "LicenseDetailsTextBox"); + this.LicenseDetailsTextBox.Name = "LicenseDetailsTextBox"; + this.LicenseDetailsTextBox.ReadOnly = true; + // // linkLabel1 // resources.ApplyResources(this.linkLabel1, "linkLabel1"); @@ -74,14 +80,40 @@ namespace XenAdmin.Dialogs this.linkLabel1.TabStop = true; this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); // - // tableLayoutPanel1 + // label2 // - resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); - this.tableLayoutPanel1.Controls.Add(this.VersionLabel, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.OkButton, 0, 4); - this.tableLayoutPanel1.Controls.Add(this.linkLabel1, 0, 3); - this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + resources.ApplyResources(this.label2, "label2"); + this.label2.BackColor = System.Drawing.Color.Transparent; + this.tableLayoutPanel1.SetColumnSpan(this.label2, 2); + this.label2.Name = "label2"; + // + // licenseDetailsLabel + // + resources.ApplyResources(this.licenseDetailsLabel, "licenseDetailsLabel"); + this.licenseDetailsLabel.BackColor = System.Drawing.Color.Transparent; + this.tableLayoutPanel1.SetColumnSpan(this.licenseDetailsLabel, 2); + this.licenseDetailsLabel.Name = "licenseDetailsLabel"; + // + // VersionLabel + // + resources.ApplyResources(this.VersionLabel, "VersionLabel"); + this.VersionLabel.BackColor = System.Drawing.Color.Transparent; + this.tableLayoutPanel1.SetColumnSpan(this.VersionLabel, 2); + this.VersionLabel.Name = "VersionLabel"; + // + // showAgainCheckBox + // + resources.ApplyResources(this.showAgainCheckBox, "showAgainCheckBox"); + this.showAgainCheckBox.Name = "showAgainCheckBox"; + this.showAgainCheckBox.UseVisualStyleBackColor = true; + this.showAgainCheckBox.CheckedChanged += new System.EventHandler(this.showAgainCheckBox_CheckedChanged); + // + // pictureBox1 + // + resources.ApplyResources(this.pictureBox1, "pictureBox1"); + this.pictureBox1.Image = global::XenAdmin.Properties.Resources.about_box_graphic_423x79; + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.TabStop = false; // // AboutDialog // @@ -94,9 +126,9 @@ namespace XenAdmin.Dialogs this.Controls.Add(this.pictureBox1); this.HelpButton = false; this.Name = "AboutDialog"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -110,5 +142,8 @@ namespace XenAdmin.Dialogs private System.Windows.Forms.Button OkButton; private System.Windows.Forms.LinkLabel linkLabel1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label licenseDetailsLabel; + private System.Windows.Forms.TextBox LicenseDetailsTextBox; + private System.Windows.Forms.CheckBox showAgainCheckBox; } } diff --git a/XenAdmin/Dialogs/AboutDialog.cs b/XenAdmin/Dialogs/AboutDialog.cs index 01efdbe12..1820d69bf 100644 --- a/XenAdmin/Dialogs/AboutDialog.cs +++ b/XenAdmin/Dialogs/AboutDialog.cs @@ -35,6 +35,7 @@ using System.ComponentModel; using System.Text; using System.Windows.Forms; using XenAdmin.Core; +using System.Linq; namespace XenAdmin.Dialogs @@ -55,6 +56,12 @@ namespace XenAdmin.Dialogs Branding.XENCENTER_VERSION, buildText, IntPtr.Size * 8); label2.Text = string.Format(Messages.COPYRIGHT, Branding.COMPANY_NAME_LEGAL); label2.Visible = !HiddenFeatures.CopyrightHidden; + + showAgainCheckBox.Checked = Properties.Settings.Default.ShowAboutDialog; + var showLicenseNag = !HiddenFeatures.LicenseNagHidden; + LicenseDetailsTextBox.Text = showLicenseNag ? GetLicenseDetails() : ""; + licenseDetailsLabel.Visible = LicenseDetailsTextBox.Visible = showLicenseNag; + showAgainCheckBox.Visible = showLicenseNag; } private void OkButton_Click(object sender, EventArgs e) @@ -76,5 +83,30 @@ namespace XenAdmin.Dialogs TheLegalDialog.Focus(); } } + + private string GetLicenseDetails() + { + List companies = new List(); + foreach (var xenConnection in ConnectionsManager.XenConnectionsCopy.Where(c => c.IsConnected)) + { + foreach (var host in xenConnection.Cache.Hosts.Where(h => h.license_params != null && h.license_params.ContainsKey("company"))) + { + if (!string.IsNullOrEmpty(host.license_params["company"]) && !companies.Contains(host.license_params["company"])) + { + companies.Add(host.license_params["company"]); + } + } + } + return string.Join("\r\n", companies); + } + + private void showAgainCheckBox_CheckedChanged(object sender, EventArgs e) + { + if (Properties.Settings.Default.ShowAboutDialog != showAgainCheckBox.Checked) + { + Properties.Settings.Default.ShowAboutDialog = showAgainCheckBox.Checked; + Settings.TrySaveSettings(); + } + } } } diff --git a/XenAdmin/Dialogs/AboutDialog.resx b/XenAdmin/Dialogs/AboutDialog.resx index 3d1ff8728..6d23b2855 100644 --- a/XenAdmin/Dialogs/AboutDialog.resx +++ b/XenAdmin/Dialogs/AboutDialog.resx @@ -117,18 +117,141 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Bottom, Right + + + + Segoe UI, 9pt + + + NoControl + + + 336, 207 + + + 0, 3, 12, 12 + + + 75, 23 + + + 0 + + + OK + + + OkButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 1 + + + Top, Bottom, Left, Right + + + True + + + GrowAndShrink + + + 2 + + + Segoe UI, 9pt + + + 15, 138 + + + 15, 3, 12, 6 + + + True + + + Both + + + 396, 60 + + + 20 + + + LicenseDetailsTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 0 + + + Bottom, Left + + + True + + + Segoe UI, 9pt + + + NoControl + + + 14, 77 + + + 14, 11, 14, 0 + + + 106, 15 + + + 18 + + + View Legal Notices + + + linkLabel1 + + + System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 2 + True - Segoe UI, 9pt + + NoControl + 14, 46 - 14, 3, 14, 5 @@ -153,6 +276,147 @@ 3 + + True + + + Segoe UI, 9pt + + + NoControl + + + 14, 115 + + + 14, 23, 14, 5 + + + 254, 15 + + + 19 + + + @BRANDING_PRODUCT_BRAND@ licensed to: + + + licenseDetailsLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 4 + + + True + + + Segoe UI, 9pt + + + NoControl + + + 14, 23 + + + 14, 23, 14, 5 + + + 323, 15 + + + 15 + + + @BRANDING_BRAND_CONSOLE@ version 1.2.3 (build 4567) + + + VersionLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 5 + + + True + + + Segoe UI, 9pt + + + NoControl + + + 12, 210 + + + 12, 6, 3, 3 + + + 321, 19 + + + 21 + + + &Show this dialog when opening @BRANDING_BRAND_CONSOLE@ + + + False + + + showAgainCheckBox + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 6 + + + Segoe UI, 9pt + + + 0, 79 + + + 7 + + + 423, 242 + + + 19 + + + tableLayoutPanel1 + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="LicenseDetailsTextBox" Row="5" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="OkButton" Row="6" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="linkLabel1" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label2" Row="1" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="licenseDetailsLabel" Row="4" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="VersionLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="2" /><Control Name="showAgainCheckBox" Row="6" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100,AutoSize,20" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,20,AutoSize,20,AutoSize,0" /></TableLayoutSettings> + Top @@ -186,156 +450,6 @@ 1 - - True - - - Segoe UI, 9pt - - - NoControl - - - 14, 23 - - - 14, 23, 14, 5 - - - 195, 15 - - - 15 - - - @BRANDING_BRAND_CONSOLE@ version 1.2.3 (build 4567) - - - VersionLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 0 - - - Bottom, Right - - - Segoe UI, 9pt - - - NoControl - - - 336, 95 - - - 0, 3, 12, 12 - - - 75, 23 - - - 0 - - - OK - - - OkButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 1 - - - Bottom, Left - - - True - - - Segoe UI, 9pt - - - 14, 77 - - - 14, 11, 14, 0 - - - 106, 15 - - - 18 - - - View Legal Notices - - - linkLabel1 - - - System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 2 - - - Top, Bottom, Left, Right - - - True - - - GrowAndShrink - - - 1 - - - Segoe UI, 9pt - - - 0, 79 - - - 5 - - - 423, 130 - - - 19 - - - tableLayoutPanel1 - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="VersionLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="OkButton" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="linkLabel1" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="label2" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0" /></TableLayoutSettings> - True @@ -349,7 +463,7 @@ GrowAndShrink - 423, 208 + 423, 321 Tahoma, 8pt diff --git a/XenAdmin/MainWindow.cs b/XenAdmin/MainWindow.cs index 0161feb84..0e89de7a4 100644 --- a/XenAdmin/MainWindow.cs +++ b/XenAdmin/MainWindow.cs @@ -129,6 +129,9 @@ namespace XenAdmin private Dictionary pluginMenuItemStartIndexes = new Dictionary(); + private bool expandTreeNodesOnStartup; + private int connectionsInProgressOnStartup; + public MainWindow(ArgType argType, string[] args) { Program.MainWindow = this; @@ -521,18 +524,19 @@ namespace XenAdmin RequestRefreshTreeView(); UpdateToolbars(); + // if there are fewer than 30 connections, then expand the tree nodes. + expandTreeNodesOnStartup = ConnectionsManager.XenConnectionsCopy.Count < 30; + + connectionsInProgressOnStartup = 0; // kick-off connections for all the loaded server list foreach (IXenConnection connection in ConnectionsManager.XenConnectionsCopy) { if (!connection.SaveDisconnected) { + connectionsInProgressOnStartup++; + connection.ConnectionStateChanged += Connection_ConnectionStateChangedOnStartup; + connection.CachePopulated += connection_CachePopulatedOnStartup; XenConnectionUI.BeginConnect(connection, true, this, true); - - // if there are fewer than 30 connections, then expand the tree nodes. - if (ConnectionsManager.XenConnectionsCopy.Count < 30) - { - connection.CachePopulated += connection_CachePopulatedOnStartup; - } } } @@ -601,7 +605,37 @@ namespace XenAdmin { IXenConnection c = (IXenConnection)sender; c.CachePopulated -= connection_CachePopulatedOnStartup; - TrySelectNewNode(c, false, true, false); + if (expandTreeNodesOnStartup) + TrySelectNewNode(c, false, true, false); + + Program.Invoke(this, ShowAboutDialogOnStartup); + } + + private void Connection_ConnectionStateChangedOnStartup(object sender, EventArgs e) + { + IXenConnection c = (IXenConnection)sender; + c.CachePopulated -= Connection_ConnectionStateChangedOnStartup; + + Program.Invoke(Program.MainWindow, delegate + { + connectionsInProgressOnStartup--; + // show the About dialog if this was the last connection in progress and the connection failed + if (!c.IsConnected) + ShowAboutDialogOnStartup(); + }); + } + + /// + /// Show the About dialog after all conncections kicked-off on startup have finished the connection phase (cache populated) + /// Must be called on the event thread. + /// + private void ShowAboutDialogOnStartup() + { + Program.AssertOnEventThread(); + if (connectionsInProgressOnStartup > 0) + return; + if (Properties.Settings.Default.ShowAboutDialog && !HiddenFeatures.LicenseNagHidden) + ShowForm(typeof(AboutDialog)); } private bool Launched = false; diff --git a/XenAdmin/Properties/Settings.Designer.cs b/XenAdmin/Properties/Settings.Designer.cs index 7cc783b69..ef354c0fc 100644 --- a/XenAdmin/Properties/Settings.Designer.cs +++ b/XenAdmin/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.18444 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -695,5 +695,17 @@ namespace XenAdmin.Properties { this["ShowJustHostInSearch"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool ShowAboutDialog { + get { + return ((bool)(this["ShowAboutDialog"])); + } + set { + this["ShowAboutDialog"] = value; + } + } } } diff --git a/XenAdmin/Properties/Settings.settings b/XenAdmin/Properties/Settings.settings index 4fbd10465..c517cb492 100644 --- a/XenAdmin/Properties/Settings.settings +++ b/XenAdmin/Properties/Settings.settings @@ -161,5 +161,8 @@ False + + True + \ No newline at end of file diff --git a/XenAdmin/app.config b/XenAdmin/app.config index a666d505d..559b86e4a 100644 --- a/XenAdmin/app.config +++ b/XenAdmin/app.config @@ -152,10 +152,13 @@ True - + False + + True +