Merge pull request #20 from RobinPerris/working

working -> master
This commit is contained in:
Robin 2020-01-10 15:53:52 +00:00 committed by GitHub
commit a9125768d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 976 additions and 45 deletions

View File

@ -0,0 +1,34 @@
using System.Drawing;
using System.Windows.Forms;
namespace DarkUI.Controls
{
public class DarkDropdownItem
{
#region Property Region
public string Text { get; set; }
public Bitmap Icon { get; set; }
#endregion
#region Constructor Region
public DarkDropdownItem()
{ }
public DarkDropdownItem(string text)
{
Text = text;
}
public DarkDropdownItem(string text, Bitmap icon)
: this(text)
{
Icon = icon;
}
#endregion
}
}

View File

@ -0,0 +1,489 @@
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 DarkDropdownList : Control
{
#region Event Region
public event EventHandler SelectedItemChanged;
#endregion
#region Field Region
private DarkControlState _controlState = DarkControlState.Normal;
private ObservableCollection<DarkDropdownItem> _items = new ObservableCollection<DarkDropdownItem>();
private DarkDropdownItem _selectedItem;
private DarkContextMenu _menu = new DarkContextMenu();
private bool _menuOpen = false;
private bool _showBorder = true;
private int _itemHeight = 22;
private int _maxHeight = 130;
private readonly int _iconSize = 16;
private ToolStripDropDownDirection _dropdownDirection = ToolStripDropDownDirection.Default;
#endregion
#region Property Region
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ObservableCollection<DarkDropdownItem> Items
{
get { return _items; }
}
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public DarkDropdownItem SelectedItem
{
get { return _selectedItem; }
set
{
_selectedItem = value;
SelectedItemChanged?.Invoke(this, new EventArgs());
}
}
[Category("Appearance")]
[Description("Determines whether a border is drawn around the control.")]
[DefaultValue(true)]
public bool ShowBorder
{
get { return _showBorder; }
set
{
_showBorder = value;
Invalidate();
}
}
protected override Size DefaultSize
{
get { return new Size(100, 26); }
}
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public DarkControlState ControlState
{
get { return _controlState; }
}
[Category("Appearance")]
[Description("Determines the height of the individual list view items.")]
[DefaultValue(22)]
public int ItemHeight
{
get { return _itemHeight; }
set
{
_itemHeight = value;
ResizeMenu();
}
}
[Category("Appearance")]
[Description("Determines the maximum height of the dropdown panel.")]
[DefaultValue(130)]
public int MaxHeight
{
get { return _maxHeight; }
set
{
_maxHeight = value;
ResizeMenu();
}
}
[Category("Behavior")]
[Description("Determines what location the dropdown list appears.")]
[DefaultValue(ToolStripDropDownDirection.Default)]
public ToolStripDropDownDirection DropdownDirection
{
get { return _dropdownDirection; }
set { _dropdownDirection = value; }
}
#endregion
#region Constructor Region
public DarkDropdownList()
{
SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.ResizeRedraw |
ControlStyles.UserPaint |
ControlStyles.Selectable |
ControlStyles.UserMouse, true);
_menu.AutoSize = false;
_menu.Closed += Menu_Closed;
Items.CollectionChanged += Items_CollectionChanged;
SelectedItemChanged += DarkDropdownList_SelectedItemChanged;
SetControlState(DarkControlState.Normal);
}
#endregion
#region Method Region
private ToolStripMenuItem GetMenuItem(DarkDropdownItem item)
{
foreach (ToolStripMenuItem menuItem in _menu.Items)
{
if ((DarkDropdownItem)menuItem.Tag == item)
return menuItem;
}
return null;
}
private void SetControlState(DarkControlState controlState)
{
if (_menuOpen)
return;
if (_controlState != controlState)
{
_controlState = controlState;
Invalidate();
}
}
private void ShowMenu()
{
if (_menu.Visible)
return;
SetControlState(DarkControlState.Pressed);
_menuOpen = true;
var pos = new Point(0, ClientRectangle.Bottom);
if (_dropdownDirection == ToolStripDropDownDirection.AboveLeft || _dropdownDirection == ToolStripDropDownDirection.AboveRight)
pos.Y = 0;
_menu.Show(this, pos, _dropdownDirection);
if (SelectedItem != null)
{
var selectedItem = GetMenuItem(SelectedItem);
selectedItem.Select();
}
}
private void ResizeMenu()
{
var width = ClientRectangle.Width;
var height = (_menu.Items.Count * _itemHeight) + 4;
if (height > _maxHeight)
height = _maxHeight;
// Dirty: Check what the autosized items are
foreach (ToolStripMenuItem item in _menu.Items)
{
item.AutoSize = true;
if (item.Size.Width > width)
width = item.Size.Width;
item.AutoSize = false;
}
// Force the size
foreach (ToolStripMenuItem item in _menu.Items)
item.Size = new Size(width - 1, _itemHeight);
_menu.Size = new Size(width, height);
}
#endregion
#region Event Handler Region
private void Items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (DarkDropdownItem item in e.NewItems)
{
var menuItem = new ToolStripMenuItem(item.Text)
{
Image = item.Icon,
AutoSize = false,
Height = _itemHeight,
Font = Font,
Tag = item,
TextAlign = ContentAlignment.MiddleLeft
};
_menu.Items.Add(menuItem);
menuItem.Click += Item_Select;
if (SelectedItem == null)
SelectedItem = item;
}
}
if (e.Action == NotifyCollectionChangedAction.Remove)
{
foreach (DarkDropdownItem item in e.OldItems)
{
foreach (ToolStripMenuItem menuItem in _menu.Items)
{
if ((DarkDropdownItem)menuItem.Tag == item)
_menu.Items.Remove(menuItem);
}
}
}
ResizeMenu();
}
private void Item_Select(object sender, EventArgs e)
{
var menuItem = sender as ToolStripMenuItem;
if (menuItem == null)
return;
var dropdownItem = (DarkDropdownItem)menuItem.Tag;
if (_selectedItem != dropdownItem)
SelectedItem = dropdownItem;
}
private void DarkDropdownList_SelectedItemChanged(object sender, EventArgs e)
{
foreach (ToolStripMenuItem item in _menu.Items)
{
if ((DarkDropdownItem)item.Tag == SelectedItem)
{
item.BackColor = Colors.DarkBlueBackground;
item.Font = new Font(Font, FontStyle.Bold);
}
else
{
item.BackColor = Colors.GreyBackground;
item.Font = new Font(Font, FontStyle.Regular);
}
}
Invalidate();
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
ResizeMenu();
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
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);
ShowMenu();
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
SetControlState(DarkControlState.Normal);
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
SetControlState(DarkControlState.Normal);
}
protected override void OnMouseCaptureChanged(EventArgs e)
{
base.OnMouseCaptureChanged(e);
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);
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)
ShowMenu();
}
private void Menu_Closed(object sender, ToolStripDropDownClosedEventArgs e)
{
_menuOpen = false;
if (!ClientRectangle.Contains(MousePosition))
SetControlState(DarkControlState.Normal);
else
SetControlState(DarkControlState.Hover);
}
#endregion
#region Render Region
protected override void OnPaint(PaintEventArgs e)
{
var g = e.Graphics;
// Draw background
using (var b = new SolidBrush(Colors.MediumBackground))
{
g.FillRectangle(b, ClientRectangle);
}
// Draw normal state
if (ControlState == DarkControlState.Normal)
{
if (ShowBorder)
{
using (var p = new Pen(Colors.LightBorder, 1))
{
var modRect = new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - 1, ClientRectangle.Height - 1);
g.DrawRectangle(p, modRect);
}
}
}
// Draw hover state
if (ControlState == DarkControlState.Hover)
{
using (var b = new SolidBrush(Colors.DarkBorder))
{
g.FillRectangle(b, ClientRectangle);
}
using (var b = new SolidBrush(Colors.DarkBackground))
{
var arrowRect = new Rectangle(ClientRectangle.Right - DropdownIcons.small_arrow.Width - 8, ClientRectangle.Top, DropdownIcons.small_arrow.Width + 8, ClientRectangle.Height);
g.FillRectangle(b, arrowRect);
}
using (var p = new Pen(Colors.BlueSelection, 1))
{
var modRect = new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - 1 - DropdownIcons.small_arrow.Width - 8, ClientRectangle.Height - 1);
g.DrawRectangle(p, modRect);
}
}
// Draw pressed state
if (ControlState == DarkControlState.Pressed)
{
using (var b = new SolidBrush(Colors.DarkBorder))
{
g.FillRectangle(b, ClientRectangle);
}
using (var b = new SolidBrush(Colors.BlueSelection))
{
var arrowRect = new Rectangle(ClientRectangle.Right - DropdownIcons.small_arrow.Width - 8, ClientRectangle.Top, DropdownIcons.small_arrow.Width + 8, ClientRectangle.Height);
g.FillRectangle(b, arrowRect);
}
}
// Draw dropdown arrow
using (var img = DropdownIcons.small_arrow)
{
g.DrawImageUnscaled(img, ClientRectangle.Right - img.Width - 4, ClientRectangle.Top + (ClientRectangle.Height / 2) - (img.Height / 2));
}
// Draw selected item
if (SelectedItem != null)
{
// Draw Icon
var hasIcon = SelectedItem.Icon != null;
if (hasIcon)
{
g.DrawImageUnscaled(SelectedItem.Icon, new Point(ClientRectangle.Left + 5, ClientRectangle.Top + (ClientRectangle.Height / 2) - (_iconSize / 2)));
}
// Draw Text
using (var b = new SolidBrush(Colors.LightText))
{
var stringFormat = new StringFormat
{
Alignment = StringAlignment.Near,
LineAlignment = StringAlignment.Center
};
var rect = new Rectangle(ClientRectangle.Left + 2, ClientRectangle.Top, ClientRectangle.Width - 16, ClientRectangle.Height);
if (hasIcon)
{
rect.X += _iconSize + 7;
rect.Width -= _iconSize + 7;
}
g.DrawString(SelectedItem.Text, Font, b, rect, stringFormat);
}
}
}
#endregion
}
}

