Skip to content

Commit

Permalink
Merge pull request #3223 from kc284/master
Browse files Browse the repository at this point in the history
Random corrections and enhancements
  • Loading branch information
kc284 authored Oct 25, 2023
2 parents 56b6a5b + 4dbfaff commit 0f4d105
Show file tree
Hide file tree
Showing 20 changed files with 626 additions and 1,027 deletions.
4 changes: 4 additions & 0 deletions XenAdmin/Controls/AD/LoggedInLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* SUCH DAMAGE.
*/

using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using XenAPI;
Expand All @@ -39,6 +40,9 @@ namespace XenAdmin.Controls
public partial class LoggedInLabel : UserControl
{
private IXenConnection connection;

[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public IXenConnection Connection
{
get
Expand Down
63 changes: 63 additions & 0 deletions XenAdmin/Controls/StatusStripEx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* Copyright (c) Cloud Software Group, Inc.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/

using System;
using System.Windows.Forms;

namespace XenAdmin.Controls
{
/// <summary>
/// A System.Windows.Forms.StatusStrip with the option of click-through
/// (see https://learn.microsoft.com/en-us/archive/blogs/rickbrew/how-to-enable-click-through-for-net-2-0-toolstrip-and-menustrip)
/// </summary>
public class StatusStripEx : StatusStrip
{
/// <summary>
/// Gets or sets whether the StatusStripEx honors item clicks when its containing form does
/// not have input focus.
/// </summary>
/// <remarks>
/// Default value is false, which is the same behavior provided by the base StatusStrip class.
/// </remarks>
public bool ClickThrough { get; set; }

protected override void WndProc(ref Message m)
{
base.WndProc(ref m);

if (ClickThrough &&
m.Msg == NativeConstants.WM_MOUSEACTIVATE &&
m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
{
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
}
}
}
}
19 changes: 4 additions & 15 deletions XenAdmin/Controls/ToolStripEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,24 @@ namespace XenAdmin.Controls
{
/// <summary>
/// A System.Windows.Forms.ToolStrip with the option of click-through
/// (see http://blogs.msdn.com/rickbrew/archive/2006/01/09/511003.aspx)
/// (see https://learn.microsoft.com/en-us/archive/blogs/rickbrew/how-to-enable-click-through-for-net-2-0-toolstrip-and-menustrip)
/// </summary>
public class ToolStripEx : ToolStrip
{
private bool clickThrough = false;

/// <summary>
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does
/// not have input focus.
/// </summary>
/// <remarks>
/// Default value is false, which is the same behavior provided by the base ToolStrip class.
/// </remarks>
public bool ClickThrough
{
get
{
return this.clickThrough;
}
set
{
this.clickThrough = value;
}
}
public bool ClickThrough { get; set; }

protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (this.clickThrough &&

if (ClickThrough &&
m.Msg == NativeConstants.WM_MOUSEACTIVATE &&
m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
{
Expand Down
8 changes: 3 additions & 5 deletions XenAdmin/Controls/UpsellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public partial class UpsellPage : UserControl, IEditPage
public UpsellPage()
{
InitializeComponent();
this.LearnMoreButton.Visible = !HiddenFeatures.LearnMoreButtonHidden;
LearnMoreButton.Visible = !HiddenFeatures.LearnMoreButtonHidden;
}

public void enableOkButton()
public void EnableOkButton()
{
OKButton.Visible = true;
}
Expand All @@ -60,11 +60,9 @@ public string BlurbText
: value + string.Format(Messages.UPSELL_BLURB_TRIAL, BrandManager.ProductBrand);
}

public string LearnMoreUrl { private get; set; } = InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL;

private void LearnMoreButton_Clicked(object sender, EventArgs e)
{
NavigateTo(LearnMoreUrl);
NavigateTo(InvisibleMessages.UPSELL_LEARNMOREURL_TRIAL);
}

private void NavigateTo(string url)
Expand Down
6 changes: 2 additions & 4 deletions XenAdmin/Dialogs/UpsellDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public UpsellDialog(string blurb)
{
InitializeComponent();
upsellPage1.BlurbText = blurb;
upsellPage1.enableOkButton();
upsellPage1.EnableOkButton();
CancelButton = upsellPage1.OKButton;
Height = upsellPage1.Height;
}
Expand All @@ -54,9 +54,7 @@ protected override void OnLoad(EventArgs e)

public static void ShowUpsellDialog(string message, IWin32Window parent)
{
using (var upsellDialog = new UpsellDialog(HiddenFeatures.LinkLabelHidden
? message
: message + string.Format(Messages.UPSELL_BLURB_TRIAL, BrandManager.ProductBrand)))
using (var upsellDialog = new UpsellDialog(message))
upsellDialog.ShowDialog(parent);
}
}
Expand Down
37 changes: 13 additions & 24 deletions XenAdmin/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions XenAdmin/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public partial class MainWindow : Form, ISynchronizeInvoke, IMainWindow, IFormWi
internal readonly DockerProcessPage DockerProcessPage = new DockerProcessPage();
internal readonly DockerDetailsPage DockerDetailsPage = new DockerDetailsPage();
internal readonly UsbPage UsbPage = new UsbPage();
private readonly SnapshotsPage snapshotPage = new SnapshotsPage();

private readonly NotificationsBasePage[] _notificationPages;

Expand Down Expand Up @@ -188,6 +189,7 @@ public MainWindow(string[] args)
components.Add(DockerProcessPage);
components.Add(DockerDetailsPage);
components.Add(UsbPage);
components.Add(snapshotPage);

AddTabContents(VMStoragePage, TabPageStorage);
AddTabContents(SrStoragePage, TabPageSR);
Expand All @@ -212,6 +214,7 @@ public MainWindow(string[] args)
AddTabContents(DockerProcessPage, TabPageDockerProcess);
AddTabContents(DockerDetailsPage, TabPageDockerDetails);
AddTabContents(UsbPage, TabPageUSB);
AddTabContents(snapshotPage, TabPageSnapshots);

#endregion

Expand Down Expand Up @@ -1570,9 +1573,8 @@ private List<TabPage> GetNewTabPages()
if(!multi && !SearchMode && isRealVMSelected)
newTabs.Add(TabPageSnapshots);

//Any Clearwater XenServer, or WLB is not licensed on XenServer, the WLB tab and any WLB menu items disappear completely.
if (!wlb_upsell && !multi && !SearchMode && isPoolSelected)
newTabs.Add(TabPageWLB);
if (!multi && !SearchMode && isPoolSelected)
newTabs.Add(wlb_upsell ? TabPageWLBUpsell : TabPageWLB);

if (!multi && !SearchMode && (isPoolSelected || isPoolOrLiveStandaloneHost))
newTabs.Add(ad_upsell ? TabPageADUpsell : TabPageAD);
Expand Down
30 changes: 0 additions & 30 deletions XenAdmin/MainWindow.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -555,36 +555,6 @@
<data name="&gt;&gt;TabPageHAUpsell.ZOrder" xml:space="preserve">
<value>12</value>
</data>
<data name="snapshotPage.AutoScroll" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="snapshotPage.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="snapshotPage.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="snapshotPage.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="snapshotPage.Size" type="System.Drawing.Size, System.Drawing">
<value>753, 592</value>
</data>
<data name="snapshotPage.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;snapshotPage.Name" xml:space="preserve">
<value>snapshotPage</value>
</data>
<data name="&gt;&gt;snapshotPage.Type" xml:space="preserve">
<value>XenAdmin.TabPages.SnapshotsPage, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;snapshotPage.Parent" xml:space="preserve">
<value>TabPageSnapshots</value>
</data>
<data name="&gt;&gt;snapshotPage.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="TabPageSnapshots.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 22</value>
</data>
Expand Down
Loading

0 comments on commit 0f4d105

Please sign in to comment.