Rename TestApp folder.
This commit is contained in:
@@ -0,0 +1,207 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="AngleHistogram.cs" company="">
|
||||
// Christian Woltering, Triangle.NET, http://triangle.codeplex.com/
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace MeshExplorer.Controls
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Displays an angle histogram.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The angle histogram is divided into two parts: the minimum angles
|
||||
/// on the left side (0 to 60 degrees) and the maximum angles on the
|
||||
/// right (60 to 180 degrees).
|
||||
/// </remarks>
|
||||
public class AngleHistogram : Control
|
||||
{
|
||||
#region Designer
|
||||
|
||||
/// <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 Component 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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
int[] maxAngles;
|
||||
int[] minAngles;
|
||||
|
||||
Brush fillBlue1 = new SolidBrush(Color.FromArgb(60, 100, 140));
|
||||
Brush fillBlue2 = new SolidBrush(Color.FromArgb(110, 150, 200));
|
||||
|
||||
Brush textBack = new SolidBrush(Color.FromArgb(72, 0, 0, 0));
|
||||
|
||||
// The maximum number of angles
|
||||
int maxAngleCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AngleHistogram" /> control.
|
||||
/// </summary>
|
||||
public AngleHistogram()
|
||||
{
|
||||
this.BackColor = ColorScheme.ColorGray78;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the histogram data and invalidates the control.
|
||||
/// </summary>
|
||||
public void SetData(int[] dataMin, int[] dataMax)
|
||||
{
|
||||
maxAngleCount = 0;
|
||||
|
||||
this.minAngles = dataMin;
|
||||
this.maxAngles = dataMax;
|
||||
|
||||
ParseData(dataMin);
|
||||
ParseData(dataMax);
|
||||
|
||||
if (maxAngleCount == 0)
|
||||
{
|
||||
this.maxAngles = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
private void ParseData(int[] data)
|
||||
{
|
||||
if (data != null)
|
||||
{
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
if (data[i] > maxAngleCount)
|
||||
{
|
||||
maxAngleCount = data[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int padding = 1;
|
||||
int paddingBottom = 0;
|
||||
int paddingTop = 15;
|
||||
|
||||
private void DrawHistogram(Graphics g, int offset, int left, int size, int[] data, Brush brush, Brush brushTop)
|
||||
{
|
||||
int count = maxAngleCount;
|
||||
int totalHeight = this.Height - paddingBottom - paddingTop;
|
||||
|
||||
int n = offset == 0 ? data.Length / 3 : data.Length;
|
||||
float value = 0;
|
||||
|
||||
for (int i = offset; i < n; i++)
|
||||
{
|
||||
if (data[i] > 0)
|
||||
{
|
||||
// Scale to control height
|
||||
value = totalHeight * data[i] / count;
|
||||
|
||||
// Fill bar
|
||||
g.FillRectangle(brush,
|
||||
left + i * size, this.Height - paddingBottom - value,
|
||||
size - 1, value);
|
||||
|
||||
// Draw top of bar (just a little effect ...)
|
||||
if (value > 2)
|
||||
{
|
||||
g.FillRectangle(brushTop,
|
||||
left + i * size, this.Height - paddingBottom - value,
|
||||
size - 1, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the labels on the bottom.
|
||||
/// </summary>
|
||||
private void DrawStrings(Graphics g, SizeF fSize, int size, int middle)
|
||||
{
|
||||
int fHeight = (int)(fSize.Height + 2);
|
||||
g.FillRectangle(textBack, 0, this.Height - fHeight, this.Width, fHeight);
|
||||
|
||||
g.DrawString("0", this.Font, Brushes.White, padding, this.Height - fSize.Height - 1);
|
||||
g.DrawString("60", this.Font, Brushes.White,
|
||||
this.minAngles.Length * size / 3.0f - 2 * fSize.Width,
|
||||
this.Height - fSize.Height - 1);
|
||||
|
||||
g.DrawString("60", this.Font, Brushes.White, middle, this.Height - fSize.Height - 1);
|
||||
g.DrawString("180", this.Font, Brushes.White,
|
||||
this.Width - 3 * fSize.Width,
|
||||
this.Height - fSize.Height - 1);
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
g.FillRectangle(new SolidBrush(this.BackColor), this.ClientRectangle);
|
||||
|
||||
if (this.minAngles == null || this.maxAngles == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SizeF fSize = g.MeasureString("0", this.Font, this.Width);
|
||||
|
||||
int n = this.minAngles.Length;
|
||||
|
||||
// Hack --- TODO: Change stats class
|
||||
if (n != this.maxAngles.Length)
|
||||
{
|
||||
n = this.minAngles.Length + this.maxAngles.Length;
|
||||
}
|
||||
|
||||
// Each bar takes up this space
|
||||
int size = (this.Width - 2 * padding) / (n + 1);
|
||||
|
||||
// Make pixel align
|
||||
int middle = this.Width - padding - n * size;
|
||||
|
||||
DrawHistogram(g, 0, padding, size, this.minAngles, Brushes.DarkGreen, Brushes.Green);
|
||||
DrawHistogram(g, n / 3, middle, size, this.maxAngles, fillBlue1, fillBlue2);
|
||||
|
||||
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
|
||||
|
||||
DrawStrings(g, fSize, size, middle + n / 3 * size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="ColorScheme.cs" company="">
|
||||
// Christian Woltering, Triangle.NET, http://triangle.codeplex.com/
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace MeshExplorer.Controls
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
/// <summary>
|
||||
/// Dark user interface color scheme.
|
||||
/// </summary>
|
||||
public static class ColorScheme
|
||||
{
|
||||
public static Color ColorGray13 = Color.FromArgb(13, 13, 13);
|
||||
public static Color ColorGray46 = Color.FromArgb(46, 46, 46);
|
||||
public static Color ColorGray64 = Color.FromArgb(64, 64, 64);
|
||||
public static Color ColorGray68 = Color.FromArgb(68, 68, 68);
|
||||
public static Color ColorGray78 = Color.FromArgb(78, 78, 78);
|
||||
public static Color ColorGray89 = Color.FromArgb(89, 89, 89);
|
||||
public static Color ColorGray98 = Color.FromArgb(98, 98, 98);
|
||||
public static Color ColorGray107 = Color.FromArgb(107, 107, 107);
|
||||
public static Color ColorGray110 = Color.FromArgb(110, 110, 110);
|
||||
public static Color ColorGray122 = Color.FromArgb(122, 122, 122);
|
||||
|
||||
public static Brush BrushGray68 = new SolidBrush(ColorGray68);
|
||||
public static Brush BrushGray78 = new SolidBrush(ColorGray78);
|
||||
|
||||
// Linear gradient horizontal
|
||||
public static Brush SliderBorderBrush = new SolidBrush(ColorGray46);
|
||||
public static Brush SliderFillBrush = new SolidBrush(ColorGray89);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="DarkButton.cs" company="">
|
||||
// Christian Woltering, Triangle.NET, http://triangle.codeplex.com/
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace MeshExplorer.Controls
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public class DarkButton : Button
|
||||
{
|
||||
#region Designer
|
||||
|
||||
/// <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 Component 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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
enum eButtonState { Normal, MouseOver, Down }
|
||||
eButtonState m_State = eButtonState.Normal;
|
||||
|
||||
// Make sure the control is invalidated when the text is changed.
|
||||
public override string Text
|
||||
{
|
||||
get { return base.Text; }
|
||||
set { base.Text = value; this.Invalidate(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DarkButton" /> control.
|
||||
/// </summary>
|
||||
public DarkButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region Control overrides
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
|
||||
|
||||
float down = 0.0f;
|
||||
|
||||
// Colors and brushes
|
||||
Pen brushBorder = null;
|
||||
LinearGradientMode mode = LinearGradientMode.Vertical;
|
||||
LinearGradientBrush brushOuter = null;
|
||||
LinearGradientBrush brushInner = null;
|
||||
|
||||
Rectangle newRect = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1);
|
||||
Color text_color = Color.White;
|
||||
|
||||
if (Enabled)
|
||||
{
|
||||
if (base.Focused)
|
||||
brushBorder = new Pen(Color.FromArgb(24, 24, 24), 1f);
|
||||
else
|
||||
brushBorder = new Pen(Color.FromArgb(56, 56, 56), 1f);
|
||||
|
||||
switch (m_State)
|
||||
{
|
||||
case eButtonState.Normal:
|
||||
brushOuter = new LinearGradientBrush(newRect, Color.FromArgb(123, 123, 123), Color.FromArgb(77, 77, 77), mode);
|
||||
brushInner = new LinearGradientBrush(newRect, Color.FromArgb(104, 104, 104), Color.FromArgb(71, 71, 71), mode);
|
||||
e.Graphics.FillRectangle(brushOuter, newRect);
|
||||
newRect.Inflate(-1, -1);
|
||||
e.Graphics.FillRectangle(brushInner, newRect);
|
||||
newRect.Inflate(1, 1);
|
||||
break;
|
||||
|
||||
case eButtonState.MouseOver:
|
||||
brushOuter = new LinearGradientBrush(newRect, Color.FromArgb(140, 140, 140), Color.FromArgb(87, 87, 87), mode);
|
||||
brushInner = new LinearGradientBrush(newRect, Color.FromArgb(118, 118, 118), Color.FromArgb(81, 81, 81), mode);
|
||||
e.Graphics.FillRectangle(brushOuter, newRect);
|
||||
newRect.Inflate(-1, -1);
|
||||
e.Graphics.FillRectangle(brushInner, newRect);
|
||||
newRect.Inflate(1, 1);
|
||||
break;
|
||||
|
||||
case eButtonState.Down:
|
||||
down = 1.0f;
|
||||
brushOuter = new LinearGradientBrush(newRect, Color.FromArgb(108, 108, 108), Color.FromArgb(68, 68, 68), mode);
|
||||
brushInner = new LinearGradientBrush(newRect, Color.FromArgb(92, 92, 92), Color.FromArgb(62, 62, 62), mode);
|
||||
e.Graphics.FillRectangle(brushOuter, newRect);
|
||||
newRect.Inflate(-1, -1);
|
||||
e.Graphics.FillRectangle(brushInner, newRect);
|
||||
newRect.Inflate(1, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
e.Graphics.DrawRectangle(brushBorder, newRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
text_color = Color.FromArgb(110, 110, 110);
|
||||
brushBorder = new Pen(Color.FromArgb(48, 48, 48), 1f);
|
||||
brushOuter = new LinearGradientBrush(newRect, Color.FromArgb(82, 82, 82), Color.FromArgb(67, 67, 67), mode);
|
||||
brushInner = new LinearGradientBrush(newRect, Color.FromArgb(76, 76, 76), Color.FromArgb(65, 65, 65), mode);
|
||||
e.Graphics.FillRectangle(brushOuter, newRect);
|
||||
newRect.Inflate(-1, -1);
|
||||
e.Graphics.FillRectangle(brushInner, newRect);
|
||||
newRect.Inflate(1, 1);
|
||||
e.Graphics.DrawRectangle(brushBorder, newRect);
|
||||
}
|
||||
|
||||
|
||||
string largetext = this.Text;
|
||||
|
||||
SizeF szL = e.Graphics.MeasureString(this.Text, base.Font, this.Width);
|
||||
if (Enabled)
|
||||
{
|
||||
e.Graphics.DrawString(largetext, base.Font, Brushes.Black,
|
||||
new RectangleF(new PointF((this.Width - szL.Width) / 2, (this.Height - szL.Height) / 2 + 1 + down), szL));
|
||||
}
|
||||
e.Graphics.DrawString(largetext, base.Font, new SolidBrush(text_color),
|
||||
new RectangleF(new PointF((this.Width - szL.Width) / 2, (this.Height - szL.Height) / 2 + down), szL));
|
||||
|
||||
brushOuter.Dispose();
|
||||
brushInner.Dispose();
|
||||
brushBorder.Dispose();
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(System.EventArgs e)
|
||||
{
|
||||
m_State = eButtonState.Normal;
|
||||
this.Invalidate();
|
||||
base.OnMouseLeave(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(System.EventArgs e)
|
||||
{
|
||||
m_State = eButtonState.MouseOver;
|
||||
this.Invalidate();
|
||||
base.OnMouseEnter(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
m_State = eButtonState.MouseOver;
|
||||
this.Invalidate();
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
m_State = eButtonState.Down;
|
||||
this.Invalidate();
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="DarkCheckBox.cs" company="">
|
||||
// Christian Woltering, Triangle.NET, http://triangle.codeplex.com/
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace MeshExplorer.Controls
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Dark checkbox control.
|
||||
/// </summary>
|
||||
public class DarkCheckBox : ButtonBase
|
||||
{
|
||||
#region Designer
|
||||
|
||||
/// <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 Component 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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
enum eButtonState { Normal, MouseOver, Down }
|
||||
eButtonState m_State = eButtonState.Normal;
|
||||
|
||||
// Make sure the control is invalidated when the text is changed.
|
||||
public override string Text
|
||||
{
|
||||
get { return base.Text; }
|
||||
set { base.Text = value; this.Invalidate(); }
|
||||
}
|
||||
|
||||
int boxSize = 13;
|
||||
|
||||
bool isChecked = false;
|
||||
public bool Checked
|
||||
{
|
||||
get { return isChecked; }
|
||||
set { isChecked = value; this.Invalidate(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DarkCheckBox" /> control.
|
||||
/// </summary>
|
||||
public DarkCheckBox()
|
||||
{
|
||||
this.BackColor = Color.FromArgb(76, 76, 76);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void DrawText(Graphics g, Color forecolor, Point location)
|
||||
{
|
||||
if (this.UseCompatibleTextRendering)
|
||||
{
|
||||
//using (StringFormat stringFormat = this.CreateStringFormat())
|
||||
{
|
||||
if (this.Enabled)
|
||||
{
|
||||
g.DrawString(this.Text, base.Font, new SolidBrush(forecolor), location.X, location.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawString(this.Text, base.Font, new SolidBrush(forecolor), location.X, location.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TextFormatFlags textFormatFlags = this.CreateTextFormatFlags();
|
||||
if (this.Enabled)
|
||||
{
|
||||
TextRenderer.DrawText((IDeviceContext)g, this.Text, this.Font, location, forecolor);
|
||||
}
|
||||
else
|
||||
{
|
||||
//forecolor = TextRenderer.DisabledTextColor(this.BackColor);
|
||||
TextRenderer.DrawText((IDeviceContext)g, this.Text, this.Font, location, forecolor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Control overrides
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
//base.OnPaint(e);
|
||||
e.Graphics.FillRectangle(new SolidBrush(this.BackColor), this.ClientRectangle);
|
||||
|
||||
Pen checkMark = new Pen(Color.White, 1.8f);
|
||||
checkMark.StartCap = LineCap.Round;
|
||||
checkMark.EndCap = LineCap.Round;
|
||||
|
||||
// Colors and brushes
|
||||
Pen brushBorder = null;
|
||||
LinearGradientMode mode = LinearGradientMode.Vertical;
|
||||
LinearGradientBrush brushOuter = null;
|
||||
LinearGradientBrush brushInner = null;
|
||||
|
||||
int y = (this.Height - boxSize) / 2;
|
||||
|
||||
Rectangle newRect = new Rectangle(1, y, boxSize, boxSize);
|
||||
Color text_color = Color.White;
|
||||
|
||||
brushOuter = new LinearGradientBrush(newRect, ColorScheme.ColorGray107, ColorScheme.ColorGray110, mode);
|
||||
e.Graphics.FillRectangle(brushOuter, newRect);
|
||||
|
||||
newRect = new Rectangle(2, y + 1, boxSize - 3, boxSize - 3);
|
||||
|
||||
if (Enabled)
|
||||
{
|
||||
if (base.Focused)
|
||||
brushBorder = new Pen(Color.FromArgb(60, 60, 60), 1f);
|
||||
else
|
||||
brushBorder = new Pen(Color.FromArgb(38, 38, 38), 1f);
|
||||
|
||||
switch (m_State)
|
||||
{
|
||||
case eButtonState.Normal:
|
||||
brushInner = new LinearGradientBrush(newRect, Color.FromArgb(111, 111, 111), Color.FromArgb(80, 80, 80), mode);
|
||||
e.Graphics.FillRectangle(brushInner, newRect);
|
||||
break;
|
||||
|
||||
case eButtonState.MouseOver:
|
||||
brushInner = new LinearGradientBrush(newRect, Color.FromArgb(118, 118, 118), Color.FromArgb(81, 81, 81), mode);
|
||||
e.Graphics.FillRectangle(brushInner, newRect);
|
||||
break;
|
||||
|
||||
case eButtonState.Down:
|
||||
brushInner = new LinearGradientBrush(newRect, Color.FromArgb(92, 92, 92), Color.FromArgb(62, 62, 62), mode);
|
||||
e.Graphics.FillRectangle(brushInner, newRect);
|
||||
break;
|
||||
}
|
||||
|
||||
e.Graphics.DrawRectangle(brushBorder, newRect);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
brushInner = new LinearGradientBrush(newRect, Color.FromArgb(76, 76, 76), Color.FromArgb(65, 65, 65), mode);
|
||||
e.Graphics.FillRectangle(brushInner, newRect);
|
||||
|
||||
brushBorder = new Pen(Color.FromArgb(48, 48, 48), 1f);
|
||||
e.Graphics.DrawRectangle(brushBorder, newRect);
|
||||
|
||||
text_color = Color.FromArgb(160, 160, 160);
|
||||
checkMark.Color = Color.FromArgb(180, 180, 180);
|
||||
}
|
||||
|
||||
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
|
||||
|
||||
SizeF szL = e.Graphics.MeasureString(this.Text, base.Font, this.Width);
|
||||
DrawText(e.Graphics, text_color, new Point(boxSize + 4, (int)((this.Height - szL.Height) / 2) + 1));
|
||||
|
||||
if (this.isChecked)
|
||||
{
|
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
||||
e.Graphics.DrawLine(checkMark, 4, newRect.Bottom - boxSize / 2, newRect.Left + boxSize / 2.5f, newRect.Bottom - 2);
|
||||
e.Graphics.DrawLine(checkMark, newRect.Left + boxSize / 2.6f, newRect.Bottom - 2, newRect.Right, newRect.Top);
|
||||
}
|
||||
|
||||
if (brushOuter != null) brushOuter.Dispose();
|
||||
if (brushInner != null) brushInner.Dispose();
|
||||
if (brushBorder != null) brushBorder.Dispose();
|
||||
if (checkMark != null) checkMark.Dispose();
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(System.EventArgs e)
|
||||
{
|
||||
m_State = eButtonState.Normal;
|
||||
this.Invalidate();
|
||||
base.OnMouseLeave(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(System.EventArgs e)
|
||||
{
|
||||
m_State = eButtonState.MouseOver;
|
||||
this.Invalidate();
|
||||
base.OnMouseEnter(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
m_State = eButtonState.MouseOver;
|
||||
this.Invalidate();
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
m_State = eButtonState.Down;
|
||||
this.Invalidate();
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnClick(EventArgs e)
|
||||
{
|
||||
this.isChecked = !this.isChecked;
|
||||
this.Invalidate();
|
||||
base.OnClick(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="DarkListBox.cs" company="">
|
||||
// Christian Woltering, Triangle.NET, http://triangle.codeplex.com/
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace MeshExplorer.Controls
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
/// <summary>
|
||||
/// Dark listbox control.
|
||||
/// </summary>
|
||||
public class DarkListBox : ListBox
|
||||
{
|
||||
Font _boldFont;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DarkListBox" /> control.
|
||||
/// </summary>
|
||||
public DarkListBox()
|
||||
{
|
||||
_boldFont = new Font(base.Font.FontFamily, base.Font.Size, FontStyle.Bold);
|
||||
|
||||
this.DrawMode = DrawMode.OwnerDrawVariable;
|
||||
this.ItemHeight = 22;
|
||||
this.FontChanged += new EventHandler(ListBoxFontChanged);
|
||||
this.BackColor = Color.FromArgb(96, 96, 96);
|
||||
}
|
||||
|
||||
void ListBoxFontChanged(object sender, EventArgs e)
|
||||
{
|
||||
_boldFont = new Font(base.Font.FontFamily, base.Font.Size, FontStyle.Bold);
|
||||
}
|
||||
|
||||
protected override void OnMeasureItem(MeasureItemEventArgs e)
|
||||
{
|
||||
e.ItemHeight = 22;
|
||||
}
|
||||
|
||||
protected override void OnDrawItem(DrawItemEventArgs e)
|
||||
{
|
||||
if (this.Items.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
|
||||
|
||||
int index = e.Index;
|
||||
|
||||
string content = "[Error]";
|
||||
|
||||
if (index < this.Items.Count && index >= 0)
|
||||
{
|
||||
content = this.Items[index].ToString();
|
||||
}
|
||||
|
||||
Color color = (e.Index % 2) == 0 ? Color.FromArgb(85, 85, 85) : Color.FromArgb(90, 90, 90);
|
||||
|
||||
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
|
||||
{
|
||||
color = Color.FromArgb(100, 105, 110);
|
||||
}
|
||||
|
||||
using (SolidBrush background = new SolidBrush(color))
|
||||
{
|
||||
e.Graphics.FillRectangle(background, e.Bounds);
|
||||
}
|
||||
|
||||
using (SolidBrush pen = new SolidBrush(Color.White))
|
||||
{
|
||||
e.Graphics.DrawString(content, this.Font, pen,
|
||||
new PointF(10, e.Bounds.Y + 3), StringFormat.GenericDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,453 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="DarkSlider.cs" company="">
|
||||
// Christian Woltering, Triangle.NET, http://triangle.codeplex.com/
|
||||
// Original code on CodeProject: Owner-drawn trackbar (slider), Michal Brylka
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace MeshExplorer.Controls
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
/// <summary>
|
||||
/// Encapsulates control that visualy displays certain integer value and allows user to change
|
||||
/// it within desired range. It imitates <see cref="System.Windows.Forms.TrackBar"/> as far as
|
||||
/// mouse usage is concerned.
|
||||
/// </summary>
|
||||
public class DarkSlider : Control
|
||||
{
|
||||
#region Designer
|
||||
|
||||
/// <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 Component 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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Fires when Slider position has changed
|
||||
/// </summary>
|
||||
public event EventHandler ValueChanging;
|
||||
|
||||
private void OnValueChanging()
|
||||
{
|
||||
var evt = ValueChanging;
|
||||
|
||||
if (evt != null)
|
||||
{
|
||||
evt(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires when Slider position has changed
|
||||
/// </summary>
|
||||
public event EventHandler ValueChanged;
|
||||
|
||||
private void OnValueChanged()
|
||||
{
|
||||
var evt = ValueChanged;
|
||||
|
||||
if (evt != null)
|
||||
{
|
||||
evt(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
int thumbSize = 7;
|
||||
private Rectangle thumbRect; //bounding rectangle of thumb area
|
||||
private Rectangle barRect; //bounding rectangle of bar area
|
||||
private bool mouseInThumbRegion = false;
|
||||
|
||||
private int trackerValue = 50;
|
||||
/// <summary>
|
||||
/// Gets or sets the value of Slider.
|
||||
/// </summary>
|
||||
/// <value>The value.</value>
|
||||
public int Value
|
||||
{
|
||||
get { return trackerValue; }
|
||||
set
|
||||
{
|
||||
if (value >= barMinimum & value <= barMaximum)
|
||||
{
|
||||
trackerValue = value;
|
||||
if (ValueChanged != null) ValueChanged(this, new EventArgs());
|
||||
Invalidate();
|
||||
}
|
||||
// ArgumentOutOfRangeException("Value is outside appropriate range (min, max)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int barMinimum = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum value.
|
||||
/// </summary>
|
||||
/// <value>The minimum value.</value>
|
||||
public int Minimum
|
||||
{
|
||||
get { return barMinimum; }
|
||||
set
|
||||
{
|
||||
if (value < barMaximum)
|
||||
{
|
||||
barMinimum = value;
|
||||
if (trackerValue < barMinimum)
|
||||
{
|
||||
trackerValue = barMinimum;
|
||||
if (ValueChanged != null) ValueChanged(this, new EventArgs());
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
// ArgumentOutOfRangeException("Minimal value is greather than maximal one");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int barMaximum = 100;
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum value.
|
||||
/// </summary>
|
||||
/// <value>The maximum value.</value>
|
||||
public int Maximum
|
||||
{
|
||||
get { return barMaximum; }
|
||||
set
|
||||
{
|
||||
if (value > barMinimum)
|
||||
{
|
||||
barMaximum = value;
|
||||
if (trackerValue > barMaximum)
|
||||
{
|
||||
trackerValue = barMaximum;
|
||||
if (ValueChanged != null) ValueChanged(this, new EventArgs());
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
// ArgumentOutOfRangeException("Maximal value is lower than minimal one");
|
||||
}
|
||||
}
|
||||
|
||||
private uint criticalPercent = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets trackbar's small change. It affects how to behave when directional keys are pressed
|
||||
/// </summary>
|
||||
/// <value>The small change value.</value>
|
||||
public uint CriticalPercent
|
||||
{
|
||||
get { return criticalPercent; }
|
||||
set { criticalPercent = value; }
|
||||
}
|
||||
|
||||
private Color thumbOuterColor = Color.White;
|
||||
private Color thumbInnerColor = Color.Gainsboro;
|
||||
private Color thumbPenColor = Color.Silver;
|
||||
private Color barOuterColor = Color.SkyBlue;
|
||||
private Color barInnerColor = Color.DarkSlateBlue;
|
||||
private Color barPenColor = Color.Gainsboro;
|
||||
private Color elapsedOuterColor = Color.DarkGreen;
|
||||
private Color elapsedInnerColor = Color.Chartreuse;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ColorSlider"/> control.
|
||||
/// </summary>
|
||||
public DarkSlider()
|
||||
{
|
||||
InitializeComponent();
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint
|
||||
| ControlStyles.OptimizedDoubleBuffer
|
||||
| ControlStyles.ResizeRedraw
|
||||
| ControlStyles.Selectable
|
||||
| ControlStyles.SupportsTransparentBackColor
|
||||
| ControlStyles.UserMouse
|
||||
| ControlStyles.UserPaint, true);
|
||||
|
||||
BackColor = Color.Transparent;
|
||||
|
||||
Minimum = 0;
|
||||
Maximum = 100;
|
||||
Value = 50;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
if (!Enabled)
|
||||
{
|
||||
DrawDisabledSlider(e.Graphics);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (mouseEffects && mouseInRegion)
|
||||
//{
|
||||
// Color[] lightenedColors = LightenColors(thumbOuterColor, thumbInnerColor, thumbPenColor,
|
||||
// barOuterColor, barInnerColor, barPenColor,
|
||||
// elapsedOuterColor, elapsedInnerColor);
|
||||
// DrawColorSlider(e, lightenedColors[0], lightenedColors[1], lightenedColors[2], lightenedColors[3],
|
||||
// lightenedColors[4], lightenedColors[5], lightenedColors[6], lightenedColors[7]);
|
||||
//}
|
||||
//else
|
||||
{
|
||||
DrawColorSlider(e.Graphics);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawDisabledSlider(Graphics g)
|
||||
{
|
||||
try
|
||||
{
|
||||
//adjust drawing rects
|
||||
barRect = new Rectangle(1, this.Height / 2, this.Width - 2, 5);
|
||||
|
||||
Brush sliderLGBrushH = new LinearGradientBrush(barRect, ColorScheme.ColorGray122,
|
||||
ColorScheme.ColorGray107, LinearGradientMode.Horizontal);
|
||||
|
||||
//draw bar
|
||||
{
|
||||
// Background gradient
|
||||
g.FillRectangle(sliderLGBrushH, barRect);
|
||||
// Background fill
|
||||
g.FillRectangle(ColorScheme.SliderBorderBrush,
|
||||
barRect.Left + 1, barRect.Top, barRect.Width - 2, barRect.Height - 1);
|
||||
// Bar fill
|
||||
g.FillRectangle(ColorScheme.SliderFillBrush,
|
||||
barRect.Left + 2, barRect.Top + 1, barRect.Width - 4, barRect.Height - 3);
|
||||
}
|
||||
|
||||
sliderLGBrushH.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{ }
|
||||
finally
|
||||
{ }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the colorslider control using passed colors.
|
||||
/// </summary>
|
||||
private void DrawColorSlider(Graphics g)
|
||||
{
|
||||
try
|
||||
{
|
||||
//set up thumbRect aproprietly
|
||||
int track = (((trackerValue - barMinimum) * (ClientRectangle.Width - thumbSize)) / (barMaximum - barMinimum));
|
||||
thumbRect = new Rectangle(track, this.Height / 2 - 3, thumbSize - 1, 10);
|
||||
|
||||
//adjust drawing rects
|
||||
barRect = new Rectangle(1, this.Height / 2, this.Width - 2, 5);
|
||||
|
||||
//get thumb shape path
|
||||
GraphicsPath thumbPath = new GraphicsPath();
|
||||
thumbPath.AddPolygon(new Point[] {
|
||||
new Point(thumbRect.Left, thumbRect.Top),
|
||||
new Point(thumbRect.Right, thumbRect.Top),
|
||||
new Point(thumbRect.Right, thumbRect.Bottom - 4),
|
||||
new Point(thumbRect.Left + thumbRect.Width / 2, thumbRect.Bottom),
|
||||
new Point(thumbRect.Left, thumbRect.Bottom - 4)
|
||||
});
|
||||
|
||||
Brush sliderLGBrushH = new LinearGradientBrush(barRect, ColorScheme.ColorGray122,
|
||||
ColorScheme.ColorGray107, LinearGradientMode.Horizontal);
|
||||
|
||||
Brush barFill = (criticalPercent > 0 && trackerValue > criticalPercent) ? Brushes.Peru : Brushes.Green;
|
||||
|
||||
//draw bar
|
||||
{
|
||||
// Background gradient
|
||||
g.FillRectangle(sliderLGBrushH, barRect);
|
||||
// Background fill
|
||||
g.FillRectangle(ColorScheme.SliderBorderBrush,
|
||||
barRect.Left + 1, barRect.Top, barRect.Width - 2, barRect.Height - 1);
|
||||
// Bar fill
|
||||
g.FillRectangle(ColorScheme.SliderFillBrush,
|
||||
barRect.Left + 2, barRect.Top + 1, barRect.Width - 4, barRect.Height - 3);
|
||||
// Elapsed bar fill
|
||||
|
||||
g.FillRectangle(barFill,
|
||||
barRect.Left + 2, barRect.Top + 1, thumbRect.Left + thumbSize / 2 - 2, barRect.Height - 3);
|
||||
|
||||
//draw bar band
|
||||
//g.DrawRectangle(barPen, barRect);
|
||||
}
|
||||
|
||||
sliderLGBrushH.Dispose();
|
||||
|
||||
//draw thumb
|
||||
Brush brushInner = new LinearGradientBrush(thumbRect,
|
||||
Color.FromArgb(111, 111, 111), Color.FromArgb(80, 80, 80),
|
||||
LinearGradientMode.Vertical);
|
||||
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.FillPath(brushInner, thumbPath);
|
||||
g.DrawPath(Pens.Black, thumbPath);
|
||||
|
||||
brushInner.Dispose();
|
||||
//draw thumb band
|
||||
//Color newThumbPenColor = thumbPenColorPaint;
|
||||
//if (mouseEffects && (Capture || mouseInThumbRegion))
|
||||
// newThumbPenColor = ControlPaint.Dark(newThumbPenColor);
|
||||
//g.DrawPath(thumbPen, thumbPath);
|
||||
}
|
||||
catch (Exception)
|
||||
{ }
|
||||
finally
|
||||
{ }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overided events
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.EnabledChanged"></see> event.
|
||||
/// </summary>
|
||||
/// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
|
||||
protected override void OnEnabledChanged(EventArgs e)
|
||||
{
|
||||
base.OnEnabledChanged(e);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseLeave"></see> event.
|
||||
/// </summary>
|
||||
/// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
mouseInThumbRegion = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseDown"></see> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param>
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
if (e.Button == MouseButtons.Left && this.Enabled)
|
||||
{
|
||||
this.Capture = true;
|
||||
OnValueChanging();
|
||||
OnMouseMove(e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseMove"></see> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param>
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
mouseInThumbRegion = thumbRect.Contains(e.Location);
|
||||
if (Capture & e.Button == MouseButtons.Left)
|
||||
{
|
||||
Point pt = e.Location;
|
||||
int p = pt.X;
|
||||
int margin = thumbSize >> 1;
|
||||
p -= margin;
|
||||
float coef = (float)(barMaximum - barMinimum) /
|
||||
(float)(ClientSize.Width - 2 * margin);
|
||||
trackerValue = (int)(p * coef + barMinimum);
|
||||
|
||||
if (trackerValue <= barMinimum)
|
||||
{
|
||||
trackerValue = barMinimum;
|
||||
}
|
||||
else if (trackerValue >= barMaximum)
|
||||
{
|
||||
trackerValue = barMaximum;
|
||||
}
|
||||
|
||||
OnValueChanging();
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseUp"></see> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param>
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
if (this.Enabled)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
this.Capture = false;
|
||||
mouseInThumbRegion = thumbRect.Contains(e.Location);
|
||||
OnValueChanged();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Help routines
|
||||
|
||||
/// <summary>
|
||||
/// Sets the trackbar value so that it wont exceed allowed range.
|
||||
/// </summary>
|
||||
/// <param name="val">The value.</param>
|
||||
private void SetProperValue(int val)
|
||||
{
|
||||
if (val < barMinimum) Value = barMinimum;
|
||||
else if (val > barMaximum) Value = barMaximum;
|
||||
else Value = val;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="DarkTabControl.cs" company="">
|
||||
// Christian Woltering, Triangle.NET, http://triangle.codeplex.com/
|
||||
// Original code on CodeProject: A .NET Flat TabControl (CustomDraw), Oscar Londono
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace MeshExplorer.Controls
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Text;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for FlatTabControl.
|
||||
/// </summary>
|
||||
public class DarkTabControl : System.Windows.Forms.TabControl
|
||||
{
|
||||
#region Designer
|
||||
|
||||
/// <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 Component 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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
private const int margin = 5;
|
||||
private Color backColor = ColorScheme.ColorGray68;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DarkTabControl" /> control.
|
||||
/// </summary>
|
||||
public DarkTabControl()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
|
||||
base.Multiline = false;
|
||||
|
||||
// double buffering
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
this.SetStyle(ControlStyles.DoubleBuffer, true);
|
||||
this.SetStyle(ControlStyles.ResizeRedraw, true);
|
||||
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
|
||||
this.SelectedIndexChanged += (obj, evt) => { Invalidate(); };
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
new public TabAlignment Alignment
|
||||
{
|
||||
get { return base.Alignment; }
|
||||
set
|
||||
{
|
||||
TabAlignment ta = value;
|
||||
if ((ta != TabAlignment.Top) && (ta != TabAlignment.Bottom))
|
||||
{
|
||||
ta = TabAlignment.Top;
|
||||
}
|
||||
|
||||
base.Alignment = ta;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color BackColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return backColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.BackColor = backColor;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
|
||||
DrawControl(e.Graphics);
|
||||
}
|
||||
|
||||
private void DrawControl(Graphics g)
|
||||
{
|
||||
if (!Visible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Rectangle controlBounds = this.ClientRectangle;
|
||||
Rectangle tabBounds = this.DisplayRectangle;
|
||||
|
||||
// Fill client area
|
||||
Brush br = new SolidBrush(this.BackColor);
|
||||
g.FillRectangle(br, controlBounds);
|
||||
br.Dispose();
|
||||
|
||||
int width = tabBounds.Width + margin;
|
||||
|
||||
// Clip region for drawing tabs
|
||||
Region clip = g.Clip;
|
||||
Rectangle region = new Rectangle(tabBounds.Left, controlBounds.Top, width - margin, controlBounds.Height);
|
||||
|
||||
g.SetClip(region);
|
||||
|
||||
// Draw tabs
|
||||
for (int i = 0; i < this.TabCount; i++)
|
||||
{
|
||||
DrawTab(g, this.TabPages[i], i);
|
||||
}
|
||||
|
||||
g.Clip = clip;
|
||||
}
|
||||
|
||||
private void DrawTab(Graphics g, TabPage tabPage, int index)
|
||||
{
|
||||
Rectangle tabBounds = this.GetTabRect(index);
|
||||
|
||||
bool selected = (this.SelectedIndex == index);
|
||||
|
||||
// Fill this tab with background color
|
||||
g.FillRectangle(selected ? Brushes.DimGray : ColorScheme.BrushGray68, tabBounds);
|
||||
|
||||
if (selected)
|
||||
{
|
||||
// Clear bottom lines
|
||||
Pen pen = new Pen(tabPage.BackColor);
|
||||
|
||||
switch (this.Alignment)
|
||||
{
|
||||
case TabAlignment.Top:
|
||||
g.DrawLine(pen, tabBounds.Left, tabBounds.Bottom, tabBounds.Right - 1, tabBounds.Bottom);
|
||||
g.DrawLine(pen, tabBounds.Left, tabBounds.Bottom + 1, tabBounds.Right - 1, tabBounds.Bottom + 1);
|
||||
break;
|
||||
|
||||
case TabAlignment.Bottom:
|
||||
g.DrawLine(pen, tabBounds.Left, tabBounds.Top, tabBounds.Right - 1, tabBounds.Top);
|
||||
g.DrawLine(pen, tabBounds.Left, tabBounds.Top - 1, tabBounds.Right - 1, tabBounds.Top - 1);
|
||||
g.DrawLine(pen, tabBounds.Left, tabBounds.Top - 2, tabBounds.Right - 1, tabBounds.Top - 2);
|
||||
break;
|
||||
}
|
||||
|
||||
pen.Dispose();
|
||||
}
|
||||
|
||||
// Draw string
|
||||
StringFormat stringFormat = new StringFormat();
|
||||
stringFormat.Alignment = StringAlignment.Center;
|
||||
stringFormat.LineAlignment = StringAlignment.Center;
|
||||
|
||||
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
|
||||
|
||||
g.DrawString(tabPage.Text, Font, Brushes.White, tabBounds, stringFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="DarkTextBox.cs" company="">
|
||||
// Christian Woltering, Triangle.NET, http://triangle.codeplex.com/
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace MeshExplorer.Controls
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
/// <summary>
|
||||
/// Dark textbox control.
|
||||
/// </summary>
|
||||
public class DarkTextBox : Control
|
||||
{
|
||||
#region Designer
|
||||
|
||||
/// <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 Component 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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
|
||||
this.textBox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBox
|
||||
//
|
||||
this.textBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.textBox.Location = new System.Drawing.Point(4, 2);
|
||||
this.textBox.Name = "textBox";
|
||||
this.textBox.TabIndex = 0;
|
||||
//
|
||||
// DarkTextBox
|
||||
//
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.Controls.Add(this.textBox);
|
||||
this.Cursor = Cursors.IBeam;
|
||||
this.Size = new System.Drawing.Size(150, 22);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
TextBox textBox;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DarkTextBox" /> control.
|
||||
/// </summary>
|
||||
public DarkTextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.MouseClick += delegate(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left) textBox.Focus();
|
||||
};
|
||||
|
||||
textBox.Font = this.Font;
|
||||
textBox.Location = new Point(4, (this.Height - textBox.Height) / 2);
|
||||
textBox.Width = this.Width - 8;
|
||||
textBox.TextAlign = HorizontalAlignment.Left;
|
||||
textBox.ForeColor = this.ForeColor;
|
||||
//textBox.MaxLength = 6;
|
||||
|
||||
textBox.GotFocus += delegate(object sender, EventArgs e)
|
||||
{
|
||||
textBox.ForeColor = this.ForeColor;
|
||||
};
|
||||
|
||||
textBox.LostFocus += delegate(object sender, EventArgs e)
|
||||
{
|
||||
textBox.ForeColor = ColorScheme.ColorGray68;
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
Rectangle rect = this.ClientRectangle;
|
||||
|
||||
//Brush brushOuter = new LinearGradientBrush(rect, Color.FromArgb(82, 82, 82),
|
||||
// Color.FromArgb(96, 96, 96), LinearGradientMode.Vertical);
|
||||
|
||||
Pen borderTop = new Pen(Color.FromArgb(76, 76, 76), 1f);
|
||||
Pen borderBottom = new Pen(Color.FromArgb(128, 128, 128), 1f);
|
||||
|
||||
//e.Graphics.FillRectangle(brushOuter, rect);
|
||||
|
||||
rect = new Rectangle(1, 1, this.Width - 3, this.Height - 3);
|
||||
g.FillRectangle(new SolidBrush(this.BackColor), rect);
|
||||
|
||||
g.DrawLine(borderTop, 0, 0, this.Width - 1, 0);
|
||||
g.DrawLine(borderTop, 0, 0, 0, this.Height - 1);
|
||||
g.DrawLine(borderBottom, 1, this.Height - 1, this.Width - 1, this.Height - 1);
|
||||
g.DrawLine(borderBottom, this.Width - 1, this.Height - 1, this.Width - 1, this.Height - 1);
|
||||
|
||||
|
||||
//brushOuter.Dispose();
|
||||
borderTop.Dispose();
|
||||
borderBottom.Dispose();
|
||||
|
||||
base.OnPaint(e);
|
||||
}
|
||||
|
||||
#region Property overrides
|
||||
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
textBox.Font = value;
|
||||
base.Font = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override String Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return textBox.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
textBox.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
textBox.ForeColor = value;
|
||||
base.ForeColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override Color BackColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.BackColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
textBox.BackColor = value;
|
||||
base.BackColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Textbox properties
|
||||
|
||||
public HorizontalAlignment TextAlign
|
||||
{
|
||||
get
|
||||
{
|
||||
return textBox.TextAlign;
|
||||
}
|
||||
set
|
||||
{
|
||||
textBox.TextAlign = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="DarkToolStripRenderer.cs" company="">
|
||||
// Christian Woltering, Triangle.NET, http://triangle.codeplex.com/
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace MeshExplorer.Controls
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
/// <summary>
|
||||
/// Toolstrip render for dark menu.
|
||||
/// </summary>
|
||||
public class DarkToolStripRenderer : ToolStripRenderer
|
||||
{
|
||||
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
|
||||
{
|
||||
e.TextColor = e.Item.Enabled ? Color.White : Color.Gray;
|
||||
|
||||
base.OnRenderItemText(e);
|
||||
}
|
||||
|
||||
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
|
||||
{
|
||||
int h = e.Item.Height;
|
||||
int size = h / 2 - 2; // Box size
|
||||
Rectangle rect = new Rectangle(10, (h - size) / 2, size - 2, size);
|
||||
|
||||
var mode = e.Graphics.SmoothingMode;
|
||||
|
||||
using (Pen pen = new Pen(Color.White, 1.6f))
|
||||
{
|
||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
e.Graphics.DrawLine(pen, rect.Left, rect.Bottom - size / 2, rect.Left + size / 2.5f, rect.Bottom - 2);
|
||||
e.Graphics.DrawLine(pen, rect.Left + size / 2.6f, rect.Bottom - 2, rect.Right, rect.Top);
|
||||
}
|
||||
|
||||
e.Graphics.SmoothingMode = mode;
|
||||
}
|
||||
|
||||
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
|
||||
{
|
||||
if (!e.Item.Selected && !e.Item.Pressed)
|
||||
{
|
||||
e.ArrowColor = ColorScheme.ColorGray89;
|
||||
}
|
||||
|
||||
base.OnRenderArrow(e);
|
||||
}
|
||||
|
||||
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
|
||||
{
|
||||
e.Graphics.FillRectangle(ColorScheme.BrushGray78, 0, 2, e.Item.Width, 1);
|
||||
}
|
||||
|
||||
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
if (e.Item.Enabled)
|
||||
{
|
||||
if (e.Item.Selected || e.Item.Pressed)
|
||||
{
|
||||
e.Graphics.FillRectangle(Brushes.DimGray, 0, 0, e.Item.Width, e.Item.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Graphics.FillRectangle(ColorScheme.BrushGray68, 0, 0, e.Item.Width, e.Item.Height);
|
||||
}
|
||||
}
|
||||
|
||||
//base.OnRenderMenuItemBackground(e);
|
||||
}
|
||||
|
||||
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
|
||||
{
|
||||
e.Graphics.FillRectangle(ColorScheme.BrushGray68, e.AffectedBounds);
|
||||
//base.OnRenderToolStripBackground(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user