View File

@ -38,6 +38,8 @@ namespace DarkUI.Controls
public FontStyle FontStyle { get; set; }
public Bitmap Icon { get; set; }
public object Tag { get; set; }
#endregion

View File

@ -23,6 +23,8 @@ namespace DarkUI.Controls
private int _itemHeight = 20;
private bool _multiSelect;
private readonly int _iconSize = 16;
private ObservableCollection<DarkListItem> _items;
private List<int> _selectedIndices;
private int _anchoredItemStart = -1;
@ -79,6 +81,11 @@ namespace DarkUI.Controls
set { _multiSelect = value; }
}
[Category("Appearance")]
[Description("Determines whether icons are rendered with the list items.")]
[DefaultValue(false)]
public bool ShowIcons { get; set; }
#endregion
#region Constructor Region
@ -397,6 +404,9 @@ namespace DarkUI.Controls
var size = g.MeasureString(item.Text, Font);
size.Width++;
if (ShowIcons)
size.Width += _iconSize + 8;
item.Area = new Rectangle(item.Area.Left, item.Area.Top, (int)size.Width, item.Area.Height);
}
@ -523,6 +533,12 @@ namespace DarkUI.Controls
g.DrawLine(p, new Point(rect.Left, rect.Bottom - 1), new Point(rect.Right, rect.Bottom - 1));
}*/
// Icon
if (ShowIcons && Items[i].Icon != null)
{
g.DrawImageUnscaled(Items[i].Icon, new Point(rect.Left + 5, rect.Top + (rect.Height / 2) - (_iconSize / 2)));
}
// Text
using (var b = new SolidBrush(Items[i].TextColor))
{
@ -535,6 +551,10 @@ namespace DarkUI.Controls
var modFont = new Font(Font, Items[i].FontStyle);
var modRect = new Rectangle(rect.Left + 2, rect.Top, rect.Width, rect.Height);
if (ShowIcons)
modRect.X += _iconSize + 8;
g.DrawString(Items[i].Text, modFont, b, modRect, stringFormat);
}
}

