2014-01-07 09:22:15 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2016-01-04 04:16:01 +13:00
|
|
|
|
Copyright (c) 2007-2016 ShareX Team
|
2014-01-07 09:22:15 +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)
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Drawing.Drawing2D;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
namespace ShareX.HelpersLib
|
2014-01-07 09:22:15 +13:00
|
|
|
|
{
|
2016-02-26 09:55:54 +13:00
|
|
|
|
public partial class MonitorTestForm : Form
|
2014-01-07 09:22:15 +13:00
|
|
|
|
{
|
|
|
|
|
public MonitorTestForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-02-26 09:55:54 +13:00
|
|
|
|
Icon = ShareXResources.Icon;
|
2014-01-07 09:22:15 +13:00
|
|
|
|
|
|
|
|
|
Rectangle screenBounds = CaptureHelpers.GetScreenBounds();
|
|
|
|
|
Location = screenBounds.Location;
|
|
|
|
|
Size = screenBounds.Size;
|
|
|
|
|
|
|
|
|
|
rbBlackWhite.Checked = true;
|
2014-01-09 14:16:48 +13:00
|
|
|
|
tbBlackWhite.Value = 128;
|
2014-01-07 09:22:15 +13:00
|
|
|
|
tbRed.Value = 255;
|
|
|
|
|
cbGradient.Items.AddRange(Enum.GetNames(typeof(LinearGradientMode)));
|
|
|
|
|
cbGradient.SelectedIndex = 1;
|
2014-01-07 09:31:38 +13:00
|
|
|
|
btnGradientColor1.Color = Color.DarkGray;
|
|
|
|
|
btnGradientColor2.Color = Color.Black;
|
2014-01-07 09:22:15 +13:00
|
|
|
|
cbShapes.SelectedIndex = 0;
|
|
|
|
|
tbShapeSize.Value = 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetBackColor()
|
|
|
|
|
{
|
|
|
|
|
SetBackColor(Color.White);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetBackColor(Color color)
|
|
|
|
|
{
|
|
|
|
|
if (BackgroundImage != null)
|
|
|
|
|
{
|
|
|
|
|
Image temp = BackgroundImage;
|
|
|
|
|
BackgroundImage = null;
|
|
|
|
|
temp.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BackColor = color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawBlackWhite(int value)
|
|
|
|
|
{
|
|
|
|
|
Color color = Color.FromArgb(value, value, value);
|
|
|
|
|
SetBackColor(color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawRedGreenBlue(int red, int green, int blue)
|
|
|
|
|
{
|
|
|
|
|
Color color = Color.FromArgb(red, green, blue);
|
|
|
|
|
SetBackColor(color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Bitmap DrawGradient(Color fromColor, Color toColor, LinearGradientMode gradientMode)
|
|
|
|
|
{
|
|
|
|
|
Bitmap bmp = new Bitmap(Width, Height);
|
|
|
|
|
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
|
|
|
|
|
|
|
|
|
|
using (Graphics g = Graphics.FromImage(bmp))
|
|
|
|
|
using (LinearGradientBrush brush = new LinearGradientBrush(rect, fromColor, toColor, gradientMode))
|
|
|
|
|
{
|
|
|
|
|
g.FillRectangle(brush, rect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Bitmap DrawHorizontalLine(int size, Color color)
|
|
|
|
|
{
|
|
|
|
|
Bitmap bmp = new Bitmap(1, size * 2);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < size; i++)
|
|
|
|
|
{
|
|
|
|
|
bmp.SetPixel(0, i, color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Bitmap DrawVerticalLine(int size, Color color)
|
|
|
|
|
{
|
|
|
|
|
Bitmap bmp = new Bitmap(size * 2, 1);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < size; i++)
|
|
|
|
|
{
|
|
|
|
|
bmp.SetPixel(i, 0, color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Bitmap DrawChecker(int size, Color color)
|
|
|
|
|
{
|
|
|
|
|
Bitmap bmp = new Bitmap(size * 2, size * 2);
|
|
|
|
|
|
|
|
|
|
using (Graphics g = Graphics.FromImage(bmp))
|
|
|
|
|
using (Brush brush = new SolidBrush(color))
|
|
|
|
|
{
|
|
|
|
|
g.FillRectangle(brush, new Rectangle(0, 0, size, size));
|
|
|
|
|
g.FillRectangle(brush, new Rectangle(size, size, size, size));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawBlackWhite()
|
|
|
|
|
{
|
|
|
|
|
if (rbBlackWhite.Checked)
|
|
|
|
|
{
|
|
|
|
|
DrawBlackWhite(tbBlackWhite.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawRedGreenBlue()
|
|
|
|
|
{
|
|
|
|
|
if (rbRedGreenBlue.Checked)
|
|
|
|
|
{
|
|
|
|
|
DrawRedGreenBlue(tbRed.Value, tbGreen.Value, tbBlue.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawGradient()
|
|
|
|
|
{
|
|
|
|
|
if (rbGradient.Checked)
|
|
|
|
|
{
|
|
|
|
|
SetBackColor();
|
|
|
|
|
|
2014-01-07 09:31:38 +13:00
|
|
|
|
Color color1 = btnGradientColor1.Color;
|
|
|
|
|
Color color2 = btnGradientColor2.Color;
|
2014-01-07 09:22:15 +13:00
|
|
|
|
LinearGradientMode gradientMode = (LinearGradientMode)cbGradient.SelectedIndex;
|
2014-01-07 09:31:38 +13:00
|
|
|
|
BackgroundImage = DrawGradient(color1, color2, gradientMode);
|
2014-01-07 09:22:15 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawSelectedShape()
|
|
|
|
|
{
|
|
|
|
|
if (rbShapes.Checked)
|
|
|
|
|
{
|
|
|
|
|
SetBackColor();
|
|
|
|
|
|
|
|
|
|
int shapeSize = Math.Max(tbShapeSize.Value, 1);
|
|
|
|
|
|
|
|
|
|
switch (cbShapes.SelectedIndex)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
BackgroundImage = DrawChecker(shapeSize, Color.Black);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
BackgroundImage = DrawHorizontalLine(shapeSize, Color.Black);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
BackgroundImage = DrawVerticalLine(shapeSize, Color.Black);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Form events
|
|
|
|
|
|
|
|
|
|
private void MainForm_KeyUp(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.KeyCode == Keys.Escape)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MainForm_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool visible = !pSettings.Visible;
|
|
|
|
|
if (visible) pSettings.Location = e.Location;
|
|
|
|
|
pSettings.Visible = visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbBlackWhite_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DrawBlackWhite();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tbBlackWhite_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lblBlackWhiteValue.Text = tbBlackWhite.Value.ToString();
|
|
|
|
|
DrawBlackWhite();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbRedGreenBlue_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DrawRedGreenBlue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnColorDialog_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-09-08 18:40:04 +12:00
|
|
|
|
using (ColorPickerForm dialogColor = new ColorPickerForm(Color.FromArgb(tbRed.Value, tbGreen.Value, tbBlue.Value)))
|
2014-01-07 09:22:15 +13:00
|
|
|
|
{
|
|
|
|
|
if (dialogColor.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
Color color = dialogColor.NewColor;
|
|
|
|
|
tbRed.Value = color.R;
|
|
|
|
|
tbGreen.Value = color.G;
|
|
|
|
|
tbBlue.Value = color.B;
|
|
|
|
|
DrawRedGreenBlue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tbRedGreenBlue_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lblRedValue.Text = tbRed.Value.ToString();
|
|
|
|
|
lblGreenValue.Text = tbGreen.Value.ToString();
|
|
|
|
|
lblBlueValue.Text = tbBlue.Value.ToString();
|
|
|
|
|
DrawRedGreenBlue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbGradient_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DrawGradient();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cbGradient_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DrawGradient();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-07 09:31:38 +13:00
|
|
|
|
private void btnGradientColor1_ColorChanged(Color color)
|
|
|
|
|
{
|
|
|
|
|
DrawGradient();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnGradientColor2_ColorChanged(Color color)
|
|
|
|
|
{
|
|
|
|
|
DrawGradient();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-07 09:22:15 +13:00
|
|
|
|
private void rbShapes_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DrawSelectedShape();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cbShapes_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DrawSelectedShape();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tbShapeSize_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lblShapeSizeValue.Text = tbShapeSize.Value.ToString();
|
|
|
|
|
DrawSelectedShape();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Form events
|
|
|
|
|
}
|
|
|
|
|
}
|