mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-03 07:39:28 +03:00
Added close buttons to tool windows.
This commit is contained in:
parent
db07a006ec
commit
61cae9e978
@ -274,6 +274,18 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Resources\inactive-close-selected.png" />
|
<None Include="Resources\inactive-close-selected.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\tw_close.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\tw_close_selected.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\tw_active_close.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\tw_active_close_selected.png" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
@ -2,12 +2,21 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace DarkUI.Docking
|
namespace DarkUI.Docking
|
||||||
{
|
{
|
||||||
[ToolboxItem(false)]
|
[ToolboxItem(false)]
|
||||||
public class DarkToolWindow : DarkDockContent
|
public class DarkToolWindow : DarkDockContent
|
||||||
{
|
{
|
||||||
|
#region Field Region
|
||||||
|
|
||||||
|
private Rectangle _closeButtonRect;
|
||||||
|
private bool _closeButtonHot = false;
|
||||||
|
private bool _closeButtonPressed = false;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Property Region
|
#region Property Region
|
||||||
|
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
@ -29,6 +38,8 @@ namespace DarkUI.Docking
|
|||||||
|
|
||||||
BackColor = Colors.GreyBackground;
|
BackColor = Colors.GreyBackground;
|
||||||
base.Padding = new Padding(0, Consts.ToolWindowHeaderSize, 0, 0);
|
base.Padding = new Padding(0, Consts.ToolWindowHeaderSize, 0, 0);
|
||||||
|
|
||||||
|
UpdateCloseButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -43,6 +54,75 @@ namespace DarkUI.Docking
|
|||||||
return DockPanel.ActiveContent == this;
|
return DockPanel.ActiveContent == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateCloseButton()
|
||||||
|
{
|
||||||
|
_closeButtonRect = new Rectangle
|
||||||
|
{
|
||||||
|
X = ClientRectangle.Right - DockIcons.tw_close.Width - 5 - 3,
|
||||||
|
Y = ClientRectangle.Top + (Consts.ToolWindowHeaderSize / 2) - (DockIcons.tw_close.Height / 2),
|
||||||
|
Width = DockIcons.tw_close.Width,
|
||||||
|
Height = DockIcons.tw_close.Height
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Event Handler Region
|
||||||
|
|
||||||
|
protected override void OnResize(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnResize(e);
|
||||||
|
|
||||||
|
UpdateCloseButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnMouseMove(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseMove(e);
|
||||||
|
|
||||||
|
if (_closeButtonRect.Contains(e.Location) || _closeButtonPressed)
|
||||||
|
{
|
||||||
|
if (!_closeButtonHot)
|
||||||
|
{
|
||||||
|
_closeButtonHot = true;
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_closeButtonHot)
|
||||||
|
{
|
||||||
|
_closeButtonHot = false;
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnMouseDown(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseDown(e);
|
||||||
|
|
||||||
|
if (_closeButtonRect.Contains(e.Location))
|
||||||
|
{
|
||||||
|
_closeButtonPressed = true;
|
||||||
|
_closeButtonHot = true;
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnMouseUp(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseUp(e);
|
||||||
|
|
||||||
|
if (_closeButtonRect.Contains(e.Location) && _closeButtonPressed)
|
||||||
|
Close();
|
||||||
|
|
||||||
|
_closeButtonPressed = false;
|
||||||
|
_closeButtonHot = false;
|
||||||
|
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Paint Region
|
#region Paint Region
|
||||||
@ -83,12 +163,14 @@ namespace DarkUI.Docking
|
|||||||
|
|
||||||
var xOffset = 2;
|
var xOffset = 2;
|
||||||
|
|
||||||
|
// Draw icon
|
||||||
if (Icon != null)
|
if (Icon != null)
|
||||||
{
|
{
|
||||||
g.DrawImageUnscaled(Icon, ClientRectangle.Left + 5, ClientRectangle.Top + (Consts.ToolWindowHeaderSize / 2) - (Icon.Height / 2) + 1);
|
g.DrawImageUnscaled(Icon, ClientRectangle.Left + 5, ClientRectangle.Top + (Consts.ToolWindowHeaderSize / 2) - (Icon.Height / 2) + 1);
|
||||||
xOffset = Icon.Width + 8;
|
xOffset = Icon.Width + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw text
|
||||||
using (var b = new SolidBrush(Colors.LightText))
|
using (var b = new SolidBrush(Colors.LightText))
|
||||||
{
|
{
|
||||||
var textRect = new Rectangle(xOffset, 0, ClientRectangle.Width - 4 - xOffset, Consts.ToolWindowHeaderSize);
|
var textRect = new Rectangle(xOffset, 0, ClientRectangle.Width - 4 - xOffset, Consts.ToolWindowHeaderSize);
|
||||||
@ -103,6 +185,14 @@ namespace DarkUI.Docking
|
|||||||
|
|
||||||
g.DrawString(DockText, Font, b, textRect, format);
|
g.DrawString(DockText, Font, b, textRect, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close button
|
||||||
|
var img = _closeButtonHot ? DockIcons.tw_close_selected : DockIcons.tw_close;
|
||||||
|
|
||||||
|
if (isActive)
|
||||||
|
img = _closeButtonHot ? DockIcons.tw_active_close_selected : DockIcons.tw_active_close;
|
||||||
|
|
||||||
|
g.DrawImageUnscaled(img, _closeButtonRect.Left, _closeButtonRect.Top);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnPaintBackground(PaintEventArgs e)
|
protected override void OnPaintBackground(PaintEventArgs e)
|
||||||
|
40
DarkUI/Icons/DockIcons.Designer.cs
generated
40
DarkUI/Icons/DockIcons.Designer.cs
generated
@ -119,5 +119,45 @@ namespace DarkUI {
|
|||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap tw_active_close {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("tw_active_close", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap tw_active_close_selected {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("tw_active_close_selected", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap tw_close {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("tw_close", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap tw_close_selected {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("tw_close_selected", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,4 +136,16 @@
|
|||||||
<data name="inactive_close_selected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="inactive_close_selected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\inactive-close-selected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\inactive-close-selected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="tw_active_close" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\tw_active_close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="tw_active_close_selected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\tw_active_close_selected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="tw_close" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\tw_close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="tw_close_selected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\tw_close_selected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
BIN
DarkUI/Resources/tw_active_close.png
Normal file
BIN
DarkUI/Resources/tw_active_close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
DarkUI/Resources/tw_active_close_selected.png
Normal file
BIN
DarkUI/Resources/tw_active_close_selected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
DarkUI/Resources/tw_close.png
Normal file
BIN
DarkUI/Resources/tw_close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
DarkUI/Resources/tw_close_selected.png
Normal file
BIN
DarkUI/Resources/tw_close_selected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Loading…
x
Reference in New Issue
Block a user