View File

@ -388,16 +388,8 @@ namespace DarkUI.Controls
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)
{
@ -427,7 +419,15 @@ namespace DarkUI.Controls
}
private void UpdateThumb(bool forceRefresh = false)
{
{
if (ViewSize >= Maximum)
return;
// Cap to maximum value
var maximumValue = Maximum - ViewSize;
if (Value > maximumValue)
Value = maximumValue;
// Calculate size ratio
_viewContentRatio = (float)ViewSize / (float)Maximum;
var viewAreaSize = Maximum - ViewSize;
@ -493,6 +493,9 @@ namespace DarkUI.Controls
if (_upArrowClicked)
upIcon = ScrollIcons.scrollbar_arrow_clicked;
if (!Enabled)
upIcon = ScrollIcons.scrollbar_arrow_disabled;
if (_scrollOrientation == DarkScrollOrientation.Vertical)
upIcon.RotateFlip(RotateFlipType.RotateNoneFlipY);
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
@ -508,6 +511,9 @@ namespace DarkUI.Controls
if (_downArrowClicked)
downIcon = ScrollIcons.scrollbar_arrow_clicked;
if (!Enabled)
downIcon = ScrollIcons.scrollbar_arrow_disabled;
if (_scrollOrientation == DarkScrollOrientation.Horizontal)
downIcon.RotateFlip(RotateFlipType.Rotate270FlipNone);
@ -516,14 +522,17 @@ namespace DarkUI.Controls
_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))
if (Enabled)
{
g.FillRectangle(b, _thumbArea);
var scrollColor = _thumbHot ? Colors.GreyHighlight : Colors.GreySelection;
if (_isScrolling)
scrollColor = Colors.ActiveControl;
using (var b = new SolidBrush(scrollColor))
{
g.FillRectangle(b, _thumbArea);
}
}
}

