Cleaned up namespaces.

Moved classes out of subfolders. Moved enums to be within the same file
as their main class. Added new DarkControl superclass.
This commit is contained in:
Robin 2015-12-07 20:21:17 +00:00
parent 54a228cdd4
commit cdaeae5264
23 changed files with 158 additions and 145 deletions

View File

@ -1,63 +0,0 @@
namespace DarkUI.Config
{
public enum DarkButtonStyle
{
Normal,
Flat
}
public enum DarkControlState
{
Normal,
Hover,
Pressed
}
public enum DarkContentAlignment
{
Center,
Left,
Right
}
public enum DarkOrientation
{
Vertical,
Horizontal
}
public enum DarkDialogButton
{
Ok,
Close,
OkCancel,
YesNo,
YesNoCancel,
AbortRetryIgnore,
RetryCancel
}
public enum DarkMessageBoxIcon
{
None,
Information,
Warning,
Error
}
public enum DarkDockArea
{
Document,
Left,
Right,
Bottom
}
public enum DarkSplitterType
{
Left,
Right,
Top,
Bottom
}
}

View File

@ -6,6 +6,12 @@ using System.Windows.Forms;
namespace DarkUI.Controls
{
public enum DarkButtonStyle
{
Normal,
Flat
}
[ToolboxBitmap(typeof(Button))]
[DefaultEvent("Click")]
public class DarkButton : Button

View File

@ -0,0 +1,41 @@
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace DarkUI.Controls
{
public enum DarkControlState
{
Normal,
Hover,
Pressed
}
public enum DarkContentAlignment
{
Center,
Left,
Right
}
public class DarkControl : Control
{
#region Property Region
[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; }
}
#endregion
}
}

View File

