Merge remote-tracking branch 'refs/remotes/origin/working'
28
DarkUI.sln
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DarkUI", "DarkUI\DarkUI.csproj", "{F19472F5-8C44-4C51-A8A0-B9DE5F555255}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{FA334815-6D78-4E9A-9F4D-6C8A58222A57}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F19472F5-8C44-4C51-A8A0-B9DE5F555255}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F19472F5-8C44-4C51-A8A0-B9DE5F555255}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F19472F5-8C44-4C51-A8A0-B9DE5F555255}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F19472F5-8C44-4C51-A8A0-B9DE5F555255}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FA334815-6D78-4E9A-9F4D-6C8A58222A57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA334815-6D78-4E9A-9F4D-6C8A58222A57}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA334815-6D78-4E9A-9F4D-6C8A58222A57}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FA334815-6D78-4E9A-9F4D-6C8A58222A57}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
85
DarkUI/Collections/ObservableList.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DarkUI.Collections
|
||||
{
|
||||
public class ObservableList<T> : List<T>, IDisposable
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Region
|
||||
|
||||
public event EventHandler<ObservableListModified<T>> ItemsAdded;
|
||||
public event EventHandler<ObservableListModified<T>> ItemsRemoved;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Destructor Region
|
||||
|
||||
~ObservableList()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dispose Region
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (ItemsAdded != null)
|
||||
ItemsAdded = null;
|
||||
|
||||
if (ItemsRemoved != null)
|
||||
ItemsRemoved = null;
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public new void Add(T item)
|
||||
{
|
||||
base.Add(item);
|
||||
|
||||
if (ItemsAdded != null)
|
||||
ItemsAdded(this, new ObservableListModified<T>(new List<T> { item }));
|
||||
}
|
||||
|
||||
public new void AddRange(IEnumerable<T> collection)
|
||||
{
|
||||
var list = collection.ToList();
|
||||
|
||||
base.AddRange(list);
|
||||
|
||||
if (ItemsAdded != null)
|
||||
ItemsAdded(this, new ObservableListModified<T>(list));
|
||||
}
|
||||
|
||||
public new void Remove(T item)
|
||||
{
|
||||
base.Remove(item);
|
||||
|
||||
if (ItemsRemoved != null)
|
||||
ItemsRemoved(this, new ObservableListModified<T>(new List<T> { item }));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
15
DarkUI/Collections/ObservableListModified.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DarkUI.Collections
|
||||
{
|
||||
public class ObservableListModified<T> : EventArgs
|
||||
{
|
||||
public IEnumerable<T> Items { get; private set; }
|
||||
|
||||
public ObservableListModified(IEnumerable<T> items)
|
||||
{
|
||||
Items = items;
|
||||
}
|
||||
}
|
||||
}
|
112
DarkUI/Config/Colors.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DarkUI.Config
|
||||
{
|
||||
public sealed class Colors
|
||||
{
|
||||
public static Color GreyBackground
|
||||
{
|
||||
get { return Color.FromArgb(60, 63, 65); }
|
||||
}
|
||||
|
||||
public static Color HeaderBackground
|
||||
{
|
||||
get { return Color.FromArgb(57, 60, 62); }
|
||||
}
|
||||
|
||||
public static Color BlueBackground
|
||||
{
|
||||
get { return Color.FromArgb(66, 77, 95); }
|
||||
}
|
||||
|
||||
public static Color DarkBlueBackground
|
||||
{
|
||||
get { return Color.FromArgb(52, 57, 66); }
|
||||
}
|
||||
|
||||
public static Color DarkBackground
|
||||
{
|
||||
get { return Color.FromArgb(43, 43, 43); }
|
||||
}
|
||||
|
||||
public static Color MediumBackground
|
||||
{
|
||||
get { return Color.FromArgb(49, 51, 53); }
|
||||
}
|
||||
|
||||
public static Color LightBackground
|
||||
{
|
||||
get { return Color.FromArgb(69, 73, 74); }
|
||||
}
|
||||
|
||||
public static Color LighterBackground
|
||||
{
|
||||
get { return Color.FromArgb(95, 101, 102); }
|
||||
}
|
||||
|
||||
public static Color LightestBackground
|
||||
{
|
||||
get { return Color.FromArgb(178, 178, 178); }
|
||||
}
|
||||
|
||||
public static Color LightBorder
|
||||
{
|
||||
get { return Color.FromArgb(81, 81, 81); }
|
||||
}
|
||||
|
||||
public static Color DarkBorder
|
||||
{
|
||||
get { return Color.FromArgb(51, 51, 51); }
|
||||
}
|
||||
|
||||
public static Color LightText
|
||||
{
|
||||
get { return Color.FromArgb(220, 220, 220); }
|
||||
}
|
||||
|
||||
public static Color DisabledText
|
||||
{
|
||||
get { return Color.FromArgb(153, 153, 153); }
|
||||
}
|
||||
|
||||
public static Color BlueHighlight
|
||||
{
|
||||
get { return Color.FromArgb(104, 151, 187); }
|
||||
}
|
||||
|
||||
public static Color BlueSelection
|
||||
{
|
||||
get { return Color.FromArgb(75, 110, 175); }
|
||||
}
|
||||
|
||||
public static Color GreyHighlight
|
||||
{
|
||||
get { return Color.FromArgb(122, 128, 132); }
|
||||
}
|
||||
|
||||
public static Color GreySelection
|
||||
{
|
||||
get { return Color.FromArgb(92, 92, 92); }
|
||||
}
|
||||
|
||||
public static Color DarkGreySelection
|
||||
{
|
||||
get { return Color.FromArgb(82, 82, 82); }
|
||||
}
|
||||
|
||||
public static Color DarkBlueBorder
|
||||
{
|
||||
get { return Color.FromArgb(51, 61, 78); }
|
||||
}
|
||||
|
||||
public static Color LightBlueBorder
|
||||
{
|
||||
get { return Color.FromArgb(86, 97, 114); }
|
||||
}
|
||||
|
||||
public static Color ActiveControl
|
||||
{
|
||||
get { return Color.FromArgb(159, 178, 196); }
|
||||
}
|
||||
}
|
||||
}
|
18
DarkUI/Config/Consts.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace DarkUI.Config
|
||||
{
|
||||
public sealed class Consts
|
||||
{
|
||||
public static int Padding = 10;
|
||||
|
||||
public static int ScrollBarSize = 15;
|
||||
public static int ArrowButtonSize = 15;
|
||||
public static int MinimumThumbSize = 11;
|
||||
|
||||
public static int CheckBoxSize = 12;
|
||||
public static int RadioButtonSize = 12;
|
||||
|
||||
public const int ToolWindowHeaderSize = 25;
|
||||
public const int DocumentTabAreaSize = 24;
|
||||
public const int ToolWindowTabAreaSize = 21;
|
||||
}
|
||||
}
|
421
DarkUI/Controls/DarkButton.cs
Normal file
@ -0,0 +1,421 @@
|
||||
using DarkUI.Config;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
[ToolboxBitmap(typeof(Button))]
|
||||
[DefaultEvent("Click")]
|
||||
public class DarkButton : Button
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private DarkButtonStyle _style = DarkButtonStyle.Normal;
|
||||
private DarkControlState _buttonState = DarkControlState.Normal;
|
||||
|
||||
private bool _isDefault;
|
||||
private bool _spacePressed;
|
||||
|
||||
private int _padding = Consts.Padding / 2;
|
||||
private int _imagePadding = 5; // Consts.Padding / 2
|
||||
|
||||
#endregion
|
||||
|
||||
#region Designer Property Region
|
||||
|
||||
public new string Text
|
||||
{
|
||||
get { return base.Text; }
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public new bool Enabled
|
||||
{
|
||||
get { return base.Enabled; }
|
||||
set
|
||||
{
|
||||
base.Enabled = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Appearance")]
|
||||
[Description("Determines the style of the button.")]
|
||||
[DefaultValue(DarkButtonStyle.Normal)]
|
||||
public DarkButtonStyle ButtonStyle
|
||||
{
|
||||
get { return _style; }
|
||||
set
|
||||
{
|
||||
_style = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Appearance")]
|
||||
[Description("Determines the amount of padding between the image and text.")]
|
||||
[DefaultValue(5)]
|
||||
public int ImagePadding
|
||||
{
|
||||
get { return _imagePadding; }
|
||||
set
|
||||
{
|
||||
_imagePadding = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Code Property Region
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool AutoEllipsis
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DarkControlState ButtonState
|
||||
{
|
||||
get { return _buttonState; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new ContentAlignment ImageAlign
|
||||
{
|
||||
get { return base.ImageAlign; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool FlatAppearance
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new FlatStyle FlatStyle
|
||||
{
|
||||
get { return base.FlatStyle; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new ContentAlignment TextAlign
|
||||
{
|
||||
get { return base.TextAlign; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool UseCompatibleTextRendering
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool UseVisualStyleBackColor
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkButton()
|
||||
{
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.UserPaint, true);
|
||||
|
||||
base.UseVisualStyleBackColor = false;
|
||||
base.UseCompatibleTextRendering = false;
|
||||
|
||||
SetButtonState(DarkControlState.Normal);
|
||||
Padding = new Padding(_padding);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
private void SetButtonState(DarkControlState buttonState)
|
||||
{
|
||||
if (_buttonState != buttonState)
|
||||
{
|
||||
_buttonState = buttonState;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
|
||||
var form = FindForm();
|
||||
if (form != null)
|
||||
{
|
||||
if (form.AcceptButton == this)
|
||||
_isDefault = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (ClientRectangle.Contains(e.Location))
|
||||
SetButtonState(DarkControlState.Pressed);
|
||||
else
|
||||
SetButtonState(DarkControlState.Hover);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetButtonState(DarkControlState.Hover);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (!ClientRectangle.Contains(e.Location))
|
||||
return;
|
||||
|
||||
SetButtonState(DarkControlState.Pressed);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
SetButtonState(DarkControlState.Normal);
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
SetButtonState(DarkControlState.Normal);
|
||||
}
|
||||
|
||||
protected override void OnMouseCaptureChanged(EventArgs e)
|
||||
{
|
||||
base.OnMouseCaptureChanged(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
var location = Cursor.Position;
|
||||
|
||||
if (!ClientRectangle.Contains(location))
|
||||
SetButtonState(DarkControlState.Normal);
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
|
||||
_spacePressed = false;
|
||||
|
||||
var location = Cursor.Position;
|
||||
|
||||
if (!ClientRectangle.Contains(location))
|
||||
SetButtonState(DarkControlState.Normal);
|
||||
else
|
||||
SetButtonState(DarkControlState.Hover);
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
|
||||
if (e.KeyCode == Keys.Space)
|
||||
{
|
||||
_spacePressed = true;
|
||||
SetButtonState(DarkControlState.Pressed);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnKeyUp(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyUp(e);
|
||||
|
||||
if (e.KeyCode == Keys.Space)
|
||||
{
|
||||
_spacePressed = false;
|
||||
|
||||
var location = Cursor.Position;
|
||||
|
||||
if (!ClientRectangle.Contains(location))
|
||||
SetButtonState(DarkControlState.Normal);
|
||||
else
|
||||
SetButtonState(DarkControlState.Hover);
|
||||
}
|
||||
}
|
||||
|
||||
public override void NotifyDefault(bool value)
|
||||
{
|
||||
base.NotifyDefault(value);
|
||||
|
||||
if (!DesignMode)
|
||||
return;
|
||||
|
||||
_isDefault = value;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
var rect = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);
|
||||
|
||||
var textColor = Colors.LightText;
|
||||
var borderColor = Colors.GreySelection;
|
||||
var fillColor = _isDefault ? Colors.DarkBlueBackground : Colors.LightBackground;
|
||||
|
||||
if (Enabled)
|
||||
{
|
||||
if (ButtonStyle == DarkButtonStyle.Normal)
|
||||
{
|
||||
if (Focused && TabStop)
|
||||
borderColor = Colors.BlueHighlight;
|
||||
|
||||
switch (ButtonState)
|
||||
{
|
||||
case DarkControlState.Hover:
|
||||
fillColor = _isDefault ? Colors.BlueBackground : Colors.LighterBackground;
|
||||
break;
|
||||
case DarkControlState.Pressed:
|
||||
fillColor = _isDefault ? Colors.DarkBackground : Colors.DarkBackground;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ButtonStyle == DarkButtonStyle.Flat)
|
||||
{
|
||||
switch (ButtonState)
|
||||
{
|
||||
case DarkControlState.Normal:
|
||||
fillColor = Colors.GreyBackground;
|
||||
break;
|
||||
case DarkControlState.Hover:
|
||||
fillColor = Colors.MediumBackground;
|
||||
break;
|
||||
case DarkControlState.Pressed:
|
||||
fillColor = Colors.DarkBackground;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
textColor = Colors.DisabledText;
|
||||
fillColor = Colors.DarkGreySelection;
|
||||
}
|
||||
|
||||
using (var b = new SolidBrush(fillColor))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
|
||||
if (ButtonStyle == DarkButtonStyle.Normal)
|
||||
{
|
||||
using (var p = new Pen(borderColor, 1))
|
||||
{
|
||||
var modRect = new Rectangle(rect.Left, rect.Top, rect.Width - 1, rect.Height - 1);
|
||||
|
||||
g.DrawRectangle(p, modRect);
|
||||
}
|
||||
}
|
||||
|
||||
var textOffsetX = 0;
|
||||
var textOffsetY = 0;
|
||||
|
||||
if (Image != null)
|
||||
{
|
||||
var stringSize = g.MeasureString(Text, Font, rect.Size);
|
||||
|
||||
var x = (ClientSize.Width / 2) - (Image.Size.Width / 2);
|
||||
var y = (ClientSize.Height / 2) - (Image.Size.Height / 2);
|
||||
|
||||
switch (TextImageRelation)
|
||||
{
|
||||
case TextImageRelation.ImageAboveText:
|
||||
textOffsetY = (Image.Size.Height / 2) + (ImagePadding / 2);
|
||||
y = y - ((int)(stringSize.Height / 2) + (ImagePadding / 2));
|
||||
break;
|
||||
case TextImageRelation.TextAboveImage:
|
||||
textOffsetY = ((Image.Size.Height / 2) + (ImagePadding / 2)) * -1;
|
||||
y = y + ((int)(stringSize.Height / 2) + (ImagePadding / 2));
|
||||
break;
|
||||
case TextImageRelation.ImageBeforeText:
|
||||
textOffsetX = Image.Size.Width + (ImagePadding * 2);
|
||||
x = ImagePadding;
|
||||
break;
|
||||
case TextImageRelation.TextBeforeImage:
|
||||
x = x + (int)stringSize.Width;
|
||||
break;
|
||||
}
|
||||
|
||||
g.DrawImageUnscaled(Image, x, y);
|
||||
}
|
||||
|
||||
using (var b = new SolidBrush(textColor))
|
||||
{
|
||||
var modRect = new Rectangle(rect.Left + textOffsetX + Padding.Left,
|
||||
rect.Top + textOffsetY + Padding.Top, rect.Width - Padding.Horizontal,
|
||||
rect.Height - Padding.Vertical);
|
||||
|
||||
var stringFormat = new StringFormat
|
||||
{
|
||||
LineAlignment = StringAlignment.Center,
|
||||
Alignment = StringAlignment.Center,
|
||||
Trimming = StringTrimming.EllipsisCharacter
|
||||
};
|
||||
|
||||
g.DrawString(Text, Font, b, modRect, stringFormat);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
8
DarkUI/Controls/DarkButtonStyle.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public enum DarkButtonStyle
|
||||
{
|
||||
Normal,
|
||||
Flat
|
||||
}
|
||||
}
|
350
DarkUI/Controls/DarkCheckBox.cs
Normal file
@ -0,0 +1,350 @@
|
||||
using DarkUI.Config;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkCheckBox : CheckBox
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private DarkControlState _controlState = DarkControlState.Normal;
|
||||
|
||||
private bool _spacePressed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Appearance Appearance
|
||||
{
|
||||
get { return base.Appearance; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool AutoEllipsis
|
||||
{
|
||||
get { return base.AutoEllipsis; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Image BackgroundImage
|
||||
{
|
||||
get { return base.BackgroundImage; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new ImageLayout BackgroundImageLayout
|
||||
{
|
||||
get { return base.BackgroundImageLayout; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool FlatAppearance
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new FlatStyle FlatStyle
|
||||
{
|
||||
get { return base.FlatStyle; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Image Image
|
||||
{
|
||||
get { return base.Image; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new ContentAlignment ImageAlign
|
||||
{
|
||||
get { return base.ImageAlign; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new int ImageIndex
|
||||
{
|
||||
get { return base.ImageIndex; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new string ImageKey
|
||||
{
|
||||
get { return base.ImageKey; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new ImageList ImageList
|
||||
{
|
||||
get { return base.ImageList; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new ContentAlignment TextAlign
|
||||
{
|
||||
get { return base.TextAlign; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new TextImageRelation TextImageRelation
|
||||
{
|
||||
get { return base.TextImageRelation; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool ThreeState
|
||||
{
|
||||
get { return base.ThreeState; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool UseCompatibleTextRendering
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool UseVisualStyleBackColor
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkCheckBox()
|
||||
{
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor |
|
||||
ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.UserPaint, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
private void SetControlState(DarkControlState controlState)
|
||||
{
|
||||
if (_controlState != controlState)
|
||||
{
|
||||
_controlState = controlState;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (ClientRectangle.Contains(e.Location))
|
||||
SetControlState(DarkControlState.Pressed);
|
||||
else
|
||||
SetControlState(DarkControlState.Hover);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetControlState(DarkControlState.Hover);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (!ClientRectangle.Contains(e.Location))
|
||||
return;
|
||||
|
||||
SetControlState(DarkControlState.Pressed);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
SetControlState(DarkControlState.Normal);
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
SetControlState(DarkControlState.Normal);
|
||||
}
|
||||
|
||||
protected override void OnMouseCaptureChanged(EventArgs e)
|
||||
{
|
||||
base.OnMouseCaptureChanged(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
var location = Cursor.Position;
|
||||
|
||||
if (!ClientRectangle.Contains(location))
|
||||
SetControlState(DarkControlState.Normal);
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
|
||||
_spacePressed = false;
|
||||
|
||||
var location = Cursor.Position;
|
||||
|
||||
if (!ClientRectangle.Contains(location))
|
||||
SetControlState(DarkControlState.Normal);
|
||||
else
|
||||
SetControlState(DarkControlState.Hover);
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
|
||||
if (e.KeyCode == Keys.Space)
|
||||
{
|
||||
_spacePressed = true;
|
||||
SetControlState(DarkControlState.Pressed);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnKeyUp(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyUp(e);
|
||||
|
||||
if (e.KeyCode == Keys.Space)
|
||||
{
|
||||
_spacePressed = false;
|
||||
|
||||
var location = Cursor.Position;
|
||||
|
||||
if (!ClientRectangle.Contains(location))
|
||||
SetControlState(DarkControlState.Normal);
|
||||
else
|
||||
SetControlState(DarkControlState.Hover);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
var rect = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);
|
||||
|
||||
var size = Consts.CheckBoxSize;
|
||||
|
||||
var textColor = Colors.LightText;
|
||||
var borderColor = Colors.LightText;
|
||||
var fillColor = Colors.LightestBackground;
|
||||
|
||||
if (Enabled)
|
||||
{
|
||||
if (Focused)
|
||||
{
|
||||
borderColor = Colors.BlueHighlight;
|
||||
fillColor = Colors.BlueSelection;
|
||||
}
|
||||
|
||||
if (_controlState == DarkControlState.Hover)
|
||||
{
|
||||
borderColor = Colors.BlueHighlight;
|
||||
fillColor = Colors.BlueSelection;
|
||||
}
|
||||
else if (_controlState == DarkControlState.Pressed)
|
||||
{
|
||||
borderColor = Colors.GreyHighlight;
|
||||
fillColor = Colors.GreySelection;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
textColor = Colors.DisabledText;
|
||||
borderColor = Colors.GreyHighlight;
|
||||
fillColor = Colors.GreySelection;
|
||||
}
|
||||
|
||||
using (var b = new SolidBrush(Colors.GreyBackground))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
|
||||
using (var p = new Pen(borderColor))
|
||||
{
|
||||
var boxRect = new Rectangle(0, (rect.Height / 2) - (size / 2), size, size);
|
||||
g.DrawRectangle(p, boxRect);
|
||||
}
|
||||
|
||||
if (Checked)
|
||||
{
|
||||
using (var b = new SolidBrush(fillColor))
|
||||
{
|
||||
Rectangle boxRect = new Rectangle(2, (rect.Height / 2) - ((size - 4) / 2), size - 3, size - 3);
|
||||
g.FillRectangle(b, boxRect);
|
||||
}
|
||||
}
|
||||
|
||||
using (var b = new SolidBrush(textColor))
|
||||
{
|
||||
var stringFormat = new StringFormat
|
||||
{
|
||||
LineAlignment = StringAlignment.Center,
|
||||
Alignment = StringAlignment.Near
|
||||
};
|
||||
|
||||
var modRect = new Rectangle(size + 4, 0, rect.Width - size, rect.Height);
|
||||
g.DrawString(Text, Font, b, modRect, stringFormat);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
9
DarkUI/Controls/DarkContentAlignment.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public enum DarkContentAlignment
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
}
|
17
DarkUI/Controls/DarkContextMenu.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using DarkUI.Renderers;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkContextMenu : ContextMenuStrip
|
||||
{
|
||||
#region Constructor Region
|
||||
|
||||
public DarkContextMenu()
|
||||
{
|
||||
Renderer = new DarkMenuRenderer();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
9
DarkUI/Controls/DarkControlState.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public enum DarkControlState
|
||||
{
|
||||
Normal,
|
||||
Hover,
|
||||
Pressed
|
||||
}
|
||||
}
|
105
DarkUI/Controls/DarkLabel.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using DarkUI.Config;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkLabel : Label
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private bool _autoUpdateHeight;
|
||||
private bool _isGrowing;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Category("Layout")]
|
||||
[Description("Enables automatic height sizing based on the contents of the label.")]
|
||||
[DefaultValue(false)]
|
||||
public bool AutoUpdateHeight
|
||||
{
|
||||
get { return _autoUpdateHeight; }
|
||||
set
|
||||
{
|
||||
_autoUpdateHeight = value;
|
||||
|
||||
if (_autoUpdateHeight)
|
||||
{
|
||||
AutoSize = false;
|
||||
ResizeLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new bool AutoSize
|
||||
{
|
||||
get { return base.AutoSize; }
|
||||
set
|
||||
{
|
||||
base.AutoSize = value;
|
||||
|
||||
if (AutoSize)
|
||||
AutoUpdateHeight = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkLabel()
|
||||
{
|
||||
ForeColor = Colors.LightText;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
private void ResizeLabel()
|
||||
{
|
||||
if (!_autoUpdateHeight || _isGrowing)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
_isGrowing = true;
|
||||
var sz = new Size(Width, int.MaxValue);
|
||||
sz = TextRenderer.MeasureText(Text, Font, sz, TextFormatFlags.WordBreak);
|
||||
Height = sz.Height + Padding.Vertical;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isGrowing = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnTextChanged(EventArgs e)
|
||||
{
|
||||
base.OnTextChanged(e);
|
||||
ResizeLabel();
|
||||
}
|
||||
|
||||
protected override void OnFontChanged(EventArgs e)
|
||||
{
|
||||
base.OnFontChanged(e);
|
||||
ResizeLabel();
|
||||
}
|
||||
|
||||
protected override void OnSizeChanged(EventArgs e)
|
||||
{
|
||||
base.OnSizeChanged(e);
|
||||
ResizeLabel();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
61
DarkUI/Controls/DarkListItem.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using DarkUI.Config;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkListItem
|
||||
{
|
||||
#region Event Region
|
||||
|
||||
public event EventHandler TextChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Field Region
|
||||
|
||||
private string _text;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return _text; }
|
||||
set
|
||||
{
|
||||
_text = value;
|
||||
|
||||
if (TextChanged != null)
|
||||
TextChanged(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
public Rectangle Area { get; set; }
|
||||
|
||||
public Color TextColor { get; set; }
|
||||
|
||||
public FontStyle FontStyle { get; set; }
|
||||
|
||||
public object Tag { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkListItem()
|
||||
{
|
||||
TextColor = Colors.LightText;
|
||||
FontStyle = FontStyle.Regular;
|
||||
}
|
||||
|
||||
public DarkListItem(string text)
|
||||
: this()
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
545
DarkUI/Controls/DarkListView.cs
Normal file
@ -0,0 +1,545 @@
|
||||
using DarkUI.Config;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkListView : DarkScrollView
|
||||
{
|
||||
#region Event Region
|
||||
|
||||
public event EventHandler SelectedIndicesChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Field Region
|
||||
|
||||
private int _itemHeight = 20;
|
||||
private bool _multiSelect;
|
||||
|
||||
private ObservableCollection<DarkListItem> _items;
|
||||
private List<int> _selectedIndices;
|
||||
private int _anchoredItemStart = -1;
|
||||
private int _anchoredItemEnd = -1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public ObservableCollection<DarkListItem> Items
|
||||
{
|
||||
get { return _items; }
|
||||
set
|
||||
{
|
||||
if (_items != null)
|
||||
_items.CollectionChanged -= Items_CollectionChanged;
|
||||
|
||||
_items = value;
|
||||
|
||||
_items.CollectionChanged += Items_CollectionChanged;
|
||||
|
||||
UpdateListBox();
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public List<int> SelectedIndices
|
||||
{
|
||||
get { return _selectedIndices; }
|
||||
}
|
||||
|
||||
[Category("Appearance")]
|
||||
[Description("Determines the height of the individual list view items.")]
|
||||
[DefaultValue(20)]
|
||||
public int ItemHeight
|
||||
{
|
||||
get { return _itemHeight; }
|
||||
set
|
||||
{
|
||||
_itemHeight = value;
|
||||
UpdateListBox();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behaviour")]
|
||||
[Description("Determines whether multiple list view items can be selected at once.")]
|
||||
[DefaultValue(false)]
|
||||
public bool MultiSelect
|
||||
{
|
||||
get { return _multiSelect; }
|
||||
set { _multiSelect = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkListView()
|
||||
{
|
||||
Items = new ObservableCollection<DarkListItem>();
|
||||
_selectedIndices = new List<int>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
private void Items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.NewItems != null)
|
||||
{
|
||||
using (var g = CreateGraphics())
|
||||
{
|
||||
// Set the area size of all new items
|
||||
foreach (DarkListItem item in e.NewItems)
|
||||
{
|
||||
item.TextChanged += Item_TextChanged;
|
||||
UpdateItemSize(item, g);
|
||||
}
|
||||
}
|
||||
|
||||
// Find the starting index of the new item list and update anything past that
|
||||
if (e.NewStartingIndex < (Items.Count - 1))
|
||||
{
|
||||
for (var i = e.NewStartingIndex; i <= Items.Count - 1; i++)
|
||||
{
|
||||
UpdateItemPosition(Items[i], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.OldItems != null)
|
||||
{
|
||||
foreach (DarkListItem item in e.OldItems)
|
||||
item.TextChanged -= Item_TextChanged;
|
||||
|
||||
// Find the starting index of the old item list and update anything past that
|
||||
if (e.OldStartingIndex < (Items.Count - 1))
|
||||
{
|
||||
for (var i = e.OldStartingIndex; i <= Items.Count - 1; i++)
|
||||
{
|
||||
UpdateItemPosition(Items[i], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Items.Count == 0)
|
||||
{
|
||||
if (_selectedIndices.Count > 0)
|
||||
{
|
||||
_selectedIndices.Clear();
|
||||
|
||||
if (SelectedIndicesChanged != null)
|
||||
SelectedIndicesChanged(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateContentSize();
|
||||
}
|
||||
|
||||
private void Item_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
var item = (DarkListItem)sender;
|
||||
|
||||
UpdateItemSize(item);
|
||||
UpdateContentSize(item);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (Items.Count == 0)
|
||||
return;
|
||||
|
||||
if (e.Button != MouseButtons.Left && e.Button != MouseButtons.Right)
|
||||
return;
|
||||
|
||||
var pos = OffsetMousePosition;
|
||||
|
||||
var range = ItemIndexesInView().ToList();
|
||||
|
||||
var top = range.Min();
|
||||
var bottom = range.Max();
|
||||
var width = Math.Max(ContentSize.Width, Viewport.Width);
|
||||
|
||||
for (var i = top; i <= bottom; i++)
|
||||
{
|
||||
var rect = new Rectangle(0, i * ItemHeight, width, ItemHeight);
|
||||
|
||||
if (rect.Contains(pos))
|
||||
{
|
||||
if (MultiSelect && ModifierKeys == Keys.Shift)
|
||||
SelectAnchoredRange(i);
|
||||
else if (MultiSelect && ModifierKeys == Keys.Control)
|
||||
ToggleItem(i);
|
||||
else
|
||||
SelectItem(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
|
||||
if (Items.Count == 0)
|
||||
return;
|
||||
|
||||
if (e.KeyCode != Keys.Down && e.KeyCode != Keys.Up)
|
||||
return;
|
||||
|
||||
if (MultiSelect && ModifierKeys == Keys.Shift)
|
||||
{
|
||||
if (e.KeyCode == Keys.Up)
|
||||
{
|
||||
if (_anchoredItemEnd - 1 >= 0)
|
||||
{
|
||||
SelectAnchoredRange(_anchoredItemEnd - 1);
|
||||
EnsureVisible();
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == Keys.Down)
|
||||
{
|
||||
if (_anchoredItemEnd + 1 <= Items.Count - 1)
|
||||
{
|
||||
SelectAnchoredRange(_anchoredItemEnd + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e.KeyCode == Keys.Up)
|
||||
{
|
||||
if (_anchoredItemEnd - 1 >= 0)
|
||||
SelectItem(_anchoredItemEnd - 1);
|
||||
}
|
||||
else if (e.KeyCode == Keys.Down)
|
||||
{
|
||||
if (_anchoredItemEnd + 1 <= Items.Count - 1)
|
||||
SelectItem(_anchoredItemEnd + 1);
|
||||
}
|
||||
}
|
||||
|
||||
EnsureVisible();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public int GetItemIndex(DarkListItem item)
|
||||
{
|
||||
return Items.IndexOf(item);
|
||||
}
|
||||
|
||||
public void SelectItem(int index)
|
||||
{
|
||||
if (index < 0 || index > Items.Count - 1)
|
||||
throw new IndexOutOfRangeException($"Value '{index}' is outside of valid range.");
|
||||
|
||||
_selectedIndices.Clear();
|
||||
_selectedIndices.Add(index);
|
||||
|
||||
if (SelectedIndicesChanged != null)
|
||||
SelectedIndicesChanged(this, null);
|
||||
|
||||
_anchoredItemStart = index;
|
||||
_anchoredItemEnd = index;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public void SelectItems(IEnumerable<int> indexes)
|
||||
{
|
||||
_selectedIndices.Clear();
|
||||
|
||||
var list = indexes.ToList();
|
||||
|
||||
foreach (var index in list)
|
||||
{
|
||||
if (index < 0 || index > Items.Count - 1)
|
||||
throw new IndexOutOfRangeException($"Value '{index}' is outside of valid range.");
|
||||
|
||||
_selectedIndices.Add(index);
|
||||
}
|
||||
|
||||
if (SelectedIndicesChanged != null)
|
||||
SelectedIndicesChanged(this, null);
|
||||
|
||||
_anchoredItemStart = list[list.Count - 1];
|
||||
_anchoredItemEnd = list[list.Count - 1];
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public void ToggleItem(int index)
|
||||
{
|
||||
if (_selectedIndices.Contains(index))
|
||||
{
|
||||
_selectedIndices.Remove(index);
|
||||
|
||||
// If we just removed both the anchor start AND end then reset them
|
||||
if (_anchoredItemStart == index && _anchoredItemEnd == index)
|
||||
{
|
||||
if (_selectedIndices.Count > 0)
|
||||
{
|
||||
_anchoredItemStart = _selectedIndices[0];
|
||||
_anchoredItemEnd = _selectedIndices[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
_anchoredItemStart = -1;
|
||||
_anchoredItemEnd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// If we just removed the anchor start then update it accordingly
|
||||
if (_anchoredItemStart == index)
|
||||
{
|
||||
if (_anchoredItemEnd < index)
|
||||
_anchoredItemStart = index - 1;
|
||||
else if (_anchoredItemEnd > index)
|
||||
_anchoredItemStart = index + 1;
|
||||
else
|
||||
_anchoredItemStart = _anchoredItemEnd;
|
||||
}
|
||||
|
||||
// If we just removed the anchor end then update it accordingly
|
||||
if (_anchoredItemEnd == index)
|
||||
{
|
||||
if (_anchoredItemStart < index)
|
||||
_anchoredItemEnd = index - 1;
|
||||
else if (_anchoredItemStart > index)
|
||||
_anchoredItemEnd = index + 1;
|
||||
else
|
||||
_anchoredItemEnd = _anchoredItemStart;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedIndices.Add(index);
|
||||
_anchoredItemStart = index;
|
||||
_anchoredItemEnd = index;
|
||||
}
|
||||
|
||||
if (SelectedIndicesChanged != null)
|
||||
SelectedIndicesChanged(this, null);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public void SelectItems(int startRange, int endRange)
|
||||
{
|
||||
_selectedIndices.Clear();
|
||||
|
||||
if (startRange == endRange)
|
||||
_selectedIndices.Add(startRange);
|
||||
|
||||
if (startRange < endRange)
|
||||
{
|
||||
for (var i = startRange; i <= endRange; i++)
|
||||
_selectedIndices.Add(i);
|
||||
}
|
||||
else if (startRange > endRange)
|
||||
{
|
||||
for (var i = startRange; i >= endRange; i--)
|
||||
_selectedIndices.Add(i);
|
||||
}
|
||||
|
||||
if (SelectedIndicesChanged != null)
|
||||
SelectedIndicesChanged(this, null);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void SelectAnchoredRange(int index)
|
||||
{
|
||||
_anchoredItemEnd = index;
|
||||
SelectItems(_anchoredItemStart, index);
|
||||
}
|
||||
|
||||
private void UpdateListBox()
|
||||
{
|
||||
using (var g = CreateGraphics())
|
||||
{
|
||||
for (var i = 0; i <= Items.Count - 1; i++)
|
||||
{
|
||||
var item = Items[i];
|
||||
UpdateItemSize(item, g);
|
||||
UpdateItemPosition(item, i);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateContentSize();
|
||||
}
|
||||
|
||||
private void UpdateItemSize(DarkListItem item)
|
||||
{
|
||||
using (var g = CreateGraphics())
|
||||
{
|
||||
UpdateItemSize(item, g);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateItemSize(DarkListItem item, Graphics g)
|
||||
{
|
||||
var size = g.MeasureString(item.Text, Font);
|
||||
size.Width++;
|
||||
|
||||
item.Area = new Rectangle(item.Area.Left, item.Area.Top, (int)size.Width, item.Area.Height);
|
||||
}
|
||||
|
||||
private void UpdateItemPosition(DarkListItem item, int index)
|
||||
{
|
||||
item.Area = new Rectangle(2, (index * ItemHeight), item.Area.Width, ItemHeight);
|
||||
}
|
||||
|
||||
private void UpdateContentSize()
|
||||
{
|
||||
var highestWidth = 0;
|
||||
|
||||
foreach (var item in Items)
|
||||
{
|
||||
if (item.Area.Right + 1 > highestWidth)
|
||||
highestWidth = item.Area.Right + 1;
|
||||
}
|
||||
|
||||
var width = highestWidth;
|
||||
var height = Items.Count * ItemHeight;
|
||||
|
||||
if (ContentSize.Width != width || ContentSize.Height != height)
|
||||
{
|
||||
ContentSize = new Size(width, height);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateContentSize(DarkListItem item)
|
||||
{
|
||||
var itemWidth = item.Area.Right + 1;
|
||||
|
||||
if (itemWidth == ContentSize.Width)
|
||||
{
|
||||
UpdateContentSize();
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemWidth > ContentSize.Width)
|
||||
{
|
||||
ContentSize = new Size(itemWidth, ContentSize.Height);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void EnsureVisible()
|
||||
{
|
||||
if (SelectedIndices.Count == 0)
|
||||
return;
|
||||
|
||||
var itemTop = -1;
|
||||
|
||||
if (!MultiSelect)
|
||||
itemTop = SelectedIndices[0] * ItemHeight;
|
||||
else
|
||||
itemTop = _anchoredItemEnd * ItemHeight;
|
||||
|
||||
var itemBottom = itemTop + ItemHeight;
|
||||
|
||||
if (itemTop < Viewport.Top)
|
||||
VScrollTo(itemTop);
|
||||
|
||||
if (itemBottom > Viewport.Bottom)
|
||||
VScrollTo((itemBottom - Viewport.Height));
|
||||
}
|
||||
|
||||
private IEnumerable<int> ItemIndexesInView()
|
||||
{
|
||||
var top = (Viewport.Top / ItemHeight) - 1;
|
||||
|
||||
if (top < 0)
|
||||
top = 0;
|
||||
|
||||
var bottom = ((Viewport.Top + Viewport.Height) / ItemHeight) + 1;
|
||||
|
||||
if (bottom > Items.Count)
|
||||
bottom = Items.Count;
|
||||
|
||||
var result = Enumerable.Range(top, bottom - top);
|
||||
return result;
|
||||
}
|
||||
|
||||
private IEnumerable<DarkListItem> ItemsInView()
|
||||
{
|
||||
var indexes = ItemIndexesInView();
|
||||
var result = indexes.Select(index => Items[index]).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void PaintContent(Graphics g)
|
||||
{
|
||||
var range = ItemIndexesInView().ToList();
|
||||
|
||||
if (range.Count == 0)
|
||||
return;
|
||||
|
||||
var top = range.Min();
|
||||
var bottom = range.Max();
|
||||
|
||||
for (var i = top; i <= bottom; i++)
|
||||
{
|
||||
var width = Math.Max(ContentSize.Width, Viewport.Width);
|
||||
var rect = new Rectangle(0, i * ItemHeight, width, ItemHeight);
|
||||
|
||||
// Background
|
||||
var odd = i % 2 != 0;
|
||||
var bgColor = !odd ? Colors.HeaderBackground : Colors.GreyBackground;
|
||||
|
||||
if (SelectedIndices.Count > 0 && SelectedIndices.Contains(i))
|
||||
bgColor = Focused ? Colors.BlueSelection : Colors.GreySelection;
|
||||
|
||||
using (var b = new SolidBrush(bgColor))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
|
||||
// DEBUG: Border
|
||||
/*using (var p = new Pen(Colors.DarkBorder))
|
||||
{
|
||||
g.DrawLine(p, new Point(rect.Left, rect.Bottom - 1), new Point(rect.Right, rect.Bottom - 1));
|
||||
}*/
|
||||
|
||||
// Text
|
||||
using (var b = new SolidBrush(Items[i].TextColor))
|
||||
{
|
||||
var stringFormat = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Near,
|
||||
LineAlignment = StringAlignment.Center
|
||||
};
|
||||
|
||||
var modFont = new Font(Font, Items[i].FontStyle);
|
||||
|
||||
var modRect = new Rectangle(rect.Left + 2, rect.Top, rect.Width, rect.Height);
|
||||
g.DrawString(Items[i].Text, modFont, b, modRect, stringFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
18
DarkUI/Controls/DarkMenuStrip.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using DarkUI.Renderers;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkMenuStrip : MenuStrip
|
||||
{
|
||||
#region Constructor Region
|
||||
|
||||
public DarkMenuStrip()
|
||||
{
|
||||
Renderer = new DarkMenuRenderer();
|
||||
Padding = new Padding(3, 2, 0, 2);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
320
DarkUI/Controls/DarkRadioButton.cs
Normal file
@ -0,0 +1,320 @@
|
||||
using DarkUI.Config;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkRadioButton : RadioButton
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private DarkControlState _controlState = DarkControlState.Normal;
|
||||
|
||||
private bool _spacePressed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Appearance Appearance
|
||||
{
|
||||
get { return base.Appearance; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool AutoEllipsis
|
||||
{
|
||||
get { return base.AutoEllipsis; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Image BackgroundImage
|
||||
{
|
||||
get { return base.BackgroundImage; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new ImageLayout BackgroundImageLayout
|
||||
{
|
||||
get { return base.BackgroundImageLayout; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool FlatAppearance
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new FlatStyle FlatStyle
|
||||
{
|
||||
get { return base.FlatStyle; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Image Image
|
||||
{
|
||||
get { return base.Image; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new ContentAlignment ImageAlign
|
||||
{
|
||||
get { return base.ImageAlign; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new int ImageIndex
|
||||
{
|
||||
get { return base.ImageIndex; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new string ImageKey
|
||||
{
|
||||
get { return base.ImageKey; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new ImageList ImageList
|
||||
{
|
||||
get { return base.ImageList; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new ContentAlignment TextAlign
|
||||
{
|
||||
get { return base.TextAlign; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new TextImageRelation TextImageRelation
|
||||
{
|
||||
get { return base.TextImageRelation; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool UseCompatibleTextRendering
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool UseVisualStyleBackColor
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkRadioButton()
|
||||
{
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor |
|
||||
ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.UserPaint, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
private void SetControlState(DarkControlState controlState)
|
||||
{
|
||||
if (_controlState != controlState)
|
||||
{
|
||||
_controlState = controlState;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (ClientRectangle.Contains(e.Location))
|
||||
SetControlState(DarkControlState.Pressed);
|
||||
else
|
||||
SetControlState(DarkControlState.Hover);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetControlState(DarkControlState.Hover);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (!ClientRectangle.Contains(e.Location))
|
||||
return;
|
||||
|
||||
SetControlState(DarkControlState.Pressed);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
SetControlState(DarkControlState.Normal);
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
SetControlState(DarkControlState.Normal);
|
||||
}
|
||||
|
||||
protected override void OnMouseCaptureChanged(EventArgs e)
|
||||
{
|
||||
base.OnMouseCaptureChanged(e);
|
||||
|
||||
if (_spacePressed)
|
||||
return;
|
||||
|
||||
var location = Cursor.Position;
|
||||
|
||||
if (!ClientRectangle.Contains(location))
|
||||
SetControlState(DarkControlState.Normal);
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
|
||||
_spacePressed = false;
|
||||
|
||||
var location = Cursor.Position;
|
||||
|
||||
if (!ClientRectangle.Contains(location))
|
||||
SetControlState(DarkControlState.Normal);
|
||||
else
|
||||
SetControlState(DarkControlState.Hover);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
var rect = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);
|
||||
|
||||
var size = Consts.RadioButtonSize;
|
||||
|
||||
var textColor = Colors.LightText;
|
||||
var borderColor = Colors.LightText;
|
||||
var fillColor = Colors.LightestBackground;
|
||||
|
||||
if (Enabled)
|
||||
{
|
||||
if (Focused)
|
||||
{
|
||||
borderColor = Colors.BlueHighlight;
|
||||
fillColor = Colors.BlueSelection;
|
||||
}
|
||||
|
||||
if (_controlState == DarkControlState.Hover)
|
||||
{
|
||||
borderColor = Colors.BlueHighlight;
|
||||
fillColor = Colors.BlueSelection;
|
||||
}
|
||||
else if (_controlState == DarkControlState.Pressed)
|
||||
{
|
||||
borderColor = Colors.GreyHighlight;
|
||||
fillColor = Colors.GreySelection;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
textColor = Colors.DisabledText;
|
||||
borderColor = Colors.GreyHighlight;
|
||||
fillColor = Colors.GreySelection;
|
||||
}
|
||||
|
||||
using (var b = new SolidBrush(Colors.GreyBackground))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
|
||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
||||
using (var p = new Pen(borderColor))
|
||||
{
|
||||
var boxRect = new Rectangle(0, (rect.Height / 2) - (size / 2), size, size);
|
||||
g.DrawEllipse(p, boxRect);
|
||||
}
|
||||
|
||||
if (Checked)
|
||||
{
|
||||
using (var b = new SolidBrush(fillColor))
|
||||
{
|
||||
Rectangle boxRect = new Rectangle(3, (rect.Height / 2) - ((size - 7) / 2) - 1, size - 6, size - 6);
|
||||
g.FillEllipse(b, boxRect);
|
||||
}
|
||||
}
|
||||
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
|
||||
using (var b = new SolidBrush(textColor))
|
||||
{
|
||||
var stringFormat = new StringFormat
|
||||
{
|
||||
LineAlignment = StringAlignment.Center,
|
||||
Alignment = StringAlignment.Near
|
||||
};
|
||||
|
||||
var modRect = new Rectangle(size + 4, 0, rect.Width - size, rect.Height);
|
||||
g.DrawString(Text, Font, b, modRect, stringFormat);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
532
DarkUI/Controls/DarkScrollBar.cs
Normal file
@ -0,0 +1,532 @@
|
||||
using DarkUI.Config;
|
||||
using DarkUI.Icons;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkScrollBar : Control
|
||||
{
|
||||
#region Event Region
|
||||
|
||||
public event EventHandler<ScrollValueEventArgs> ValueChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Field Region
|
||||
|
||||
private DarkScrollOrientation _scrollOrientation;
|
||||
|
||||
private int _value;
|
||||
private int _minimum = 0;
|
||||
private int _maximum = 100;
|
||||
|
||||
private int _viewSize;
|
||||
|
||||
private Rectangle _trackArea;
|
||||
private float _viewContentRatio;
|
||||
|
||||
private Rectangle _thumbArea;
|
||||
private Rectangle _upArrowArea;
|
||||
private Rectangle _downArrowArea;
|
||||
|
||||
private bool _thumbHot;
|
||||
private bool _upArrowHot;
|
||||
private bool _downArrowHot;
|
||||
|
||||
private bool _thumbClicked;
|
||||
private bool _upArrowClicked;
|
||||
private bool _downArrowClicked;
|
||||
|
||||
private bool _isScrolling;
|
||||
private int _initialValue;
|
||||
private Point _initialContact;
|
||||
|
||||
private Timer _scrollTimer;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Category("Behavior")]
|
||||
[Description("The orientation type of the scrollbar.")]
|
||||
[DefaultValue(DarkScrollOrientation.Vertical)]
|
||||
public DarkScrollOrientation ScrollOrientation
|
||||
{
|
||||
get { return _scrollOrientation; }
|
||||
set
|
||||
{
|
||||
_scrollOrientation = value;
|
||||
UpdateScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[Description("The value that the scroll thumb position represents.")]
|
||||
[DefaultValue(0)]
|
||||
public int Value
|
||||
{
|
||||
get { return _value; }
|
||||
set
|
||||
{
|
||||
if (value < Minimum)
|
||||
value = Minimum;
|
||||
|
||||
var maximumValue = Maximum - ViewSize;
|
||||
if (value > maximumValue)
|
||||
value = maximumValue;
|
||||
|
||||
if (_value == value)
|
||||
return;
|
||||
|
||||
_value = value;
|
||||
|
||||
UpdateThumb(true);
|
||||
|
||||
if (ValueChanged != null)
|
||||
ValueChanged(this, new ScrollValueEventArgs(Value));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[Description("The lower limit value of the scrollable range.")]
|
||||
[DefaultValue(0)]
|
||||
public int Minimum
|
||||
{
|
||||
get { return _minimum; }
|
||||
set
|
||||
{
|
||||
_minimum = value;
|
||||
UpdateScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[Description("The upper limit value of the scrollable range.")]
|
||||
[DefaultValue(100)]
|
||||
public int Maximum
|
||||
{
|
||||
get { return _maximum; }
|
||||
set
|
||||
{
|
||||
_maximum = value;
|
||||
UpdateScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[Description("The view size for the scrollable area.")]
|
||||
[DefaultValue(0)]
|
||||
public int ViewSize
|
||||
{
|
||||
get { return _viewSize; }
|
||||
set
|
||||
{
|
||||
_viewSize = value;
|
||||
UpdateScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
public new bool Visible
|
||||
{
|
||||
get { return base.Visible; }
|
||||
set
|
||||
{
|
||||
if (base.Visible == value)
|
||||
return;
|
||||
|
||||
base.Visible = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkScrollBar()
|
||||
{
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.UserPaint, true);
|
||||
|
||||
SetStyle(ControlStyles.Selectable, false);
|
||||
|
||||
_scrollTimer = new Timer();
|
||||
_scrollTimer.Interval = 1;
|
||||
_scrollTimer.Tick += ScrollTimerTick;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
UpdateScrollBar();
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (_thumbArea.Contains(e.Location) && e.Button == MouseButtons.Left)
|
||||
{
|
||||
_isScrolling = true;
|
||||
_initialContact = e.Location;
|
||||
|
||||
if (_scrollOrientation == DarkScrollOrientation.Vertical)
|
||||
_initialValue = _thumbArea.Top;
|
||||
else
|
||||
_initialValue = _thumbArea.Left;
|
||||
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_upArrowArea.Contains(e.Location) && e.Button == MouseButtons.Left)
|
||||
{
|
||||
_upArrowClicked = true;
|
||||
_scrollTimer.Enabled = true;
|
||||
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_downArrowArea.Contains(e.Location) && e.Button == MouseButtons.Left)
|
||||
{
|
||||
_downArrowClicked = true;
|
||||
_scrollTimer.Enabled = true;
|
||||
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_trackArea.Contains(e.Location) && e.Button == MouseButtons.Left)
|
||||
{
|
||||
// Step 1. Check if our input is at least aligned with the thumb
|
||||
if (_scrollOrientation == DarkScrollOrientation.Vertical)
|
||||
{
|
||||
var modRect = new Rectangle(_thumbArea.Left, _trackArea.Top, _thumbArea.Width, _trackArea.Height);
|
||||
if (!modRect.Contains(e.Location))
|
||||
return;
|
||||
}
|
||||
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
|
||||
{
|
||||
var modRect = new Rectangle(_trackArea.Left, _thumbArea.Top, _trackArea.Width, _thumbArea.Height);
|
||||
if (!modRect.Contains(e.Location))
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 2. Scroll to the area initially clicked.
|
||||
if (_scrollOrientation == DarkScrollOrientation.Vertical)
|
||||
{
|
||||
var loc = e.Location.Y;
|
||||
loc -= _upArrowArea.Bottom - 1;
|
||||
loc -= _thumbArea.Height / 2;
|
||||
ScrollToPhysical(loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
var loc = e.Location.X;
|
||||
loc -= _upArrowArea.Right - 1;
|
||||
loc -= _thumbArea.Width / 2;
|
||||
ScrollToPhysical(loc);
|
||||
}
|
||||
|
||||
// Step 3. Initiate a thumb drag.
|
||||
_isScrolling = true;
|
||||
_initialContact = e.Location;
|
||||
_thumbHot = true;
|
||||
|
||||
if (_scrollOrientation == DarkScrollOrientation.Vertical)
|
||||
_initialValue = _thumbArea.Top;
|
||||
else
|
||||
_initialValue = _thumbArea.Left;
|
||||
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
_isScrolling = false;
|
||||
|
||||
_thumbClicked = false;
|
||||
_upArrowClicked = false;
|
||||
_downArrowClicked = false;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
if (!_isScrolling)
|
||||
{
|
||||
var thumbHot = _thumbArea.Contains(e.Location);
|
||||
if (_thumbHot != thumbHot)
|
||||
{
|
||||
_thumbHot = thumbHot;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
var upArrowHot = _upArrowArea.Contains(e.Location);
|
||||
if (_upArrowHot != upArrowHot)
|
||||
{
|
||||
_upArrowHot = upArrowHot;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
var downArrowHot = _downArrowArea.Contains(e.Location);
|
||||
if (_downArrowHot != downArrowHot)
|
||||
{
|
||||
_downArrowHot = downArrowHot;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
if (_isScrolling)
|
||||
{
|
||||
if (e.Button != MouseButtons.Left)
|
||||
{
|
||||
OnMouseUp(null);
|
||||
return;
|
||||
}
|
||||
|
||||
var difference = new Point(e.Location.X - _initialContact.X, e.Location.Y - _initialContact.Y);
|
||||
|
||||
if (_scrollOrientation == DarkScrollOrientation.Vertical)
|
||||
{
|
||||
var thumbPos = (_initialValue - _trackArea.Top);
|
||||
var newPosition = thumbPos + difference.Y;
|
||||
|
||||
ScrollToPhysical(newPosition);
|
||||
}
|
||||
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
|
||||
{
|
||||
var thumbPos = (_initialValue - _trackArea.Left);
|
||||
var newPosition = thumbPos + difference.X;
|
||||
|
||||
ScrollToPhysical(newPosition);
|
||||
}
|
||||
|
||||
UpdateScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
|
||||
_thumbHot = false;
|
||||
_upArrowHot = false;
|
||||
_downArrowHot = false;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void ScrollTimerTick(object sender, EventArgs e)
|
||||
{
|
||||
if (!_upArrowClicked && !_downArrowClicked)
|
||||
{
|
||||
_scrollTimer.Enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_upArrowClicked)
|
||||
ScrollBy(-1);
|
||||
else if (_downArrowClicked)
|
||||
ScrollBy(1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public void ScrollTo(int position)
|
||||
{
|
||||
Value = position;
|
||||
}
|
||||
|
||||
public void ScrollToPhysical(int positionInPixels)
|
||||
{
|
||||
var isVert = _scrollOrientation == DarkScrollOrientation.Vertical;
|
||||
|
||||
var trackAreaSize = isVert ? _trackArea.Height - _thumbArea.Height : _trackArea.Width - _thumbArea.Width;
|
||||
|
||||
var positionRatio = (float)positionInPixels / (float)trackAreaSize;
|
||||
var viewScrollSize = (Maximum - ViewSize);
|
||||
|
||||
var newValue = (int)(positionRatio * viewScrollSize);
|
||||
Value = newValue;
|
||||
}
|
||||
|
||||
public void ScrollBy(int offset)
|
||||
{
|
||||
var newValue = Value + offset;
|
||||
ScrollTo(newValue);
|
||||
}
|
||||
|
||||
public void ScrollByPhysical(int offsetInPixels)
|
||||
{
|
||||
var isVert = _scrollOrientation == DarkScrollOrientation.Vertical;
|
||||
|
||||
var thumbPos = isVert ? (_thumbArea.Top - _trackArea.Top) : (_thumbArea.Left - _trackArea.Left);
|
||||
|
||||
var newPosition = thumbPos - offsetInPixels;
|
||||
|
||||
ScrollToPhysical(newPosition);
|
||||
}
|
||||
|
||||
public void UpdateScrollBar()
|
||||
{
|
||||
if (ViewSize >= Maximum)
|
||||
return;
|
||||
|
||||
var area = ClientRectangle;
|
||||
|
||||
// Cap to maximum value
|
||||
var maximumValue = Maximum - ViewSize;
|
||||
if (Value > maximumValue)
|
||||
Value = maximumValue;
|
||||
|
||||
// Arrow buttons
|
||||
if (_scrollOrientation == DarkScrollOrientation.Vertical)
|
||||
{
|
||||
_upArrowArea = new Rectangle(area.Left, area.Top, Consts.ArrowButtonSize, Consts.ArrowButtonSize);
|
||||
_downArrowArea = new Rectangle(area.Left, area.Bottom - Consts.ArrowButtonSize, Consts.ArrowButtonSize, Consts.ArrowButtonSize);
|
||||
}
|
||||
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
|
||||
{
|
||||
_upArrowArea = new Rectangle(area.Left, area.Top, Consts.ArrowButtonSize, Consts.ArrowButtonSize);
|
||||
_downArrowArea = new Rectangle(area.Right - Consts.ArrowButtonSize, area.Top, Consts.ArrowButtonSize, Consts.ArrowButtonSize);
|
||||
}
|
||||
|
||||
// Track
|
||||
if (_scrollOrientation == DarkScrollOrientation.Vertical)
|
||||
{
|
||||
_trackArea = new Rectangle(area.Left, area.Top + Consts.ArrowButtonSize, area.Width, area.Height - (Consts.ArrowButtonSize * 2));
|
||||
}
|
||||
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
|
||||
{
|
||||
_trackArea = new Rectangle(area.Left + Consts.ArrowButtonSize, area.Top, area.Width - (Consts.ArrowButtonSize * 2), area.Height);
|
||||
}
|
||||
|
||||
// Thumb
|
||||
UpdateThumb();
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void UpdateThumb(bool forceRefresh = false)
|
||||
{
|
||||
// Calculate size ratio
|
||||
_viewContentRatio = (float)ViewSize / (float)Maximum;
|
||||
var viewAreaSize = Maximum - ViewSize;
|
||||
var positionRatio = (float)Value / (float)viewAreaSize;
|
||||
|
||||
// Update area
|
||||
if (_scrollOrientation == DarkScrollOrientation.Vertical)
|
||||
{
|
||||
var thumbSize = (int)(_trackArea.Height * _viewContentRatio);
|
||||
|
||||
if (thumbSize < Consts.MinimumThumbSize)
|
||||
thumbSize = Consts.MinimumThumbSize;
|
||||
|
||||
var trackAreaSize = _trackArea.Height - thumbSize;
|
||||
var thumbPosition = (int)(trackAreaSize * positionRatio);
|
||||
|
||||
_thumbArea = new Rectangle(_trackArea.Left + 3, _trackArea.Top + thumbPosition, Consts.ScrollBarSize - 6, thumbSize);
|
||||
}
|
||||
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
|
||||
{
|
||||
var thumbSize = (int)(_trackArea.Width * _viewContentRatio);
|
||||
|
||||
if (thumbSize < Consts.MinimumThumbSize)
|
||||
thumbSize = Consts.MinimumThumbSize;
|
||||
|
||||
var trackAreaSize = _trackArea.Width - thumbSize;
|
||||
var thumbPosition = (int)(trackAreaSize * positionRatio);
|
||||
|
||||
_thumbArea = new Rectangle(_trackArea.Left + thumbPosition, _trackArea.Top + 3, thumbSize, Consts.ScrollBarSize - 6);
|
||||
}
|
||||
|
||||
if (forceRefresh)
|
||||
{
|
||||
Invalidate();
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
// DEBUG: Scrollbar bg
|
||||
/*using (var b = new SolidBrush(Colors.MediumBackground))
|
||||
{
|
||||
g.FillRectangle(b, ClientRectangle);
|
||||
}*/
|
||||
|
||||
// DEBUG: Arrow backgrounds
|
||||
/*using (var b = new SolidBrush(Color.White))
|
||||
{
|
||||
g.FillRectangle(b, _upArrowArea);
|
||||
g.FillRectangle(b, _downArrowArea);
|
||||
}*/
|
||||
|
||||
// Up arrow
|
||||
var upIcon = _upArrowHot ? ScrollIcons.scrollbar_arrow_hot : ScrollIcons.scrollbar_arrow_standard;
|
||||
|
||||
if (_upArrowClicked)
|
||||
upIcon = ScrollIcons.scrollbar_arrow_clicked;
|
||||
|
||||
if (_scrollOrientation == DarkScrollOrientation.Vertical)
|
||||
upIcon.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
|
||||
upIcon.RotateFlip(RotateFlipType.Rotate90FlipNone);
|
||||
|
||||
g.DrawImageUnscaled(upIcon,
|
||||
_upArrowArea.Left + (_upArrowArea.Width / 2) - (upIcon.Width / 2),
|
||||
_upArrowArea.Top + (_upArrowArea.Height / 2) - (upIcon.Height / 2));
|
||||
|
||||
// Down arrow
|
||||
var downIcon = _downArrowHot ? ScrollIcons.scrollbar_arrow_hot : ScrollIcons.scrollbar_arrow_standard;
|
||||
|
||||
if (_downArrowClicked)
|
||||
downIcon = ScrollIcons.scrollbar_arrow_clicked;
|
||||
|
||||
if (_scrollOrientation == DarkScrollOrientation.Horizontal)
|
||||
downIcon.RotateFlip(RotateFlipType.Rotate270FlipNone);
|
||||
|
||||
g.DrawImageUnscaled(downIcon,
|
||||
_downArrowArea.Left + (_downArrowArea.Width / 2) - (downIcon.Width / 2),
|
||||
_downArrowArea.Top + (_downArrowArea.Height / 2) - (downIcon.Height / 2));
|
||||
|
||||
// Draw thumb
|
||||
var scrollColor = _thumbHot ? Colors.GreyHighlight : Colors.GreySelection;
|
||||
|
||||
if (_isScrolling)
|
||||
scrollColor = Colors.ActiveControl;
|
||||
|
||||
using (var b = new SolidBrush(scrollColor))
|
||||
{
|
||||
g.FillRectangle(b, _thumbArea);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
403
DarkUI/Controls/DarkScrollBase.cs
Normal file
@ -0,0 +1,403 @@
|
||||
using DarkUI.Config;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public abstract class DarkScrollBase : Control
|
||||
{
|
||||
#region Event Region
|
||||
|
||||
public event EventHandler ViewportChanged;
|
||||
public event EventHandler ContentSizeChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Field Region
|
||||
|
||||
protected readonly DarkScrollBar _vScrollBar;
|
||||
protected readonly DarkScrollBar _hScrollBar;
|
||||
|
||||
private Size _visibleSize;
|
||||
private Size _contentSize;
|
||||
|
||||
private Rectangle _viewport;
|
||||
|
||||
private Point _offsetMousePosition;
|
||||
|
||||
private int _maxDragChange = 0;
|
||||
private Timer _dragTimer;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Rectangle Viewport
|
||||
{
|
||||
get { return _viewport; }
|
||||
private set
|
||||
{
|
||||
_viewport = value;
|
||||
|
||||
if (ViewportChanged != null)
|
||||
ViewportChanged(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Size ContentSize
|
||||
{
|
||||
get { return _contentSize; }
|
||||
set
|
||||
{
|
||||
_contentSize = value;
|
||||
UpdateScrollBars();
|
||||
|
||||
if (ContentSizeChanged != null)
|
||||
ContentSizeChanged(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Point OffsetMousePosition
|
||||
{
|
||||
get { return _offsetMousePosition; }
|
||||
}
|
||||
|
||||
[Category("Behavior")]
|
||||
[Description("Determines the maximum scroll change when dragging.")]
|
||||
[DefaultValue(0)]
|
||||
public int MaxDragChange
|
||||
{
|
||||
get { return _maxDragChange; }
|
||||
set
|
||||
{
|
||||
_maxDragChange = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool IsDragging { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
protected DarkScrollBase()
|
||||
{
|
||||
SetStyle(ControlStyles.Selectable |
|
||||
ControlStyles.UserMouse, true);
|
||||
|
||||
_vScrollBar = new DarkScrollBar { ScrollOrientation = DarkScrollOrientation.Vertical };
|
||||
_hScrollBar = new DarkScrollBar { ScrollOrientation = DarkScrollOrientation.Horizontal };
|
||||
|
||||
Controls.Add(_vScrollBar);
|
||||
Controls.Add(_hScrollBar);
|
||||
|
||||
_vScrollBar.ValueChanged += delegate { UpdateViewport(); };
|
||||
_hScrollBar.ValueChanged += delegate { UpdateViewport(); };
|
||||
|
||||
_vScrollBar.MouseDown += delegate { Select(); };
|
||||
_hScrollBar.MouseDown += delegate { Select(); };
|
||||
|
||||
_dragTimer = new Timer();
|
||||
_dragTimer.Interval = 1;
|
||||
_dragTimer.Tick += DragTimer_Tick;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
private void UpdateScrollBars()
|
||||
{
|
||||
if (_vScrollBar.Maximum != ContentSize.Height)
|
||||
_vScrollBar.Maximum = ContentSize.Height;
|
||||
|
||||
if (_hScrollBar.Maximum != ContentSize.Width)
|
||||
_hScrollBar.Maximum = ContentSize.Width;
|
||||
|
||||
var scrollSize = Consts.ScrollBarSize;
|
||||
|
||||
_vScrollBar.Location = new Point(ClientSize.Width - scrollSize, 0);
|
||||
_vScrollBar.Size = new Size(scrollSize, ClientSize.Height);
|
||||
|
||||
_hScrollBar.Location = new Point(0, ClientSize.Height - scrollSize);
|
||||
_hScrollBar.Size = new Size(ClientSize.Width, scrollSize);
|
||||
|
||||
if (DesignMode)
|
||||
return;
|
||||
|
||||
// Do this twice in case changing the visibility of the scrollbars
|
||||
// causes the VisibleSize to change in such a way as to require a second scrollbar.
|
||||
// Probably a better way to detect that scenario...
|
||||
SetVisibleSize();
|
||||
SetScrollBarVisibility();
|
||||
SetVisibleSize();
|
||||
SetScrollBarVisibility();
|
||||
|
||||
if (_vScrollBar.Visible)
|
||||
_hScrollBar.Width -= scrollSize;
|
||||
|
||||
if (_hScrollBar.Visible)
|
||||
_vScrollBar.Height -= scrollSize;
|
||||
|
||||
_vScrollBar.ViewSize = _visibleSize.Height;
|
||||
_hScrollBar.ViewSize = _visibleSize.Width;
|
||||
|
||||
UpdateViewport();
|
||||
}
|
||||
|
||||
private void SetScrollBarVisibility()
|
||||
{
|
||||
_vScrollBar.Visible = _visibleSize.Height < ContentSize.Height;
|
||||
_hScrollBar.Visible = _visibleSize.Width < ContentSize.Width;
|
||||
}
|
||||
|
||||
private void SetVisibleSize()
|
||||
{
|
||||
var scrollSize = Consts.ScrollBarSize;
|
||||
|
||||
_visibleSize = new Size(ClientSize.Width, ClientSize.Height);
|
||||
|
||||
if (_vScrollBar.Visible)
|
||||
_visibleSize.Width -= scrollSize;
|
||||
|
||||
if (_hScrollBar.Visible)
|
||||
_visibleSize.Height -= scrollSize;
|
||||
}
|
||||
|
||||
private void UpdateViewport()
|
||||
{
|
||||
var left = 0;
|
||||
var top = 0;
|
||||
var width = ClientSize.Width;
|
||||
var height = ClientSize.Height;
|
||||
|
||||
if (_hScrollBar.Visible)
|
||||
{
|
||||
left = _hScrollBar.Value;
|
||||
height -= _hScrollBar.Height;
|
||||
}
|
||||
|
||||
if (_vScrollBar.Visible)
|
||||
{
|
||||
top = _vScrollBar.Value;
|
||||
width -= _vScrollBar.Width;
|
||||
}
|
||||
|
||||
Viewport = new Rectangle(left, top, width, height);
|
||||
|
||||
var pos = PointToClient(MousePosition);
|
||||
_offsetMousePosition = new Point(pos.X + Viewport.Left, pos.Y + Viewport.Top);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public void ScrollTo(Point point)
|
||||
{
|
||||
HScrollTo(point.X);
|
||||
VScrollTo(point.Y);
|
||||
}
|
||||
|
||||
public void VScrollTo(int value)
|
||||
{
|
||||
if (_vScrollBar.Visible)
|
||||
_vScrollBar.Value = value;
|
||||
}
|
||||
|
||||
public void HScrollTo(int value)
|
||||
{
|
||||
if (_hScrollBar.Visible)
|
||||
_hScrollBar.Value = value;
|
||||
}
|
||||
|
||||
protected virtual void StartDrag()
|
||||
{
|
||||
IsDragging = true;
|
||||
_dragTimer.Start();
|
||||
}
|
||||
|
||||
protected virtual void StopDrag()
|
||||
{
|
||||
IsDragging = false;
|
||||
_dragTimer.Stop();
|
||||
}
|
||||
|
||||
public Point PointToView(Point point)
|
||||
{
|
||||
return new Point(point.X - Viewport.Left, point.Y - Viewport.Top);
|
||||
}
|
||||
|
||||
public Rectangle RectangleToView(Rectangle rect)
|
||||
{
|
||||
return new Rectangle(new Point(rect.Left - Viewport.Left, rect.Top - Viewport.Top), rect.Size);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
|
||||
UpdateScrollBars();
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
UpdateScrollBars();
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
_offsetMousePosition = new Point(e.X + Viewport.Left, e.Y + Viewport.Top);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (e.Button == MouseButtons.Right)
|
||||
Select();
|
||||
}
|
||||
|
||||
protected override void OnMouseWheel(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseWheel(e);
|
||||
|
||||
var horizontal = false;
|
||||
|
||||
if (_hScrollBar.Visible && ModifierKeys == Keys.Control)
|
||||
horizontal = true;
|
||||
|
||||
if (_hScrollBar.Visible && !_vScrollBar.Visible)
|
||||
horizontal = true;
|
||||
|
||||
if (!horizontal)
|
||||
{
|
||||
if (e.Delta > 0)
|
||||
_vScrollBar.ScrollByPhysical(3);
|
||||
else if (e.Delta < 0)
|
||||
_vScrollBar.ScrollByPhysical(-3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e.Delta > 0)
|
||||
_hScrollBar.ScrollByPhysical(3);
|
||||
else if (e.Delta < 0)
|
||||
_hScrollBar.ScrollByPhysical(-3);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPreviewKeyDown(PreviewKeyDownEventArgs e)
|
||||
{
|
||||
base.OnPreviewKeyDown(e);
|
||||
|
||||
// Allows arrow keys to trigger OnKeyPress
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Up:
|
||||
case Keys.Down:
|
||||
case Keys.Left:
|
||||
case Keys.Right:
|
||||
e.IsInputKey = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DragTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
var pos = PointToClient(MousePosition);
|
||||
|
||||
var right = ClientRectangle.Right;
|
||||
var bottom = ClientRectangle.Bottom;
|
||||
|
||||
if (_vScrollBar.Visible)
|
||||
right = _vScrollBar.Left;
|
||||
|
||||
if (_hScrollBar.Visible)
|
||||
bottom = _hScrollBar.Top;
|
||||
|
||||
if (_vScrollBar.Visible)
|
||||
{
|
||||
// Scroll up
|
||||
if (pos.Y < ClientRectangle.Top)
|
||||
{
|
||||
var difference = (pos.Y - ClientRectangle.Top) * -1;
|
||||
|
||||
if (MaxDragChange > 0 && difference > MaxDragChange)
|
||||
difference = MaxDragChange;
|
||||
|
||||
_vScrollBar.Value = _vScrollBar.Value - difference;
|
||||
}
|
||||
|
||||
// Scroll down
|
||||
if (pos.Y > bottom)
|
||||
{
|
||||
var difference = pos.Y - bottom;
|
||||
|
||||
if (MaxDragChange > 0 && difference > MaxDragChange)
|
||||
difference = MaxDragChange;
|
||||
|
||||
_vScrollBar.Value = _vScrollBar.Value + difference;
|
||||
}
|
||||
}
|
||||
|
||||
if (_hScrollBar.Visible)
|
||||
{
|
||||
// Scroll left
|
||||
if (pos.X < ClientRectangle.Left)
|
||||
{
|
||||
var difference = (pos.X - ClientRectangle.Left) * -1;
|
||||
|
||||
if (MaxDragChange > 0 && difference > MaxDragChange)
|
||||
difference = MaxDragChange;
|
||||
|
||||
_hScrollBar.Value = _hScrollBar.Value - difference;
|
||||
}
|
||||
|
||||
// Scroll right
|
||||
if (pos.X > right)
|
||||
{
|
||||
var difference = pos.X - right;
|
||||
|
||||
if (MaxDragChange > 0 && difference > MaxDragChange)
|
||||
difference = MaxDragChange;
|
||||
|
||||
_hScrollBar.Value = _hScrollBar.Value + difference;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
8
DarkUI/Controls/DarkScrollOrientation.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public enum DarkScrollOrientation
|
||||
{
|
||||
Vertical,
|
||||
Horizontal
|
||||
}
|
||||
}
|
60
DarkUI/Controls/DarkScrollView.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public abstract class DarkScrollView : DarkScrollBase
|
||||
{
|
||||
#region Constructor Region
|
||||
|
||||
protected DarkScrollView()
|
||||
{
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.UserPaint, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected abstract void PaintContent(Graphics g);
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
// Draw background
|
||||
using (var b = new SolidBrush(BackColor))
|
||||
{
|
||||
g.FillRectangle(b, ClientRectangle);
|
||||
}
|
||||
|
||||
// Offset the graphics based on the viewport, render the control contents, then reset it.
|
||||
g.TranslateTransform(Viewport.Left * -1, Viewport.Top * -1);
|
||||
|
||||
PaintContent(g);
|
||||
|
||||
g.TranslateTransform(Viewport.Left, Viewport.Top);
|
||||
|
||||
// Draw the bit where the scrollbars meet
|
||||
if (_vScrollBar.Visible && _hScrollBar.Visible)
|
||||
{
|
||||
using (var b = new SolidBrush(BackColor))
|
||||
{
|
||||
var rect = new Rectangle(_hScrollBar.Right, _vScrollBar.Bottom, _vScrollBar.Width,
|
||||
_hScrollBar.Height);
|
||||
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
// Absorb event
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
146
DarkUI/Controls/DarkSectionPanel.cs
Normal file
@ -0,0 +1,146 @@
|
||||
using DarkUI.Config;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkSectionPanel : Panel
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private string _sectionHeader;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Padding Padding
|
||||
{
|
||||
get { return base.Padding; }
|
||||
}
|
||||
|
||||
[Category("Appearance")]
|
||||
[Description("The section header text associated with this control.")]
|
||||
public string SectionHeader
|
||||
{
|
||||
get { return _sectionHeader; }
|
||||
set
|
||||
{
|
||||
_sectionHeader = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkSectionPanel()
|
||||
{
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.UserPaint, true);
|
||||
|
||||
base.Padding = new Padding(1, 25, 1, 1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnEnter(System.EventArgs e)
|
||||
{
|
||||
base.OnEnter(e);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnLeave(System.EventArgs e)
|
||||
{
|
||||
base.OnLeave(e);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (Controls.Count > 0)
|
||||
Controls[0].Focus();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
var rect = ClientRectangle;
|
||||
|
||||
// Fill body
|
||||
using (var b = new SolidBrush(Colors.GreyBackground))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
|
||||
// Draw header
|
||||
var bgColor = ContainsFocus ? Colors.BlueBackground : Colors.HeaderBackground;
|
||||
var darkColor = ContainsFocus ? Colors.DarkBlueBorder : Colors.DarkBorder;
|
||||
var lightColor = ContainsFocus ? Colors.LightBlueBorder : Colors.LightBorder;
|
||||
|
||||
using (var b = new SolidBrush(bgColor))
|
||||
{
|
||||
var bgRect = new Rectangle(0, 0, rect.Width, 25);
|
||||
g.FillRectangle(b, bgRect);
|
||||
}
|
||||
|
||||
using (var p = new Pen(darkColor))
|
||||
{
|
||||
g.DrawLine(p, rect.Left, 0, rect.Right, 0);
|
||||
g.DrawLine(p, rect.Left, 25 - 1, rect.Right, 25 - 1);
|
||||
}
|
||||
|
||||
using (var p = new Pen(lightColor))
|
||||
{
|
||||
g.DrawLine(p, rect.Left, 1, rect.Right, 1);
|
||||
}
|
||||
|
||||
var xOffset = 3;
|
||||
|
||||
using (var b = new SolidBrush(Colors.LightText))
|
||||
{
|
||||
var textRect = new Rectangle(xOffset, 0, rect.Width - 4 - xOffset, 25);
|
||||
|
||||
var format = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Near,
|
||||
LineAlignment = StringAlignment.Center,
|
||||
FormatFlags = StringFormatFlags.NoWrap,
|
||||
Trimming = StringTrimming.EllipsisCharacter
|
||||
};
|
||||
|
||||
g.DrawString(SectionHeader, Font, b, textRect, format);
|
||||
}
|
||||
|
||||
// Draw border
|
||||
using (var p = new Pen(Colors.DarkBorder, 1))
|
||||
{
|
||||
var modRect = new Rectangle(rect.Left, rect.Top, rect.Width - 1, rect.Height - 1);
|
||||
|
||||
g.DrawRectangle(p, modRect);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
// Absorb event
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
45
DarkUI/Controls/DarkSeparator.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using DarkUI.Config;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkSeparator : Control
|
||||
{
|
||||
#region Constructor Region
|
||||
|
||||
public DarkSeparator()
|
||||
{
|
||||
SetStyle(ControlStyles.Selectable, false);
|
||||
|
||||
Dock = DockStyle.Top;
|
||||
Size = new Size(1, 2);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
using (var p = new Pen(Colors.DarkBorder))
|
||||
{
|
||||
g.DrawLine(p, ClientRectangle.Left, 0, ClientRectangle.Right, 0);
|
||||
}
|
||||
|
||||
using (var p = new Pen(Colors.LightBorder))
|
||||
{
|
||||
g.DrawLine(p, ClientRectangle.Left, 1, ClientRectangle.Right, 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
// Absorb event
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
47
DarkUI/Controls/DarkStatusStrip.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using DarkUI.Config;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkStatusStrip : StatusStrip
|
||||
{
|
||||
#region Constructor Region
|
||||
|
||||
public DarkStatusStrip()
|
||||
{
|
||||
AutoSize = false;
|
||||
BackColor = Colors.GreyBackground;
|
||||
ForeColor = Colors.LightText;
|
||||
Padding = new Padding(0, 5, 0, 3);
|
||||
Size = new Size(Size.Width, 24);
|
||||
SizingGrip = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
using (var b = new SolidBrush(Colors.GreyBackground))
|
||||
{
|
||||
g.FillRectangle(b, ClientRectangle);
|
||||
}
|
||||
|
||||
using (var p = new Pen(Colors.DarkBorder))
|
||||
{
|
||||
g.DrawLine(p, ClientRectangle.Left, 0, ClientRectangle.Right, 0);
|
||||
}
|
||||
|
||||
using (var p = new Pen(Colors.LightBorder))
|
||||
{
|
||||
g.DrawLine(p, ClientRectangle.Left, 1, ClientRectangle.Right, 1);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
20
DarkUI/Controls/DarkTextBox.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using DarkUI.Config;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkTextBox : TextBox
|
||||
{
|
||||
#region Constructor Region
|
||||
|
||||
public DarkTextBox()
|
||||
{
|
||||
BackColor = Colors.LightBackground;
|
||||
ForeColor = Colors.LightText;
|
||||
Padding = new Padding(2, 2, 2, 2);
|
||||
BorderStyle = BorderStyle.FixedSingle;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
40
DarkUI/Controls/DarkTitle.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using DarkUI.Config;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkTitle : Label
|
||||
{
|
||||
#region Constructor Region
|
||||
|
||||
public DarkTitle()
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
var rect = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);
|
||||
|
||||
var textSize = g.MeasureString(Text, Font);
|
||||
|
||||
using (var b = new SolidBrush(Colors.LightText))
|
||||
{
|
||||
g.DrawString(Text, Font, b, new PointF(-2, 0));
|
||||
}
|
||||
|
||||
using (var p = new Pen(Colors.GreyHighlight))
|
||||
{
|
||||
var p1 = new PointF(textSize.Width + 5, textSize.Height / 2);
|
||||
var p2 = new PointF(rect.Width, textSize.Height / 2);
|
||||
g.DrawLine(p, p1, p2);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
21
DarkUI/Controls/DarkToolStrip.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using DarkUI.Renderers;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkToolStrip : ToolStrip
|
||||
{
|
||||
#region Constructor Region
|
||||
|
||||
public DarkToolStrip()
|
||||
{
|
||||
Renderer = new DarkToolStripRenderer();
|
||||
Padding = new Padding(5, 0, 1, 0);
|
||||
AutoSize = false;
|
||||
Size = new Size(1, 28);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
259
DarkUI/Controls/DarkTreeNode.cs
Normal file
@ -0,0 +1,259 @@
|
||||
using DarkUI.Collections;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkTreeNode
|
||||
{
|
||||
#region Event Region
|
||||
|
||||
public event EventHandler<ObservableListModified<DarkTreeNode>> ItemsAdded;
|
||||
public event EventHandler<ObservableListModified<DarkTreeNode>> ItemsRemoved;
|
||||
|
||||
public event EventHandler TextChanged;
|
||||
public event EventHandler NodeExpanded;
|
||||
public event EventHandler NodeCollapsed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Field Region
|
||||
|
||||
private string _text;
|
||||
private bool _isRoot;
|
||||
private DarkTreeView _parentTree;
|
||||
private DarkTreeNode _parentNode;
|
||||
|
||||
private ObservableList<DarkTreeNode> _nodes;
|
||||
|
||||
private bool _expanded;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return _text; }
|
||||
set
|
||||
{
|
||||
if (_text == value)
|
||||
return;
|
||||
|
||||
_text = value;
|
||||
|
||||
OnTextChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public Rectangle ExpandArea { get; set; }
|
||||
|
||||
public Rectangle IconArea { get; set; }
|
||||
|
||||
public Rectangle TextArea { get; set; }
|
||||
|
||||
public Rectangle FullArea { get; set; }
|
||||
|
||||
public bool ExpandAreaHot { get; set; }
|
||||
|
||||
public Bitmap Icon { get; set; }
|
||||
|
||||
public Bitmap ExpandedIcon { get; set; }
|
||||
|
||||
public bool Expanded
|
||||
{
|
||||
get { return _expanded; }
|
||||
set
|
||||
{
|
||||
if (_expanded == value)
|
||||
return;
|
||||
|
||||
if (value == true && Nodes.Count == 0)
|
||||
return;
|
||||
|
||||
_expanded = value;
|
||||
|
||||
if (_expanded)
|
||||
{
|
||||
if (NodeExpanded != null)
|
||||
NodeExpanded(this, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (NodeCollapsed != null)
|
||||
NodeCollapsed(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableList<DarkTreeNode> Nodes
|
||||
{
|
||||
get { return _nodes; }
|
||||
set
|
||||
{
|
||||
if (_nodes != null)
|
||||
{
|
||||
_nodes.ItemsAdded -= Nodes_ItemsAdded;
|
||||
_nodes.ItemsRemoved -= Nodes_ItemsRemoved;
|
||||
}
|
||||
|
||||
_nodes = value;
|
||||
|
||||
_nodes.ItemsAdded += Nodes_ItemsAdded;
|
||||
_nodes.ItemsRemoved += Nodes_ItemsRemoved;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRoot
|
||||
{
|
||||
get { return _isRoot; }
|
||||
set { _isRoot = value; }
|
||||
}
|
||||
|
||||
public DarkTreeView ParentTree
|
||||
{
|
||||
get { return _parentTree; }
|
||||
set
|
||||
{
|
||||
if (_parentTree == value)
|
||||
return;
|
||||
|
||||
_parentTree = value;
|
||||
|
||||
foreach (var node in Nodes)
|
||||
node.ParentTree = _parentTree;
|
||||
}
|
||||
}
|
||||
|
||||
public DarkTreeNode ParentNode
|
||||
{
|
||||
get { return _parentNode; }
|
||||
set { _parentNode = value; }
|
||||
}
|
||||
|
||||
public bool Odd { get; set; }
|
||||
|
||||
public object NodeType { get; set; }
|
||||
|
||||
public object Tag { get; set; }
|
||||
|
||||
public string FullPath
|
||||
{
|
||||
get
|
||||
{
|
||||
var parent = ParentNode;
|
||||
var path = Text;
|
||||
|
||||
while (parent != null)
|
||||
{
|
||||
path = string.Format("{0}{1}{2}", parent.Text, "\\", path);
|
||||
parent = parent.ParentNode;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
public DarkTreeNode PrevVisibleNode { get; set; }
|
||||
|
||||
public DarkTreeNode NextVisibleNode { get; set; }
|
||||
|
||||
public int VisibleIndex { get; set; }
|
||||
|
||||
public bool IsNodeAncestor(DarkTreeNode node)
|
||||
{
|
||||
var parent = ParentNode;
|
||||
while (parent != null)
|
||||
{
|
||||
if (parent == node)
|
||||
return true;
|
||||
|
||||
parent = parent.ParentNode;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkTreeNode()
|
||||
{
|
||||
Nodes = new ObservableList<DarkTreeNode>();
|
||||
}
|
||||
|
||||
public DarkTreeNode(string text)
|
||||
: this()
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
if (ParentNode != null)
|
||||
ParentNode.Nodes.Remove(this);
|
||||
else
|
||||
ParentTree.Nodes.Remove(this);
|
||||
}
|
||||
|
||||
public void EnsureVisible()
|
||||
{
|
||||
var parent = ParentNode;
|
||||
|
||||
while (parent != null)
|
||||
{
|
||||
parent.Expanded = true;
|
||||
parent = parent.ParentNode;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
private void OnTextChanged()
|
||||
{
|
||||
if (ParentTree != null && ParentTree.TreeViewNodeSorter != null)
|
||||
{
|
||||
if (ParentNode != null)
|
||||
ParentNode.Nodes.Sort(ParentTree.TreeViewNodeSorter);
|
||||
else
|
||||
ParentTree.Nodes.Sort(ParentTree.TreeViewNodeSorter);
|
||||
}
|
||||
|
||||
if (TextChanged != null)
|
||||
TextChanged(this, null);
|
||||
}
|
||||
|
||||
private void Nodes_ItemsAdded(object sender, ObservableListModified<DarkTreeNode> e)
|
||||
{
|
||||
foreach (var node in e.Items)
|
||||
{
|
||||
node.ParentNode = this;
|
||||
node.ParentTree = ParentTree;
|
||||
}
|
||||
|
||||
if (ParentTree != null && ParentTree.TreeViewNodeSorter != null)
|
||||
Nodes.Sort(ParentTree.TreeViewNodeSorter);
|
||||
|
||||
if (ItemsAdded != null)
|
||||
ItemsAdded(this, e);
|
||||
}
|
||||
|
||||
private void Nodes_ItemsRemoved(object sender, ObservableListModified<DarkTreeNode> e)
|
||||
{
|
||||
if (Nodes.Count == 0)
|
||||
Expanded = false;
|
||||
|
||||
if (ItemsRemoved != null)
|
||||
ItemsRemoved(this, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
1274
DarkUI/Controls/DarkTreeView.cs
Normal file
14
DarkUI/Controls/ScrollValueEventArgs.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class ScrollValueEventArgs : EventArgs
|
||||
{
|
||||
public int Value { get; private set; }
|
||||
|
||||
public ScrollValueEventArgs(int value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
}
|
303
DarkUI/DarkUI.csproj
Normal file
@ -0,0 +1,303 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{F19472F5-8C44-4C51-A8A0-B9DE5F555255}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DarkUI</RootNamespace>
|
||||
<AssemblyName>DarkUI</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Collections\ObservableList.cs" />
|
||||
<Compile Include="Collections\ObservableListModified.cs" />
|
||||
<Compile Include="Config\Colors.cs" />
|
||||
<Compile Include="Config\Consts.cs" />
|
||||
<Compile Include="Controls\DarkButtonStyle.cs" />
|
||||
<Compile Include="Controls\DarkCheckBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkContentAlignment.cs" />
|
||||
<Compile Include="Controls\DarkControlState.cs" />
|
||||
<Compile Include="Controls\DarkRadioButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkScrollOrientation.cs" />
|
||||
<Compile Include="Controls\DarkTitle.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkTreeView.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkListItem.cs" />
|
||||
<Compile Include="Controls\DarkListView.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkScrollBase.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkContextMenu.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkLabel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkMenuStrip.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkScrollBar.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkScrollView.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkSectionPanel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkSeparator.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkStatusStrip.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkTextBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkToolStrip.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkTreeNode.cs" />
|
||||
<Compile Include="Controls\ScrollValueEventArgs.cs" />
|
||||
<Compile Include="Docking\DarkDockArea.cs" />
|
||||
<Compile Include="Docking\DarkDockContent.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Docking\DarkDockGroup.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Docking\DarkDockPanel.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Docking\DarkDockRegion.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Docking\DarkDocument.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Docking\DarkSplitterType.cs" />
|
||||
<Compile Include="Docking\DarkToolWindow.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Docking\DarkDockSplitter.cs" />
|
||||
<Compile Include="Docking\DarkDockTab.cs" />
|
||||
<Compile Include="Docking\DarkDockTabArea.cs" />
|
||||
<Compile Include="Docking\DockContentEventArgs.cs" />
|
||||
<Compile Include="Docking\DockDropArea.cs" />
|
||||
<Compile Include="Docking\DockDropCollection.cs" />
|
||||
<Compile Include="Docking\DockGroupState.cs" />
|
||||
<Compile Include="Docking\DockPanelState.cs" />
|
||||
<Compile Include="Docking\DockRegionState.cs" />
|
||||
<Compile Include="Docking\DockInsertType.cs" />
|
||||
<Compile Include="Extensions\BitmapExtensions.cs" />
|
||||
<Compile Include="Extensions\IEnumerableExtensions.cs" />
|
||||
<Compile Include="Forms\DarkDialog.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\DarkDialog.Designer.cs">
|
||||
<DependentUpon>DarkDialog.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\DarkDialogButton.cs" />
|
||||
<Compile Include="Forms\DarkForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\DarkMessageBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\DarkMessageBox.Designer.cs">
|
||||
<DependentUpon>DarkMessageBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\DarkMessageBoxIcon.cs" />
|
||||
<Compile Include="Forms\DarkTranslucentForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Icons\DockIcons.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>DockIcons.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Icons\MenuIcons.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>MenuIcons.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Icons\MessageBoxIcons.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>MessageBoxIcons.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Icons\ScrollIcons.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ScrollIcons.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Icons\TreeViewIcons.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>TreeViewIcons.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Win32\ControlScrollFilter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Renderers\DarkMenuRenderer.cs" />
|
||||
<Compile Include="Renderers\DarkToolStripRenderer.cs" />
|
||||
<Compile Include="Win32\DockResizeFilter.cs" />
|
||||
<Compile Include="Win32\DockContentDragFilter.cs" />
|
||||
<Compile Include="Win32\Native.cs" />
|
||||
<Compile Include="Win32\WindowsMessages.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Forms\DarkDialog.resx">
|
||||
<DependentUpon>DarkDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\DarkMessageBox.resx">
|
||||
<DependentUpon>DarkMessageBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Icons\DockIcons.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>DockIcons.Designer.cs</LastGenOutput>
|
||||
<CustomToolNamespace>DarkUI</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Icons\MenuIcons.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>MenuIcons.Designer.cs</LastGenOutput>
|
||||
<CustomToolNamespace>DarkUI</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Icons\MessageBoxIcons.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>MessageBoxIcons.Designer.cs</LastGenOutput>
|
||||
<CustomToolNamespace>DarkUI</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Icons\ScrollIcons.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>ScrollIcons.Designer.cs</LastGenOutput>
|
||||
<CustomToolNamespace>DarkUI</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Icons\TreeViewIcons.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>TreeViewIcons.Designer.cs</LastGenOutput>
|
||||
<CustomToolNamespace>DarkUI</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\grip.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\tick.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\scrollbar_arrow.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\scrollbar_arrow_clicked.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\scrollbar_arrow_hot.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\scrollbar_arrow_standard.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\error.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\info.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\warning.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\node_closed_empty.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\node_closed_full.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\node_open.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\node_open_empty.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\active-inactive-close.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\arrow.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\close.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\close-selected.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\inactive-close.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\inactive-close-selected.png" />
|
||||
</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" />
|
||||
<!-- 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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
11
DarkUI/Docking/DarkDockArea.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
public enum DarkDockArea
|
||||
{
|
||||
None,
|
||||
Document,
|
||||
Left,
|
||||
Right,
|
||||
Bottom
|
||||
}
|
||||
}
|
118
DarkUI/Docking/DarkDockContent.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
[ToolboxItem(false)]
|
||||
public class DarkDockContent : UserControl
|
||||
{
|
||||
#region Event Handler Region
|
||||
|
||||
public event EventHandler DockTextChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Field Region
|
||||
|
||||
private string _dockText;
|
||||
private Image _icon;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Category("Appearance")]
|
||||
[Description("Determines the text that will appear in the content tabs and headers.")]
|
||||
public string DockText
|
||||
{
|
||||
get { return _dockText; }
|
||||
set
|
||||
{
|
||||
var oldText = _dockText;
|
||||
|
||||
_dockText = value;
|
||||
|
||||
if (DockTextChanged != null)
|
||||
DockTextChanged(this, null);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Appearance")]
|
||||
[Description("Determines the icon that will appear in the content tabs and headers.")]
|
||||
public Image Icon
|
||||
{
|
||||
get { return _icon; }
|
||||
set
|
||||
{
|
||||
_icon = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Category("Layout")]
|
||||
[Description("Determines the default area of the dock panel this content will be added to.")]
|
||||
[DefaultValue(DarkDockArea.Document)]
|
||||
public DarkDockArea DefaultDockArea { get; set; }
|
||||
|
||||
[Category("Behavior")]
|
||||
[Description("Determines the key used by this content in the dock serialization.")]
|
||||
public string SerializationKey { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DarkDockPanel DockPanel { get; internal set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DarkDockRegion DockRegion { get; internal set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DarkDockGroup DockGroup { get; internal set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DarkDockArea DockArea { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public int Order { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkDockContent()
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public virtual void Close()
|
||||
{
|
||||
if (DockPanel != null)
|
||||
DockPanel.RemoveContent(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnEnter(EventArgs e)
|
||||
{
|
||||
base.OnEnter(e);
|
||||
|
||||
if (DockPanel == null)
|
||||
return;
|
||||
|
||||
DockPanel.ActiveContent = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
796
DarkUI/Docking/DarkDockGroup.cs
Normal file
@ -0,0 +1,796 @@
|
||||
using DarkUI.Config;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
[ToolboxItem(false)]
|
||||
public class DarkDockGroup : Panel
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private List<DarkDockContent> _contents = new List<DarkDockContent>();
|
||||
|
||||
private Dictionary<DarkDockContent, DarkDockTab> _tabs = new Dictionary<DarkDockContent, DarkDockTab>();
|
||||
|
||||
private DarkDockTabArea _tabArea;
|
||||
|
||||
private DarkDockTab _dragTab = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
public DarkDockPanel DockPanel { get; private set; }
|
||||
|
||||
public DarkDockRegion DockRegion { get; private set; }
|
||||
|
||||
public DarkDockArea DockArea { get; private set; }
|
||||
|
||||
public DarkDockContent VisibleContent { get; private set; }
|
||||
|
||||
public int Order { get; set; }
|
||||
|
||||
public int ContentCount { get { return _contents.Count; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkDockGroup(DarkDockPanel dockPanel, DarkDockRegion dockRegion, int order)
|
||||
{
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.UserPaint, true);
|
||||
|
||||
DockPanel = dockPanel;
|
||||
DockRegion = dockRegion;
|
||||
DockArea = dockRegion.DockArea;
|
||||
|
||||
Order = order;
|
||||
|
||||
_tabArea = new DarkDockTabArea(DockArea);
|
||||
|
||||
DockPanel.ActiveContentChanged += DockPanel_ActiveContentChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public void AddContent(DarkDockContent dockContent)
|
||||
{
|
||||
dockContent.DockGroup = this;
|
||||
dockContent.Dock = DockStyle.Fill;
|
||||
|
||||
dockContent.Order = 0;
|
||||
|
||||
if (_contents.Count > 0)
|
||||
{
|
||||
var order = -1;
|
||||
foreach (var otherContent in _contents)
|
||||
{
|
||||
if (otherContent.Order >= order)
|
||||
order = otherContent.Order + 1;
|
||||
}
|
||||
|
||||
dockContent.Order = order;
|
||||
}
|
||||
|
||||
_contents.Add(dockContent);
|
||||
Controls.Add(dockContent);
|
||||
|
||||
dockContent.DockTextChanged += DockContent_DockTextChanged;
|
||||
|
||||
_tabs.Add(dockContent, new DarkDockTab(dockContent));
|
||||
|
||||
if (VisibleContent == null)
|
||||
{
|
||||
dockContent.Visible = true;
|
||||
VisibleContent = dockContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
dockContent.Visible = false;
|
||||
}
|
||||
|
||||
var menuItem = new ToolStripMenuItem(dockContent.DockText);
|
||||
menuItem.Tag = dockContent;
|
||||
menuItem.Click += TabMenuItem_Select;
|
||||
menuItem.Image = dockContent.Icon;
|
||||
_tabArea.AddMenuItem(menuItem);
|
||||
|
||||
UpdateTabArea();
|
||||
}
|
||||
|
||||
public void RemoveContent(DarkDockContent dockContent)
|
||||
{
|
||||
dockContent.DockGroup = null;
|
||||
|
||||
var order = dockContent.Order;
|
||||
|
||||
_contents.Remove(dockContent);
|
||||
Controls.Remove(dockContent);
|
||||
|
||||
foreach (var otherContent in _contents)
|
||||
{
|
||||
if (otherContent.Order > order)
|
||||
otherContent.Order--;
|
||||
}
|
||||
|
||||
dockContent.DockTextChanged -= DockContent_DockTextChanged;
|
||||
|
||||
if (_tabs.ContainsKey(dockContent))
|
||||
_tabs.Remove(dockContent);
|
||||
|
||||
if (VisibleContent == dockContent)
|
||||
{
|
||||
VisibleContent = null;
|
||||
|
||||
if (_contents.Count > 0)
|
||||
{
|
||||
var newContent = _contents[0];
|
||||
newContent.Visible = true;
|
||||
VisibleContent = newContent;
|
||||
}
|
||||
}
|
||||
|
||||
var menuItem = _tabArea.GetMenuItem(dockContent);
|
||||
|
||||
menuItem.Click -= TabMenuItem_Select;
|
||||
_tabArea.RemoveMenuItem(menuItem);
|
||||
|
||||
UpdateTabArea();
|
||||
}
|
||||
|
||||
public List<DarkDockContent> GetContents()
|
||||
{
|
||||
return _contents.OrderBy(c => c.Order).ToList();
|
||||
}
|
||||
|
||||
private void UpdateTabArea()
|
||||
{
|
||||
if (DockArea == DarkDockArea.Document)
|
||||
_tabArea.Visible = (_contents.Count > 0);
|
||||
else
|
||||
_tabArea.Visible = (_contents.Count > 1);
|
||||
|
||||
var size = 0;
|
||||
|
||||
switch (DockArea)
|
||||
{
|
||||
case DarkDockArea.Document:
|
||||
size = _tabArea.Visible ? Consts.DocumentTabAreaSize : 0;
|
||||
Padding = new Padding(0, size, 0, 0);
|
||||
_tabArea.ClientRectangle = new Rectangle(Padding.Left, 0, ClientRectangle.Width - Padding.Horizontal, size);
|
||||
break;
|
||||
case DarkDockArea.Left:
|
||||
case DarkDockArea.Right:
|
||||
size = _tabArea.Visible ? Consts.ToolWindowTabAreaSize : 0;
|
||||
Padding = new Padding(0, 0, 0, size);
|
||||
_tabArea.ClientRectangle = new Rectangle(Padding.Left, ClientRectangle.Bottom - size, ClientRectangle.Width - Padding.Horizontal, size);
|
||||
break;
|
||||
case DarkDockArea.Bottom:
|
||||
size = _tabArea.Visible ? Consts.ToolWindowTabAreaSize : 0;
|
||||
Padding = new Padding(1, 0, 0, size);
|
||||
_tabArea.ClientRectangle = new Rectangle(Padding.Left, ClientRectangle.Bottom - size, ClientRectangle.Width - Padding.Horizontal, size);
|
||||
break;
|
||||
}
|
||||
|
||||
if (DockArea == DarkDockArea.Document)
|
||||
{
|
||||
var dropdownSize = Consts.DocumentTabAreaSize;
|
||||
_tabArea.DropdownRectangle = new Rectangle(_tabArea.ClientRectangle.Right - dropdownSize, 0, dropdownSize, dropdownSize);
|
||||
}
|
||||
|
||||
BuildTabs();
|
||||
|
||||
EnsureVisible();
|
||||
}
|
||||
|
||||
private void BuildTabs()
|
||||
{
|
||||
if (!_tabArea.Visible)
|
||||
return;
|
||||
|
||||
SuspendLayout();
|
||||
|
||||
var closeButtonSize = DockIcons.close.Width;
|
||||
|
||||
// Calculate areas of all tabs
|
||||
var totalSize = 0;
|
||||
|
||||
var orderedContent = _contents.OrderBy(c => c.Order);
|
||||
|
||||
foreach (var content in orderedContent)
|
||||
{
|
||||
int width;
|
||||
|
||||
var tab = _tabs[content];
|
||||
|
||||
using (var g = CreateGraphics())
|
||||
{
|
||||
width = tab.CalculateWidth(g, Font);
|
||||
}
|
||||
|
||||
// Add additional width for document tab items
|
||||
if (DockArea == DarkDockArea.Document)
|
||||
{
|
||||
width += 5;
|
||||
width += closeButtonSize;
|
||||
|
||||
if (tab.DockContent.Icon != null)
|
||||
width += tab.DockContent.Icon.Width + 5;
|
||||
}
|
||||
|
||||
// Show separator on all tabs for now
|
||||
tab.ShowSeparator = true;
|
||||
width += 1;
|
||||
|
||||
var y = DockArea == DarkDockArea.Document ? 0 : ClientRectangle.Height - Consts.ToolWindowTabAreaSize;
|
||||
var height = DockArea == DarkDockArea.Document ? Consts.DocumentTabAreaSize : Consts.ToolWindowTabAreaSize;
|
||||
|
||||
var tabRect = new Rectangle(_tabArea.ClientRectangle.Left + totalSize, y, width, height);
|
||||
tab.ClientRectangle = tabRect;
|
||||
|
||||
totalSize += width;
|
||||
}
|
||||
|
||||
// Cap the size if too large for the tab area
|
||||
if (DockArea != DarkDockArea.Document)
|
||||
{
|
||||
if (totalSize > _tabArea.ClientRectangle.Width)
|
||||
{
|
||||
var difference = totalSize - _tabArea.ClientRectangle.Width;
|
||||
|
||||
// No matter what, we want to slice off the 1 pixel separator from the final tab.
|
||||
var lastTab = _tabs[orderedContent.Last()];
|
||||
var tabRect = lastTab.ClientRectangle;
|
||||
lastTab.ClientRectangle = new Rectangle(tabRect.Left, tabRect.Top, tabRect.Width - 1, tabRect.Height);
|
||||
lastTab.ShowSeparator = false;
|
||||
|
||||
var differenceMadeUp = 1;
|
||||
|
||||
// Loop through and progressively resize the larger tabs until the total size fits within the tab area.
|
||||
while (differenceMadeUp < difference)
|
||||
{
|
||||
var largest = _tabs.Values.OrderByDescending(tab => tab.ClientRectangle.Width)
|
||||
.First()
|
||||
.ClientRectangle.Width;
|
||||
|
||||
foreach (var content in orderedContent)
|
||||
{
|
||||
var tab = _tabs[content];
|
||||
|
||||
// Check if previous iteration of loop met the difference
|
||||
if (differenceMadeUp >= difference)
|
||||
break;
|
||||
|
||||
if (tab.ClientRectangle.Width >= largest)
|
||||
{
|
||||
var rect = tab.ClientRectangle;
|
||||
tab.ClientRectangle = new Rectangle(rect.Left, rect.Top, rect.Width - 1, rect.Height);
|
||||
differenceMadeUp += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// After resizing the tabs reposition them accordingly.
|
||||
var xOffset = 0;
|
||||
foreach (var content in orderedContent)
|
||||
{
|
||||
var tab = _tabs[content];
|
||||
|
||||
var rect = tab.ClientRectangle;
|
||||
tab.ClientRectangle = new Rectangle(_tabArea.ClientRectangle.Left + xOffset, rect.Top, rect.Width, rect.Height);
|
||||
|
||||
xOffset += rect.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build close button rectangles
|
||||
if (DockArea == DarkDockArea.Document)
|
||||
{
|
||||
foreach (var content in orderedContent)
|
||||
{
|
||||
var tab = _tabs[content];
|
||||
var closeRect = new Rectangle(tab.ClientRectangle.Right - 7 - closeButtonSize - 1,
|
||||
tab.ClientRectangle.Top + (tab.ClientRectangle.Height / 2) - (closeButtonSize / 2) - 1,
|
||||
closeButtonSize, closeButtonSize);
|
||||
tab.CloseButtonRectangle = closeRect;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the tab area with the new total tab width
|
||||
totalSize = 0;
|
||||
foreach (var content in orderedContent)
|
||||
{
|
||||
var tab = _tabs[content];
|
||||
totalSize += tab.ClientRectangle.Width;
|
||||
}
|
||||
|
||||
_tabArea.TotalTabSize = totalSize;
|
||||
|
||||
ResumeLayout();
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public void EnsureVisible()
|
||||
{
|
||||
if (DockArea != DarkDockArea.Document)
|
||||
return;
|
||||
|
||||
if (VisibleContent == null)
|
||||
return;
|
||||
|
||||
var width = ClientRectangle.Width - Padding.Horizontal - _tabArea.DropdownRectangle.Width;
|
||||
var offsetArea = new Rectangle(Padding.Left, 0, width, 0);
|
||||
|
||||
var tab = _tabs[VisibleContent];
|
||||
|
||||
if (tab.ClientRectangle.IsEmpty)
|
||||
return;
|
||||
|
||||
if (RectangleToTabArea(tab.ClientRectangle).Left < offsetArea.Left)
|
||||
_tabArea.Offset = tab.ClientRectangle.Left;
|
||||
else if (RectangleToTabArea(tab.ClientRectangle).Right > offsetArea.Right)
|
||||
_tabArea.Offset = tab.ClientRectangle.Right - width;
|
||||
|
||||
if (_tabArea.TotalTabSize < offsetArea.Width)
|
||||
_tabArea.Offset = 0;
|
||||
|
||||
if (_tabArea.TotalTabSize > offsetArea.Width)
|
||||
{
|
||||
var orderedContent = _contents.OrderBy(x => x.Order);
|
||||
var lastTab = _tabs[orderedContent.Last()];
|
||||
if (lastTab != null)
|
||||
{
|
||||
if (RectangleToTabArea(lastTab.ClientRectangle).Right < offsetArea.Right)
|
||||
_tabArea.Offset = lastTab.ClientRectangle.Right - width;
|
||||
}
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public void SetVisibleContent(DarkDockContent content)
|
||||
{
|
||||
if (!_contents.Contains(content))
|
||||
return;
|
||||
|
||||
if (VisibleContent != content)
|
||||
{
|
||||
VisibleContent = content;
|
||||
content.Visible = true;
|
||||
|
||||
foreach (var otherContent in _contents)
|
||||
{
|
||||
if (otherContent != content)
|
||||
otherContent.Visible = false;
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private Point PointToTabArea(Point point)
|
||||
{
|
||||
return new Point(point.X - _tabArea.Offset, point.Y);
|
||||
}
|
||||
|
||||
private Rectangle RectangleToTabArea(Rectangle rectangle)
|
||||
{
|
||||
return new Rectangle(PointToTabArea(rectangle.Location), rectangle.Size);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnResize(EventArgs eventargs)
|
||||
{
|
||||
base.OnResize(eventargs);
|
||||
|
||||
UpdateTabArea();
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
if (_dragTab != null)
|
||||
{
|
||||
var offsetX = e.Location.X + _tabArea.Offset;
|
||||
if (offsetX < _dragTab.ClientRectangle.Left)
|
||||
{
|
||||
if (_dragTab.DockContent.Order > 0)
|
||||
{
|
||||
var otherTabs = _tabs.Values.Where(t => t.DockContent.Order == _dragTab.DockContent.Order - 1).ToList();
|
||||
if (otherTabs.Count == 0)
|
||||
return;
|
||||
|
||||
var otherTab = otherTabs.First();
|
||||
|
||||
if (otherTab == null)
|
||||
return;
|
||||
|
||||
var oldIndex = _dragTab.DockContent.Order;
|
||||
_dragTab.DockContent.Order = oldIndex - 1;
|
||||
otherTab.DockContent.Order = oldIndex;
|
||||
|
||||
BuildTabs();
|
||||
EnsureVisible();
|
||||
|
||||
_tabArea.RebuildMenu();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (offsetX > _dragTab.ClientRectangle.Right)
|
||||
{
|
||||
var maxOrder = _contents.Count;
|
||||
|
||||
if (_dragTab.DockContent.Order < maxOrder)
|
||||
{
|
||||
var otherTabs = _tabs.Values.Where(t => t.DockContent.Order == _dragTab.DockContent.Order + 1).ToList();
|
||||
if(otherTabs.Count == 0)
|
||||
return;
|
||||
|
||||
var otherTab = otherTabs.First();
|
||||
|
||||
if (otherTab == null)
|
||||
return;
|
||||
|
||||
var oldIndex = _dragTab.DockContent.Order;
|
||||
_dragTab.DockContent.Order = oldIndex + 1;
|
||||
otherTab.DockContent.Order = oldIndex;
|
||||
|
||||
BuildTabs();
|
||||
EnsureVisible();
|
||||
|
||||
_tabArea.RebuildMenu();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_tabArea.DropdownRectangle.Contains(e.Location))
|
||||
{
|
||||
_tabArea.DropdownHot = true;
|
||||
|
||||
foreach (var tab in _tabs.Values)
|
||||
tab.Hot = false;
|
||||
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
_tabArea.DropdownHot = false;
|
||||
|
||||
foreach (var tab in _tabs.Values)
|
||||
{
|
||||
var rect = RectangleToTabArea(tab.ClientRectangle);
|
||||
var hot = rect.Contains(e.Location);
|
||||
|
||||
if (tab.Hot != hot)
|
||||
{
|
||||
tab.Hot = hot;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
var closeRect = RectangleToTabArea(tab.CloseButtonRectangle);
|
||||
var closeHot = closeRect.Contains(e.Location);
|
||||
|
||||
if (tab.CloseButtonHot != closeHot)
|
||||
{
|
||||
tab.CloseButtonHot = closeHot;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (_tabArea.DropdownRectangle.Contains(e.Location))
|
||||
{
|
||||
_tabArea.DropdownHot = true;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var tab in _tabs.Values)
|
||||
{
|
||||
var rect = RectangleToTabArea(tab.ClientRectangle);
|
||||
if (rect.Contains(e.Location))
|
||||
{
|
||||
if (e.Button == MouseButtons.Middle)
|
||||
{
|
||||
tab.DockContent.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
var closeRect = RectangleToTabArea(tab.CloseButtonRectangle);
|
||||
if (closeRect.Contains(e.Location))
|
||||
{
|
||||
_tabArea.ClickedCloseButton = tab;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DockPanel.ActiveContent = tab.DockContent;
|
||||
EnsureVisible();
|
||||
|
||||
_dragTab = tab;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (VisibleContent != null)
|
||||
DockPanel.ActiveContent = VisibleContent;
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
_dragTab = null;
|
||||
|
||||
if (_tabArea.DropdownRectangle.Contains(e.Location))
|
||||
{
|
||||
if (_tabArea.DropdownHot)
|
||||
_tabArea.ShowMenu(this, new Point(_tabArea.DropdownRectangle.Left, _tabArea.DropdownRectangle.Bottom - 2));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_tabArea.ClickedCloseButton == null)
|
||||
return;
|
||||
|
||||
var closeRect = RectangleToTabArea(_tabArea.ClickedCloseButton.CloseButtonRectangle);
|
||||
if (closeRect.Contains(e.Location))
|
||||
_tabArea.ClickedCloseButton.DockContent.Close();
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
|
||||
foreach (var tab in _tabs.Values)
|
||||
tab.Hot = false;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void TabMenuItem_Select(object sender, EventArgs e)
|
||||
{
|
||||
var menuItem = sender as ToolStripMenuItem;
|
||||
if (menuItem == null)
|
||||
return;
|
||||
|
||||
var content = menuItem.Tag as DarkDockContent;
|
||||
if (content == null)
|
||||
return;
|
||||
|
||||
DockPanel.ActiveContent = content;
|
||||
}
|
||||
|
||||
private void DockPanel_ActiveContentChanged(object sender, DockContentEventArgs e)
|
||||
{
|
||||
if (!_contents.Contains(e.Content))
|
||||
return;
|
||||
|
||||
if (e.Content == VisibleContent)
|
||||
{
|
||||
VisibleContent.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
VisibleContent = e.Content;
|
||||
|
||||
foreach (var content in _contents)
|
||||
content.Visible = content == VisibleContent;
|
||||
|
||||
VisibleContent.Focus();
|
||||
|
||||
EnsureVisible();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void DockContent_DockTextChanged(object sender, EventArgs e)
|
||||
{
|
||||
BuildTabs();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Render Region
|
||||
|
||||
public void Redraw()
|
||||
{
|
||||
Invalidate();
|
||||
|
||||
foreach (var content in _contents)
|
||||
content.Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
using (var b = new SolidBrush(Colors.GreyBackground))
|
||||
{
|
||||
g.FillRectangle(b, ClientRectangle);
|
||||
}
|
||||
|
||||
if (!_tabArea.Visible)
|
||||
return;
|
||||
|
||||
using (var b = new SolidBrush(Colors.MediumBackground))
|
||||
{
|
||||
g.FillRectangle(b, _tabArea.ClientRectangle);
|
||||
}
|
||||
|
||||
foreach (var tab in _tabs.Values)
|
||||
{
|
||||
if (DockArea == DarkDockArea.Document)
|
||||
PaintDocumentTab(g, tab);
|
||||
else
|
||||
PaintToolWindowTab(g, tab);
|
||||
}
|
||||
|
||||
if (DockArea == DarkDockArea.Document)
|
||||
{
|
||||
// Color divider
|
||||
var isActiveGroup = DockPanel.ActiveGroup == this;
|
||||
var divColor = isActiveGroup ? Colors.BlueSelection : Colors.GreySelection;
|
||||
using (var b = new SolidBrush(divColor))
|
||||
{
|
||||
var divRect = new Rectangle(_tabArea.ClientRectangle.Left, _tabArea.ClientRectangle.Bottom - 2, _tabArea.ClientRectangle.Width, 2);
|
||||
g.FillRectangle(b, divRect);
|
||||
}
|
||||
|
||||
// Content dropdown list
|
||||
var dropdownRect = new Rectangle(_tabArea.DropdownRectangle.Left, _tabArea.DropdownRectangle.Top, _tabArea.DropdownRectangle.Width, _tabArea.DropdownRectangle.Height - 2);
|
||||
|
||||
using (var b = new SolidBrush(Colors.MediumBackground))
|
||||
{
|
||||
g.FillRectangle(b, dropdownRect);
|
||||
}
|
||||
|
||||
using (var img = DockIcons.arrow)
|
||||
{
|
||||
g.DrawImageUnscaled(img, dropdownRect.Left + (dropdownRect.Width / 2) - (img.Width / 2), dropdownRect.Top + (dropdownRect.Height / 2) - (img.Height / 2) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PaintDocumentTab(Graphics g, DarkDockTab tab)
|
||||
{
|
||||
var tabRect = RectangleToTabArea(tab.ClientRectangle);
|
||||
|
||||
var isVisibleTab = VisibleContent == tab.DockContent;
|
||||
var isActiveGroup = DockPanel.ActiveGroup == this;
|
||||
|
||||
var bgColor = isVisibleTab ? Colors.BlueSelection : Colors.DarkBackground;
|
||||
|
||||
if (!isActiveGroup)
|
||||
bgColor = isVisibleTab ? Colors.GreySelection : Colors.DarkBackground;
|
||||
|
||||
if (tab.Hot && !isVisibleTab)
|
||||
bgColor = Colors.MediumBackground;
|
||||
|
||||
using (var b = new SolidBrush(bgColor))
|
||||
{
|
||||
g.FillRectangle(b, tabRect);
|
||||
}
|
||||
|
||||
// Draw separators
|
||||
if (tab.ShowSeparator)
|
||||
{
|
||||
using (var p = new Pen(Colors.DarkBorder))
|
||||
{
|
||||
g.DrawLine(p, tabRect.Right - 1, tabRect.Top, tabRect.Right - 1, tabRect.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
var xOffset = 0;
|
||||
|
||||
// Draw icon
|
||||
if (tab.DockContent.Icon != null)
|
||||
{
|
||||
g.DrawImageUnscaled(tab.DockContent.Icon, tabRect.Left + 5, tabRect.Top + 4);
|
||||
xOffset += tab.DockContent.Icon.Width + 2;
|
||||
}
|
||||
|
||||
var tabTextFormat = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Near,
|
||||
LineAlignment = StringAlignment.Center,
|
||||
FormatFlags = StringFormatFlags.NoWrap,
|
||||
Trimming = StringTrimming.EllipsisCharacter
|
||||
};
|
||||
|
||||
// Draw text
|
||||
var textColor = isVisibleTab ? Colors.LightText : Colors.DisabledText;
|
||||
using (var b = new SolidBrush(textColor))
|
||||
{
|
||||
var textRect = new Rectangle(tabRect.Left + 5 + xOffset, tabRect.Top, tabRect.Width - tab.CloseButtonRectangle.Width - 7 - 5 - xOffset, tabRect.Height);
|
||||
g.DrawString(tab.DockContent.DockText, Font, b, textRect, tabTextFormat);
|
||||
}
|
||||
|
||||
// Close button
|
||||
var img = tab.CloseButtonHot ? DockIcons.inactive_close_selected : DockIcons.inactive_close;
|
||||
|
||||
if (isVisibleTab)
|
||||
{
|
||||
if (isActiveGroup)
|
||||
img = tab.CloseButtonHot ? DockIcons.close_selected : DockIcons.close;
|
||||
else
|
||||
img = tab.CloseButtonHot ? DockIcons.close_selected : DockIcons.active_inactive_close;
|
||||
}
|
||||
|
||||
var closeRect = RectangleToTabArea(tab.CloseButtonRectangle);
|
||||
g.DrawImageUnscaled(img, closeRect.Left, closeRect.Top);
|
||||
}
|
||||
|
||||
private void PaintToolWindowTab(Graphics g, DarkDockTab tab)
|
||||
{
|
||||
var tabRect = tab.ClientRectangle;
|
||||
|
||||
var isVisibleTab = VisibleContent == tab.DockContent;
|
||||
|
||||
var bgColor = isVisibleTab ? Colors.GreyBackground : Colors.DarkBackground;
|
||||
|
||||
if (tab.Hot && !isVisibleTab)
|
||||
bgColor = Colors.MediumBackground;
|
||||
|
||||
using (var b = new SolidBrush(bgColor))
|
||||
{
|
||||
g.FillRectangle(b, tabRect);
|
||||
}
|
||||
|
||||
// Draw separators
|
||||
if (tab.ShowSeparator)
|
||||
{
|
||||
using (var p = new Pen(Colors.DarkBorder))
|
||||
{
|
||||
g.DrawLine(p, tabRect.Right - 1, tabRect.Top, tabRect.Right - 1, tabRect.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
var tabTextFormat = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Near,
|
||||
LineAlignment = StringAlignment.Center,
|
||||
FormatFlags = StringFormatFlags.NoWrap,
|
||||
Trimming = StringTrimming.EllipsisCharacter
|
||||
};
|
||||
|
||||
var textColor = isVisibleTab ? Colors.BlueHighlight : Colors.DisabledText;
|
||||
using (var b = new SolidBrush(textColor))
|
||||
{
|
||||
var textRect = new Rectangle(tabRect.Left + 5, tabRect.Top, tabRect.Width - 5, tabRect.Height);
|
||||
g.DrawString(tab.DockContent.DockText, Font, b, textRect, tabTextFormat);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
// Absorb event
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
324
DarkUI/Docking/DarkDockPanel.cs
Normal file
@ -0,0 +1,324 @@
|
||||
using DarkUI.Config;
|
||||
using DarkUI.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
public class DarkDockPanel : UserControl
|
||||
{
|
||||
#region Event Region
|
||||
|
||||
public event EventHandler<DockContentEventArgs> ActiveContentChanged;
|
||||
public event EventHandler<DockContentEventArgs> ContentAdded;
|
||||
public event EventHandler<DockContentEventArgs> ContentRemoved;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Field Region
|
||||
|
||||
private List<DarkDockContent> _contents;
|
||||
private Dictionary<DarkDockArea, DarkDockRegion> _regions;
|
||||
|
||||
private DarkDockContent _activeContent;
|
||||
private bool _switchingContent = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DarkDockContent ActiveContent
|
||||
{
|
||||
get { return _activeContent; }
|
||||
set
|
||||
{
|
||||
// Don't let content visibility changes re-trigger event
|
||||
if (_switchingContent)
|
||||
return;
|
||||
|
||||
_switchingContent = true;
|
||||
|
||||
_activeContent = value;
|
||||
|
||||
ActiveGroup = _activeContent.DockGroup;
|
||||
ActiveRegion = ActiveGroup.DockRegion;
|
||||
|
||||
foreach (var region in _regions.Values)
|
||||
region.Redraw();
|
||||
|
||||
if (ActiveContentChanged != null)
|
||||
ActiveContentChanged(this, new DockContentEventArgs(_activeContent));
|
||||
|
||||
_switchingContent = false;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DarkDockRegion ActiveRegion { get; internal set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DarkDockGroup ActiveGroup { get; internal set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DarkDockContent ActiveDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
return _regions[DarkDockArea.Document].ActiveDocument;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DockContentDragFilter DockContentDragFilter { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public DockResizeFilter DockResizeFilter { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public List<DarkDockSplitter> Splitters { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public MouseButtons MouseButtonState
|
||||
{
|
||||
get
|
||||
{
|
||||
var buttonState = MouseButtons;
|
||||
return buttonState;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Dictionary<DarkDockArea, DarkDockRegion> Regions
|
||||
{
|
||||
get
|
||||
{
|
||||
return _regions;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkDockPanel()
|
||||
{
|
||||
Splitters = new List<DarkDockSplitter>();
|
||||
DockContentDragFilter = new DockContentDragFilter(this);
|
||||
DockResizeFilter = new DockResizeFilter(this);
|
||||
|
||||
_regions = new Dictionary<DarkDockArea, DarkDockRegion>();
|
||||
_contents = new List<DarkDockContent>();
|
||||
|
||||
BackColor = Colors.GreyBackground;
|
||||
|
||||
CreateRegions();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public void AddContent(DarkDockContent dockContent)
|
||||
{
|
||||
AddContent(dockContent, null);
|
||||
}
|
||||
|
||||
public void AddContent(DarkDockContent dockContent, DarkDockGroup dockGroup)
|
||||
{
|
||||
if (_contents.Contains(dockContent))
|
||||
RemoveContent(dockContent);
|
||||
|
||||
dockContent.DockPanel = this;
|
||||
_contents.Add(dockContent);
|
||||
|
||||
if (dockGroup != null)
|
||||
dockContent.DockArea = dockGroup.DockArea;
|
||||
|
||||
if (dockContent.DockArea == DarkDockArea.None)
|
||||
dockContent.DockArea = dockContent.DefaultDockArea;
|
||||
|
||||
var region = _regions[dockContent.DockArea];
|
||||
region.AddContent(dockContent, dockGroup);
|
||||
|
||||
if (ContentAdded != null)
|
||||
ContentAdded(this, new DockContentEventArgs(dockContent));
|
||||
|
||||
dockContent.Select();
|
||||
}
|
||||
|
||||
public void InsertContent(DarkDockContent dockContent, DarkDockGroup dockGroup, DockInsertType insertType)
|
||||
{
|
||||
if (_contents.Contains(dockContent))
|
||||
RemoveContent(dockContent);
|
||||
|
||||
dockContent.DockPanel = this;
|
||||
_contents.Add(dockContent);
|
||||
|
||||
dockContent.DockArea = dockGroup.DockArea;
|
||||
|
||||
var region = _regions[dockGroup.DockArea];
|
||||
region.InsertContent(dockContent, dockGroup, insertType);
|
||||
|
||||
if (ContentAdded != null)
|
||||
ContentAdded(this, new DockContentEventArgs(dockContent));
|
||||
|
||||
dockContent.Select();
|
||||
}
|
||||
|
||||
public void RemoveContent(DarkDockContent dockContent)
|
||||
{
|
||||
if (!_contents.Contains(dockContent))
|
||||
return;
|
||||
|
||||
dockContent.DockPanel = null;
|
||||
_contents.Remove(dockContent);
|
||||
|
||||
var region = _regions[dockContent.DockArea];
|
||||
region.RemoveContent(dockContent);
|
||||
|
||||
if (ContentRemoved != null)
|
||||
ContentRemoved(this, new DockContentEventArgs(dockContent));
|
||||
}
|
||||
|
||||
public bool ContainsContent(DarkDockContent dockContent)
|
||||
{
|
||||
return _contents.Contains(dockContent);
|
||||
}
|
||||
|
||||
public List<DarkDockContent> GetDocuments()
|
||||
{
|
||||
return _regions[DarkDockArea.Document].GetContents();
|
||||
}
|
||||
|
||||
private void CreateRegions()
|
||||
{
|
||||
var documentRegion = new DarkDockRegion(this, DarkDockArea.Document);
|
||||
_regions.Add(DarkDockArea.Document, documentRegion);
|
||||
|
||||
var leftRegion = new DarkDockRegion(this, DarkDockArea.Left);
|
||||
_regions.Add(DarkDockArea.Left, leftRegion);
|
||||
|
||||
var rightRegion = new DarkDockRegion(this, DarkDockArea.Right);
|
||||
_regions.Add(DarkDockArea.Right, rightRegion);
|
||||
|
||||
var bottomRegion = new DarkDockRegion(this, DarkDockArea.Bottom);
|
||||
_regions.Add(DarkDockArea.Bottom, bottomRegion);
|
||||
|
||||
// Add the regions in this order to force the bottom region to be positioned
|
||||
// between the left and right regions properly.
|
||||
Controls.Add(documentRegion);
|
||||
Controls.Add(bottomRegion);
|
||||
Controls.Add(leftRegion);
|
||||
Controls.Add(rightRegion);
|
||||
|
||||
// Create tab index for intuitive tabbing order
|
||||
documentRegion.TabIndex = 0;
|
||||
rightRegion.TabIndex = 1;
|
||||
bottomRegion.TabIndex = 2;
|
||||
leftRegion.TabIndex = 3;
|
||||
}
|
||||
|
||||
public void DragContent(DarkDockContent content)
|
||||
{
|
||||
DockContentDragFilter.StartDrag(content);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Serialization Region
|
||||
|
||||
public DockPanelState GetDockPanelState()
|
||||
{
|
||||
var state = new DockPanelState();
|
||||
|
||||
state.Regions.Add(new DockRegionState(DarkDockArea.Document));
|
||||
state.Regions.Add(new DockRegionState(DarkDockArea.Left, _regions[DarkDockArea.Left].Size));
|
||||
state.Regions.Add(new DockRegionState(DarkDockArea.Right, _regions[DarkDockArea.Right].Size));
|
||||
state.Regions.Add(new DockRegionState(DarkDockArea.Bottom, _regions[DarkDockArea.Bottom].Size));
|
||||
|
||||
var _groupStates = new Dictionary<DarkDockGroup, DockGroupState>();
|
||||
|
||||
var orderedContent = _contents.OrderBy(c => c.Order);
|
||||
foreach (var content in orderedContent)
|
||||
{
|
||||
foreach (var region in state.Regions)
|
||||
{
|
||||
if (region.Area == content.DockArea)
|
||||
{
|
||||
DockGroupState groupState;
|
||||
|
||||
if (_groupStates.ContainsKey(content.DockGroup))
|
||||
{
|
||||
groupState = _groupStates[content.DockGroup];
|
||||
}
|
||||
else
|
||||
{
|
||||
groupState = new DockGroupState();
|
||||
region.Groups.Add(groupState);
|
||||
_groupStates.Add(content.DockGroup, groupState);
|
||||
}
|
||||
|
||||
groupState.Contents.Add(content.SerializationKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
public void RestoreDockPanelState(DockPanelState state, Func<string, DarkDockContent> getContentBySerializationKey)
|
||||
{
|
||||
foreach (var region in state.Regions)
|
||||
{
|
||||
switch (region.Area)
|
||||
{
|
||||
case DarkDockArea.Left:
|
||||
_regions[DarkDockArea.Left].Size = region.Size;
|
||||
break;
|
||||
case DarkDockArea.Right:
|
||||
_regions[DarkDockArea.Right].Size = region.Size;
|
||||
break;
|
||||
case DarkDockArea.Bottom:
|
||||
_regions[DarkDockArea.Bottom].Size = region.Size;
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var group in region.Groups)
|
||||
{
|
||||
DarkDockContent previousContent = null;
|
||||
|
||||
foreach (var contentKey in group.Contents)
|
||||
{
|
||||
var content = getContentBySerializationKey(contentKey);
|
||||
|
||||
if (content == null)
|
||||
continue;
|
||||
|
||||
if (previousContent == null)
|
||||
AddContent(content);
|
||||
else
|
||||
AddContent(content, previousContent.DockGroup);
|
||||
|
||||
previousContent = content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
402
DarkUI/Docking/DarkDockRegion.cs
Normal file
@ -0,0 +1,402 @@
|
||||
using DarkUI.Config;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
[ToolboxItem(false)]
|
||||
public class DarkDockRegion : Panel
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private List<DarkDockGroup> _groups;
|
||||
|
||||
private Form _parentForm;
|
||||
private DarkDockSplitter _splitter;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
public DarkDockPanel DockPanel { get; private set; }
|
||||
|
||||
public DarkDockArea DockArea { get; private set; }
|
||||
|
||||
public DarkDockContent ActiveDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DockArea != DarkDockArea.Document || _groups.Count == 0)
|
||||
return null;
|
||||
|
||||
return _groups[0].VisibleContent;
|
||||
}
|
||||
}
|
||||
|
||||
public List<DarkDockGroup> Groups
|
||||
{
|
||||
get
|
||||
{
|
||||
return _groups.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkDockRegion(DarkDockPanel dockPanel, DarkDockArea dockArea)
|
||||
{
|
||||
_groups = new List<DarkDockGroup>();
|
||||
|
||||
DockPanel = dockPanel;
|
||||
DockArea = dockArea;
|
||||
|
||||
BuildProperties();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
internal void AddContent(DarkDockContent dockContent)
|
||||
{
|
||||
AddContent(dockContent, null);
|
||||
}
|
||||
|
||||
internal void AddContent(DarkDockContent dockContent, DarkDockGroup dockGroup)
|
||||
{
|
||||
// If no existing group is specified then create a new one
|
||||
if (dockGroup == null)
|
||||
{
|
||||
// If this is the document region, then default to first group if it exists
|
||||
if (DockArea == DarkDockArea.Document && _groups.Count > 0)
|
||||
dockGroup = _groups[0];
|
||||
else
|
||||
dockGroup = CreateGroup();
|
||||
}
|
||||
|
||||
dockContent.DockRegion = this;
|
||||
dockGroup.AddContent(dockContent);
|
||||
|
||||
if (!Visible)
|
||||
{
|
||||
Visible = true;
|
||||
CreateSplitter();
|
||||
}
|
||||
|
||||
PositionGroups();
|
||||
}
|
||||
|
||||
internal void InsertContent(DarkDockContent dockContent, DarkDockGroup dockGroup, DockInsertType insertType)
|
||||
{
|
||||
var order = dockGroup.Order;
|
||||
|
||||
if (insertType == DockInsertType.After)
|
||||
order++;
|
||||
|
||||
var newGroup = InsertGroup(order);
|
||||
|
||||
dockContent.DockRegion = this;
|
||||
newGroup.AddContent(dockContent);
|
||||
|
||||
if (!Visible)
|
||||
{
|
||||
Visible = true;
|
||||
CreateSplitter();
|
||||
}
|
||||
|
||||
PositionGroups();
|
||||
}
|
||||
|
||||
internal void RemoveContent(DarkDockContent dockContent)
|
||||
{
|
||||
dockContent.DockRegion = null;
|
||||
|
||||
var group = dockContent.DockGroup;
|
||||
group.RemoveContent(dockContent);
|
||||
|
||||
dockContent.DockArea = DarkDockArea.None;
|
||||
|
||||
// If that was the final content in the group then remove the group
|
||||
if (group.ContentCount == 0)
|
||||
RemoveGroup(group);
|
||||
|
||||
// If we just removed the final group, and this isn't the document region, then hide
|
||||
if (_groups.Count == 0 && DockArea != DarkDockArea.Document)
|
||||
{
|
||||
Visible = false;
|
||||
RemoveSplitter();
|
||||
}
|
||||
|
||||
PositionGroups();
|
||||
}
|
||||
|
||||
public List<DarkDockContent> GetContents()
|
||||
{
|
||||
var result = new List<DarkDockContent>();
|
||||
|
||||
foreach (var group in _groups)
|
||||
result.AddRange(group.GetContents());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private DarkDockGroup CreateGroup()
|
||||
{
|
||||
var order = 0;
|
||||
|
||||
if (_groups.Count >= 1)
|
||||
{
|
||||
order = -1;
|
||||
foreach (var group in _groups)
|
||||
{
|
||||
if (group.Order >= order)
|
||||
order = group.Order + 1;
|
||||
}
|
||||
}
|
||||
|
||||
var newGroup = new DarkDockGroup(DockPanel, this, order);
|
||||
_groups.Add(newGroup);
|
||||
Controls.Add(newGroup);
|
||||
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
private DarkDockGroup InsertGroup(int order)
|
||||
{
|
||||
foreach (var group in _groups)
|
||||
{
|
||||
if (group.Order >= order)
|
||||
group.Order++;
|
||||
}
|
||||
|
||||
var newGroup = new DarkDockGroup(DockPanel, this, order);
|
||||
_groups.Add(newGroup);
|
||||
Controls.Add(newGroup);
|
||||
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
private void RemoveGroup(DarkDockGroup group)
|
||||
{
|
||||
var lastOrder = group.Order;
|
||||
|
||||
_groups.Remove(group);
|
||||
Controls.Remove(group);
|
||||
|
||||
foreach (var otherGroup in _groups)
|
||||
{
|
||||
if (otherGroup.Order > lastOrder)
|
||||
otherGroup.Order--;
|
||||
}
|
||||
}
|
||||
|
||||
private void PositionGroups()
|
||||
{
|
||||
DockStyle dockStyle;
|
||||
|
||||
switch (DockArea)
|
||||
{
|
||||
default:
|
||||
case DarkDockArea.Document:
|
||||
dockStyle = DockStyle.Fill;
|
||||
break;
|
||||
case DarkDockArea.Left:
|
||||
case DarkDockArea.Right:
|
||||
dockStyle = DockStyle.Top;
|
||||
break;
|
||||
case DarkDockArea.Bottom:
|
||||
dockStyle = DockStyle.Left;
|
||||
break;
|
||||
}
|
||||
|
||||
if (_groups.Count == 1)
|
||||
{
|
||||
_groups[0].Dock = DockStyle.Fill;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_groups.Count > 1)
|
||||
{
|
||||
var lastGroup = _groups.OrderByDescending(g => g.Order).First();
|
||||
|
||||
foreach (var group in _groups.OrderByDescending(g => g.Order))
|
||||
{
|
||||
group.SendToBack();
|
||||
|
||||
if (group.Order == lastGroup.Order)
|
||||
group.Dock = DockStyle.Fill;
|
||||
else
|
||||
group.Dock = dockStyle;
|
||||
}
|
||||
|
||||
SizeGroups();
|
||||
}
|
||||
}
|
||||
|
||||
private void SizeGroups()
|
||||
{
|
||||
if (_groups.Count <= 1)
|
||||
return;
|
||||
|
||||
var size = new Size(0, 0);
|
||||
|
||||
switch (DockArea)
|
||||
{
|
||||
default:
|
||||
case DarkDockArea.Document:
|
||||
return;
|
||||
case DarkDockArea.Left:
|
||||
case DarkDockArea.Right:
|
||||
size = new Size(ClientRectangle.Width, ClientRectangle.Height / _groups.Count);
|
||||
break;
|
||||
case DarkDockArea.Bottom:
|
||||
size = new Size(ClientRectangle.Width / _groups.Count, ClientRectangle.Height);
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var group in _groups)
|
||||
group.Size = size;
|
||||
}
|
||||
|
||||
private void BuildProperties()
|
||||
{
|
||||
MinimumSize = new Size(50, 50);
|
||||
|
||||
switch (DockArea)
|
||||
{
|
||||
default:
|
||||
case DarkDockArea.Document:
|
||||
Dock = DockStyle.Fill;
|
||||
Padding = new Padding(0, 1, 0, 0);
|
||||
break;
|
||||
case DarkDockArea.Left:
|
||||
Dock = DockStyle.Left;
|
||||
Padding = new Padding(0, 0, 1, 0);
|
||||
Visible = false;
|
||||
break;
|
||||
case DarkDockArea.Right:
|
||||
Dock = DockStyle.Right;
|
||||
Padding = new Padding(1, 0, 0, 0);
|
||||
Visible = false;
|
||||
break;
|
||||
case DarkDockArea.Bottom:
|
||||
Dock = DockStyle.Bottom;
|
||||
Padding = new Padding(0, 0, 0, 0);
|
||||
Visible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateSplitter()
|
||||
{
|
||||
if (_splitter != null && DockPanel.Splitters.Contains(_splitter))
|
||||
DockPanel.Splitters.Remove(_splitter);
|
||||
|
||||
switch (DockArea)
|
||||
{
|
||||
case DarkDockArea.Left:
|
||||
_splitter = new DarkDockSplitter(DockPanel, this, DarkSplitterType.Right);
|
||||
break;
|
||||
case DarkDockArea.Right:
|
||||
_splitter = new DarkDockSplitter(DockPanel, this, DarkSplitterType.Left);
|
||||
break;
|
||||
case DarkDockArea.Bottom:
|
||||
_splitter = new DarkDockSplitter(DockPanel, this, DarkSplitterType.Top);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
DockPanel.Splitters.Add(_splitter);
|
||||
}
|
||||
|
||||
private void RemoveSplitter()
|
||||
{
|
||||
if (DockPanel.Splitters.Contains(_splitter))
|
||||
DockPanel.Splitters.Remove(_splitter);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
|
||||
_parentForm = FindForm();
|
||||
_parentForm.ResizeEnd += ParentForm_ResizeEnd;
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs eventargs)
|
||||
{
|
||||
base.OnResize(eventargs);
|
||||
|
||||
SizeGroups();
|
||||
}
|
||||
|
||||
private void ParentForm_ResizeEnd(object sender, EventArgs e)
|
||||
{
|
||||
if (_splitter != null)
|
||||
_splitter.UpdateBounds();
|
||||
}
|
||||
|
||||
protected override void OnLayout(LayoutEventArgs e)
|
||||
{
|
||||
base.OnLayout(e);
|
||||
|
||||
if (_splitter != null)
|
||||
_splitter.UpdateBounds();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
public void Redraw()
|
||||
{
|
||||
Invalidate();
|
||||
|
||||
foreach (var group in _groups)
|
||||
group.Redraw();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
if (!Visible)
|
||||
return;
|
||||
|
||||
// Fill body
|
||||
using (var b = new SolidBrush(Colors.GreyBackground))
|
||||
{
|
||||
g.FillRectangle(b, ClientRectangle);
|
||||
}
|
||||
|
||||
// Draw border
|
||||
using (var p = new Pen(Colors.DarkBorder))
|
||||
{
|
||||
// Top border
|
||||
if (DockArea == DarkDockArea.Document)
|
||||
g.DrawLine(p, ClientRectangle.Left, 0, ClientRectangle.Right, 0);
|
||||
|
||||
// Left border
|
||||
if (DockArea == DarkDockArea.Right)
|
||||
g.DrawLine(p, ClientRectangle.Left, 0, ClientRectangle.Left, ClientRectangle.Height);
|
||||
|
||||
// Right border
|
||||
if (DockArea == DarkDockArea.Left)
|
||||
g.DrawLine(p, ClientRectangle.Right - 1, 0, ClientRectangle.Right - 1, ClientRectangle.Height);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
160
DarkUI/Docking/DarkDockSplitter.cs
Normal file
@ -0,0 +1,160 @@
|
||||
using DarkUI.Forms;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
public class DarkDockSplitter
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private Control _parentControl;
|
||||
private Control _control;
|
||||
|
||||
private DarkSplitterType _splitterType;
|
||||
|
||||
private int _minimum;
|
||||
private int _maximum;
|
||||
private DarkTranslucentForm _overlayForm;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
public Rectangle Bounds { get; set; }
|
||||
|
||||
public Cursor ResizeCursor { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkDockSplitter(Control parentControl, Control control, DarkSplitterType splitterType)
|
||||
{
|
||||
_parentControl = parentControl;
|
||||
_control = control;
|
||||
_splitterType = splitterType;
|
||||
|
||||
switch (_splitterType)
|
||||
{
|
||||
case DarkSplitterType.Left:
|
||||
case DarkSplitterType.Right:
|
||||
ResizeCursor = Cursors.SizeWE;
|
||||
break;
|
||||
case DarkSplitterType.Top:
|
||||
case DarkSplitterType.Bottom:
|
||||
ResizeCursor = Cursors.SizeNS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public void ShowOverlay()
|
||||
{
|
||||
_overlayForm = new DarkTranslucentForm(Color.Black);
|
||||
_overlayForm.Visible = true;
|
||||
|
||||
UpdateOverlay(new Point(0, 0));
|
||||
}
|
||||
|
||||
public void HideOverlay()
|
||||
{
|
||||
_overlayForm.Visible = false;
|
||||
}
|
||||
|
||||
public void UpdateOverlay(Point difference)
|
||||
{
|
||||
var bounds = new Rectangle(Bounds.Location, Bounds.Size);
|
||||
|
||||
switch (_splitterType)
|
||||
{
|
||||
case DarkSplitterType.Left:
|
||||
var leftX = Math.Max(bounds.Location.X - difference.X, _minimum);
|
||||
|
||||
if (_maximum != 0 && leftX > _maximum)
|
||||
leftX = _maximum;
|
||||
|
||||
bounds.Location = new Point(leftX, bounds.Location.Y);
|
||||
break;
|
||||
case DarkSplitterType.Right:
|
||||
var rightX = Math.Max(bounds.Location.X - difference.X, _minimum);
|
||||
|
||||
if (_maximum != 0 && rightX > _maximum)
|
||||
rightX = _maximum;
|
||||
|
||||
bounds.Location = new Point(rightX, bounds.Location.Y);
|
||||
break;
|
||||
case DarkSplitterType.Top:
|
||||
var topY = Math.Max(bounds.Location.Y - difference.Y, _minimum);
|
||||
|
||||
if (_maximum != 0 && topY > _maximum)
|
||||
topY = _maximum;
|
||||
|
||||
bounds.Location = new Point(bounds.Location.X, topY);
|
||||
break;
|
||||
case DarkSplitterType.Bottom:
|
||||
var bottomY = Math.Max(bounds.Location.Y - difference.Y, _minimum);
|
||||
|
||||
if (_maximum != 0 && bottomY > _maximum)
|
||||
topY = _maximum;
|
||||
|
||||
bounds.Location = new Point(bounds.Location.X, bottomY);
|
||||
break;
|
||||
}
|
||||
|
||||
_overlayForm.Bounds = bounds;
|
||||
}
|
||||
|
||||
public void Move(Point difference)
|
||||
{
|
||||
switch (_splitterType)
|
||||
{
|
||||
case DarkSplitterType.Left:
|
||||
_control.Width += difference.X;
|
||||
break;
|
||||
case DarkSplitterType.Right:
|
||||
_control.Width -= difference.X;
|
||||
break;
|
||||
case DarkSplitterType.Top:
|
||||
_control.Height += difference.Y;
|
||||
break;
|
||||
case DarkSplitterType.Bottom:
|
||||
_control.Height -= difference.Y;
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateBounds();
|
||||
}
|
||||
|
||||
public void UpdateBounds()
|
||||
{
|
||||
var bounds = _parentControl.RectangleToScreen(_control.Bounds);
|
||||
|
||||
switch (_splitterType)
|
||||
{
|
||||
case DarkSplitterType.Left:
|
||||
Bounds = new Rectangle(bounds.Left - 2, bounds.Top, 5, bounds.Height);
|
||||
_maximum = bounds.Right - 2 - _control.MinimumSize.Width;
|
||||
break;
|
||||
case DarkSplitterType.Right:
|
||||
Bounds = new Rectangle(bounds.Right - 2, bounds.Top, 5, bounds.Height);
|
||||
_minimum = bounds.Left - 2 + _control.MinimumSize.Width;
|
||||
break;
|
||||
case DarkSplitterType.Top:
|
||||
Bounds = new Rectangle(bounds.Left, bounds.Top - 2, bounds.Width, 5);
|
||||
_maximum = bounds.Bottom - 2 - _control.MinimumSize.Height;
|
||||
break;
|
||||
case DarkSplitterType.Bottom:
|
||||
Bounds = new Rectangle(bounds.Left, bounds.Bottom - 2, bounds.Width, 5);
|
||||
_minimum = bounds.Top - 2 + _control.MinimumSize.Height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
44
DarkUI/Docking/DarkDockTab.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
internal class DarkDockTab
|
||||
{
|
||||
#region Property Region
|
||||
|
||||
public DarkDockContent DockContent { get; set; }
|
||||
|
||||
public Rectangle ClientRectangle { get; set; }
|
||||
|
||||
public Rectangle CloseButtonRectangle { get; set; }
|
||||
|
||||
public bool Hot { get; set; }
|
||||
|
||||
public bool CloseButtonHot { get; set; }
|
||||
|
||||
public bool ShowSeparator { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkDockTab(DarkDockContent content)
|
||||
{
|
||||
DockContent = content;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public int CalculateWidth(Graphics g, Font font)
|
||||
{
|
||||
var width = (int)g.MeasureString(DockContent.DockText, font).Width;
|
||||
width += 10;
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
107
DarkUI/Docking/DarkDockTabArea.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using DarkUI.Controls;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
internal class DarkDockTabArea
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private Dictionary<DarkDockContent, DarkDockTab> _tabs = new Dictionary<DarkDockContent, DarkDockTab>();
|
||||
|
||||
private List<ToolStripMenuItem> _menuItems = new List<ToolStripMenuItem>();
|
||||
private DarkContextMenu _tabMenu = new DarkContextMenu();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
public DarkDockArea DockArea { get; private set; }
|
||||
|
||||
public Rectangle ClientRectangle { get; set; }
|
||||
|
||||
public Rectangle DropdownRectangle { get; set; }
|
||||
|
||||
public bool DropdownHot { get; set; }
|
||||
|
||||
public int Offset { get; set; }
|
||||
|
||||
public int TotalTabSize { get; set; }
|
||||
|
||||
public bool Visible { get; set; }
|
||||
|
||||
public DarkDockTab ClickedCloseButton { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkDockTabArea(DarkDockArea dockArea)
|
||||
{
|
||||
DockArea = dockArea;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public void ShowMenu(Control control, Point location)
|
||||
{
|
||||
_tabMenu.Show(control, location);
|
||||
}
|
||||
|
||||
public void AddMenuItem(ToolStripMenuItem menuItem)
|
||||
{
|
||||
_menuItems.Add(menuItem);
|
||||
RebuildMenu();
|
||||
}
|
||||
|
||||
public void RemoveMenuItem(ToolStripMenuItem menuItem)
|
||||
{
|
||||
_menuItems.Remove(menuItem);
|
||||
RebuildMenu();
|
||||
}
|
||||
|
||||
public ToolStripMenuItem GetMenuItem(DarkDockContent content)
|
||||
{
|
||||
ToolStripMenuItem menuItem = null;
|
||||
foreach (ToolStripMenuItem item in _menuItems)
|
||||
{
|
||||
var menuContent = item.Tag as DarkDockContent;
|
||||
if (menuContent == null)
|
||||
continue;
|
||||
|
||||
if (menuContent == content)
|
||||
menuItem = item;
|
||||
}
|
||||
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
public void RebuildMenu()
|
||||
{
|
||||
_tabMenu.Items.Clear();
|
||||
|
||||
var orderedItems = new List<ToolStripMenuItem>();
|
||||
|
||||
var index = 0;
|
||||
for (var i = 0; i < _menuItems.Count; i++)
|
||||
{
|
||||
foreach (var item in _menuItems)
|
||||
{
|
||||
var content = (DarkDockContent)item.Tag;
|
||||
if (content.Order == index)
|
||||
orderedItems.Add(item);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
foreach (var item in orderedItems)
|
||||
_tabMenu.Items.Add(item);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
30
DarkUI/Docking/DarkDocument.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using DarkUI.Config;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
[ToolboxItem(false)]
|
||||
public class DarkDocument : DarkDockContent
|
||||
{
|
||||
#region Property Region
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new DarkDockArea DefaultDockArea
|
||||
{
|
||||
get { return base.DefaultDockArea; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkDocument()
|
||||
{
|
||||
BackColor = Colors.GreyBackground;
|
||||
base.DefaultDockArea = DarkDockArea.Document;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
10
DarkUI/Docking/DarkSplitterType.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
public enum DarkSplitterType
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Top,
|
||||
Bottom
|
||||
}
|
||||
}
|
231
DarkUI/Docking/DarkToolWindow.cs
Normal file
@ -0,0 +1,231 @@
|
||||
using DarkUI.Config;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
[ToolboxItem(false)]
|
||||
public class DarkToolWindow : DarkDockContent
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private Rectangle _closeButtonRect;
|
||||
private bool _closeButtonHot = false;
|
||||
private bool _closeButtonPressed = false;
|
||||
|
||||
private Rectangle _headerRect;
|
||||
private bool _shouldDrag;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Padding Padding
|
||||
{
|
||||
get { return base.Padding; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkToolWindow()
|
||||
{
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.UserPaint, true);
|
||||
|
||||
BackColor = Colors.GreyBackground;
|
||||
base.Padding = new Padding(0, Consts.ToolWindowHeaderSize, 0, 0);
|
||||
|
||||
UpdateCloseButton();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
private bool IsActive()
|
||||
{
|
||||
if (DockPanel == null)
|
||||
return false;
|
||||
|
||||
return DockPanel.ActiveContent == this;
|
||||
}
|
||||
|
||||
private void UpdateCloseButton()
|
||||
{
|
||||
_headerRect = new Rectangle
|
||||
{
|
||||
X = ClientRectangle.Left,
|
||||
Y = ClientRectangle.Top,
|
||||
Width = ClientRectangle.Width,
|
||||
Height = Consts.ToolWindowHeaderSize
|
||||
};
|
||||
|
||||
_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();
|
||||
}
|
||||
|
||||
if (_shouldDrag)
|
||||
{
|
||||
DockPanel.DragContent(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (_closeButtonRect.Contains(e.Location))
|
||||
{
|
||||
_closeButtonPressed = true;
|
||||
_closeButtonHot = true;
|
||||
Invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_headerRect.Contains(e.Location))
|
||||
{
|
||||
_shouldDrag = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
if (_closeButtonRect.Contains(e.Location) && _closeButtonPressed)
|
||||
Close();
|
||||
|
||||
_closeButtonPressed = false;
|
||||
_closeButtonHot = false;
|
||||
|
||||
_shouldDrag = false;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
// Fill body
|
||||
using (var b = new SolidBrush(Colors.GreyBackground))
|
||||
{
|
||||
g.FillRectangle(b, ClientRectangle);
|
||||
}
|
||||
|
||||
var isActive = IsActive();
|
||||
|
||||
// Draw header
|
||||
var bgColor = isActive ? Colors.BlueBackground : Colors.HeaderBackground;
|
||||
var darkColor = isActive ? Colors.DarkBlueBorder : Colors.DarkBorder;
|
||||
var lightColor = isActive ? Colors.LightBlueBorder : Colors.LightBorder;
|
||||
|
||||
using (var b = new SolidBrush(bgColor))
|
||||
{
|
||||
var bgRect = new Rectangle(0, 0, ClientRectangle.Width, Consts.ToolWindowHeaderSize);
|
||||
g.FillRectangle(b, bgRect);
|
||||
}
|
||||
|
||||
using (var p = new Pen(darkColor))
|
||||
{
|
||||
g.DrawLine(p, ClientRectangle.Left, 0, ClientRectangle.Right, 0);
|
||||
g.DrawLine(p, ClientRectangle.Left, Consts.ToolWindowHeaderSize - 1, ClientRectangle.Right, Consts.ToolWindowHeaderSize - 1);
|
||||
}
|
||||
|
||||
using (var p = new Pen(lightColor))
|
||||
{
|
||||
g.DrawLine(p, ClientRectangle.Left, 1, ClientRectangle.Right, 1);
|
||||
}
|
||||
|
||||
var xOffset = 2;
|
||||
|
||||
// Draw icon
|
||||
if (Icon != null)
|
||||
{
|
||||
g.DrawImageUnscaled(Icon, ClientRectangle.Left + 5, ClientRectangle.Top + (Consts.ToolWindowHeaderSize / 2) - (Icon.Height / 2) + 1);
|
||||
xOffset = Icon.Width + 8;
|
||||
}
|
||||
|
||||
// Draw text
|
||||
using (var b = new SolidBrush(Colors.LightText))
|
||||
{
|
||||
var textRect = new Rectangle(xOffset, 0, ClientRectangle.Width - 4 - xOffset, Consts.ToolWindowHeaderSize);
|
||||
|
||||
var format = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Near,
|
||||
LineAlignment = StringAlignment.Center,
|
||||
FormatFlags = StringFormatFlags.NoWrap,
|
||||
Trimming = StringTrimming.EllipsisCharacter
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
// Absorb event
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
14
DarkUI/Docking/DockContentEventArgs.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
public class DockContentEventArgs : EventArgs
|
||||
{
|
||||
public DarkDockContent Content { get; private set; }
|
||||
|
||||
public DockContentEventArgs(DarkDockContent content)
|
||||
{
|
||||
Content = content;
|
||||
}
|
||||
}
|
||||
}
|
204
DarkUI/Docking/DockDropArea.cs
Normal file
@ -0,0 +1,204 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
internal class DockDropArea
|
||||
{
|
||||
#region Property Region
|
||||
|
||||
internal DarkDockPanel DockPanel { get; private set; }
|
||||
|
||||
internal Rectangle DropArea { get; private set; }
|
||||
|
||||
internal Rectangle HighlightArea { get; private set; }
|
||||
|
||||
internal DarkDockRegion DockRegion { get; private set; }
|
||||
|
||||
internal DarkDockGroup DockGroup { get; private set; }
|
||||
|
||||
internal DockInsertType InsertType { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
internal DockDropArea(DarkDockPanel dockPanel, DarkDockRegion region)
|
||||
{
|
||||
DockPanel = dockPanel;
|
||||
DockRegion = region;
|
||||
InsertType = DockInsertType.None;
|
||||
|
||||
BuildAreas();
|
||||
}
|
||||
|
||||
internal DockDropArea(DarkDockPanel dockPanel, DarkDockGroup group, DockInsertType insertType)
|
||||
{
|
||||
DockPanel = dockPanel;
|
||||
DockGroup = group;
|
||||
InsertType = insertType;
|
||||
|
||||
BuildAreas();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
internal void BuildAreas()
|
||||
{
|
||||
if (DockRegion != null)
|
||||
BuildRegionAreas();
|
||||
else if (DockGroup != null)
|
||||
BuildGroupAreas();
|
||||
}
|
||||
|
||||
private void BuildRegionAreas()
|
||||
{
|
||||
switch (DockRegion.DockArea)
|
||||
{
|
||||
case DarkDockArea.Left:
|
||||
|
||||
var leftRect = new Rectangle
|
||||
{
|
||||
X = DockPanel.PointToScreen(Point.Empty).X,
|
||||
Y = DockPanel.PointToScreen(Point.Empty).Y,
|
||||
Width = 50,
|
||||
Height = DockPanel.Height
|
||||
};
|
||||
|
||||
DropArea = leftRect;
|
||||
HighlightArea = leftRect;
|
||||
|
||||
break;
|
||||
|
||||
case DarkDockArea.Right:
|
||||
|
||||
var rightRect = new Rectangle
|
||||
{
|
||||
X = DockPanel.PointToScreen(Point.Empty).X + DockPanel.Width - 50,
|
||||
Y = DockPanel.PointToScreen(Point.Empty).Y,
|
||||
Width = 50,
|
||||
Height = DockPanel.Height
|
||||
};
|
||||
|
||||
DropArea = rightRect;
|
||||
HighlightArea = rightRect;
|
||||
|
||||
break;
|
||||
|
||||
case DarkDockArea.Bottom:
|
||||
|
||||
var x = DockPanel.PointToScreen(Point.Empty).X;
|
||||
var width = DockPanel.Width;
|
||||
|
||||
if (DockPanel.Regions[DarkDockArea.Left].Visible)
|
||||
{
|
||||
x += DockPanel.Regions[DarkDockArea.Left].Width;
|
||||
width -= DockPanel.Regions[DarkDockArea.Left].Width;
|
||||
}
|
||||
|
||||
if (DockPanel.Regions[DarkDockArea.Right].Visible)
|
||||
{
|
||||
width -= DockPanel.Regions[DarkDockArea.Right].Width;
|
||||
}
|
||||
|
||||
var bottomRect = new Rectangle
|
||||
{
|
||||
X = x,
|
||||
Y = DockPanel.PointToScreen(Point.Empty).Y + DockPanel.Height - 50,
|
||||
Width = width,
|
||||
Height = 50
|
||||
};
|
||||
|
||||
DropArea = bottomRect;
|
||||
HighlightArea = bottomRect;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildGroupAreas()
|
||||
{
|
||||
switch (InsertType)
|
||||
{
|
||||
case DockInsertType.None:
|
||||
var dropRect = new Rectangle
|
||||
{
|
||||
X = DockGroup.PointToScreen(Point.Empty).X,
|
||||
Y = DockGroup.PointToScreen(Point.Empty).Y,
|
||||
Width = DockGroup.Width,
|
||||
Height = DockGroup.Height
|
||||
};
|
||||
|
||||
DropArea = dropRect;
|
||||
HighlightArea = dropRect;
|
||||
|
||||
break;
|
||||
|
||||
case DockInsertType.Before:
|
||||
var beforeDropWidth = DockGroup.Width;
|
||||
var beforeDropHeight = DockGroup.Height;
|
||||
|
||||
switch (DockGroup.DockArea)
|
||||
{
|
||||
case DarkDockArea.Left:
|
||||
case DarkDockArea.Right:
|
||||
beforeDropHeight = DockGroup.Height / 4;
|
||||
break;
|
||||
|
||||
case DarkDockArea.Bottom:
|
||||
beforeDropWidth = DockGroup.Width / 4;
|
||||
break;
|
||||
}
|
||||
|
||||
var beforeDropRect = new Rectangle
|
||||
{
|
||||
X = DockGroup.PointToScreen(Point.Empty).X,
|
||||
Y = DockGroup.PointToScreen(Point.Empty).Y,
|
||||
Width = beforeDropWidth,
|
||||
Height = beforeDropHeight
|
||||
};
|
||||
|
||||
DropArea = beforeDropRect;
|
||||
HighlightArea = beforeDropRect;
|
||||
|
||||
break;
|
||||
|
||||
case DockInsertType.After:
|
||||
var afterDropX = DockGroup.PointToScreen(Point.Empty).X;
|
||||
var afterDropY = DockGroup.PointToScreen(Point.Empty).Y;
|
||||
var afterDropWidth = DockGroup.Width;
|
||||
var afterDropHeight = DockGroup.Height;
|
||||
|
||||
switch (DockGroup.DockArea)
|
||||
{
|
||||
case DarkDockArea.Left:
|
||||
case DarkDockArea.Right:
|
||||
afterDropHeight = DockGroup.Height / 4;
|
||||
afterDropY = DockGroup.PointToScreen(Point.Empty).Y + DockGroup.Height - afterDropHeight;
|
||||
break;
|
||||
|
||||
case DarkDockArea.Bottom:
|
||||
afterDropWidth = DockGroup.Width / 4;
|
||||
afterDropX = DockGroup.PointToScreen(Point.Empty).X + DockGroup.Width - afterDropWidth;
|
||||
break;
|
||||
}
|
||||
|
||||
var afterDropRect = new Rectangle
|
||||
{
|
||||
X = afterDropX,
|
||||
Y = afterDropY,
|
||||
Width = afterDropWidth,
|
||||
Height = afterDropHeight
|
||||
};
|
||||
|
||||
DropArea = afterDropRect;
|
||||
HighlightArea = afterDropRect;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
26
DarkUI/Docking/DockDropCollection.cs
Normal file
@ -0,0 +1,26 @@
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
internal class DockDropCollection
|
||||
{
|
||||
#region Property Region
|
||||
|
||||
internal DockDropArea DropArea { get; private set; }
|
||||
|
||||
internal DockDropArea InsertBeforeArea { get; private set; }
|
||||
|
||||
internal DockDropArea InsertAfterArea { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
internal DockDropCollection(DarkDockPanel dockPanel, DarkDockGroup group)
|
||||
{
|
||||
DropArea = new DockDropArea(dockPanel, group, DockInsertType.None);
|
||||
InsertBeforeArea = new DockDropArea(dockPanel, group, DockInsertType.Before);
|
||||
InsertAfterArea = new DockDropArea(dockPanel, group, DockInsertType.After);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
22
DarkUI/Docking/DockGroupState.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
public class DockGroupState
|
||||
{
|
||||
#region Property Region
|
||||
|
||||
public List<string> Contents { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DockGroupState()
|
||||
{
|
||||
Contents = new List<string>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
9
DarkUI/Docking/DockInsertType.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
public enum DockInsertType
|
||||
{
|
||||
None,
|
||||
Before,
|
||||
After
|
||||
}
|
||||
}
|
22
DarkUI/Docking/DockPanelState.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
public class DockPanelState
|
||||
{
|
||||
#region Property Region
|
||||
|
||||
public List<DockRegionState> Regions { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DockPanelState()
|
||||
{
|
||||
Regions = new List<DockRegionState>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
39
DarkUI/Docking/DockRegionState.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DarkUI.Docking
|
||||
{
|
||||
public class DockRegionState
|
||||
{
|
||||
#region Property Region
|
||||
|
||||
public DarkDockArea Area { get; set; }
|
||||
|
||||
public Size Size { get; set; }
|
||||
|
||||
public List<DockGroupState> Groups { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DockRegionState()
|
||||
{
|
||||
Groups = new List<DockGroupState>();
|
||||
}
|
||||
|
||||
public DockRegionState(DarkDockArea area)
|
||||
: this()
|
||||
{
|
||||
Area = area;
|
||||
}
|
||||
|
||||
public DockRegionState(DarkDockArea area, Size size)
|
||||
: this(area)
|
||||
{
|
||||
Size = size;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
37
DarkUI/Extensions/BitmapExtensions.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DarkUI.Extensions
|
||||
{
|
||||
internal static class BitmapExtensions
|
||||
{
|
||||
internal static Bitmap SetColor(this Bitmap bitmap, Color color)
|
||||
{
|
||||
var newBitmap = new Bitmap(bitmap.Width, bitmap.Height);
|
||||
for (int i = 0; i < bitmap.Width; i++)
|
||||
{
|
||||
for (int j = 0; j < bitmap.Height; j++)
|
||||
{
|
||||
var pixel = bitmap.GetPixel(i, j);
|
||||
if (pixel.A > 0)
|
||||
newBitmap.SetPixel(i, j, color);
|
||||
}
|
||||
}
|
||||
return newBitmap;
|
||||
}
|
||||
|
||||
internal static Bitmap ChangeColor(this Bitmap bitmap, Color oldColor, Color newColor)
|
||||
{
|
||||
var newBitmap = new Bitmap(bitmap.Width, bitmap.Height);
|
||||
for (int i = 0; i < bitmap.Width; i++)
|
||||
{
|
||||
for (int j = 0; j < bitmap.Height; j++)
|
||||
{
|
||||
var pixel = bitmap.GetPixel(i, j);
|
||||
if (pixel == oldColor)
|
||||
newBitmap.SetPixel(i, j, newColor);
|
||||
}
|
||||
}
|
||||
return newBitmap;
|
||||
}
|
||||
}
|
||||
}
|
29
DarkUI/Extensions/IEnumerableExtensions.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DarkUI.Extensions
|
||||
{
|
||||
internal static class IEnumerableExtensions
|
||||
{
|
||||
internal static bool IsLast<T>(this IEnumerable<T> items, T item)
|
||||
{
|
||||
var last = items.LastOrDefault();
|
||||
if (last == null)
|
||||
return false;
|
||||
return item.Equals(last);
|
||||
}
|
||||
|
||||
internal static bool IsFirst<T>(this IEnumerable<T> items, T item)
|
||||
{
|
||||
var first = items.FirstOrDefault();
|
||||
if (first == null)
|
||||
return false;
|
||||
return item.Equals(first);
|
||||
}
|
||||
|
||||
internal static bool IsFirstOrLast<T>(this IEnumerable<T> items, T item)
|
||||
{
|
||||
return items.IsFirst(item) || items.IsLast(item);
|
||||
}
|
||||
}
|
||||
}
|
180
DarkUI/Forms/DarkDialog.Designer.cs
generated
Normal file
@ -0,0 +1,180 @@
|
||||
using DarkUI.Controls;
|
||||
|
||||
namespace DarkUI.Forms
|
||||
{
|
||||
partial class DarkDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pnlFooter = new System.Windows.Forms.Panel();
|
||||
this.flowInner = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.btnOk = new DarkButton();
|
||||
this.btnCancel = new DarkButton();
|
||||
this.btnClose = new DarkButton();
|
||||
this.btnYes = new DarkButton();
|
||||
this.btnNo = new DarkButton();
|
||||
this.btnAbort = new DarkButton();
|
||||
this.btnRetry = new DarkButton();
|
||||
this.btnIgnore = new DarkButton();
|
||||
this.pnlFooter.SuspendLayout();
|
||||
this.flowInner.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pnlFooter
|
||||
//
|
||||
this.pnlFooter.Controls.Add(this.flowInner);
|
||||
this.pnlFooter.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.pnlFooter.Location = new System.Drawing.Point(0, 357);
|
||||
this.pnlFooter.Name = "pnlFooter";
|
||||
this.pnlFooter.Size = new System.Drawing.Size(767, 45);
|
||||
this.pnlFooter.TabIndex = 1;
|
||||
//
|
||||
// flowInner
|
||||
//
|
||||
this.flowInner.Controls.Add(this.btnOk);
|
||||
this.flowInner.Controls.Add(this.btnCancel);
|
||||
this.flowInner.Controls.Add(this.btnClose);
|
||||
this.flowInner.Controls.Add(this.btnYes);
|
||||
this.flowInner.Controls.Add(this.btnNo);
|
||||
this.flowInner.Controls.Add(this.btnAbort);
|
||||
this.flowInner.Controls.Add(this.btnRetry);
|
||||
this.flowInner.Controls.Add(this.btnIgnore);
|
||||
this.flowInner.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.flowInner.Location = new System.Drawing.Point(104, 0);
|
||||
this.flowInner.Name = "flowInner";
|
||||
this.flowInner.Padding = new System.Windows.Forms.Padding(10);
|
||||
this.flowInner.Size = new System.Drawing.Size(663, 45);
|
||||
this.flowInner.TabIndex = 10014;
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnOk.Location = new System.Drawing.Point(10, 10);
|
||||
this.btnOk.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnOk.Name = "btnOk";
|
||||
this.btnOk.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.btnOk.Size = new System.Drawing.Size(75, 26);
|
||||
this.btnOk.TabIndex = 3;
|
||||
this.btnOk.Text = "Ok";
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Location = new System.Drawing.Point(85, 10);
|
||||
this.btnCancel.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.btnCancel.Size = new System.Drawing.Size(75, 26);
|
||||
this.btnCancel.TabIndex = 4;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnClose.Location = new System.Drawing.Point(160, 10);
|
||||
this.btnClose.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.btnClose.Size = new System.Drawing.Size(75, 26);
|
||||
this.btnClose.TabIndex = 5;
|
||||
this.btnClose.Text = "Close";
|
||||
//
|
||||
// btnYes
|
||||
//
|
||||
this.btnYes.DialogResult = System.Windows.Forms.DialogResult.Yes;
|
||||
this.btnYes.Location = new System.Drawing.Point(235, 10);
|
||||
this.btnYes.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnYes.Name = "btnYes";
|
||||
this.btnYes.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.btnYes.Size = new System.Drawing.Size(75, 26);
|
||||
this.btnYes.TabIndex = 6;
|
||||
this.btnYes.Text = "Yes";
|
||||
//
|
||||
// btnNo
|
||||
//
|
||||
this.btnNo.DialogResult = System.Windows.Forms.DialogResult.No;
|
||||
this.btnNo.Location = new System.Drawing.Point(310, 10);
|
||||
this.btnNo.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnNo.Name = "btnNo";
|
||||
this.btnNo.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.btnNo.Size = new System.Drawing.Size(75, 26);
|
||||
this.btnNo.TabIndex = 7;
|
||||
this.btnNo.Text = "No";
|
||||
//
|
||||
// btnAbort
|
||||
//
|
||||
this.btnAbort.DialogResult = System.Windows.Forms.DialogResult.Abort;
|
||||
this.btnAbort.Location = new System.Drawing.Point(385, 10);
|
||||
this.btnAbort.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnAbort.Name = "btnAbort";
|
||||
this.btnAbort.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.btnAbort.Size = new System.Drawing.Size(75, 26);
|
||||
this.btnAbort.TabIndex = 8;
|
||||
this.btnAbort.Text = "Abort";
|
||||
//
|
||||
// btnRetry
|
||||
//
|
||||
this.btnRetry.DialogResult = System.Windows.Forms.DialogResult.Retry;
|
||||
this.btnRetry.Location = new System.Drawing.Point(460, 10);
|
||||
this.btnRetry.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnRetry.Name = "btnRetry";
|
||||
this.btnRetry.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.btnRetry.Size = new System.Drawing.Size(75, 26);
|
||||
this.btnRetry.TabIndex = 9;
|
||||
this.btnRetry.Text = "Retry";
|
||||
//
|
||||
// btnIgnore
|
||||
//
|
||||
this.btnIgnore.DialogResult = System.Windows.Forms.DialogResult.Ignore;
|
||||
this.btnIgnore.Location = new System.Drawing.Point(535, 10);
|
||||
this.btnIgnore.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnIgnore.Name = "btnIgnore";
|
||||
this.btnIgnore.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.btnIgnore.Size = new System.Drawing.Size(75, 26);
|
||||
this.btnIgnore.TabIndex = 10;
|
||||
this.btnIgnore.Text = "Ignore";
|
||||
//
|
||||
// DarkDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(767, 402);
|
||||
this.Controls.Add(this.pnlFooter);
|
||||
this.Name = "DarkDialog";
|
||||
this.Text = "DarkDialog";
|
||||
this.pnlFooter.ResumeLayout(false);
|
||||
this.flowInner.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel pnlFooter;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowInner;
|
||||
}
|
||||
}
|
176
DarkUI/Forms/DarkDialog.cs
Normal file
@ -0,0 +1,176 @@
|
||||
using DarkUI.Controls;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Forms
|
||||
{
|
||||
public partial class DarkDialog : DarkForm
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private DarkDialogButton _dialogButtons = DarkDialogButton.Ok;
|
||||
private List<DarkButton> _buttons;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Button Region
|
||||
|
||||
protected DarkButton btnOk;
|
||||
protected DarkButton btnCancel;
|
||||
protected DarkButton btnClose;
|
||||
protected DarkButton btnYes;
|
||||
protected DarkButton btnNo;
|
||||
protected DarkButton btnAbort;
|
||||
protected DarkButton btnRetry;
|
||||
protected DarkButton btnIgnore;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Description("Determines the type of the dialog window.")]
|
||||
[DefaultValue(DarkDialogButton.Ok)]
|
||||
public DarkDialogButton DialogButtons
|
||||
{
|
||||
get { return _dialogButtons; }
|
||||
set
|
||||
{
|
||||
if (_dialogButtons == value)
|
||||
return;
|
||||
|
||||
_dialogButtons = value;
|
||||
SetButtons();
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public int TotalButtonSize { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new IButtonControl AcceptButton
|
||||
{
|
||||
get { return base.AcceptButton; }
|
||||
private set { base.AcceptButton = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new IButtonControl CancelButton
|
||||
{
|
||||
get { return base.CancelButton; }
|
||||
private set { base.CancelButton = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_buttons = new List<DarkButton>
|
||||
{
|
||||
btnAbort, btnRetry, btnIgnore, btnOk,
|
||||
btnCancel, btnClose, btnYes, btnNo
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnLoad(System.EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
SetButtons();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
private void SetButtons()
|
||||
{
|
||||
foreach (var btn in _buttons)
|
||||
btn.Visible = false;
|
||||
|
||||
switch (_dialogButtons)
|
||||
{
|
||||
case DarkDialogButton.Ok:
|
||||
ShowButton(btnOk, true);
|
||||
AcceptButton = btnOk;
|
||||
break;
|
||||
case DarkDialogButton.Close:
|
||||
ShowButton(btnClose, true);
|
||||
AcceptButton = btnClose;
|
||||
CancelButton = btnClose;
|
||||
break;
|
||||
case DarkDialogButton.OkCancel:
|
||||
ShowButton(btnOk);
|
||||
ShowButton(btnCancel, true);
|
||||
AcceptButton = btnOk;
|
||||
CancelButton = btnCancel;
|
||||
break;
|
||||
case DarkDialogButton.AbortRetryIgnore:
|
||||
ShowButton(btnAbort);
|
||||
ShowButton(btnRetry);
|
||||
ShowButton(btnIgnore, true);
|
||||
AcceptButton = btnAbort;
|
||||
CancelButton = btnIgnore;
|
||||
break;
|
||||
case DarkDialogButton.RetryCancel:
|
||||
ShowButton(btnRetry);
|
||||
ShowButton(btnCancel, true);
|
||||
AcceptButton = btnRetry;
|
||||
CancelButton = btnCancel;
|
||||
break;
|
||||
case DarkDialogButton.YesNo:
|
||||
ShowButton(btnYes);
|
||||
ShowButton(btnNo, true);
|
||||
AcceptButton = btnYes;
|
||||
CancelButton = btnNo;
|
||||
break;
|
||||
case DarkDialogButton.YesNoCancel:
|
||||
ShowButton(btnYes);
|
||||
ShowButton(btnNo);
|
||||
ShowButton(btnCancel, true);
|
||||
AcceptButton = btnYes;
|
||||
CancelButton = btnCancel;
|
||||
break;
|
||||
}
|
||||
|
||||
SetFlowSize();
|
||||
}
|
||||
|
||||
private void ShowButton(DarkButton button, bool isLast = false)
|
||||
{
|
||||
button.SendToBack();
|
||||
|
||||
if (!isLast)
|
||||
button.Margin = new Padding(0, 0, 10, 0);
|
||||
|
||||
button.Visible = true;
|
||||
}
|
||||
|
||||
private void SetFlowSize()
|
||||
{
|
||||
var width = flowInner.Padding.Horizontal;
|
||||
|
||||
foreach (var btn in _buttons)
|
||||
{
|
||||
if (btn.Visible)
|
||||
width += btn.Width + btn.Margin.Right;
|
||||
}
|
||||
|
||||
flowInner.Width = width;
|
||||
TotalButtonSize = width;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
120
DarkUI/Forms/DarkDialog.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
13
DarkUI/Forms/DarkDialogButton.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace DarkUI.Forms
|
||||
{
|
||||
public enum DarkDialogButton
|
||||
{
|
||||
Ok,
|
||||
Close,
|
||||
OkCancel,
|
||||
YesNo,
|
||||
YesNoCancel,
|
||||
AbortRetryIgnore,
|
||||
RetryCancel
|
||||
}
|
||||
}
|
62
DarkUI/Forms/DarkForm.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using DarkUI.Config;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Forms
|
||||
{
|
||||
public class DarkForm : Form
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private bool _flatBorder;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Category("Appearance")]
|
||||
[Description("Determines whether a single pixel border should be rendered around the form.")]
|
||||
[DefaultValue(false)]
|
||||
public bool FlatBorder
|
||||
{
|
||||
get { return _flatBorder; }
|
||||
set
|
||||
{
|
||||
_flatBorder = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkForm()
|
||||
{
|
||||
BackColor = Colors.GreyBackground;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint Region
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaintBackground(e);
|
||||
|
||||
if (!_flatBorder)
|
||||
return;
|
||||
|
||||
var g = e.Graphics;
|
||||
|
||||
using (var p = new Pen(Colors.DarkBorder))
|
||||
{
|
||||
var modRect = new Rectangle(ClientRectangle.Location, new Size(ClientRectangle.Width - 1, ClientRectangle.Height - 1));
|
||||
g.DrawRectangle(p, modRect);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
83
DarkUI/Forms/DarkMessageBox.Designer.cs
generated
Normal file
@ -0,0 +1,83 @@
|
||||
using DarkUI.Controls;
|
||||
|
||||
namespace DarkUI.Forms
|
||||
{
|
||||
partial class DarkMessageBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.picIcon = new System.Windows.Forms.PictureBox();
|
||||
this.lblText = new DarkLabel();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picIcon)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// picIcon
|
||||
//
|
||||
this.picIcon.Location = new System.Drawing.Point(10, 10);
|
||||
this.picIcon.Name = "picIcon";
|
||||
this.picIcon.Size = new System.Drawing.Size(32, 32);
|
||||
this.picIcon.TabIndex = 3;
|
||||
this.picIcon.TabStop = false;
|
||||
//
|
||||
// lblText
|
||||
//
|
||||
this.lblText.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
|
||||
this.lblText.Location = new System.Drawing.Point(50, 9);
|
||||
this.lblText.Name = "lblText";
|
||||
this.lblText.Size = new System.Drawing.Size(185, 15);
|
||||
this.lblText.TabIndex = 4;
|
||||
this.lblText.Text = "Something something something";
|
||||
//
|
||||
// DarkMessageBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(244, 86);
|
||||
this.Controls.Add(this.lblText);
|
||||
this.Controls.Add(this.picIcon);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "DarkMessageBox";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Message box";
|
||||
this.Controls.SetChildIndex(this.picIcon, 0);
|
||||
this.Controls.SetChildIndex(this.lblText, 0);
|
||||
((System.ComponentModel.ISupportInitialize)(this.picIcon)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox picIcon;
|
||||
private DarkLabel lblText;
|
||||
}
|
||||
}
|
177
DarkUI/Forms/DarkMessageBox.cs
Normal file
@ -0,0 +1,177 @@
|
||||
using DarkUI.Icons;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Forms
|
||||
{
|
||||
public partial class DarkMessageBox : DarkDialog
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private string _message;
|
||||
private int _maximumWidth = 350;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Region
|
||||
|
||||
[Description("Determines the maximum width of the message box when it autosizes around the displayed message.")]
|
||||
[DefaultValue(350)]
|
||||
public int MaximumWidth
|
||||
{
|
||||
get { return _maximumWidth; }
|
||||
set
|
||||
{
|
||||
_maximumWidth = value;
|
||||
CalculateSize();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkMessageBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public DarkMessageBox(string message, string title, DarkMessageBoxIcon icon, DarkDialogButton buttons)
|
||||
: this()
|
||||
{
|
||||
Text = title;
|
||||
_message = message;
|
||||
|
||||
DialogButtons = buttons;
|
||||
SetIcon(icon);
|
||||
}
|
||||
|
||||
public DarkMessageBox(string message)
|
||||
: this(message, null, DarkMessageBoxIcon.None, DarkDialogButton.Ok)
|
||||
{ }
|
||||
|
||||
public DarkMessageBox(string message, string title)
|
||||
: this(message, title, DarkMessageBoxIcon.None, DarkDialogButton.Ok)
|
||||
{ }
|
||||
|
||||
public DarkMessageBox(string message, string title, DarkDialogButton buttons)
|
||||
: this(message, title, DarkMessageBoxIcon.None, buttons)
|
||||
{ }
|
||||
|
||||
public DarkMessageBox(string message, string title, DarkMessageBoxIcon icon)
|
||||
: this(message, title, icon, DarkDialogButton.Ok)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static Method Region
|
||||
|
||||
public static DialogResult ShowInformation(string message, string caption, DarkDialogButton buttons = DarkDialogButton.Ok)
|
||||
{
|
||||
return ShowDialog(message, caption, DarkMessageBoxIcon.Information, buttons);
|
||||
}
|
||||
|
||||
public static DialogResult ShowWarning(string message, string caption, DarkDialogButton buttons = DarkDialogButton.Ok)
|
||||
{
|
||||
return ShowDialog(message, caption, DarkMessageBoxIcon.Warning, buttons);
|
||||
}
|
||||
|
||||
public static DialogResult ShowError(string message, string caption, DarkDialogButton buttons = DarkDialogButton.Ok)
|
||||
{
|
||||
return ShowDialog(message, caption, DarkMessageBoxIcon.Error, buttons);
|
||||
}
|
||||
|
||||
private static DialogResult ShowDialog(string message, string caption, DarkMessageBoxIcon icon, DarkDialogButton buttons)
|
||||
{
|
||||
using (var dlg = new DarkMessageBox(message, caption, icon, buttons))
|
||||
{
|
||||
var result = dlg.ShowDialog();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
private void SetIcon(DarkMessageBoxIcon icon)
|
||||
{
|
||||
switch (icon)
|
||||
{
|
||||
case DarkMessageBoxIcon.None:
|
||||
picIcon.Visible = false;
|
||||
lblText.Left = 10;
|
||||
break;
|
||||
case DarkMessageBoxIcon.Information:
|
||||
picIcon.Image = MessageBoxIcons.info;
|
||||
break;
|
||||
case DarkMessageBoxIcon.Warning:
|
||||
picIcon.Image = MessageBoxIcons.warning;
|
||||
break;
|
||||
case DarkMessageBoxIcon.Error:
|
||||
picIcon.Image = MessageBoxIcons.error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void CalculateSize()
|
||||
{
|
||||
var width = 260; var height = 124;
|
||||
|
||||
// Reset form back to original size
|
||||
Size = new Size(width, height);
|
||||
|
||||
lblText.Text = string.Empty;
|
||||
lblText.AutoSize = true;
|
||||
lblText.Text = _message;
|
||||
|
||||
// Set the minimum dialog size to whichever is bigger - the original size or the buttons.
|
||||
var minWidth = Math.Max(width, TotalButtonSize + 15);
|
||||
|
||||
// Calculate the total size of the message
|
||||
var totalWidth = lblText.Right + 25;
|
||||
|
||||
// Make sure we're not making the dialog bigger than the maximum size
|
||||
if (totalWidth < _maximumWidth)
|
||||
{
|
||||
// Width is smaller than the maximum width.
|
||||
// This means we can have a single-line message box.
|
||||
// Move the label to accomodate this.
|
||||
width = totalWidth;
|
||||
lblText.Top = picIcon.Top + (picIcon.Height / 2) - (lblText.Height / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Width is larger than the maximum width.
|
||||
// Change the label size and wrap it.
|
||||
width = _maximumWidth;
|
||||
var offsetHeight = Height - picIcon.Height;
|
||||
lblText.AutoUpdateHeight = true;
|
||||
lblText.Width = width - lblText.Left - 25;
|
||||
height = offsetHeight + lblText.Height;
|
||||
}
|
||||
|
||||
// Force the width to the minimum width
|
||||
if (width < minWidth)
|
||||
width = minWidth;
|
||||
|
||||
// Set the new size of the dialog
|
||||
Size = new Size(width, height);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
CalculateSize();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
120
DarkUI/Forms/DarkMessageBox.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
10
DarkUI/Forms/DarkMessageBoxIcon.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace DarkUI.Forms
|
||||
{
|
||||
public enum DarkMessageBoxIcon
|
||||
{
|
||||
None,
|
||||
Information,
|
||||
Warning,
|
||||
Error
|
||||
}
|
||||
}
|
32
DarkUI/Forms/DarkTranslucentForm.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Forms
|
||||
{
|
||||
internal class DarkTranslucentForm : Form
|
||||
{
|
||||
#region Property Region
|
||||
|
||||
protected override bool ShowWithoutActivation
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DarkTranslucentForm(Color backColor, double opacity = 0.6)
|
||||
{
|
||||
StartPosition = FormStartPosition.Manual;
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
Size = new Size(1, 1);
|
||||
ShowInTaskbar = false;
|
||||
AllowTransparency = true;
|
||||
Opacity = opacity;
|
||||
BackColor = backColor;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
163
DarkUI/Icons/DockIcons.Designer.cs
generated
Normal file
@ -0,0 +1,163 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DarkUI {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class DockIcons {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal DockIcons() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DarkUI.Icons.DockIcons", typeof(DockIcons).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap active_inactive_close {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("active_inactive_close", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrow {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrow", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap close {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("close", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap close_selected {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("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 inactive_close {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("inactive_close", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap inactive_close_selected {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("inactive_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_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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
151
DarkUI/Icons/DockIcons.resx
Normal file
@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="active_inactive_close" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\active-inactive-close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="close" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="close_selected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\close-selected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="inactive_close" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\inactive-close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<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>
|
||||
</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>
|
83
DarkUI/Icons/MenuIcons.Designer.cs
generated
Normal file
@ -0,0 +1,83 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DarkUI.Icons {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class MenuIcons {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal MenuIcons() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DarkUI.Icons.MenuIcons", typeof(MenuIcons).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
public static System.Drawing.Bitmap grip {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("grip", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
public static System.Drawing.Bitmap tick {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("tick", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
127
DarkUI/Icons/MenuIcons.resx
Normal file
@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="grip" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\grip.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="tick" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\tick.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
93
DarkUI/Icons/MessageBoxIcons.Designer.cs
generated
Normal file
@ -0,0 +1,93 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DarkUI.Icons {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class MessageBoxIcons {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal MessageBoxIcons() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DarkUI.Icons.MessageBoxIcons", typeof(MessageBoxIcons).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap error {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("error", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap info {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("info", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap warning {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("warning", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
130
DarkUI/Icons/MessageBoxIcons.resx
Normal file
@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="error" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="info" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\info.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="warning" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\warning.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
103
DarkUI/Icons/ScrollIcons.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DarkUI.Icons {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class ScrollIcons {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal ScrollIcons() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DarkUI.Icons.ScrollIcons", typeof(ScrollIcons).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap scrollbar_arrow {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("scrollbar_arrow", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap scrollbar_arrow_clicked {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("scrollbar_arrow_clicked", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap scrollbar_arrow_hot {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("scrollbar_arrow_hot", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap scrollbar_arrow_standard {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("scrollbar_arrow_standard", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
DarkUI/Icons/ScrollIcons.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="scrollbar_arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\scrollbar_arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="scrollbar_arrow_clicked" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\scrollbar_arrow_clicked.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="scrollbar_arrow_hot" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\scrollbar_arrow_hot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="scrollbar_arrow_standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\scrollbar_arrow_standard.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
103
DarkUI/Icons/TreeViewIcons.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DarkUI.Icons {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class TreeViewIcons {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal TreeViewIcons() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DarkUI.Icons.TreeViewIcons", typeof(TreeViewIcons).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap node_closed_empty {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("node_closed_empty", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap node_closed_full {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("node_closed_full", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap node_open {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("node_open", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap node_open_empty {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("node_open_empty", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
DarkUI/Icons/TreeViewIcons.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="node_closed_empty" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\node_closed_empty.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="node_closed_full" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\node_closed_full.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="node_open" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\node_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="node_open_empty" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\node_open_empty.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
36
DarkUI/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Dark UI")]
|
||||
[assembly: AssemblyDescription("Dark themed control and docking library for .NET WinForms.")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Robin Perris")]
|
||||
[assembly: AssemblyProduct("Dark UI")]
|
||||
[assembly: AssemblyCopyright("Copyright © Robin Perris")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("f19472f5-8c44-4c51-a8a0-b9de5f555255")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
139
DarkUI/Renderers/DarkMenuRenderer.cs
Normal file
@ -0,0 +1,139 @@
|
||||
using DarkUI.Config;
|
||||
using DarkUI.Icons;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Renderers
|
||||
{
|
||||
public class DarkMenuRenderer : ToolStripRenderer
|
||||
{
|
||||
#region Initialisation Region
|
||||
|
||||
protected override void Initialize(ToolStrip toolStrip)
|
||||
{
|
||||
base.Initialize(toolStrip);
|
||||
|
||||
toolStrip.BackColor = Colors.GreyBackground;
|
||||
toolStrip.ForeColor = Colors.LightText;
|
||||
}
|
||||
|
||||
protected override void InitializeItem(ToolStripItem item)
|
||||
{
|
||||
base.InitializeItem(item);
|
||||
|
||||
item.ForeColor = Colors.LightText;
|
||||
|
||||
if (item.GetType() == typeof(ToolStripSeparator))
|
||||
{
|
||||
item.Margin = new Padding(0, 0, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Render Region
|
||||
|
||||
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
using (var b = new SolidBrush(Colors.GreyBackground))
|
||||
{
|
||||
g.FillRectangle(b, e.AffectedBounds);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
var rect = new Rectangle(0, 0, e.ToolStrip.Width - 1, e.ToolStrip.Height - 1);
|
||||
|
||||
using (var p = new Pen(Colors.LightBorder))
|
||||
{
|
||||
g.DrawRectangle(p, rect);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
var rect = new Rectangle(e.ImageRectangle.Left - 2, e.ImageRectangle.Top - 2,
|
||||
e.ImageRectangle.Width + 4, e.ImageRectangle.Height + 4);
|
||||
|
||||
using (var b = new SolidBrush(Colors.LightBorder))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
|
||||
using (var p = new Pen(Colors.BlueHighlight))
|
||||
{
|
||||
var modRect = new Rectangle(rect.Left, rect.Top, rect.Width - 1, rect.Height - 1);
|
||||
g.DrawRectangle(p, modRect);
|
||||
}
|
||||
|
||||
if (e.Item.ImageIndex == -1 && String.IsNullOrEmpty(e.Item.ImageKey) && e.Item.Image == null)
|
||||
{
|
||||
g.DrawImageUnscaled(MenuIcons.tick, new Point(e.ImageRectangle.Left, e.ImageRectangle.Top));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
var rect = new Rectangle(1, 3, e.Item.Width, 1);
|
||||
|
||||
using (var b = new SolidBrush(Colors.LightBorder))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
|
||||
{
|
||||
e.ArrowColor = Colors.LightText;
|
||||
e.ArrowRectangle = new Rectangle(new Point(e.ArrowRectangle.Left, e.ArrowRectangle.Top - 1), e.ArrowRectangle.Size);
|
||||
|
||||
base.OnRenderArrow(e);
|
||||
}
|
||||
|
||||
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
e.Item.ForeColor = e.Item.Enabled ? Colors.LightText : Colors.DisabledText;
|
||||
|
||||
if (e.Item.Enabled)
|
||||
{
|
||||
// Normal item
|
||||
if (e.Item.Selected)
|
||||
{
|
||||
var rect = new Rectangle(2, 0, e.Item.Width - 3, e.Item.Height);
|
||||
|
||||
using (var b = new SolidBrush(Colors.GreySelection))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
}
|
||||
|
||||
// Header item on open menu
|
||||
if (e.Item.GetType() == typeof(ToolStripMenuItem))
|
||||
{
|
||||
if (((ToolStripMenuItem)e.Item).DropDown.Visible && e.Item.IsOnDropDown == false)
|
||||
{
|
||||
var rect = new Rectangle(2, 0, e.Item.Width - 3, e.Item.Height);
|
||||
|
||||
using (var b = new SolidBrush(Colors.GreySelection))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
198
DarkUI/Renderers/DarkToolStripRenderer.cs
Normal file
@ -0,0 +1,198 @@
|
||||
using DarkUI.Config;
|
||||
using DarkUI.Extensions;
|
||||
using DarkUI.Icons;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Renderers
|
||||
{
|
||||
public class DarkToolStripRenderer : DarkMenuRenderer
|
||||
{
|
||||
#region Initialisation Region
|
||||
|
||||
protected override void InitializeItem(ToolStripItem item)
|
||||
{
|
||||
base.InitializeItem(item);
|
||||
|
||||
if (item.GetType() == typeof(ToolStripSeparator))
|
||||
{
|
||||
var castItem = (ToolStripSeparator)item;
|
||||
if (!castItem.IsOnDropDown)
|
||||
item.Margin = new Padding(0, 0, 2, 0);
|
||||
}
|
||||
|
||||
if (item.GetType() == typeof(ToolStripButton))
|
||||
{
|
||||
item.AutoSize = false;
|
||||
item.Size = new Size(24, 24);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Render Region
|
||||
|
||||
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
|
||||
{
|
||||
base.OnRenderToolStripBackground(e);
|
||||
|
||||
var g = e.Graphics;
|
||||
|
||||
if (e.ToolStrip.GetType() == typeof(ToolStripOverflow))
|
||||
{
|
||||
using (var p = new Pen(Colors.GreyBackground))
|
||||
{
|
||||
var rect = new Rectangle(e.AffectedBounds.Left, e.AffectedBounds.Top, e.AffectedBounds.Width - 1, e.AffectedBounds.Height - 1);
|
||||
g.DrawRectangle(p, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
|
||||
{
|
||||
if (e.ToolStrip.GetType() != typeof(ToolStrip))
|
||||
base.OnRenderToolStripBorder(e);
|
||||
}
|
||||
|
||||
protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
var rect = new Rectangle(0, 1, e.Item.Width, e.Item.Height - 2);
|
||||
|
||||
if (e.Item.Selected || e.Item.Pressed)
|
||||
{
|
||||
using (var b = new SolidBrush(Colors.GreySelection))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
}
|
||||
|
||||
if (e.Item.GetType() == typeof(ToolStripButton))
|
||||
{
|
||||
var castItem = (ToolStripButton)e.Item;
|
||||
|
||||
if (castItem.Checked)
|
||||
{
|
||||
using (var b = new SolidBrush(Colors.GreySelection))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
}
|
||||
|
||||
if (castItem.Checked && castItem.Selected)
|
||||
{
|
||||
var modRect = new Rectangle(rect.Left, rect.Top, rect.Width - 1, rect.Height - 1);
|
||||
using (var p = new Pen(Colors.GreyHighlight))
|
||||
{
|
||||
g.DrawRectangle(p, modRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
var rect = new Rectangle(0, 1, e.Item.Width, e.Item.Height - 2);
|
||||
|
||||
if (e.Item.Selected || e.Item.Pressed)
|
||||
{
|
||||
using (var b = new SolidBrush(Colors.GreySelection))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderGrip(ToolStripGripRenderEventArgs e)
|
||||
{
|
||||
if (e.GripStyle == ToolStripGripStyle.Hidden)
|
||||
return;
|
||||
|
||||
var g = e.Graphics;
|
||||
|
||||
using (var img = MenuIcons.grip.SetColor(Colors.LightBorder))
|
||||
{
|
||||
g.DrawImageUnscaled(img, new Point(e.AffectedBounds.Left, e.AffectedBounds.Top));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
var castItem = (ToolStripSeparator)e.Item;
|
||||
if (castItem.IsOnDropDown)
|
||||
{
|
||||
base.OnRenderSeparator(e);
|
||||
return;
|
||||
}
|
||||
|
||||
var rect = new Rectangle(3, 3, 2, e.Item.Height - 4);
|
||||
|
||||
using (var p = new Pen(Colors.DarkBorder))
|
||||
{
|
||||
g.DrawLine(p, rect.Left, rect.Top, rect.Left, rect.Height);
|
||||
}
|
||||
|
||||
using (var p = new Pen(Colors.LightBorder))
|
||||
{
|
||||
g.DrawLine(p, rect.Left + 1, rect.Top, rect.Left + 1, rect.Height);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
|
||||
if (e.Image == null)
|
||||
return;
|
||||
|
||||
if (e.Item.Enabled)
|
||||
g.DrawImageUnscaled(e.Image, new Point(e.ImageRectangle.Left, e.ImageRectangle.Top));
|
||||
else
|
||||
ControlPaint.DrawImageDisabled(g, e.Image, e.ImageRectangle.Left, e.ImageRectangle.Top, Color.Transparent);
|
||||
}
|
||||
|
||||
protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
/*var g = e.Graphics;
|
||||
|
||||
var rect = new Rectangle(1, 0, e.Item.Width - 5, e.Item.Height);
|
||||
|
||||
var castItem = (ToolStripOverflowButton)e.Item;
|
||||
|
||||
var bgColor = BasicColors.White;
|
||||
if (castItem.Selected)
|
||||
bgColor = StyleColors.Weak(style);
|
||||
if (castItem.Pressed)
|
||||
bgColor = StyleColors.Medium(style);
|
||||
|
||||
using (var b = new SolidBrush(bgColor))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
|
||||
var fgColor = BasicColors.Grey;
|
||||
if (castItem.Selected)
|
||||
fgColor = StyleColors.Medium(style);
|
||||
if (castItem.Pressed)
|
||||
fgColor = StyleColors.Strong(style);
|
||||
|
||||
using (var p = new Pen(fgColor))
|
||||
{
|
||||
var modRect = new Rectangle(1, 0, e.Item.Width - 6, e.Item.Height - 1);
|
||||
g.DrawRectangle(p, modRect);
|
||||
}
|
||||
|
||||
using (var img = MenuIcons.overflow.SetColor(BasicColors.MediumGrey))
|
||||
{
|
||||
g.DrawImageUnscaled(img, e.Item.Width - 13, e.Item.Height - 9);
|
||||
}*/
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
BIN
DarkUI/Resources/active-inactive-close.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DarkUI/Resources/arrow.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
DarkUI/Resources/close-selected.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DarkUI/Resources/close.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DarkUI/Resources/error.png
Normal file
After Width: | Height: | Size: 745 B |
BIN
DarkUI/Resources/grip.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
DarkUI/Resources/inactive-close-selected.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DarkUI/Resources/inactive-close.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DarkUI/Resources/info.png
Normal file
After Width: | Height: | Size: 629 B |
BIN
DarkUI/Resources/node_closed_empty.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
DarkUI/Resources/node_closed_full.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
DarkUI/Resources/node_open.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
DarkUI/Resources/node_open_empty.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
DarkUI/Resources/scrollbar_arrow.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DarkUI/Resources/scrollbar_arrow_clicked.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DarkUI/Resources/scrollbar_arrow_hot.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DarkUI/Resources/scrollbar_arrow_standard.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
DarkUI/Resources/tick.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
DarkUI/Resources/tw_active_close.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DarkUI/Resources/tw_active_close_selected.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DarkUI/Resources/tw_close.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DarkUI/Resources/tw_close_selected.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
DarkUI/Resources/warning.png
Normal file
After Width: | Height: | Size: 431 B |
26
DarkUI/Win32/ControlScrollFilter.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Win32
|
||||
{
|
||||
public class ControlScrollFilter : IMessageFilter
|
||||
{
|
||||
public bool PreFilterMessage(ref Message m)
|
||||
{
|
||||
switch (m.Msg)
|
||||
{
|
||||
case (int)WM.MOUSEWHEEL:
|
||||
case (int)WM.MOUSEHWHEEL:
|
||||
var hControlUnderMouse = Native.WindowFromPoint(new Point((int)m.LParam));
|
||||
|
||||
if (hControlUnderMouse == m.HWnd)
|
||||
return false;
|
||||
|
||||
Native.SendMessage(hControlUnderMouse, (uint)m.Msg, m.WParam, m.LParam);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
258
DarkUI/Win32/DockContentDragFilter.cs
Normal file
@ -0,0 +1,258 @@
|
||||
using DarkUI.Config;
|
||||
using DarkUI.Docking;
|
||||
using DarkUI.Forms;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Win32
|
||||
{
|
||||
public class DockContentDragFilter : IMessageFilter
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private DarkDockPanel _dockPanel;
|
||||
|
||||
private DarkDockContent _dragContent;
|
||||
|
||||
private DarkTranslucentForm _highlightForm;
|
||||
|
||||
private bool _isDragging = false;
|
||||
private DarkDockRegion _targetRegion;
|
||||
private DarkDockGroup _targetGroup;
|
||||
private DockInsertType _insertType = DockInsertType.None;
|
||||
|
||||
private Dictionary<DarkDockRegion, DockDropArea> _regionDropAreas = new Dictionary<DarkDockRegion, DockDropArea>();
|
||||
private Dictionary<DarkDockGroup, DockDropCollection> _groupDropAreas = new Dictionary<DarkDockGroup, DockDropCollection>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DockContentDragFilter(DarkDockPanel dockPanel)
|
||||
{
|
||||
_dockPanel = dockPanel;
|
||||
|
||||
_highlightForm = new DarkTranslucentForm(Colors.BlueSelection);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IMessageFilter Region
|
||||
|
||||
public bool PreFilterMessage(ref Message m)
|
||||
{
|
||||
// Exit out early if we're not dragging any content
|
||||
if (!_isDragging)
|
||||
return false;
|
||||
|
||||
// We only care about mouse events
|
||||
if (!(m.Msg == (int)WM.MOUSEMOVE ||
|
||||
m.Msg == (int)WM.LBUTTONDOWN || m.Msg == (int)WM.LBUTTONUP || m.Msg == (int)WM.LBUTTONDBLCLK ||
|
||||
m.Msg == (int)WM.RBUTTONDOWN || m.Msg == (int)WM.RBUTTONUP || m.Msg == (int)WM.RBUTTONDBLCLK))
|
||||
return false;
|
||||
|
||||
// Move content
|
||||
if (m.Msg == (int)WM.MOUSEMOVE)
|
||||
{
|
||||
HandleDrag();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Drop content
|
||||
if (m.Msg == (int)WM.LBUTTONUP)
|
||||
{
|
||||
if (_targetRegion != null)
|
||||
{
|
||||
_dockPanel.RemoveContent(_dragContent);
|
||||
_dragContent.DockArea = _targetRegion.DockArea;
|
||||
_dockPanel.AddContent(_dragContent);
|
||||
}
|
||||
else if (_targetGroup != null)
|
||||
{
|
||||
_dockPanel.RemoveContent(_dragContent);
|
||||
|
||||
switch (_insertType)
|
||||
{
|
||||
case DockInsertType.None:
|
||||
_dockPanel.AddContent(_dragContent, _targetGroup);
|
||||
break;
|
||||
|
||||
case DockInsertType.Before:
|
||||
case DockInsertType.After:
|
||||
_dockPanel.InsertContent(_dragContent, _targetGroup, _insertType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StopDrag();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
public void StartDrag(DarkDockContent content)
|
||||
{
|
||||
_regionDropAreas = new Dictionary<DarkDockRegion, DockDropArea>();
|
||||
_groupDropAreas = new Dictionary<DarkDockGroup, DockDropCollection>();
|
||||
|
||||
// Add all regions and groups to the drop collections
|
||||
foreach (var region in _dockPanel.Regions.Values)
|
||||
{
|
||||
if (region.DockArea == DarkDockArea.Document)
|
||||
continue;
|
||||
|
||||
// If the region is visible then build drop areas for the groups.
|
||||
if (region.Visible)
|
||||
{
|
||||
foreach (var group in region.Groups)
|
||||
{
|
||||
var collection = new DockDropCollection(_dockPanel, group);
|
||||
_groupDropAreas.Add(group, collection);
|
||||
}
|
||||
}
|
||||
// If the region is NOT visible then build the drop area for the region itself.
|
||||
else
|
||||
{
|
||||
var area = new DockDropArea(_dockPanel, region);
|
||||
_regionDropAreas.Add(region, area);
|
||||
}
|
||||
}
|
||||
|
||||
_dragContent = content;
|
||||
_isDragging = true;
|
||||
}
|
||||
|
||||
private void StopDrag()
|
||||
{
|
||||
Cursor.Current = Cursors.Default;
|
||||
|
||||
_highlightForm.Hide();
|
||||
_dragContent = null;
|
||||
_isDragging = false;
|
||||
}
|
||||
|
||||
private void UpdateHighlightForm(Rectangle rect)
|
||||
{
|
||||
Cursor.Current = Cursors.SizeAll;
|
||||
|
||||
_highlightForm.SuspendLayout();
|
||||
|
||||
_highlightForm.Size = new Size(rect.Width, rect.Height);
|
||||
_highlightForm.Location = new Point(rect.X, rect.Y);
|
||||
|
||||
_highlightForm.ResumeLayout();
|
||||
|
||||
if (!_highlightForm.Visible)
|
||||
{
|
||||
_highlightForm.Show();
|
||||
_highlightForm.BringToFront();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleDrag()
|
||||
{
|
||||
var location = Cursor.Position;
|
||||
|
||||
_insertType = DockInsertType.None;
|
||||
|
||||
_targetRegion = null;
|
||||
_targetGroup = null;
|
||||
|
||||
// Check all region drop areas
|
||||
foreach (var area in _regionDropAreas.Values)
|
||||
{
|
||||
if (area.DropArea.Contains(location))
|
||||
{
|
||||
_insertType = DockInsertType.None;
|
||||
_targetRegion = area.DockRegion;
|
||||
UpdateHighlightForm(area.HighlightArea);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check all group drop areas
|
||||
foreach (var collection in _groupDropAreas.Values)
|
||||
{
|
||||
var sameRegion = false;
|
||||
var sameGroup = false;
|
||||
var groupHasOtherContent = false;
|
||||
|
||||
if (collection.DropArea.DockGroup == _dragContent.DockGroup)
|
||||
sameGroup = true;
|
||||
|
||||
if (collection.DropArea.DockGroup.DockRegion == _dragContent.DockRegion)
|
||||
sameRegion = true;
|
||||
|
||||
if (_dragContent.DockGroup.ContentCount > 1)
|
||||
groupHasOtherContent = true;
|
||||
|
||||
// If we're hovering over the group itself, only allow inserting before/after if multiple content is tabbed.
|
||||
if (!sameGroup || groupHasOtherContent)
|
||||
{
|
||||
var skipBefore = false;
|
||||
var skipAfter = false;
|
||||
|
||||
// Inserting before/after other content might cause the content to be dropped on to its own location.
|
||||
// Check if the group above/below the hovered group contains our drag content.
|
||||
if (sameRegion && !groupHasOtherContent)
|
||||
{
|
||||
if (collection.InsertBeforeArea.DockGroup.Order == _dragContent.DockGroup.Order + 1)
|
||||
skipBefore = true;
|
||||
|
||||
if (collection.InsertAfterArea.DockGroup.Order == _dragContent.DockGroup.Order - 1)
|
||||
skipAfter = true;
|
||||
}
|
||||
|
||||
if (!skipBefore)
|
||||
{
|
||||
if (collection.InsertBeforeArea.DropArea.Contains(location))
|
||||
{
|
||||
_insertType = DockInsertType.Before;
|
||||
_targetGroup = collection.InsertBeforeArea.DockGroup;
|
||||
UpdateHighlightForm(collection.InsertBeforeArea.HighlightArea);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipAfter)
|
||||
{
|
||||
if (collection.InsertAfterArea.DropArea.Contains(location))
|
||||
{
|
||||
_insertType = DockInsertType.After;
|
||||
_targetGroup = collection.InsertAfterArea.DockGroup;
|
||||
UpdateHighlightForm(collection.InsertAfterArea.HighlightArea);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't allow content to be dragged on to itself
|
||||
if (!sameGroup)
|
||||
{
|
||||
if (collection.DropArea.DropArea.Contains(location))
|
||||
{
|
||||
_insertType = DockInsertType.None;
|
||||
_targetGroup = collection.DropArea.DockGroup;
|
||||
UpdateHighlightForm(collection.DropArea.HighlightArea);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not hovering over anything - hide the highlight
|
||||
if (_highlightForm.Visible)
|
||||
_highlightForm.Hide();
|
||||
|
||||
// Show we can't drag here
|
||||
Cursor.Current = Cursors.No;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
174
DarkUI/Win32/DockResizeFilter.cs
Normal file
@ -0,0 +1,174 @@
|
||||
using DarkUI.Docking;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Win32
|
||||
{
|
||||
public class DockResizeFilter : IMessageFilter
|
||||
{
|
||||
#region Field Region
|
||||
|
||||
private DarkDockPanel _dockPanel;
|
||||
|
||||
private Timer _dragTimer;
|
||||
private bool _isDragging;
|
||||
private Point _initialContact;
|
||||
private DarkDockSplitter _activeSplitter;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor Region
|
||||
|
||||
public DockResizeFilter(DarkDockPanel dockPanel)
|
||||
{
|
||||
_dockPanel = dockPanel;
|
||||
|
||||
_dragTimer = new Timer();
|
||||
_dragTimer.Interval = 1;
|
||||
_dragTimer.Tick += DragTimer_Tick;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IMessageFilter Region
|
||||
|
||||
public bool PreFilterMessage(ref Message m)
|
||||
{
|
||||
// We only care about mouse events
|
||||
if (!(m.Msg == (int)WM.MOUSEMOVE ||
|
||||
m.Msg == (int)WM.LBUTTONDOWN || m.Msg == (int)WM.LBUTTONUP || m.Msg == (int)WM.LBUTTONDBLCLK ||
|
||||
m.Msg == (int)WM.RBUTTONDOWN || m.Msg == (int)WM.RBUTTONUP || m.Msg == (int)WM.RBUTTONDBLCLK))
|
||||
return false;
|
||||
|
||||
// Stop drag.
|
||||
if (m.Msg == (int)WM.LBUTTONUP)
|
||||
{
|
||||
if (_isDragging)
|
||||
{
|
||||
StopDrag();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Exit out early if we're simply releasing a non-splitter drag over the area
|
||||
if (m.Msg == (int)WM.LBUTTONUP && !_isDragging)
|
||||
return false;
|
||||
|
||||
// Force cursor if already dragging.
|
||||
if (_isDragging)
|
||||
Cursor.Current = _activeSplitter.ResizeCursor;
|
||||
|
||||
// Return out early if we're dragging something that's not a splitter.
|
||||
if (m.Msg == (int)WM.MOUSEMOVE && !_isDragging && _dockPanel.MouseButtonState != MouseButtons.None)
|
||||
return false;
|
||||
|
||||
// Try and create a control from the message handle.
|
||||
var control = Control.FromHandle(m.HWnd);
|
||||
|
||||
// Exit out if we didn't manage to create a control.
|
||||
if (control == null)
|
||||
return false;
|
||||
|
||||
// Exit out if the control is not the dock panel or a child control.
|
||||
if (!(control == _dockPanel || _dockPanel.Contains(control)))
|
||||
return false;
|
||||
|
||||
// Update the mouse cursor
|
||||
CheckCursor();
|
||||
|
||||
// Start drag.
|
||||
if (m.Msg == (int)WM.LBUTTONDOWN)
|
||||
{
|
||||
var hotSplitter = HotSplitter();
|
||||
if (hotSplitter != null)
|
||||
{
|
||||
StartDrag(hotSplitter);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Stop events passing through if we're hovering over a splitter
|
||||
if (HotSplitter() != null)
|
||||
return true;
|
||||
|
||||
// Stop all events from going through if we're dragging a splitter.
|
||||
if (_isDragging)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler Region
|
||||
|
||||
private void DragTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (_dockPanel.MouseButtonState != MouseButtons.Left)
|
||||
{
|
||||
StopDrag();
|
||||
return;
|
||||
}
|
||||
|
||||
var difference = new Point(_initialContact.X - Cursor.Position.X, _initialContact.Y - Cursor.Position.Y);
|
||||
_activeSplitter.UpdateOverlay(difference);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method Region
|
||||
|
||||
private void StartDrag(DarkDockSplitter splitter)
|
||||
{
|
||||
_activeSplitter = splitter;
|
||||
Cursor.Current = _activeSplitter.ResizeCursor;
|
||||
|
||||
_initialContact = Cursor.Position;
|
||||
_isDragging = true;
|
||||
|
||||
_activeSplitter.ShowOverlay();
|
||||
_dragTimer.Start();
|
||||
}
|
||||
|
||||
private void StopDrag()
|
||||
{
|
||||
_dragTimer.Stop();
|
||||
_activeSplitter.HideOverlay();
|
||||
|
||||
var difference = new Point(_initialContact.X - Cursor.Position.X, _initialContact.Y - Cursor.Position.Y);
|
||||
_activeSplitter.Move(difference);
|
||||
|
||||
_isDragging = false;
|
||||
}
|
||||
|
||||
private DarkDockSplitter HotSplitter()
|
||||
{
|
||||
foreach (var splitter in _dockPanel.Splitters)
|
||||
{
|
||||
if (splitter.Bounds.Contains(Cursor.Position))
|
||||
return splitter;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void CheckCursor()
|
||||
{
|
||||
if (_isDragging)
|
||||
return;
|
||||
|
||||
var hotSplitter = HotSplitter();
|
||||
if (hotSplitter != null)
|
||||
Cursor.Current = hotSplitter.ResizeCursor;
|
||||
}
|
||||
|
||||
private void ResetCursor()
|
||||
{
|
||||
Cursor.Current = Cursors.Default;
|
||||
CheckCursor();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
15
DarkUI/Win32/Native.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DarkUI.Win32
|
||||
{
|
||||
internal sealed class Native
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr WindowFromPoint(Point point);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam);
|
||||
}
|
||||
}
|