mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-02 07:09:27 +03:00
Added DarkNumericUpDown
This commit is contained in:
parent
d7f3cd40fb
commit
5712a441b4
153
DarkUI/Controls/DarkNumericUpDown.cs
Normal file
153
DarkUI/Controls/DarkNumericUpDown.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using DarkUI.Config;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.Security;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DarkUI.Controls
|
||||
{
|
||||
public class DarkNumericUpDown : NumericUpDown
|
||||
{
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Color ForeColor { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new Color BackColor { get; set; }
|
||||
|
||||
private bool _mouseDown;
|
||||
|
||||
public DarkNumericUpDown()
|
||||
{
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.UserPaint, true);
|
||||
|
||||
base.ForeColor = Color.Gainsboro;
|
||||
base.BackColor = Colors.LightBackground;
|
||||
|
||||
Controls[0].Paint += DarkNumericUpDown_Paint;
|
||||
|
||||
try
|
||||
{
|
||||
// Prevent flickering, only if our assembly has reflection permission
|
||||
Type type = Controls[0].GetType();
|
||||
BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance;
|
||||
MethodInfo method = type.GetMethod("SetStyle", flags);
|
||||
|
||||
if (method != null)
|
||||
{
|
||||
object[] param = { ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true };
|
||||
method.Invoke(Controls[0], param);
|
||||
}
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
// Don't do anything, we are running in a trusted contex
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
_mouseDown = true;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs mevent)
|
||||
{
|
||||
_mouseDown = false;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(EventArgs e)
|
||||
{
|
||||
base.OnMouseEnter(e);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnTextBoxLostFocus(object source, EventArgs e)
|
||||
{
|
||||
base.OnTextBoxLostFocus(source, e);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void DarkNumericUpDown_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
var rect = e.ClipRectangle;
|
||||
|
||||
var fillColor = Colors.HeaderBackground;
|
||||
|
||||
using (var b = new SolidBrush(fillColor))
|
||||
{
|
||||
g.FillRectangle(b, rect);
|
||||
}
|
||||
|
||||
var mousePos = Controls[0].PointToClient(Cursor.Position);
|
||||
|
||||
var upArea = new Rectangle(0, 0, rect.Width, rect.Height / 2);
|
||||
var upHot = upArea.Contains(mousePos);
|
||||
|
||||
var upIcon = upHot ? ScrollIcons.scrollbar_arrow_small_hot : ScrollIcons.scrollbar_arrow_small_standard;
|
||||
if (upHot && _mouseDown)
|
||||
upIcon = ScrollIcons.scrollbar_arrow_small_clicked;
|
||||
|
||||
upIcon.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
||||
g.DrawImageUnscaled(upIcon, (upArea.Width / 2) - (upIcon.Width / 2), (upArea.Height / 2) - (upIcon.Height / 2));
|
||||
|
||||
var downArea = new Rectangle(0, rect.Height / 2, rect.Width, rect.Height / 2);
|
||||
var downHot = downArea.Contains(mousePos);
|
||||
|
||||
var downIcon = downHot ? ScrollIcons.scrollbar_arrow_small_hot : ScrollIcons.scrollbar_arrow_small_standard;
|
||||
if (downHot && _mouseDown)
|
||||
downIcon = ScrollIcons.scrollbar_arrow_small_clicked;
|
||||
|
||||
g.DrawImageUnscaled(downIcon, (downArea.Width / 2) - (downIcon.Width / 2), downArea.Top + (downArea.Height / 2) - (downIcon.Height / 2));
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
|
||||
var g = e.Graphics;
|
||||
var rect = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);
|
||||
|
||||
var borderColor = Colors.GreySelection;
|
||||
|
||||
if (Focused && TabStop)
|
||||
borderColor = Colors.BlueHighlight;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -58,6 +58,9 @@
|
||||
<Compile Include="Controls\DarkGroupBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkNumericUpDown.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\DarkRadioButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@ -298,6 +301,15 @@
|
||||
<ItemGroup>
|
||||
<None Include="Resources\tw_active_close_selected.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\scrollbar_arrow_small_clicked.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\scrollbar_arrow_small_hot.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\scrollbar_arrow_small_standard.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.
|
||||
|
34
DarkUI/Icons/ScrollIcons.Designer.cs
generated
34
DarkUI/Icons/ScrollIcons.Designer.cs
generated
@ -8,7 +8,7 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DarkUI.Icons {
|
||||
namespace DarkUI {
|
||||
using System;
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ namespace DarkUI.Icons {
|
||||
// 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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class ScrollIcons {
|
||||
@ -90,6 +90,36 @@ namespace DarkUI.Icons {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap scrollbar_arrow_small_clicked {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("scrollbar_arrow_small_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_small_hot {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("scrollbar_arrow_small_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_small_standard {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("scrollbar_arrow_small_standard", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
@ -127,6 +127,15 @@
|
||||
<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_small_clicked" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\scrollbar_arrow_small_clicked.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="scrollbar_arrow_small_hot" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\scrollbar_arrow_small_hot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="scrollbar_arrow_small_standard" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\scrollbar_arrow_small_standard.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>
|
||||
|
BIN
DarkUI/Resources/scrollbar_arrow_small_clicked.png
Normal file
BIN
DarkUI/Resources/scrollbar_arrow_small_clicked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
DarkUI/Resources/scrollbar_arrow_small_hot.png
Normal file
BIN
DarkUI/Resources/scrollbar_arrow_small_hot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
DarkUI/Resources/scrollbar_arrow_small_standard.png
Normal file
BIN
DarkUI/Resources/scrollbar_arrow_small_standard.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
101
Example/Forms/Dialogs/DialogControls.Designer.cs
generated
101
Example/Forms/Dialogs/DialogControls.Designer.cs
generated
@ -39,8 +39,13 @@ namespace Example
|
||||
this.lstTest = new DarkUI.Controls.DarkListView();
|
||||
this.pnlMessageBox = new DarkUI.Controls.DarkSectionPanel();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.darkGroupBox1 = new DarkUI.Controls.DarkGroupBox();
|
||||
this.panel7 = new System.Windows.Forms.Panel();
|
||||
this.darkComboBox1 = new DarkUI.Controls.DarkComboBox();
|
||||
this.darkTitle4 = new DarkUI.Controls.DarkTitle();
|
||||
this.panel6 = new System.Windows.Forms.Panel();
|
||||
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
|
||||
this.darkNumericUpDown1 = new DarkUI.Controls.DarkNumericUpDown();
|
||||
this.darkTitle5 = new DarkUI.Controls.DarkTitle();
|
||||
this.panel5 = new System.Windows.Forms.Panel();
|
||||
this.darkRadioButton3 = new DarkUI.Controls.DarkRadioButton();
|
||||
this.darkRadioButton2 = new DarkUI.Controls.DarkRadioButton();
|
||||
@ -61,7 +66,10 @@ namespace Example
|
||||
this.pnlListView.SuspendLayout();
|
||||
this.pnlMessageBox.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
this.darkGroupBox1.SuspendLayout();
|
||||
this.panel7.SuspendLayout();
|
||||
this.panel6.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.darkNumericUpDown1)).BeginInit();
|
||||
this.panel5.SuspendLayout();
|
||||
this.panel4.SuspendLayout();
|
||||
this.panel3.SuspendLayout();
|
||||
@ -153,7 +161,8 @@ namespace Example
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.darkGroupBox1);
|
||||
this.panel1.Controls.Add(this.panel7);
|
||||
this.panel1.Controls.Add(this.panel6);
|
||||
this.panel1.Controls.Add(this.panel5);
|
||||
this.panel1.Controls.Add(this.panel4);
|
||||
this.panel1.Controls.Add(this.panel3);
|
||||
@ -165,20 +174,15 @@ namespace Example
|
||||
this.panel1.Size = new System.Drawing.Size(220, 583);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// darkGroupBox1
|
||||
// panel7
|
||||
//
|
||||
this.darkGroupBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65)))));
|
||||
this.darkGroupBox1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51)))));
|
||||
this.darkGroupBox1.Controls.Add(this.darkComboBox1);
|
||||
this.darkGroupBox1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.darkGroupBox1.ForeColor = System.Drawing.Color.Gainsboro;
|
||||
this.darkGroupBox1.Location = new System.Drawing.Point(10, 285);
|
||||
this.darkGroupBox1.Name = "darkGroupBox1";
|
||||
this.darkGroupBox1.Padding = new System.Windows.Forms.Padding(10);
|
||||
this.darkGroupBox1.Size = new System.Drawing.Size(200, 144);
|
||||
this.darkGroupBox1.TabIndex = 14;
|
||||
this.darkGroupBox1.TabStop = false;
|
||||
this.darkGroupBox1.Text = "DarkUI 2.0 Controls";
|
||||
this.panel7.Controls.Add(this.darkComboBox1);
|
||||
this.panel7.Controls.Add(this.darkTitle4);
|
||||
this.panel7.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel7.Location = new System.Drawing.Point(10, 371);
|
||||
this.panel7.Name = "panel7";
|
||||
this.panel7.Size = new System.Drawing.Size(200, 63);
|
||||
this.panel7.TabIndex = 23;
|
||||
//
|
||||
// darkComboBox1
|
||||
//
|
||||
@ -190,10 +194,57 @@ namespace Example
|
||||
"Item 2",
|
||||
"This is a really long item in the collection to check out how text is clipped",
|
||||
"Item 4"});
|
||||
this.darkComboBox1.Location = new System.Drawing.Point(10, 26);
|
||||
this.darkComboBox1.Location = new System.Drawing.Point(0, 26);
|
||||
this.darkComboBox1.Name = "darkComboBox1";
|
||||
this.darkComboBox1.Size = new System.Drawing.Size(180, 24);
|
||||
this.darkComboBox1.TabIndex = 18;
|
||||
this.darkComboBox1.Size = new System.Drawing.Size(200, 24);
|
||||
this.darkComboBox1.TabIndex = 20;
|
||||
//
|
||||
// darkTitle4
|
||||
//
|
||||
this.darkTitle4.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.darkTitle4.Location = new System.Drawing.Point(0, 0);
|
||||
this.darkTitle4.Name = "darkTitle4";
|
||||
this.darkTitle4.Size = new System.Drawing.Size(200, 26);
|
||||
this.darkTitle4.TabIndex = 21;
|
||||
this.darkTitle4.Text = "ComboBox";
|
||||
//
|
||||
// panel6
|
||||
//
|
||||
this.panel6.Controls.Add(this.numericUpDown1);
|
||||
this.panel6.Controls.Add(this.darkNumericUpDown1);
|
||||
this.panel6.Controls.Add(this.darkTitle5);
|
||||
this.panel6.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel6.Location = new System.Drawing.Point(10, 285);
|
||||
this.panel6.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.panel6.Name = "panel6";
|
||||
this.panel6.Size = new System.Drawing.Size(200, 86);
|
||||
this.panel6.TabIndex = 22;
|
||||
//
|
||||
// numericUpDown1
|
||||
//
|
||||
this.numericUpDown1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.numericUpDown1.Location = new System.Drawing.Point(0, 49);
|
||||
this.numericUpDown1.Name = "numericUpDown1";
|
||||
this.numericUpDown1.Size = new System.Drawing.Size(200, 23);
|
||||
this.numericUpDown1.TabIndex = 25;
|
||||
//
|
||||
// darkNumericUpDown1
|
||||
//
|
||||
this.darkNumericUpDown1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.darkNumericUpDown1.Location = new System.Drawing.Point(0, 26);
|
||||
this.darkNumericUpDown1.Name = "darkNumericUpDown1";
|
||||
this.darkNumericUpDown1.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
this.darkNumericUpDown1.Size = new System.Drawing.Size(200, 23);
|
||||
this.darkNumericUpDown1.TabIndex = 24;
|
||||
//
|
||||
// darkTitle5
|
||||
//
|
||||
this.darkTitle5.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.darkTitle5.Location = new System.Drawing.Point(0, 0);
|
||||
this.darkTitle5.Name = "darkTitle5";
|
||||
this.darkTitle5.Size = new System.Drawing.Size(200, 26);
|
||||
this.darkTitle5.TabIndex = 23;
|
||||
this.darkTitle5.Text = "Numeric Up/Down";
|
||||
//
|
||||
// panel5
|
||||
//
|
||||
@ -365,7 +416,10 @@ namespace Example
|
||||
this.pnlMessageBox.ResumeLayout(false);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.darkGroupBox1.ResumeLayout(false);
|
||||
this.panel7.ResumeLayout(false);
|
||||
this.panel6.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.darkNumericUpDown1)).EndInit();
|
||||
this.panel5.ResumeLayout(false);
|
||||
this.panel5.PerformLayout();
|
||||
this.panel4.ResumeLayout(false);
|
||||
@ -400,7 +454,12 @@ namespace Example
|
||||
private DarkTitle darkTitle1;
|
||||
private DarkTitle darkTitle2;
|
||||
private DarkTitle darkTitle3;
|
||||
private DarkGroupBox darkGroupBox1;
|
||||
private System.Windows.Forms.Panel panel7;
|
||||
private DarkComboBox darkComboBox1;
|
||||
private DarkTitle darkTitle4;
|
||||
private System.Windows.Forms.Panel panel6;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDown1;
|
||||
private DarkNumericUpDown darkNumericUpDown1;
|
||||
private DarkTitle darkTitle5;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user