View File

@ -30,6 +30,8 @@ namespace DarkUI.Controls
private int _maxDragChange = 0;
private Timer _dragTimer;
private bool _hideScrollBars = true;
#endregion
#region Property Region
@ -88,6 +90,19 @@ namespace DarkUI.Controls
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsDragging { get; private set; }
[Category("Behavior")]
[Description("Determines whether scrollbars will remain visible when disabled.")]
[DefaultValue(true)]
public bool HideScrollBars
{
get { return _hideScrollBars; }
set
{
_hideScrollBars = value;
UpdateScrollBars();
}
}
#endregion
#region Constructor Region
@ -159,8 +174,14 @@ namespace DarkUI.Controls
private void SetScrollBarVisibility()
{
_vScrollBar.Visible = _visibleSize.Height < ContentSize.Height;
_hScrollBar.Visible = _visibleSize.Width < ContentSize.Width;
_vScrollBar.Enabled = _visibleSize.Height < ContentSize.Height;
_hScrollBar.Enabled = _visibleSize.Width < ContentSize.Width;
if (_hideScrollBars)
{
_vScrollBar.Visible = _vScrollBar.Enabled;
_hScrollBar.Visible = _hScrollBar.Enabled;
}
}
private void SetVisibleSize()

View File

@ -50,6 +50,10 @@
<Compile Include="Controls\DarkCheckBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\DarkDropdownItem.cs" />
<Compile Include="Controls\DarkDropdownList.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\DarkContentAlignment.cs" />
<Compile Include="Controls\DarkControlState.cs" />
<Compile Include="Controls\DarkRadioButton.cs">
@ -161,6 +165,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>DockIcons.resx</DependentUpon>
</Compile>
<Compile Include="Icons\DropdownIcons.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>DropdownIcons.resx</DependentUpon>
</Compile>
<Compile Include="Icons\MenuIcons.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@ -202,6 +211,11 @@
<LastGenOutput>DockIcons.Designer.cs</LastGenOutput>
<CustomToolNamespace>DarkUI</CustomToolNamespace>
</EmbeddedResource>
<EmbeddedResource Include="Icons\DropdownIcons.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>DropdownIcons.Designer.cs</LastGenOutput>
<CustomToolNamespace>DarkUI</CustomToolNamespace>
</EmbeddedResource>
<EmbeddedResource Include="Icons\MenuIcons.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>MenuIcons.Designer.cs</LastGenOutput>
@ -292,6 +306,12 @@
<ItemGroup>
<None Include="Resources\tw_active_close_selected.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\small_arrow.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\scrollbar_disabled.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.

View File