@ -7,7 +7,23 @@ using System.Windows.Forms;
namespace DarkUI.Controls
{
public class DarkScrollBar : Control
public enum DarkScrollOrientation
{
Vertical,
Horizontal
}
public class ScrollValueEventArgs : EventArgs
{
public int Value { get; private set; }
public ScrollValueEventArgs(int value)
{
Value = value;
}
}
public class DarkScrollBar : DarkControl
{
#region Event Region
@ -17,7 +33,7 @@ namespace DarkUI.Controls
#region Field Region
private DarkOrientation _scrollOrientation;
private DarkScrollOrientation _scrollOrientation;
private int _value;
private int _minimum = 0;
@ -52,8 +68,8 @@ namespace DarkUI.Controls
[Category("Behavior")]
[Description("The orientation type of the scrollbar.")]
[DefaultValue(DarkOrientation.Vertical)]
public DarkOrientation ScrollOrientation
[DefaultValue(DarkScrollOrientation.Vertical)]
public DarkScrollOrientation ScrollOrientation
{
get { return _scrollOrientation; }
set
@ -178,7 +194,7 @@ namespace DarkUI.Controls
_isScrolling = true;
_initialContact = e.Location;
if (_scrollOrientation == DarkOrientation.Vertical)
if (_scrollOrientation == DarkScrollOrientation.Vertical)
_initialValue = _thumbArea.Top;
else
_initialValue = _thumbArea.Left;
@ -208,13 +224,13 @@ namespace DarkUI.Controls
if (_trackArea.Contains(e.Location) && e.Button == MouseButtons.Left)
{
// Step 1. Check if our input is at least aligned with the thumb
if (_scrollOrientation == DarkOrientation.Vertical)
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 == DarkOrientation.Horizontal)
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
{
var modRect = new Rectangle(_trackArea.Left, _thumbArea.Top, _trackArea.Width, _thumbArea.Height);
if (!modRect.Contains(e.Location))
@ -222,7 +238,7 @@ namespace DarkUI.Controls
}
// Step 2. Scroll to the area initially clicked.
if (_scrollOrientation == DarkOrientation.Vertical)
if (_scrollOrientation == DarkScrollOrientation.Vertical)
{
var loc = e.Location.Y;
loc -= _upArrowArea.Bottom - 1;
@ -242,7 +258,7 @@ namespace DarkUI.Controls
_initialContact = e.Location;
_thumbHot = true;
if (_scrollOrientation == DarkOrientation.Vertical)
if (_scrollOrientation == DarkScrollOrientation.Vertical)
_initialValue = _thumbArea.Top;
else
_initialValue = _thumbArea.Left;
@ -303,14 +319,14 @@ namespace DarkUI.Controls
var difference = new Point(e.Location.X - _initialContact.X, e.Location.Y - _initialContact.Y);
if (_scrollOrientation == DarkOrientation.Vertical)
if (_scrollOrientation == DarkScrollOrientation.Vertical)
{
var thumbPos = (_initialValue - _trackArea.Top);
var newPosition = thumbPos + difference.Y;
ScrollToPhysical(newPosition);
}
else if (_scrollOrientation == DarkOrientation.Horizontal)
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
{
var thumbPos = (_initialValue - _trackArea.Left);
var newPosition = thumbPos + difference.X;
@ -358,7 +374,7 @@ namespace DarkUI.Controls
public void ScrollToPhysical(int positionInPixels)
{
var isVert = _scrollOrientation == DarkOrientation.Vertical;
var isVert = _scrollOrientation == DarkScrollOrientation.Vertical;
var trackAreaSize = isVert ? _trackArea.Height - _thumbArea.Height : _trackArea.Width - _thumbArea.Width;
@ -377,7 +393,7 @@ namespace DarkUI.Controls
public void ScrollByPhysical(int offsetInPixels)
{
var isVert = _scrollOrientation == DarkOrientation.Vertical;
var isVert = _scrollOrientation == DarkScrollOrientation.Vertical;
var thumbPos = isVert ? (_thumbArea.Top - _trackArea.Top) : (_thumbArea.Left - _trackArea.Left);
@ -399,23 +415,23 @@ namespace DarkUI.Controls
Value = maximumValue;
// Arrow buttons
if (_scrollOrientation == DarkOrientation.Vertical)
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 == DarkOrientation.Horizontal)
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 == DarkOrientation.Vertical)
if (_scrollOrientation == DarkScrollOrientation.Vertical)
{
_trackArea = new Rectangle(area.Left, area.Top + Consts.ArrowButtonSize, area.Width, area.Height - (Consts.ArrowButtonSize * 2));
}
else if (_scrollOrientation == DarkOrientation.Horizontal)
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
{
_trackArea = new Rectangle(area.Left + Consts.ArrowButtonSize, area.Top, area.Width - (Consts.ArrowButtonSize * 2), area.Height);
}
@ -434,7 +450,7 @@ namespace DarkUI.Controls
var positionRatio = (float)Value / (float)viewAreaSize;
// Update area
if (_scrollOrientation == DarkOrientation.Vertical)
if (_scrollOrientation == DarkScrollOrientation.Vertical)
{
var thumbSize = (int)(_trackArea.Height * _viewContentRatio);
@ -446,7 +462,7 @@ namespace DarkUI.Controls
_thumbArea = new Rectangle(_trackArea.Left + 3, _trackArea.Top + thumbPosition, Consts.ScrollBarSize - 6, thumbSize);
}
else if (_scrollOrientation == DarkOrientation.Horizontal)
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
{
var thumbSize = (int)(_trackArea.Width * _viewContentRatio);
@ -493,9 +509,9 @@ namespace DarkUI.Controls
if (_upArrowClicked)
upIcon = ScrollIcons.scrollbar_arrow_clicked;
if (_scrollOrientation == DarkOrientation.Vertical)
if (_scrollOrientation == DarkScrollOrientation.Vertical)
upIcon.RotateFlip(RotateFlipType.RotateNoneFlipY);
else if (_scrollOrientation == DarkOrientation.Horizontal)
else if (_scrollOrientation == DarkScrollOrientation.Horizontal)
upIcon.RotateFlip(RotateFlipType.Rotate90FlipNone);
g.DrawImageUnscaled(upIcon,
@ -508,7 +524,7 @@ namespace DarkUI.Controls
if (_downArrowClicked)
downIcon = ScrollIcons.scrollbar_arrow_clicked;
if (_scrollOrientation == DarkOrientation.Horizontal)
if (_scrollOrientation == DarkScrollOrientation.Horizontal)
downIcon.RotateFlip(RotateFlipType.Rotate270FlipNone);
g.DrawImageUnscaled(downIcon,

View File

@ -6,7 +6,7 @@ using System.Windows.Forms;
namespace DarkUI.Controls
{
public abstract class DarkScrollBase : Control
public abstract class DarkScrollBase : DarkControl
{
#region Event Region
@ -97,8 +97,8 @@ namespace DarkUI.Controls
SetStyle(ControlStyles.Selectable |
ControlStyles.UserMouse, true);
_vScrollBar = new DarkScrollBar { ScrollOrientation = DarkOrientation.Vertical };
_hScrollBar = new DarkScrollBar { ScrollOrientation = DarkOrientation.Horizontal };
_vScrollBar = new DarkScrollBar { ScrollOrientation = DarkScrollOrientation.Vertical };
_hScrollBar = new DarkScrollBar { ScrollOrientation = DarkScrollOrientation.Horizontal };
Controls.Add(_vScrollBar);
Controls.Add(_hScrollBar);

View File

@ -4,7 +4,7 @@ using System.Windows.Forms;
namespace DarkUI.Controls
{
public class DarkSeparator : Control
public class DarkSeparator : DarkControl
{
#region Constructor Region

View File

@ -1,14 +0,0 @@
using System;
namespace DarkUI.Controls
{
public class ScrollValueEventArgs : EventArgs
{
public int Value { get; private set; }
public ScrollValueEventArgs(int value)
{
Value = value;
}
}
}

View File

@ -42,10 +42,12 @@
<Compile Include="Collections\ObservableListModified.cs" />
<Compile Include="Config\Colors.cs" />
<Compile Include="Config\Consts.cs" />
<Compile Include="Config\Enums.cs" />
<Compile Include="Controls\DarkCheckBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\DarkControl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\DarkRadioButton.cs">
<SubType>Component</SubType>
</Compile>
@ -55,7 +57,7 @@
<Compile Include="Controls\DarkTreeView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Items\DarkListItem.cs" />
<Compile Include="Controls\DarkListItem.cs" />
<Compile Include="Controls\DarkListView.cs">
<SubType>Component</SubType>
</Compile>
@ -74,9 +76,7 @@
<Compile Include="Controls\DarkMenuStrip.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\DarkScrollBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\DarkScrollBar.cs" />
<Compile Include="Controls\DarkScrollView.cs">
<SubType>Component</SubType>
</Compile>
@ -95,11 +95,8 @@
<Compile Include="Controls\DarkToolStrip.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\EventArgs\ScrollValueEventArgs.cs" />
<Compile Include="Controls\Items\DarkTreeNode.cs" />
<Compile Include="Docking\DarkDockContent.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\DarkTreeNode.cs" />
<Compile Include="Docking\DarkDockContent.cs" />
<Compile Include="Docking\DarkDockGroup.cs">
<SubType>Component</SubType>
</Compile>
@ -115,10 +112,9 @@
<Compile Include="Docking\DarkToolWindow.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Docking\EventArgs\DockContentEventArgs.cs" />
<Compile Include="Docking\Items\DarkDockSplitter.cs" />
<Compile Include="Docking\Items\DarkDockTab.cs" />
<Compile Include="Docking\Items\DarkDockTabArea.cs" />
<Compile Include="Docking\DarkDockSplitter.cs" />
<Compile Include="Docking\DarkDockTab.cs" />
<Compile Include="Docking\DarkDockTabArea.cs" />
<Compile Include="Extensions\BitmapExtensions.cs" />
<Compile Include="Extensions\IEnumerableExtensions.cs" />
<Compile Include="Forms\DarkDialog.cs">
@ -139,6 +135,7 @@
<Compile Include="Forms\DarkTranslucentForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Enums.cs" />
<Compile Include="Icons\DockIcons.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>

View File

@ -1,11 +1,20 @@
using DarkUI.Config;
using System;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace DarkUI.Docking
{
public class DockContentEventArgs : EventArgs
{
public DarkDockContent Content { get; private set; }
public DockContentEventArgs(DarkDockContent content)
{
Content = content;
}
}
[ToolboxItem(false)]
public class DarkDockContent : UserControl
{

View File

@ -7,6 +7,14 @@ using System.Windows.Forms;
namespace DarkUI.Docking
{
public enum DarkDockArea
{
Document,
Left,
Right,
Bottom
}
public class DarkDockPanel : UserControl
{
#region Event Region

View File

@ -1,11 +1,18 @@
using DarkUI.Config;
using DarkUI.Forms;
using DarkUI.Forms;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace DarkUI.Docking
{
public enum DarkSplitterType
{
Left,
Right,
Top,
Bottom
}
public class DarkDockSplitter
{
#region Field Region

View File

@ -1,14 +0,0 @@
using System;
namespace DarkUI.Docking
{
public class DockContentEventArgs : EventArgs
{
public DarkDockContent Content { get; private set; }
public DockContentEventArgs(DarkDockContent content)
{
Content = content;
}
}
}

View File

@ -1,11 +1,21 @@
using DarkUI.Config;
using DarkUI.Controls;
using DarkUI.Controls;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
namespace DarkUI.Forms
{
public enum DarkDialogButton
{
Ok,
Close,
OkCancel,
YesNo,
YesNoCancel,
AbortRetryIgnore,
RetryCancel
}
public partial class DarkDialog : DarkForm
{
#region Field Region

View File

@ -1,5 +1,4 @@
using DarkUI.Config;
using DarkUI.Icons;
using DarkUI.Icons;
using System;
using System.ComponentModel;
using System.Drawing;
@ -7,6 +6,14 @@ using System.Windows.Forms;
namespace DarkUI.Forms
{
public enum DarkMessageBoxIcon
{
None,
Information,
Warning,
Error
}
public partial class DarkMessageBox : DarkDialog
{
#region Field Region

View File

@ -1,5 +1,5 @@
using DarkUI.Config;
using DarkUI.Controls;
using DarkUI.Controls;
using DarkUI.Docking;
namespace Example
{

View File

@ -1,5 +1,6 @@
using DarkUI.Config;
using DarkUI.Controls;
using DarkUI.Docking;
namespace Example
{
@ -48,7 +49,7 @@ namespace Example
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lstHistory);
this.DockArea = DarkUI.Config.DarkDockArea.Right;
this.DockArea = DarkDockArea.Right;
this.DockText = "History";
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Icon = global::Example.Icons.RefactoringLog_12810;

View File

@ -1,5 +1,5 @@
using DarkUI.Config;
using DarkUI.Controls;
using DarkUI.Controls;
using DarkUI.Docking;
namespace Example
{

View File

@ -1,5 +1,6 @@
using DarkUI.Config;
using DarkUI.Controls;
using DarkUI.Docking;
namespace Example
{

View File

@ -1,4 +1,5 @@
using DarkUI.Config;
using DarkUI.Docking;
namespace Example
{
@ -176,7 +177,7 @@ namespace Example
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.pnlMain);
this.DockArea = DarkUI.Config.DarkDockArea.Right;
this.DockArea = DarkDockArea.Right;
this.DockText = "Properties";
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Icon = global::Example.Icons.properties_16xLG;