2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2015-08-13 13:07:38 +12:00
|
|
|
|
Copyright (c) 2007-2015 ShareX Team
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
2015-05-18 18:22:40 +12:00
|
|
|
|
using System;
|
2014-06-28 09:41:07 +12:00
|
|
|
|
using System.ComponentModel;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System.Drawing;
|
2015-01-04 01:50:16 +13:00
|
|
|
|
using System.Drawing.Design;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
namespace ShareX.HelpersLib
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-06-28 09:41:07 +12:00
|
|
|
|
public class BlackStyleLabel : Control
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-06-28 09:41:07 +12:00
|
|
|
|
private string text;
|
|
|
|
|
|
2015-01-04 01:50:16 +13:00
|
|
|
|
[Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
|
|
|
|
|
[SettingsBindable(true)]
|
2013-11-03 23:53:49 +13:00
|
|
|
|
public override string Text
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == null)
|
|
|
|
|
{
|
|
|
|
|
value = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (text != value)
|
|
|
|
|
{
|
|
|
|
|
text = value;
|
|
|
|
|
Refresh();
|
2015-05-18 18:22:40 +12:00
|
|
|
|
OnTextChanged(EventArgs.Empty);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 09:41:07 +12:00
|
|
|
|
private ContentAlignment textAlign;
|
|
|
|
|
|
|
|
|
|
[DefaultValue(ContentAlignment.TopLeft)]
|
|
|
|
|
public ContentAlignment TextAlign
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return textAlign;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
textAlign = value;
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-24 12:09:16 +13:00
|
|
|
|
private Color textShadowColor;
|
|
|
|
|
|
|
|
|
|
[DefaultValue(typeof(Color), "Black")]
|
|
|
|
|
public Color TextShadowColor
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return textShadowColor;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
textShadowColor = value;
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 09:41:07 +12:00
|
|
|
|
private bool drawBorder;
|
|
|
|
|
|
|
|
|
|
[DefaultValue(false)]
|
|
|
|
|
public bool DrawBorder
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return drawBorder;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
drawBorder = value;
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-06-28 09:41:07 +12:00
|
|
|
|
public BlackStyleLabel()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
DoubleBuffered = true;
|
2014-06-28 09:41:07 +12:00
|
|
|
|
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
|
2014-06-28 10:05:12 +12:00
|
|
|
|
TextAlign = ContentAlignment.TopLeft;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
BackColor = Color.Transparent;
|
|
|
|
|
ForeColor = Color.White;
|
2014-11-24 12:09:16 +13:00
|
|
|
|
TextShadowColor = Color.Black;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
Font = new Font("Arial", 12);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs pe)
|
|
|
|
|
{
|
|
|
|
|
Graphics g = pe.Graphics;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(Text))
|
|
|
|
|
{
|
|
|
|
|
DrawText(g);
|
2014-06-28 09:41:07 +12:00
|
|
|
|
|
|
|
|
|
if (drawBorder)
|
|
|
|
|
{
|
|
|
|
|
g.DrawRectangleProper(Pens.Black, ClientRectangle);
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawText(Graphics g)
|
|
|
|
|
{
|
2014-06-28 09:41:07 +12:00
|
|
|
|
TextFormatFlags tff;
|
|
|
|
|
|
|
|
|
|
switch (TextAlign)
|
|
|
|
|
{
|
|
|
|
|
case ContentAlignment.TopLeft:
|
|
|
|
|
tff = TextFormatFlags.Top | TextFormatFlags.Left;
|
|
|
|
|
break;
|
|
|
|
|
case ContentAlignment.MiddleLeft:
|
|
|
|
|
tff = TextFormatFlags.VerticalCenter | TextFormatFlags.Left;
|
|
|
|
|
break;
|
|
|
|
|
case ContentAlignment.BottomLeft:
|
|
|
|
|
tff = TextFormatFlags.Bottom | TextFormatFlags.Left;
|
|
|
|
|
break;
|
|
|
|
|
case ContentAlignment.TopCenter:
|
|
|
|
|
tff = TextFormatFlags.Top | TextFormatFlags.HorizontalCenter;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
case ContentAlignment.MiddleCenter:
|
|
|
|
|
tff = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter;
|
|
|
|
|
break;
|
|
|
|
|
case ContentAlignment.BottomCenter:
|
|
|
|
|
tff = TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter;
|
|
|
|
|
break;
|
|
|
|
|
case ContentAlignment.TopRight:
|
|
|
|
|
tff = TextFormatFlags.Top | TextFormatFlags.Right;
|
|
|
|
|
break;
|
|
|
|
|
case ContentAlignment.MiddleRight:
|
|
|
|
|
tff = TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
|
|
|
|
|
break;
|
|
|
|
|
case ContentAlignment.BottomRight:
|
|
|
|
|
tff = TextFormatFlags.Bottom | TextFormatFlags.Right;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-24 12:09:16 +13:00
|
|
|
|
TextRenderer.DrawText(g, Text, Font, new Rectangle(ClientRectangle.X, ClientRectangle.Y + 1, ClientRectangle.Width, ClientRectangle.Height + 1), TextShadowColor, tff);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
TextRenderer.DrawText(g, Text, Font, ClientRectangle, ForeColor, tff);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|