Using enum for screen test mode

This commit is contained in:
Jaex 2016-06-08 04:58:08 +03:00
parent d452087e75
commit eefb810afa
5 changed files with 39 additions and 32 deletions

View file

@ -173,4 +173,10 @@ public enum SlashType
Prefix,
Suffix
}
public enum ScreenTearingTestMode
{
VerticalLines,
HorizontalLines
}
}

View file

@ -31,6 +31,8 @@ private void InitializeComponent()
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MonitorTestForm));
this.pSettings = new System.Windows.Forms.Panel();
this.btnScreenTearingTest = new System.Windows.Forms.Button();
this.btnGradientColor2 = new ShareX.HelpersLib.ColorButton();
this.btnGradientColor1 = new ShareX.HelpersLib.ColorButton();
this.lblTip = new System.Windows.Forms.Label();
this.cbGradient = new System.Windows.Forms.ComboBox();
this.rbGradient = new System.Windows.Forms.RadioButton();
@ -54,8 +56,6 @@ private void InitializeComponent()
this.lblBlackWhiteValue = new System.Windows.Forms.Label();
this.tbBlackWhite = new System.Windows.Forms.TrackBar();
this.rbBlackWhite = new System.Windows.Forms.RadioButton();
this.btnGradientColor2 = new ShareX.HelpersLib.ColorButton();
this.btnGradientColor1 = new ShareX.HelpersLib.ColorButton();
this.pSettings.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.tbShapeSize)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tbBlue)).BeginInit();
@ -104,6 +104,22 @@ private void InitializeComponent()
this.btnScreenTearingTest.UseVisualStyleBackColor = true;
this.btnScreenTearingTest.Click += new System.EventHandler(this.btnScreenTearingTest_Click);
//
// btnGradientColor2
//
this.btnGradientColor2.Color = System.Drawing.Color.Empty;
resources.ApplyResources(this.btnGradientColor2, "btnGradientColor2");
this.btnGradientColor2.Name = "btnGradientColor2";
this.btnGradientColor2.UseVisualStyleBackColor = true;
this.btnGradientColor2.ColorChanged += new ShareX.HelpersLib.ColorButton.ColorChangedEventHandler(this.btnGradientColor2_ColorChanged);
//
// btnGradientColor1
//
this.btnGradientColor1.Color = System.Drawing.Color.Empty;
resources.ApplyResources(this.btnGradientColor1, "btnGradientColor1");
this.btnGradientColor1.Name = "btnGradientColor1";
this.btnGradientColor1.UseVisualStyleBackColor = true;
this.btnGradientColor1.ColorChanged += new ShareX.HelpersLib.ColorButton.ColorChangedEventHandler(this.btnGradientColor1_ColorChanged);
//
// lblTip
//
resources.ApplyResources(this.lblTip, "lblTip");
@ -258,22 +274,6 @@ private void InitializeComponent()
this.rbBlackWhite.UseVisualStyleBackColor = true;
this.rbBlackWhite.CheckedChanged += new System.EventHandler(this.rbBlackWhite_CheckedChanged);
//
// btnGradientColor2
//
this.btnGradientColor2.Color = System.Drawing.Color.Empty;
resources.ApplyResources(this.btnGradientColor2, "btnGradientColor2");
this.btnGradientColor2.Name = "btnGradientColor2";
this.btnGradientColor2.UseVisualStyleBackColor = true;
this.btnGradientColor2.ColorChanged += new ShareX.HelpersLib.ColorButton.ColorChangedEventHandler(this.btnGradientColor2_ColorChanged);
//
// btnGradientColor1
//
this.btnGradientColor1.Color = System.Drawing.Color.Empty;
resources.ApplyResources(this.btnGradientColor1, "btnGradientColor1");
this.btnGradientColor1.Name = "btnGradientColor1";
this.btnGradientColor1.UseVisualStyleBackColor = true;
this.btnGradientColor1.ColorChanged += new ShareX.HelpersLib.ColorButton.ColorChangedEventHandler(this.btnGradientColor1_ColorChanged);
//
// MonitorTestForm
//
resources.ApplyResources(this, "$this");

View file

@ -49,7 +49,7 @@ public MonitorTestForm()
btnGradientColor1.Color = Color.DarkGray;
btnGradientColor2.Color = Color.Black;
cbShapes.SelectedIndex = 0;
tbShapeSize.Value = 3;
tbShapeSize.Value = 5;
}
private void SetBackColor()
@ -173,14 +173,14 @@ private void DrawSelectedShape()
switch (cbShapes.SelectedIndex)
{
case 0:
BackgroundImage = DrawChecker(shapeSize, Color.Black);
break;
case 1:
BackgroundImage = DrawHorizontalLine(shapeSize, Color.Black);
break;
case 2:
case 1:
BackgroundImage = DrawVerticalLine(shapeSize, Color.Black);
break;
case 2:
BackgroundImage = DrawChecker(shapeSize, Color.Black);
break;
}
}
}

View file

@ -436,14 +436,14 @@
<value>10</value>
</data>
<data name="cbShapes.Items" xml:space="preserve">
<value>Checker</value>
</data>
<data name="cbShapes.Items1" xml:space="preserve">
<value>Horizontal lines</value>
</data>
<data name="cbShapes.Items2" xml:space="preserve">
<data name="cbShapes.Items1" xml:space="preserve">
<value>Vertical lines</value>
</data>
<data name="cbShapes.Items2" xml:space="preserve">
<value>Checker</value>
</data>
<data name="cbShapes.Location" type="System.Drawing.Point, System.Drawing">
<value>120, 295</value>
</data>

View file

@ -33,12 +33,13 @@ namespace ShareX.HelpersLib
{
public class ScreenTearingTestForm : Form
{
public ScreenTearingTestMode Mode { get; set; } = ScreenTearingTestMode.VerticalLines;
private Rectangle screenRectangle, screenRectangle0Based;
private Stopwatch animationTime;
private TimeSpan lastElapsed;
private int rectangleSize = 50;
private float animationSpeed = 500, minSpeed = 100, maxSpeed = 2000, speedChange = 50, currentPosition;
private bool isVerticalLines = true;
public ScreenTearingTestForm()
{
@ -85,9 +86,9 @@ protected override void OnKeyUp(KeyEventArgs e)
protected override void OnMouseUp(MouseEventArgs e)
{
if (isVerticalLines)
if (Mode == ScreenTearingTestMode.VerticalLines)
{
isVerticalLines = false;
Mode = ScreenTearingTestMode.HorizontalLines;
}
else
{
@ -124,14 +125,14 @@ protected override void OnPaint(PaintEventArgs e)
int nextPosition = rectangleSize * 2;
int startOffset = (int)(currentPosition % nextPosition);
if (isVerticalLines)
if (Mode == ScreenTearingTestMode.VerticalLines)
{
for (int x = startOffset - rectangleSize; x < screenRectangle.Width; x += nextPosition)
{
g.FillRectangle(Brushes.Black, x, 0, rectangleSize, screenRectangle.Height);
}
}
else
else if (Mode == ScreenTearingTestMode.HorizontalLines)
{
for (int y = startOffset - rectangleSize; y < screenRectangle.Height; y += nextPosition)
{