@ -272,6 +272,8 @@ namespace DarkUI.Docking
}
groupState.Contents.Add(content.SerializationKey);
groupState.VisibleContent = content.DockGroup.VisibleContent.SerializationKey;
}
}
}
@ -299,6 +301,7 @@ namespace DarkUI.Docking
foreach (var group in region.Groups)
{
DarkDockContent previousContent = null;
DarkDockContent visibleContent = null;
foreach (var contentKey in group.Contents)
{
@ -307,13 +310,21 @@ namespace DarkUI.Docking
if (content == null)
continue;
content.DockArea = region.Area;
if (previousContent == null)
AddContent(content);
else
AddContent(content, previousContent.DockGroup);
previousContent = content;
if (group.VisibleContent == contentKey)
visibleContent = content;
}
if (visibleContent != null)
visibleContent.Select();
}
}
}

View File

@ -8,6 +8,8 @@ namespace DarkUI.Docking
public List<string> Contents { get; set; }
public string VisibleContent { get; set; }
#endregion
#region Constructor Region

73
DarkUI/Icons/DropdownIcons.Designer.cs generated Normal file
View File

@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <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 DropdownIcons {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal DropdownIcons() {
}
/// <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.DropdownIcons", typeof(DropdownIcons).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 small_arrow {
get {
object obj = ResourceManager.GetObject("small_arrow", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,124 @@
<?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="small_arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\small_arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace DarkUI.Icons {
namespace DarkUI {
using System;
@ -80,6 +80,16 @@ namespace DarkUI.Icons {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap scrollbar_arrow_disabled {
get {
object obj = ResourceManager.GetObject("scrollbar_arrow_disabled", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -124,6 +124,9 @@
<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_disabled" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scrollbar_disabled.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>

View File

@ -1,4 +1,5 @@
using DarkUI.Config;
using DarkUI.Controls;
using DarkUI.Icons;
using System;
using System.Drawing;
@ -22,6 +23,7 @@ namespace DarkUI.Renderers
{
base.InitializeItem(item);
item.BackColor = Colors.GreyBackground;
item.ForeColor = Colors.LightText;
if (item.GetType() == typeof(ToolStripSeparator))
@ -107,15 +109,15 @@ namespace DarkUI.Renderers
if (e.Item.Enabled)
{
// Normal item
if (e.Item.Selected)
{
var rect = new Rectangle(2, 0, e.Item.Width - 3, e.Item.Height);
var bgColor = e.Item.Selected ? Colors.GreyHighlight : e.Item.BackColor;
using (var b = new SolidBrush(Colors.GreySelection))
{
g.FillRectangle(b, rect);
}
// Normal item
var rect = new Rectangle(2, 0, e.Item.Width - 3, e.Item.Height);
using (var b = new SolidBrush(bgColor))
{
g.FillRectangle(b, rect);
}
// Header item on open menu
@ -123,8 +125,6 @@ namespace DarkUI.Renderers
{
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);

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -29,6 +29,7 @@
private void InitializeComponent()
{
this.txtDocument = new System.Windows.Forms.TextBox();
this.cmbOptions = new DarkUI.Controls.DarkDropdownList();
this.SuspendLayout();
//
// txtDocument
@ -44,10 +45,24 @@
this.txtDocument.TabIndex = 1;
this.txtDocument.Text = "This is some example text";
//
// cmbOptions
//
this.cmbOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.cmbOptions.DropdownDirection = System.Windows.Forms.ToolStripDropDownDirection.AboveRight;
this.cmbOptions.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cmbOptions.Location = new System.Drawing.Point(0, 158);
this.cmbOptions.MaxHeight = 300;
this.cmbOptions.Name = "cmbOptions";
this.cmbOptions.ShowBorder = false;
this.cmbOptions.Size = new System.Drawing.Size(65, 15);
this.cmbOptions.TabIndex = 2;
this.cmbOptions.Text = "darkComboBox1";
//
// DockDocument
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.cmbOptions);
this.Controls.Add(this.txtDocument);
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "DockDocument";
@ -60,5 +75,6 @@
#endregion
private System.Windows.Forms.TextBox txtDocument;
private DarkUI.Controls.DarkDropdownList cmbOptions;
}
}

View File

@ -1,4 +1,5 @@
using DarkUI.Config;
using DarkUI.Controls;
using DarkUI.Docking;
using DarkUI.Forms;
using System.Drawing;
@ -16,6 +17,14 @@ namespace Example
// Workaround to stop the textbox from highlight all text.
txtDocument.SelectionStart = txtDocument.Text.Length;
// Build dummy dropdown data
cmbOptions.Items.Add(new DarkDropdownItem("25%"));
cmbOptions.Items.Add(new DarkDropdownItem("50%"));
cmbOptions.Items.Add(new DarkDropdownItem("100%"));
cmbOptions.Items.Add(new DarkDropdownItem("200%"));
cmbOptions.Items.Add(new DarkDropdownItem("300%"));
cmbOptions.Items.Add(new DarkDropdownItem("400%"));
}
public DockDocument(string text, Image icon)

View File

@ -32,22 +32,36 @@ namespace Example
private void InitializeComponent()
{
this.lstLayers = new DarkUI.Controls.DarkListView();
this.cmbList = new DarkUI.Controls.DarkDropdownList();
this.SuspendLayout();
//
// lstLayers
//
this.lstLayers.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstLayers.Location = new System.Drawing.Point(0, 25);
this.lstLayers.HideScrollBars = false;
this.lstLayers.Location = new System.Drawing.Point(0, 51);
this.lstLayers.Name = "lstLayers";
this.lstLayers.Size = new System.Drawing.Size(280, 425);
this.lstLayers.ShowIcons = true;
this.lstLayers.Size = new System.Drawing.Size(280, 399);
this.lstLayers.TabIndex = 0;
this.lstLayers.Text = "darkListView1";
//
// cmbList
//
this.cmbList.Dock = System.Windows.Forms.DockStyle.Top;
this.cmbList.Location = new System.Drawing.Point(0, 25);
this.cmbList.Name = "cmbList";
this.cmbList.ShowBorder = false;
this.cmbList.Size = new System.Drawing.Size(280, 26);
this.cmbList.TabIndex = 1;
this.cmbList.Text = "darkDropdownList1";
//
// DockLayers
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lstLayers);
this.Controls.Add(this.cmbList);
this.DefaultDockArea = DarkUI.Docking.DarkDockArea.Right;
this.DockText = "Layers";
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -62,5 +76,6 @@ namespace Example
#endregion
private DarkListView lstLayers;
private DarkDropdownList cmbList;
}
}

View File

@ -1,4 +1,5 @@
using DarkUI.Controls;
using System;
using DarkUI.Controls;
using DarkUI.Docking;
namespace Example
@ -15,8 +16,15 @@ namespace Example
for (var i = 0; i < 100; i++)
{
var item = new DarkListItem($"List item #{i}");
item.Icon = Icons.application_16x;
lstLayers.Items.Add(item);
}
// Build dropdown list data
for (var i = 0; i < 5; i++)
{
cmbList.Items.Add(new DarkDropdownItem($"Dropdown item #{i}"));
}
}
#endregion

View File

@ -42,20 +42,26 @@ namespace Example
this.darkCheckBox2 = new DarkUI.Controls.DarkCheckBox();
this.darkCheckBox1 = new DarkUI.Controls.DarkCheckBox();
this.darkTitle2 = new DarkUI.Controls.DarkTitle();
this.darkScrollBar1 = new DarkUI.Controls.DarkScrollBar();
this.panel3 = new System.Windows.Forms.Panel();
this.darkTitle3 = new DarkUI.Controls.DarkTitle();
this.cmbList = new DarkUI.Controls.DarkDropdownList();
this.pnlMain.SuspendLayout();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// pnlMain
//
this.pnlMain.Controls.Add(this.panel3);
this.pnlMain.Controls.Add(this.panel1);
this.pnlMain.Controls.Add(this.panel2);
this.pnlMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlMain.Location = new System.Drawing.Point(0, 25);
this.pnlMain.Name = "pnlMain";
this.pnlMain.Padding = new System.Windows.Forms.Padding(10);
this.pnlMain.Size = new System.Drawing.Size(280, 425);
this.pnlMain.Padding = new System.Windows.Forms.Padding(10, 10, 5, 10);
this.pnlMain.Size = new System.Drawing.Size(265, 425);
this.pnlMain.TabIndex = 0;
//
// panel1
@ -69,7 +75,7 @@ namespace Example
this.panel1.Location = new System.Drawing.Point(10, 103);
this.panel1.Name = "panel1";
this.panel1.Padding = new System.Windows.Forms.Padding(0, 0, 0, 10);
this.panel1.Size = new System.Drawing.Size(260, 93);
this.panel1.Size = new System.Drawing.Size(250, 93);
this.panel1.TabIndex = 2;
//
// darkRadioButton3
@ -79,7 +85,7 @@ namespace Example
this.darkRadioButton3.Enabled = false;
this.darkRadioButton3.Location = new System.Drawing.Point(0, 64);
this.darkRadioButton3.Name = "darkRadioButton3";
this.darkRadioButton3.Size = new System.Drawing.Size(260, 19);
this.darkRadioButton3.Size = new System.Drawing.Size(250, 19);
this.darkRadioButton3.TabIndex = 6;
this.darkRadioButton3.TabStop = true;
this.darkRadioButton3.Text = "Disabled radiobutton";
@ -90,7 +96,7 @@ namespace Example
this.darkRadioButton2.Dock = System.Windows.Forms.DockStyle.Top;
this.darkRadioButton2.Location = new System.Drawing.Point(0, 45);
this.darkRadioButton2.Name = "darkRadioButton2";
this.darkRadioButton2.Size = new System.Drawing.Size(260, 19);
this.darkRadioButton2.Size = new System.Drawing.Size(250, 19);
this.darkRadioButton2.TabIndex = 5;
this.darkRadioButton2.TabStop = true;
this.darkRadioButton2.Text = "Radiobutton";
@ -101,7 +107,7 @@ namespace Example
this.darkRadioButton1.Dock = System.Windows.Forms.DockStyle.Top;
this.darkRadioButton1.Location = new System.Drawing.Point(0, 26);
this.darkRadioButton1.Name = "darkRadioButton1";
this.darkRadioButton1.Size = new System.Drawing.Size(260, 19);
this.darkRadioButton1.Size = new System.Drawing.Size(250, 19);
this.darkRadioButton1.TabIndex = 4;
this.darkRadioButton1.TabStop = true;
this.darkRadioButton1.Text = "Radiobutton";
@ -111,7 +117,7 @@ namespace Example
this.darkTitle1.Dock = System.Windows.Forms.DockStyle.Top;
this.darkTitle1.Location = new System.Drawing.Point(0, 0);
this.darkTitle1.Name = "darkTitle1";
this.darkTitle1.Size = new System.Drawing.Size(260, 26);
this.darkTitle1.Size = new System.Drawing.Size(250, 26);
this.darkTitle1.TabIndex = 7;
this.darkTitle1.Text = "Radio buttons";
//
@ -126,7 +132,7 @@ namespace Example
this.panel2.Location = new System.Drawing.Point(10, 10);
this.panel2.Name = "panel2";
this.panel2.Padding = new System.Windows.Forms.Padding(0, 0, 0, 10);
this.panel2.Size = new System.Drawing.Size(260, 93);
this.panel2.Size = new System.Drawing.Size(250, 93);
this.panel2.TabIndex = 1;
//
// darkCheckBox3
@ -138,7 +144,7 @@ namespace Example
this.darkCheckBox3.Enabled = false;
this.darkCheckBox3.Location = new System.Drawing.Point(0, 64);
this.darkCheckBox3.Name = "darkCheckBox3";
this.darkCheckBox3.Size = new System.Drawing.Size(260, 19);
this.darkCheckBox3.Size = new System.Drawing.Size(250, 19);
this.darkCheckBox3.TabIndex = 6;
this.darkCheckBox3.Text = "Disabled checked checkbox";
//
@ -149,7 +155,7 @@ namespace Example
this.darkCheckBox2.Enabled = false;
this.darkCheckBox2.Location = new System.Drawing.Point(0, 45);
this.darkCheckBox2.Name = "darkCheckBox2";
this.darkCheckBox2.Size = new System.Drawing.Size(260, 19);
this.darkCheckBox2.Size = new System.Drawing.Size(250, 19);
this.darkCheckBox2.TabIndex = 5;
this.darkCheckBox2.Text = "Disabled checkbox";
//
@ -159,7 +165,7 @@ namespace Example
this.darkCheckBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.darkCheckBox1.Location = new System.Drawing.Point(0, 26);
this.darkCheckBox1.Name = "darkCheckBox1";
this.darkCheckBox1.Size = new System.Drawing.Size(260, 19);
this.darkCheckBox1.Size = new System.Drawing.Size(250, 19);
this.darkCheckBox1.TabIndex = 4;
this.darkCheckBox1.Text = "Checkbox";
//
@ -168,15 +174,58 @@ namespace Example
this.darkTitle2.Dock = System.Windows.Forms.DockStyle.Top;
this.darkTitle2.Location = new System.Drawing.Point(0, 0);
this.darkTitle2.Name = "darkTitle2";
this.darkTitle2.Size = new System.Drawing.Size(260, 26);
this.darkTitle2.Size = new System.Drawing.Size(250, 26);
this.darkTitle2.TabIndex = 8;
this.darkTitle2.Text = "Check boxes";
//
// darkScrollBar1
//
this.darkScrollBar1.Dock = System.Windows.Forms.DockStyle.Right;
this.darkScrollBar1.Enabled = false;
this.darkScrollBar1.Location = new System.Drawing.Point(265, 25);
this.darkScrollBar1.Maximum = 5;
this.darkScrollBar1.Minimum = 1;
this.darkScrollBar1.Name = "darkScrollBar1";
this.darkScrollBar1.Size = new System.Drawing.Size(15, 425);
this.darkScrollBar1.TabIndex = 1;
this.darkScrollBar1.Text = "darkScrollBar1";
//
// panel3
//
this.panel3.AutoSize = true;
this.panel3.Controls.Add(this.cmbList);
this.panel3.Controls.Add(this.darkTitle3);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(10, 196);
this.panel3.Name = "panel3";
this.panel3.Padding = new System.Windows.Forms.Padding(0, 0, 0, 10);
this.panel3.Size = new System.Drawing.Size(250, 62);
this.panel3.TabIndex = 3;
//
// darkTitle3
//
this.darkTitle3.Dock = System.Windows.Forms.DockStyle.Top;
this.darkTitle3.Location = new System.Drawing.Point(0, 0);
this.darkTitle3.Name = "darkTitle3";
this.darkTitle3.Size = new System.Drawing.Size(250, 26);
this.darkTitle3.TabIndex = 7;
this.darkTitle3.Text = "Lists";
//
// cmbList
//
this.cmbList.Dock = System.Windows.Forms.DockStyle.Top;
this.cmbList.Location = new System.Drawing.Point(0, 26);
this.cmbList.Name = "cmbList";
this.cmbList.Size = new System.Drawing.Size(250, 26);
this.cmbList.TabIndex = 8;
this.cmbList.Text = "darkDropdownList1";
//
// DockProperties
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.pnlMain);
this.Controls.Add(this.darkScrollBar1);
this.DefaultDockArea = DarkUI.Docking.DarkDockArea.Right;
this.DockText = "Properties";
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -190,6 +239,7 @@ namespace Example
this.panel1.PerformLayout();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.panel3.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -207,5 +257,9 @@ namespace Example
private DarkUI.Controls.DarkCheckBox darkCheckBox2;
private DarkUI.Controls.DarkCheckBox darkCheckBox1;
private DarkUI.Controls.DarkTitle darkTitle2;
private DarkUI.Controls.DarkScrollBar darkScrollBar1;
private System.Windows.Forms.Panel panel3;
private DarkUI.Controls.DarkTitle darkTitle3;
private DarkUI.Controls.DarkDropdownList cmbList;
}
}

View File

@ -1,4 +1,5 @@
using DarkUI.Docking;
using DarkUI.Controls;
using DarkUI.Docking;
namespace Example
{
@ -9,6 +10,16 @@ namespace Example
public DockProperties()
{
InitializeComponent();
// Build dummy dropdown data
cmbList.Items.Add(new DarkDropdownItem("Item1"));
cmbList.Items.Add(new DarkDropdownItem("Item2"));
cmbList.Items.Add(new DarkDropdownItem("Item3"));
cmbList.Items.Add(new DarkDropdownItem("Item4"));
cmbList.Items.Add(new DarkDropdownItem("Item5"));
cmbList.Items.Add(new DarkDropdownItem("Item6"));
cmbList.SelectedItemChanged += delegate { System.Console.WriteLine($"Item changed to {cmbList.SelectedItem.Text}"); };
}
#endregion