Removed BlueBorderPanel.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2021-04-30 10:00:44 +01:00
parent 75b05f81a2
commit 0fc835a194
9 changed files with 11 additions and 231 deletions

View File

@ -1,210 +0,0 @@
/* Copyright (c) Citrix Systems, Inc.
* All rights reserved.
*
* 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.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using XenAdmin.Core;
namespace XenAdmin.Controls
{
// Taken from http://209.85.165.104/search?q=cache:hnUUN2Zhi7YJ:www.developersdex.com/vb/message.asp%3Fp%3D2927%26r%3D5855234+NativeMethods.GetDCEx&hl=en&ct=clnk&cd=1&gl=uk&client=firefox-a
public class BlueBorderPanel : DoubleBufferedPanel
{
private Color borderColor = Drawing.XPBorderColor;
public Color BorderColor
{
get { return borderColor; }
set
{
if (borderColor != value)
{
borderColor = value;
NativeMethods.SendMessage(this.Handle,
NativeMethods.WM_NCPAINT,
(IntPtr)1, IntPtr.Zero);
}
}
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
NativeMethods.SendMessage(this.Handle,
NativeMethods.WM_NCPAINT, (IntPtr)1, IntPtr.Zero);
}
protected override void WndProc(ref Message m)
{
if (m.Msg == NativeMethods.WM_NCPAINT)
{
if (this.Parent != null)
{
NCPaint();
m.WParam = GetHRegion();
base.DefWndProc(ref m);
NativeMethods.DeleteObject(m.WParam);
m.Result = (IntPtr)1;
}
}
base.WndProc(ref m);
}
private void NCPaint()
{
if (this.Parent == null)
return;
if (this.Width <= 0 || this.Height <= 0)
return;
IntPtr windowDC = NativeMethods.GetDCEx(this.Handle,
IntPtr.Zero, NativeMethods.DCX_CACHE |
NativeMethods.DCX_WINDOW |
NativeMethods.DCX_CLIPSIBLINGS |
NativeMethods.DCX_LOCKWINDOWUPDATE);
if (windowDC.Equals(IntPtr.Zero))
return;
using (Bitmap bm = new Bitmap(this.Width, this.Height,
System.Drawing.Imaging.PixelFormat.Format32bppPArgb))
{
using (Graphics g = Graphics.FromImage(bm))
{
Rectangle borderRect = new Rectangle(0, 0,
Width - 1, Height - 1);
using (Pen borderPen = new Pen(this.borderColor, 1))
{
borderPen.Alignment = PenAlignment.Inset;
g.DrawRectangle(borderPen, borderRect);
}
// Create and Apply a Clip Region to the WindowDC
using (Region Rgn = new Region(new
Rectangle(0, 0, Width, Height)))
{
Rgn.Exclude(new Rectangle(1, 1, Width - 2, Height - 2));
IntPtr hRgn = Rgn.GetHrgn(g);
if (!hRgn.Equals(IntPtr.Zero))
NativeMethods.SelectClipRgn(windowDC, hRgn);
IntPtr bmDC = g.GetHdc();
IntPtr hBmp = bm.GetHbitmap();
IntPtr oldDC = NativeMethods.SelectObject(bmDC,
hBmp);
NativeMethods.BitBlt(windowDC, 0, 0, bm.Width,
bm.Height, bmDC, 0, 0, NativeMethods.SRCCOPY);
NativeMethods.SelectClipRgn(windowDC, IntPtr.Zero);
NativeMethods.DeleteObject(hRgn);
g.ReleaseHdc(bmDC);
NativeMethods.SelectObject(oldDC, hBmp);
NativeMethods.DeleteObject(hBmp);
bm.Dispose();
}
}
}
NativeMethods.ReleaseDC(this.Handle, windowDC);
}
private IntPtr GetHRegion()
{
//Define a Clip Region to pass back to WM_NCPAINTs wParam.
//Must be in Screen Coordinates.
IntPtr hRgn;
Rectangle winRect = this.Parent.RectangleToScreen(this.Bounds);
Rectangle clientRect =
this.RectangleToScreen(this.ClientRectangle);
Region updateRegion = new Region(winRect);
updateRegion.Complement(clientRect);
using (Graphics g = this.CreateGraphics())
hRgn = updateRegion.GetHrgn(g);
updateRegion.Dispose();
return hRgn;
}
}
internal class NativeMethods
{
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg,
IntPtr wParam,
IntPtr lParam);
[DllImport("gdi32.dll")]
public static extern int SelectClipRgn(IntPtr hdc, IntPtr hrgn);
[DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hdc,
IntPtr hgdiobj);
[DllImport("gdi32.dll")]
public static extern bool BitBlt(IntPtr hdcDest,
int nXDest, int nYDest,
int nWidth, int nHeight,
IntPtr hdcSrc,
int nXSrc, int nYSrc, int dwRop);
[DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
[DllImport("user32.dll")]
public static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip,
int flags);
[DllImport("user32.dll")]
public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
public const int WM_NCPAINT = 0x85;
public const int DCX_WINDOW = 0x1;
public const int DCX_CACHE = 0x2;
public const int DCX_CLIPCHILDREN = 0x8;
public const int DCX_CLIPSIBLINGS = 0x10;
public const int DCX_LOCKWINDOWUPDATE = 0x400;
public const int SRCCOPY = 0xCC0020;
}
}

View File

@ -78,7 +78,6 @@ namespace XenAdmin.Dialogs
// //
// blueBorder // blueBorder
// //
this.blueBorder.BorderStyle = System.Windows.Forms.BorderStyle.None;
resources.ApplyResources(this.blueBorder, "blueBorder"); resources.ApplyResources(this.blueBorder, "blueBorder");
// //
// BlurbLabel // BlurbLabel

View File

@ -76,7 +76,6 @@ namespace XenAdmin.Dialogs
// //
// blueBorder // blueBorder
// //
this.blueBorder.BorderStyle = System.Windows.Forms.BorderStyle.None;
resources.ApplyResources(this.blueBorder, "blueBorder"); resources.ApplyResources(this.blueBorder, "blueBorder");
// //
// BlurbLabel // BlurbLabel

View File

@ -31,7 +31,7 @@ namespace XenAdmin.Dialogs
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VerticallyTabbedDialog)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VerticallyTabbedDialog));
this.splitContainer = new System.Windows.Forms.SplitContainer(); this.splitContainer = new System.Windows.Forms.SplitContainer();
this.verticalTabs = new XenAdmin.Controls.VerticalTabs(); this.verticalTabs = new XenAdmin.Controls.VerticalTabs();
this.blueBorder = new XenAdmin.Controls.BlueBorderPanel(); this.blueBorder = new System.Windows.Forms.Panel();
this.TopPanel = new XenAdmin.Controls.GradientPanel.HorizontalGradientPanel(); this.TopPanel = new XenAdmin.Controls.GradientPanel.HorizontalGradientPanel();
this.TabImage = new System.Windows.Forms.PictureBox(); this.TabImage = new System.Windows.Forms.PictureBox();
this.TabTitle = new System.Windows.Forms.Label(); this.TabTitle = new System.Windows.Forms.Label();
@ -73,7 +73,6 @@ namespace XenAdmin.Dialogs
// blueBorder // blueBorder
// //
this.blueBorder.BackColor = System.Drawing.SystemColors.Window; this.blueBorder.BackColor = System.Drawing.SystemColors.Window;
this.blueBorder.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(123)))), ((int)(((byte)(158)))), ((int)(((byte)(189)))));
this.blueBorder.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.blueBorder.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.blueBorder.Controls.Add(this.TopPanel); this.blueBorder.Controls.Add(this.TopPanel);
this.blueBorder.Controls.Add(this.ContentPanel); this.blueBorder.Controls.Add(this.ContentPanel);
@ -151,12 +150,12 @@ namespace XenAdmin.Dialogs
private System.Windows.Forms.PictureBox TabImage; private System.Windows.Forms.PictureBox TabImage;
private System.Windows.Forms.Label TabTitle; private System.Windows.Forms.Label TabTitle;
private XenAdmin.Controls.GradientPanel.GradientPanel TopPanel; private Controls.GradientPanel.HorizontalGradientPanel TopPanel;
protected System.Windows.Forms.Panel ContentPanel; protected System.Windows.Forms.Panel ContentPanel;
protected XenAdmin.Controls.VerticalTabs verticalTabs; protected XenAdmin.Controls.VerticalTabs verticalTabs;
protected System.Windows.Forms.Button cancelButton; protected System.Windows.Forms.Button cancelButton;
protected System.Windows.Forms.Button okButton; protected System.Windows.Forms.Button okButton;
protected System.Windows.Forms.SplitContainer splitContainer; protected System.Windows.Forms.SplitContainer splitContainer;
protected XenAdmin.Controls.BlueBorderPanel blueBorder; protected System.Windows.Forms.Panel blueBorder;
} }
} }

View File

@ -59,8 +59,6 @@ namespace XenAdmin.Dialogs
TabTitle.ForeColor = Program.HeaderGradientForeColor; TabTitle.ForeColor = Program.HeaderGradientForeColor;
TabTitle.Font = Program.TabbedDialogHeaderFont; TabTitle.Font = Program.TabbedDialogHeaderFont;
if (!Application.RenderWithVisualStyles)
blueBorder.BackColor = SystemColors.Control;
} }
public VerticalTabs.IVerticalTab[] Tabs public VerticalTabs.IVerticalTab[] Tabs

View File

@ -259,7 +259,7 @@
<value>TopPanel</value> <value>TopPanel</value>
</data> </data>
<data name="&gt;&gt;TopPanel.Type" xml:space="preserve"> <data name="&gt;&gt;TopPanel.Type" xml:space="preserve">
<value>XenAdmin.Controls.GradientPanel.GradientPanel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value> <value>XenAdmin.Controls.GradientPanel.HorizontalGradientPanel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data> </data>
<data name="&gt;&gt;TopPanel.Parent" xml:space="preserve"> <data name="&gt;&gt;TopPanel.Parent" xml:space="preserve">
<value>blueBorder</value> <value>blueBorder</value>
@ -325,7 +325,7 @@
<value>blueBorder</value> <value>blueBorder</value>
</data> </data>
<data name="&gt;&gt;blueBorder.Type" xml:space="preserve"> <data name="&gt;&gt;blueBorder.Type" xml:space="preserve">
<value>XenAdmin.Controls.BlueBorderPanel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value> <value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;blueBorder.Parent" xml:space="preserve"> <data name="&gt;&gt;blueBorder.Parent" xml:space="preserve">
<value>splitContainer.Panel2</value> <value>splitContainer.Panel2</value>

View File

@ -42,8 +42,8 @@ namespace XenAdmin.SettingsPanels
this.lblDescrReadOnly = new System.Windows.Forms.Label(); this.lblDescrReadOnly = new System.Windows.Forms.Label();
this.txtDescrReadOnly = new System.Windows.Forms.Label(); this.txtDescrReadOnly = new System.Windows.Forms.Label();
this.labelTitle = new XenAdmin.Controls.Common.AutoHeightLabel(); this.labelTitle = new XenAdmin.Controls.Common.AutoHeightLabel();
this.folderPanel = new XenAdmin.Controls.BlueBorderPanel(); this.folderPanel = new System.Windows.Forms.Panel();
this.tagsPanel = new XenAdmin.Controls.BlueBorderPanel(); this.tagsPanel = new System.Windows.Forms.Panel();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -135,7 +135,6 @@ namespace XenAdmin.SettingsPanels
// folderPanel // folderPanel
// //
this.folderPanel.BackColor = System.Drawing.SystemColors.Window; this.folderPanel.BackColor = System.Drawing.SystemColors.Window;
this.folderPanel.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(123)))), ((int)(((byte)(158)))), ((int)(((byte)(189)))));
this.folderPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.folderPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
resources.ApplyResources(this.folderPanel, "folderPanel"); resources.ApplyResources(this.folderPanel, "folderPanel");
this.folderPanel.Name = "folderPanel"; this.folderPanel.Name = "folderPanel";
@ -144,7 +143,6 @@ namespace XenAdmin.SettingsPanels
// tagsPanel // tagsPanel
// //
this.tagsPanel.BackColor = System.Drawing.SystemColors.Window; this.tagsPanel.BackColor = System.Drawing.SystemColors.Window;
this.tagsPanel.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(123)))), ((int)(((byte)(158)))), ((int)(((byte)(189)))));
this.tagsPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.tagsPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
resources.ApplyResources(this.tagsPanel, "tagsPanel"); resources.ApplyResources(this.tagsPanel, "tagsPanel");
this.tagsPanel.Name = "tagsPanel"; this.tagsPanel.Name = "tagsPanel";
@ -175,8 +173,8 @@ namespace XenAdmin.SettingsPanels
private System.Windows.Forms.TextBox txtName; private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.TextBox txtDescription; private System.Windows.Forms.TextBox txtDescription;
private System.Windows.Forms.TextBox txtIQN; private System.Windows.Forms.TextBox txtIQN;
private XenAdmin.Controls.BlueBorderPanel tagsPanel; private System.Windows.Forms.Panel tagsPanel;
private XenAdmin.Controls.BlueBorderPanel folderPanel; private System.Windows.Forms.Panel folderPanel;
private XenAdmin.Controls.Common.AutoHeightLabel labelTitle; private XenAdmin.Controls.Common.AutoHeightLabel labelTitle;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label lblDescrReadOnly; private System.Windows.Forms.Label lblDescrReadOnly;

View File

@ -562,7 +562,7 @@
<value>folderPanel</value> <value>folderPanel</value>
</data> </data>
<data name="&gt;&gt;folderPanel.Type" xml:space="preserve"> <data name="&gt;&gt;folderPanel.Type" xml:space="preserve">
<value>XenAdmin.Controls.BlueBorderPanel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value> <value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;folderPanel.Parent" xml:space="preserve"> <data name="&gt;&gt;folderPanel.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value> <value>tableLayoutPanel1</value>
@ -589,7 +589,7 @@
<value>tagsPanel</value> <value>tagsPanel</value>
</data> </data>
<data name="&gt;&gt;tagsPanel.Type" xml:space="preserve"> <data name="&gt;&gt;tagsPanel.Type" xml:space="preserve">
<value>XenAdmin.Controls.BlueBorderPanel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value> <value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;tagsPanel.Parent" xml:space="preserve"> <data name="&gt;&gt;tagsPanel.Parent" xml:space="preserve">
<value>tableLayoutPanel1</value> <value>tableLayoutPanel1</value>

View File

@ -596,9 +596,6 @@
<Compile Include="SettingsPanels\PerfmonAlertOptionsPage.Designer.cs"> <Compile Include="SettingsPanels\PerfmonAlertOptionsPage.Designer.cs">
<DependentUpon>PerfmonAlertOptionsPage.cs</DependentUpon> <DependentUpon>PerfmonAlertOptionsPage.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\BlueBorderPanel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\CustomDataGraph\ArchiveMaintainer.cs"> <Compile Include="Controls\CustomDataGraph\ArchiveMaintainer.cs">
</Compile> </Compile>
<Compile Include="Controls\CustomDataGraph\DataArchive.cs" /> <Compile Include="Controls\CustomDataGraph\DataArchive.cs" />