Fix "Use of implied arithmetic operator precedence"

This commit is contained in:
Jaex 2018-05-16 16:27:11 +03:00
parent 81ca81eb98
commit cb3711632c
51 changed files with 183 additions and 139 deletions

View file

@ -48,5 +48,10 @@
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -210,9 +210,9 @@ public static ColorMatrix Saturation(float value)
{
return new ColorMatrix(new[]
{
new float[] { (1.0f - value) * rw + value, (1.0f - value) * rw, (1.0f - value) * rw, 0, 0 },
new float[] { (1.0f - value) * gw, (1.0f - value) * gw + value, (1.0f - value) * gw, 0, 0 },
new float[] { (1.0f - value) * bw, (1.0f - value) * bw, (1.0f - value) * bw + value, 0, 0 },
new float[] { ((1.0f - value) * rw) + value, (1.0f - value) * rw, (1.0f - value) * rw, 0, 0 },
new float[] { (1.0f - value) * gw, ((1.0f - value) * gw) + value, (1.0f - value) * gw, 0, 0 },
new float[] { (1.0f - value) * bw, (1.0f - value) * bw, ((1.0f - value) * bw) + value, 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 0, 0, 0, 0, 1 }
});
@ -229,9 +229,9 @@ public static ColorMatrix Colorize(Color color, float value)
return new ColorMatrix(new[]
{
new float[] { inv_amount + value * r * rw, value * g * rw, value * b * rw, 0, 0 },
new float[] { value * r * gw, inv_amount + value * g * gw, value * b * gw, 0, 0 },
new float[] { value * r * bw, value * g * bw, inv_amount + value * b * bw, 0, 0 },
new float[] { inv_amount + (value * r * rw), value * g * rw, value * b * rw, 0, 0 },
new float[] { value * r * gw, inv_amount + (value * g * gw), value * b * gw, 0, 0 },
new float[] { value * r * bw, value * g * bw, inv_amount + (value * b * bw), 0, 0 },
new float[] { 0, 0, 0, 1, 0 },
new float[] { 0, 0, 0, 0, 1 }
});

View file

@ -64,7 +64,7 @@ protected override void DrawHue()
for (int y = 0; y < clientHeight; y++)
{
start.Brightness = end.Brightness = 1.0 - (double)y / (clientHeight - 1);
start.Brightness = end.Brightness = 1.0 - ((double)y / (clientHeight - 1));
using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, clientWidth, 1), start, end, LinearGradientMode.Horizontal))
{

View file

@ -50,7 +50,7 @@ protected override void DrawCrosshair(Graphics g)
private void DrawCrosshair(Graphics g, Pen pen, int offset, int height)
{
g.DrawRectangleProper(pen, new Rectangle(offset, lastPos.Y - height / 2, clientWidth - offset * 2, height));
g.DrawRectangleProper(pen, new Rectangle(offset, lastPos.Y - (height / 2), clientWidth - (offset * 2), height));
}
// Y = Hue 360 -> 0
@ -62,7 +62,7 @@ protected override void DrawHue()
for (int y = 0; y < clientHeight; y++)
{
color.Hue = 1.0 - (double)y / (clientHeight - 1);
color.Hue = 1.0 - ((double)y / (clientHeight - 1));
using (Pen pen = new Pen(color))
{

View file

@ -254,15 +254,15 @@ protected void SetBoxMarker()
break;
case DrawStyle.Red:
lastPos.X = Round((clientWidth - 1) * (double)SelectedColor.RGBA.Blue / 255);
lastPos.Y = Round((clientHeight - 1) * (1.0 - (double)SelectedColor.RGBA.Green / 255));
lastPos.Y = Round((clientHeight - 1) * (1.0 - ((double)SelectedColor.RGBA.Green / 255)));
break;
case DrawStyle.Green:
lastPos.X = Round((clientWidth - 1) * (double)SelectedColor.RGBA.Blue / 255);
lastPos.Y = Round((clientHeight - 1) * (1.0 - (double)SelectedColor.RGBA.Red / 255));
lastPos.Y = Round((clientHeight - 1) * (1.0 - ((double)SelectedColor.RGBA.Red / 255)));
break;
case DrawStyle.Blue:
lastPos.X = Round((clientWidth - 1) * (double)SelectedColor.RGBA.Red / 255);
lastPos.Y = Round((clientHeight - 1) * (1.0 - (double)SelectedColor.RGBA.Green / 255));
lastPos.Y = Round((clientHeight - 1) * (1.0 - ((double)SelectedColor.RGBA.Green / 255)));
break;
}
@ -275,32 +275,32 @@ protected void GetBoxColor()
{
case DrawStyle.Hue:
selectedColor.HSB.Saturation = (double)lastPos.X / (clientWidth - 1);
selectedColor.HSB.Brightness = 1.0 - (double)lastPos.Y / (clientHeight - 1);
selectedColor.HSB.Brightness = 1.0 - ((double)lastPos.Y / (clientHeight - 1));
selectedColor.HSBUpdate();
break;
case DrawStyle.Saturation:
selectedColor.HSB.Hue = (double)lastPos.X / (clientWidth - 1);
selectedColor.HSB.Brightness = 1.0 - (double)lastPos.Y / (clientHeight - 1);
selectedColor.HSB.Brightness = 1.0 - ((double)lastPos.Y / (clientHeight - 1));
selectedColor.HSBUpdate();
break;
case DrawStyle.Brightness:
selectedColor.HSB.Hue = (double)lastPos.X / (clientWidth - 1);
selectedColor.HSB.Saturation = 1.0 - (double)lastPos.Y / (clientHeight - 1);
selectedColor.HSB.Saturation = 1.0 - ((double)lastPos.Y / (clientHeight - 1));
selectedColor.HSBUpdate();
break;
case DrawStyle.Red:
selectedColor.RGBA.Blue = Round(255 * (double)lastPos.X / (clientWidth - 1));
selectedColor.RGBA.Green = Round(255 * (1.0 - (double)lastPos.Y / (clientHeight - 1)));
selectedColor.RGBA.Green = Round(255 * (1.0 - ((double)lastPos.Y / (clientHeight - 1))));
selectedColor.RGBAUpdate();
break;
case DrawStyle.Green:
selectedColor.RGBA.Blue = Round(255 * (double)lastPos.X / (clientWidth - 1));
selectedColor.RGBA.Red = Round(255 * (1.0 - (double)lastPos.Y / (clientHeight - 1)));
selectedColor.RGBA.Red = Round(255 * (1.0 - ((double)lastPos.Y / (clientHeight - 1))));
selectedColor.RGBAUpdate();
break;
case DrawStyle.Blue:
selectedColor.RGBA.Red = Round(255 * (double)lastPos.X / (clientWidth - 1));
selectedColor.RGBA.Green = Round(255 * (1.0 - (double)lastPos.Y / (clientHeight - 1)));
selectedColor.RGBA.Green = Round(255 * (1.0 - ((double)lastPos.Y / (clientHeight - 1))));
selectedColor.RGBAUpdate();
break;
}
@ -337,15 +337,15 @@ protected void GetSliderColor()
switch (DrawStyle)
{
case DrawStyle.Hue:
selectedColor.HSB.Hue = 1.0 - (double)lastPos.Y / (clientHeight - 1);
selectedColor.HSB.Hue = 1.0 - ((double)lastPos.Y / (clientHeight - 1));
selectedColor.HSBUpdate();
break;
case DrawStyle.Saturation:
selectedColor.HSB.Saturation = 1.0 - (double)lastPos.Y / (clientHeight - 1);
selectedColor.HSB.Saturation = 1.0 - ((double)lastPos.Y / (clientHeight - 1));
selectedColor.HSBUpdate();
break;
case DrawStyle.Brightness:
selectedColor.HSB.Brightness = 1.0 - (double)lastPos.Y / (clientHeight - 1);
selectedColor.HSB.Brightness = 1.0 - ((double)lastPos.Y / (clientHeight - 1));
selectedColor.HSBUpdate();
break;
case DrawStyle.Red:

View file

@ -113,7 +113,7 @@ protected override void OnPaint(PaintEventArgs pevent)
base.OnPaint(pevent);
}
int boxSize = ClientRectangle.Height - Offset * 2;
int boxSize = ClientRectangle.Height - (Offset * 2);
Rectangle boxRectangle = new Rectangle(ClientRectangle.Width - Offset - boxSize, Offset, boxSize, boxSize);
Graphics g = pevent.Graphics;

View file

@ -65,7 +65,7 @@ protected override void OnPaint(PaintEventArgs pevent)
if (Menu != null)
{
int arrowX = ClientRectangle.Width - 14;
int arrowY = ClientRectangle.Height / 2 - 1;
int arrowY = (ClientRectangle.Height / 2) - 1;
Brush brush = Enabled ? SystemBrushes.ControlText : SystemBrushes.ButtonShadow;
Point[] arrows = new Point[] { new Point(arrowX, arrowY), new Point(arrowX + 7, arrowY), new Point(arrowX + 3, arrowY + 4) };

View file

@ -60,7 +60,7 @@ private void UpdateImage()
}
else
{
int size = Height - ExtraImagePadding * 2;
int size = Height - (ExtraImagePadding * 2);
Bitmap bmp = new Bitmap(size, size);
using (Graphics g = Graphics.FromImage(bmp))

View file

@ -131,9 +131,9 @@ public static T Last<T>(this List<T> list, int index = 0)
public static double ToDouble(this Version value)
{
return Math.Max(value.Major, 0) * Math.Pow(10, 12) +
Math.Max(value.Minor, 0) * Math.Pow(10, 9) +
Math.Max(value.Build, 0) * Math.Pow(10, 6) +
return (Math.Max(value.Major, 0) * Math.Pow(10, 12)) +
(Math.Max(value.Minor, 0) * Math.Pow(10, 9)) +
(Math.Max(value.Build, 0) * Math.Pow(10, 6)) +
Math.Max(value.Revision, 0);
}
@ -169,7 +169,7 @@ public static Size Offset(this Size size, int width, int height)
public static Rectangle Offset(this Rectangle rect, int offset)
{
return new Rectangle(rect.X - offset, rect.Y - offset, rect.Width + offset * 2, rect.Height + offset * 2);
return new Rectangle(rect.X - offset, rect.Y - offset, rect.Width + (offset * 2), rect.Height + (offset * 2));
}
public static Rectangle LocationOffset(this Rectangle rect, int x, int y)
@ -587,7 +587,7 @@ public static Rectangle CreateRectangle(this IEnumerable<Point> points)
public static Point Center(this Rectangle rect)
{
return new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
return new Point(rect.X + (rect.Width / 2), rect.Y + (rect.Height / 2));
}
public static Point Restrict(this Point point, Rectangle rect)

View file

@ -59,8 +59,8 @@ public static void DrawRectangleShadow(this Graphics g, Rectangle rect, Color sh
{
using (Pen pen = new Pen(Color.FromArgb(currentAlpha, shadowColor)))
{
Rectangle shadowRect = new Rectangle(rect.X + -shadowDirection.Left * i, rect.Y + -shadowDirection.Top * i,
rect.Width + (shadowDirection.Left + shadowDirection.Right) * i, rect.Height + (shadowDirection.Top + shadowDirection.Bottom) * i);
Rectangle shadowRect = new Rectangle(rect.X + (-shadowDirection.Left * i), rect.Y + (-shadowDirection.Top * i),
rect.Width + ((shadowDirection.Left + shadowDirection.Right) * i), rect.Height + ((shadowDirection.Top + shadowDirection.Bottom) * i));
g.DrawRectangleProper(pen, shadowRect);
}

View file

@ -145,10 +145,10 @@ public static void AddCapsule(this GraphicsPath gp, RectangleF rect)
public static void AddDiamond(this GraphicsPath graphicsPath, RectangleF rect)
{
PointF p1 = new PointF(rect.X + rect.Width / 2.0f, rect.Y);
PointF p2 = new PointF(rect.X + rect.Width, rect.Y + rect.Height / 2.0f);
PointF p3 = new PointF(rect.X + rect.Width / 2.0f, rect.Y + rect.Height);
PointF p4 = new PointF(rect.X, rect.Y + rect.Height / 2.0f);
PointF p1 = new PointF(rect.X + (rect.Width / 2.0f), rect.Y);
PointF p2 = new PointF(rect.X + rect.Width, rect.Y + (rect.Height / 2.0f));
PointF p3 = new PointF(rect.X + (rect.Width / 2.0f), rect.Y + rect.Height);
PointF p4 = new PointF(rect.X, rect.Y + (rect.Height / 2.0f));
graphicsPath.AddPolygon(new PointF[] { p1, p2, p3, p4 });
}
@ -161,8 +161,8 @@ public static void AddPolygon(this GraphicsPath graphicsPath, RectangleF rect, i
for (int i = 0; i < sideCount; i++)
{
points[i] = new PointF(rect.X + ((rect.Width / 2.0f) * (float)Math.Cos(a)) + rect.Width / 2.0f,
rect.Y + ((rect.Height / 2.0f) * (float)Math.Sin(a)) + rect.Height / 2.0f);
points[i] = new PointF(rect.X + ((rect.Width / 2.0f) * (float)Math.Cos(a)) + (rect.Width / 2.0f),
rect.Y + ((rect.Height / 2.0f) * (float)Math.Sin(a)) + (rect.Height / 2.0f));
a += (float)Math.PI * 2.0f / sideCount;
}

View file

@ -94,7 +94,7 @@ public static int BetweenOrDefault(this int num, int min, int max, int defaultVa
public static float Remap(this float value, float from1, float to1, float from2, float to2)
{
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
return ((value - from1) / (to1 - from1) * (to2 - from2)) + from2;
}
public static int RandomAdd(this int num, int min, int max)

View file

@ -125,7 +125,7 @@ private byte[] CreateGraphicsControlExtensionBlock(int delay)
buffer[1] = 0xF9; // Graphic control extension
buffer[2] = 0x04; // Size of block
buffer[3] = 0x09; // Flags: reserved, disposal method, user input, transparent color
buffer[4] = (byte)(delay / 10 % 0x100); // Delay time low byte
buffer[4] = (byte)((delay / 10) % 0x100); // Delay time low byte
buffer[5] = (byte)(delay / 10 / 0x100); // Delay time high byte
buffer[6] = 0xFF; // Transparent color index
buffer[7] = 0x00; // Block terminator

View file

@ -270,7 +270,7 @@ public static Point SnapPositionToDegree(Point pos, Point pos2, float degree, fl
float angle = MathHelpers.LookAtRadian(pos, pos2);
float startAngle = MathHelpers.DegreeToRadian(startDegree);
float snapAngle = MathHelpers.DegreeToRadian(degree);
float newAngle = (float)Math.Round((angle + startAngle) / snapAngle) * snapAngle - startAngle;
float newAngle = ((float)Math.Round((angle + startAngle) / snapAngle) * snapAngle) - startAngle;
float distance = MathHelpers.Distance(pos, pos2);
return (Point)(pos + MathHelpers.RadianToVector2(newAngle, distance));
}

View file

@ -340,7 +340,7 @@ private static Image GetDIBImage(MemoryStream ms)
using (Bitmap bmp = new Bitmap(infoHeader.biWidth, infoHeader.biHeight, -(int)(infoHeader.biSizeImage / infoHeader.biHeight),
infoHeader.biBitCount == 32 ? PixelFormat.Format32bppArgb : PixelFormat.Format24bppRgb,
new IntPtr((long)handle.AddrOfPinnedObject() + infoHeader.OffsetToPixels + (infoHeader.biHeight - 1) * (int)(infoHeader.biSizeImage / infoHeader.biHeight))))
new IntPtr((long)handle.AddrOfPinnedObject() + infoHeader.OffsetToPixels + ((infoHeader.biHeight - 1) * (int)(infoHeader.biSizeImage / infoHeader.biHeight)))))
{
return new Bitmap(bmp);
}

View file

@ -94,11 +94,11 @@ public static HSB ColorToHSB(Color color)
if (Max == color.R)
{
if (color.G < color.B) hsb.Hue = (360 + q * (color.G - color.B)) / 360;
if (color.G < color.B) hsb.Hue = (360 + (q * (color.G - color.B))) / 360;
else hsb.Hue = q * (color.G - color.B) / 360;
}
else if (Max == color.G) hsb.Hue = (120 + q * (color.B - color.R)) / 360;
else if (Max == color.B) hsb.Hue = (240 + q * (color.R - color.G)) / 360;
else if (Max == color.G) hsb.Hue = (120 + (q * (color.B - color.R))) / 360;
else if (Max == color.B) hsb.Hue = (240 + (q * (color.R - color.G))) / 360;
else hsb.Hue = 0.0;
hsb.Alpha = color.A;
@ -220,37 +220,37 @@ public static Color HSBToColor(HSB hsb)
if (hsb.Hue >= 0 && hsb.Hue <= (double)1 / 6)
{
Mid = (int)Math.Round(((hsb.Hue - 0) * q) * 1530 + Min);
Mid = (int)Math.Round((((hsb.Hue - 0) * q) * 1530) + Min);
return Color.FromArgb(hsb.Alpha, Max, Mid, Min);
}
if (hsb.Hue <= (double)1 / 3)
{
Mid = (int)Math.Round(-((hsb.Hue - (double)1 / 6) * q) * 1530 + Max);
Mid = (int)Math.Round((-((hsb.Hue - ((double)1 / 6)) * q) * 1530) + Max);
return Color.FromArgb(hsb.Alpha, Mid, Max, Min);
}
if (hsb.Hue <= 0.5)
{
Mid = (int)Math.Round(((hsb.Hue - (double)1 / 3) * q) * 1530 + Min);
Mid = (int)Math.Round((((hsb.Hue - ((double)1 / 3)) * q) * 1530) + Min);
return Color.FromArgb(hsb.Alpha, Min, Max, Mid);
}
if (hsb.Hue <= (double)2 / 3)
{
Mid = (int)Math.Round(-((hsb.Hue - 0.5) * q) * 1530 + Max);
Mid = (int)Math.Round((-((hsb.Hue - 0.5) * q) * 1530) + Max);
return Color.FromArgb(hsb.Alpha, Min, Mid, Max);
}
if (hsb.Hue <= (double)5 / 6)
{
Mid = (int)Math.Round(((hsb.Hue - (double)2 / 3) * q) * 1530 + Min);
Mid = (int)Math.Round((((hsb.Hue - ((double)2 / 3)) * q) * 1530) + Min);
return Color.FromArgb(hsb.Alpha, Mid, Min, Max);
}
if (hsb.Hue <= 1.0)
{
Mid = (int)Math.Round(-((hsb.Hue - (double)5 / 6) * q) * 1530 + Max);
Mid = (int)Math.Round((-((hsb.Hue - ((double)5 / 6)) * q) * 1530) + Max);
return Color.FromArgb(hsb.Alpha, Max, Min, Mid);
}
@ -268,9 +268,9 @@ public static Color CMYKToColor(CMYK cmyk)
return Color.FromArgb(cmyk.Alpha, 0, 0, 0);
}
double c = cmyk.Cyan * (1 - cmyk.Key) + cmyk.Key;
double m = cmyk.Magenta * (1 - cmyk.Key) + cmyk.Key;
double y = cmyk.Yellow * (1 - cmyk.Key) + cmyk.Key;
double c = (cmyk.Cyan * (1 - cmyk.Key)) + cmyk.Key;
double m = (cmyk.Magenta * (1 - cmyk.Key)) + cmyk.Key;
double y = (cmyk.Yellow * (1 - cmyk.Key)) + cmyk.Key;
int r = (int)Math.Round((1 - c) * 255);
int g = (int)Math.Round((1 - m) * 255);
@ -335,7 +335,7 @@ public static bool ParseColor(string text, out Color color)
public static int PerceivedBrightness(Color color)
{
return (int)Math.Sqrt(color.R * color.R * .299 + color.G * color.G * .587 + color.B * color.B * .114);
return (int)Math.Sqrt((color.R * color.R * .299) + (color.G * color.G * .587) + (color.B * color.B * .114));
}
public static Color VisibleColor(Color color)

View file

@ -271,7 +271,7 @@ public static string GetRandomAlphanumeric(int length)
public static string GetRandomKey(int length = 5, int count = 3, char separator = '-')
{
return Enumerable.Range(1, (length + 1) * count - 1).Aggregate("", (x, index) => x += index % (length + 1) == 0 ? separator : GetRandomChar(Alphanumeric));
return Enumerable.Range(1, ((length + 1) * count) - 1).Aggregate("", (x, index) => x += index % (length + 1) == 0 ? separator : GetRandomChar(Alphanumeric));
}
public static string GetAllCharacters()
@ -929,8 +929,8 @@ public static string GetUniqueID()
public static Point GetPosition(ContentAlignment placement, Point offset, Size backgroundSize, Size objectSize)
{
int midX = backgroundSize.Width / 2 - objectSize.Width / 2;
int midY = backgroundSize.Height / 2 - objectSize.Height / 2;
int midX = (backgroundSize.Width / 2) - (objectSize.Width / 2);
int midY = (backgroundSize.Height / 2) - (objectSize.Height / 2);
int right = backgroundSize.Width - objectSize.Width;
int bottom = backgroundSize.Height - objectSize.Height;
@ -1274,7 +1274,7 @@ public static string NumberToLetters(int num)
string result = "";
while (--num >= 0)
{
result = (char)('A' + num % 26) + result;
result = (char)('A' + (num % 26)) + result;
num /= 26;
}
return result;

View file

@ -864,8 +864,8 @@ public static Bitmap RotateImage(Image img, float angleDegrees, bool upsize, boo
double cos = Math.Abs(Math.Cos(angleRadians));
double sin = Math.Abs(Math.Sin(angleRadians));
newWidth = (int)Math.Round(oldWidth * cos + oldHeight * sin);
newHeight = (int)Math.Round(oldWidth * sin + oldHeight * cos);
newWidth = (int)Math.Round((oldWidth * cos) + (oldHeight * sin));
newHeight = (int)Math.Round((oldWidth * sin) + (oldHeight * cos));
}
// If upsizing not wanted and clipping not OK need a scaling factor
@ -1017,18 +1017,18 @@ public static Bitmap Sharpen(Image img, double strength)
int imageX = (x - s + filterX + width) % width;
int imageY = (y - s + filterY + height) % height;
rgb = imageY * pbits.Stride + 3 * imageX;
rgb = (imageY * pbits.Stride) + (3 * imageX);
red += rgbValues[rgb + 2] * filter[filterX, filterY];
green += rgbValues[rgb + 1] * filter[filterX, filterY];
blue += rgbValues[rgb + 0] * filter[filterX, filterY];
}
rgb = y * pbits.Stride + 3 * x;
rgb = (y * pbits.Stride) + (3 * x);
int r = Math.Min(Math.Max((int)(factor * red + (bias * rgbValues[rgb + 2])), 0), 255);
int g = Math.Min(Math.Max((int)(factor * green + (bias * rgbValues[rgb + 1])), 0), 255);
int b = Math.Min(Math.Max((int)(factor * blue + (bias * rgbValues[rgb + 0])), 0), 255);
int r = Math.Min(Math.Max((int)((factor * red) + (bias * rgbValues[rgb + 2])), 0), 255);
int g = Math.Min(Math.Max((int)((factor * green) + (bias * rgbValues[rgb + 1])), 0), 255);
int b = Math.Min(Math.Max((int)((factor * blue) + (bias * rgbValues[rgb + 0])), 0), 255);
result[x, y] = Color.FromArgb(r, g, b);
}
@ -1040,7 +1040,7 @@ public static Bitmap Sharpen(Image img, double strength)
{
for (int y = s; y < height - s; y++)
{
rgb = y * pbits.Stride + 3 * x;
rgb = (y * pbits.Stride) + (3 * x);
rgbValues[rgb + 2] = result[x, y].R;
rgbValues[rgb + 1] = result[x, y].G;
@ -1439,7 +1439,7 @@ public static Image TornEdges(Image img, int tornDepth, int tornRange, AnchorSty
{
for (int x = 0; x < horizontalTornCount - 1; x++)
{
points.Add(new Point(img.Width - 1 - tornRange * x, img.Height - 1 - MathHelpers.Random(0, tornDepth)));
points.Add(new Point(img.Width - 1 - (tornRange * x), img.Height - 1 - MathHelpers.Random(0, tornDepth)));
}
}
else
@ -1452,7 +1452,7 @@ public static Image TornEdges(Image img, int tornDepth, int tornRange, AnchorSty
{
for (int y = 0; y < verticalTornCount - 1; y++)
{
points.Add(new Point(MathHelpers.Random(0, tornDepth), img.Height - 1 - tornRange * y));
points.Add(new Point(MathHelpers.Random(0, tornDepth), img.Height - 1 - (tornRange * y)));
}
}
else
@ -1704,7 +1704,7 @@ public static void DrawColorPickerIcon(Graphics g, Color color, Rectangle rect,
{
g.CompositingMode = CompositingMode.SourceCopy;
Rectangle holeRect = new Rectangle(rect.Width / 2 - holeSize / 2, rect.Height / 2 - holeSize / 2, holeSize, holeSize);
Rectangle holeRect = new Rectangle((rect.Width / 2) - (holeSize / 2), (rect.Height / 2) - (holeSize / 2), holeSize, holeSize);
g.FillRectangle(Brushes.Transparent, holeRect);
g.DrawRectangleProper(Pens.Black, holeRect);

View file

@ -114,7 +114,7 @@ public static float Distance(Vector2 pos1, Vector2 pos2)
public static float Lerp(float value1, float value2, float amount)
{
return value1 + (value2 - value1) * amount;
return value1 + ((value2 - value1) * amount);
}
public static Vector2 Lerp(Vector2 pos1, Vector2 pos2, float amount)

View file

@ -656,7 +656,7 @@ public uint OffsetToPixels
{
if (biCompression == BI_COMPRESSION.BI_BITFIELDS)
{
return biSize + 3 * 4;
return biSize + (3 * 4);
}
return biSize;

View file

@ -1312,6 +1312,9 @@
<PackageReference Include="Newtonsoft.Json">
<Version>11.0.2</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -149,7 +149,7 @@ public ColorBgra GetPixel(int i)
public ColorBgra GetPixel(int x, int y)
{
return Pointer[x + y * Width];
return Pointer[x + (y * Width)];
}
public void SetPixel(int i, ColorBgra color)
@ -164,12 +164,12 @@ public void SetPixel(int i, uint color)
public void SetPixel(int x, int y, ColorBgra color)
{
Pointer[x + y * Width] = color;
Pointer[x + (y * Width)] = color;
}
public void SetPixel(int x, int y, uint color)
{
Pointer[x + y * Width] = color;
Pointer[x + (y * Width)] = color;
}
public void ClearPixel(int i)
@ -179,7 +179,7 @@ public void ClearPixel(int i)
public void ClearPixel(int x, int y)
{
Pointer[x + y * Width] = 0;
Pointer[x + (y * Width)] = 0;
}
public void Dispose()

View file

@ -290,6 +290,9 @@
<PackageReference Include="ImageListView">
<Version>11.0.4</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View file

@ -244,6 +244,9 @@
<PackageReference Include="Newtonsoft.Json">
<Version>11.0.2</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -125,6 +125,9 @@
<PackageReference Include="Newtonsoft.Json">
<Version>11.0.2</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -238,6 +238,11 @@
<EmbeddedResource Include="Properties\Resources.zh-CN.resx" />
<EmbeddedResource Include="Properties\Resources.zh-TW.resx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</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.

View file

@ -182,7 +182,7 @@ private int GetRandomTimeSlice(int start)
}
Random random = new Random();
return (int)(random.NextDouble() * (mediaSeekTimes[start + 1] - mediaSeekTimes[start]) + mediaSeekTimes[start]);
return (int)((random.NextDouble() * (mediaSeekTimes[start + 1] - mediaSeekTimes[start])) + mediaSeekTimes[start]);
}
private Image CombineScreenshots(List<VideoThumbnailInfo> thumbnails)
@ -222,18 +222,18 @@ private Image CombineScreenshots(List<VideoThumbnailInfo> thumbnails)
int thumbWidth = images[0].Width;
int width = Options.Padding * 2 +
thumbWidth * columnCount +
(columnCount - 1) * Options.Spacing;
int width = (Options.Padding * 2) +
(thumbWidth * columnCount) +
((columnCount - 1) * Options.Spacing);
int rowCount = (int)Math.Ceiling(images.Count / (float)columnCount);
int thumbHeight = images[0].Height;
int height = Options.Padding * 3 +
int height = (Options.Padding * 3) +
infoStringHeight +
thumbHeight * rowCount +
(rowCount - 1) * Options.Spacing;
(thumbHeight * rowCount) +
((rowCount - 1) * Options.Spacing);
finalImage = new Bitmap(width, height);
@ -250,7 +250,7 @@ private Image CombineScreenshots(List<VideoThumbnailInfo> thumbnails)
}
int i = 0;
int offsetY = Options.Padding * 2 + infoStringHeight;
int offsetY = (Options.Padding * 2) + infoStringHeight;
for (int y = 0; y < rowCount; y++)
{

View file

@ -65,6 +65,9 @@
<PackageReference Include="Newtonsoft.Json">
<Version>11.0.2</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -60,7 +60,7 @@ public override bool Update()
}
else
{
Opacity = 1 - (Timer.Elapsed - (FadeInDuration + Duration)).TotalMilliseconds / FadeOutDuration.TotalMilliseconds;
Opacity = 1 - ((Timer.Elapsed - (FadeInDuration + Duration)).TotalMilliseconds / FadeOutDuration.TotalMilliseconds);
}
if (Opacity == 0)

View file

@ -194,8 +194,8 @@ private void InitializeComponent()
if (Options.ImageEditorStartMode == ImageEditorStartMode.AutoSize)
{
int margin = 100;
Size canvasWindowSize = new Size(Canvas.Width + SystemInformation.BorderSize.Width * 2 + margin,
Canvas.Height + SystemInformation.CaptionHeight + SystemInformation.BorderSize.Height * 2 + margin);
Size canvasWindowSize = new Size(Canvas.Width + (SystemInformation.BorderSize.Width * 2) + margin,
Canvas.Height + SystemInformation.CaptionHeight + (SystemInformation.BorderSize.Height * 2) + margin);
canvasWindowSize = new Size(Math.Max(MinimumSize.Width, canvasWindowSize.Width), Math.Max(MinimumSize.Height, canvasWindowSize.Height));
if (canvasWindowSize.Width < activeScreenWorkingArea.Width && canvasWindowSize.Height < activeScreenWorkingArea.Height)
@ -378,7 +378,7 @@ private void Pan(int deltaX, int deltaY, bool usePanningStretch = true)
Rectangle limitRectangle = new Rectangle(
ClientArea.X + panLimitSize.Width, ClientArea.Y + panLimitSize.Height,
ClientArea.Width - panLimitSize.Width * 2, ClientArea.Height - panLimitSize.Height * 2);
ClientArea.Width - (panLimitSize.Width * 2), ClientArea.Height - (panLimitSize.Height * 2));
deltaX = Math.Max(deltaX, limitRectangle.Left - CanvasRectangle.Right);
deltaX = Math.Min(deltaX, limitRectangle.Right - CanvasRectangle.Left);
@ -418,10 +418,10 @@ private void AutomaticPan(Vector2 centerOffset)
{
if (IsEditorMode)
{
int x = (int)Math.Round(ClientArea.Width * 0.5f + centerOffset.X);
int y = (int)Math.Round(ClientArea.Height * 0.5f + centerOffset.Y);
int newX = x - CanvasRectangle.Width / 2;
int newY = y - CanvasRectangle.Height / 2;
int x = (int)Math.Round((ClientArea.Width * 0.5f) + centerOffset.X);
int y = (int)Math.Round((ClientArea.Height * 0.5f) + centerOffset.Y);
int newX = x - (CanvasRectangle.Width / 2);
int newY = y - (CanvasRectangle.Height / 2);
int deltaX = newX - CanvasRectangle.X;
int deltaY = newY - CanvasRectangle.Y;
Pan(deltaX, deltaY, false);
@ -436,8 +436,8 @@ public void AutomaticPan()
private void UpdateCenterOffset()
{
CanvasCenterOffset = new Vector2(
(CanvasRectangle.X + CanvasRectangle.Width / 2f) - ClientArea.Width / 2f,
(CanvasRectangle.Y + CanvasRectangle.Height / 2f) - ClientArea.Height / 2f);
(CanvasRectangle.X + (CanvasRectangle.Width / 2f)) - (ClientArea.Width / 2f),
(CanvasRectangle.Y + (CanvasRectangle.Height / 2f)) - (ClientArea.Height / 2f));
}
public void CenterCanvas()
@ -941,7 +941,7 @@ internal void DrawAreaText(Graphics g, string text, Rectangle area)
Size textSize = g.MeasureString(text, infoFont).ToSize();
Point textPos;
if (area.Y - offset - textSize.Height - backgroundPadding * 2 < ClientArea.Y)
if (area.Y - offset - textSize.Height - (backgroundPadding * 2) < ClientArea.Y)
{
textPos = new Point(area.X + offset + backgroundPadding, area.Y + offset + backgroundPadding);
}
@ -955,7 +955,7 @@ internal void DrawAreaText(Graphics g, string text, Rectangle area)
textPos.X = ClientArea.Width - textSize.Width - backgroundPadding;
}
Rectangle backgroundRect = new Rectangle(textPos.X - backgroundPadding, textPos.Y - backgroundPadding, textSize.Width + backgroundPadding * 2, textSize.Height + backgroundPadding * 2);
Rectangle backgroundRect = new Rectangle(textPos.X - backgroundPadding, textPos.Y - backgroundPadding, textSize.Width + (backgroundPadding * 2), textSize.Height + (backgroundPadding * 2));
DrawInfoText(g, text, backgroundRect, infoFont, backgroundPadding);
}
@ -989,7 +989,7 @@ private void DrawBottomTipAnimation(Graphics g, TextAnimation textAnimation)
textSize.Width += padding * 2;
textSize.Height += padding * 2;
int margin = 20;
Rectangle textRectangle = new Rectangle(ClientArea.Width / 2 - textSize.Width / 2, ClientArea.Height - textSize.Height - margin, textSize.Width, textSize.Height);
Rectangle textRectangle = new Rectangle((ClientArea.Width / 2) - (textSize.Width / 2), ClientArea.Height - textSize.Height - margin, textSize.Width, textSize.Height);
DrawTextAnimation(g, textAnimation, textRectangle, padding);
}
@ -1100,7 +1100,7 @@ private void DrawCursorGraphics(Graphics g)
CurrentPosition = InputManager.MousePosition;
infoText = GetInfoText();
Size textSize = g.MeasureString(infoText, infoFont).ToSize();
infoTextRect.Size = new Size(textSize.Width + infoTextPadding * 2, textSize.Height + infoTextPadding * 2);
infoTextRect.Size = new Size(textSize.Width + (infoTextPadding * 2), textSize.Height + (infoTextPadding * 2));
totalSize.Width = Math.Max(totalSize.Width, infoTextRect.Width);
totalSize.Height += infoTextRect.Height;
@ -1154,7 +1154,7 @@ private void DrawCursorGraphics(Graphics g)
{
int colorBoxOffset = 3;
int colorBoxWidth = 15;
colorRect = new Rectangle(infoTextRect.X + colorBoxOffset, infoTextRect.Y + colorBoxOffset, colorBoxWidth, infoTextRect.Height - colorBoxOffset * 2);
colorRect = new Rectangle(infoTextRect.X + colorBoxOffset, infoTextRect.Y + colorBoxOffset, colorBoxWidth, infoTextRect.Height - (colorBoxOffset * 2));
int colorExtraWidth = colorRect.Width + colorBoxOffset;
infoTextRect.Width += colorExtraWidth;
padding.X += colorExtraWidth;
@ -1195,8 +1195,8 @@ private Bitmap Magnifier(Image img, Point position, int horizontalPixelCount, in
g.InterpolationMode = InterpolationMode.NearestNeighbor;
g.PixelOffsetMode = PixelOffsetMode.Half;
g.DrawImage(img, new Rectangle(0, 0, width, height), new Rectangle(position.X - horizontalPixelCount / 2 - CanvasRectangle.X,
position.Y - verticalPixelCount / 2 - CanvasRectangle.Y, horizontalPixelCount, verticalPixelCount), GraphicsUnit.Pixel);
g.DrawImage(img, new Rectangle(0, 0, width, height), new Rectangle(position.X - (horizontalPixelCount / 2) - CanvasRectangle.X,
position.Y - (verticalPixelCount / 2) - CanvasRectangle.Y, horizontalPixelCount, verticalPixelCount), GraphicsUnit.Pixel);
g.PixelOffsetMode = PixelOffsetMode.None;
@ -1212,16 +1212,16 @@ private Bitmap Magnifier(Image img, Point position, int horizontalPixelCount, in
{
for (int x = 1; x < horizontalPixelCount; x++)
{
g.DrawLine(pen, new Point(x * pixelSize - 1, 0), new Point(x * pixelSize - 1, height - 1));
g.DrawLine(pen, new Point((x * pixelSize) - 1, 0), new Point((x * pixelSize) - 1, height - 1));
}
for (int y = 1; y < verticalPixelCount; y++)
{
g.DrawLine(pen, new Point(0, y * pixelSize - 1), new Point(width - 1, y * pixelSize - 1));
g.DrawLine(pen, new Point(0, (y * pixelSize) - 1), new Point(width - 1, (y * pixelSize) - 1));
}
}
g.DrawRectangle(Pens.Black, (width - pixelSize) / 2 - 1, (height - pixelSize) / 2 - 1, pixelSize, pixelSize);
g.DrawRectangle(Pens.Black, ((width - pixelSize) / 2) - 1, ((height - pixelSize) / 2) - 1, pixelSize, pixelSize);
if (pixelSize >= 6)
{
@ -1238,14 +1238,14 @@ private void DrawRuler(Graphics g, Rectangle rect, Pen pen, int rulerSize, int r
{
for (int x = 1; x <= rect.Width / rulerWidth; x++)
{
g.DrawLine(pen, new Point(rect.X + x * rulerWidth, rect.Y), new Point(rect.X + x * rulerWidth, rect.Y + rulerSize));
g.DrawLine(pen, new Point(rect.X + x * rulerWidth, rect.Bottom), new Point(rect.X + x * rulerWidth, rect.Bottom - rulerSize));
g.DrawLine(pen, new Point(rect.X + (x * rulerWidth), rect.Y), new Point(rect.X + (x * rulerWidth), rect.Y + rulerSize));
g.DrawLine(pen, new Point(rect.X + (x * rulerWidth), rect.Bottom), new Point(rect.X + (x * rulerWidth), rect.Bottom - rulerSize));
}
for (int y = 1; y <= rect.Height / rulerWidth; y++)
{
g.DrawLine(pen, new Point(rect.X, rect.Y + y * rulerWidth), new Point(rect.X + rulerSize, rect.Y + y * rulerWidth));
g.DrawLine(pen, new Point(rect.Right, rect.Y + y * rulerWidth), new Point(rect.Right - rulerSize, rect.Y + y * rulerWidth));
g.DrawLine(pen, new Point(rect.X, rect.Y + (y * rulerWidth)), new Point(rect.X + rulerSize, rect.Y + (y * rulerWidth)));
g.DrawLine(pen, new Point(rect.Right, rect.Y + (y * rulerWidth)), new Point(rect.Right - rulerSize, rect.Y + (y * rulerWidth)));
}
}
}

View file

@ -54,11 +54,11 @@ public override void DrawItem(Graphics g, ImageListViewItem item, ItemState stat
string text = Path.GetFileNameWithoutExtension(item.Text);
Size szt = TextRenderer.MeasureText(text, ImageListView.Font);
int textWidth = szt.Width + itemPadding.Width * 2;
int textWidth = szt.Width + (itemPadding.Width * 2);
if ((state & ItemState.Hovered) != ItemState.None && textWidth > bounds.Width)
{
bounds = new Rectangle(bounds.X + bounds.Width / 2 - textWidth / 2, bounds.Y, textWidth, bounds.Height);
bounds = new Rectangle(bounds.X + (bounds.Width / 2) - (textWidth / 2), bounds.Y, textWidth, bounds.Height);
}
// Paint background
@ -135,7 +135,7 @@ public override void DrawItem(Graphics g, ImageListViewItem item, ItemState stat
}
}
Rectangle rt = new Rectangle(bounds.Left, bounds.Top + 2 * itemPadding.Height + ImageListView.ThumbnailSize.Height, bounds.Width, szt.Height);
Rectangle rt = new Rectangle(bounds.Left, bounds.Top + (2 * itemPadding.Height) + ImageListView.ThumbnailSize.Height, bounds.Width, szt.Height);
TextFormatFlags flags;
if ((state & ItemState.Hovered) != ItemState.None)

View file

@ -104,15 +104,15 @@ public void Update()
inCanvasCenterOffset = form.CanvasCenterOffset.Y;
}
int trackLength = inClientAreaSize - Margin * 2 - Padding * 2 - Thickness;
int trackLengthInternal = trackLength - Padding * 2;
int trackLength = inClientAreaSize - (Margin * 2) - (Padding * 2) - Thickness;
int trackLengthInternal = trackLength - (Padding * 2);
int thumbLength = Math.Max(Thickness, (int)Math.Round((float)inImageVisibleSize / inImageSize * trackLengthInternal));
double thumbLimit = (trackLengthInternal - thumbLength) / 2.0f;
int thumbPosition = (int)Math.Round(Margin + trackLength / 2.0f - (thumbLength / 2.0f) -
int thumbPosition = (int)Math.Round(Margin + (trackLength / 2.0f) - (thumbLength / 2.0f) -
Math.Min(thumbLimit, Math.Max(-thumbLimit, inCanvasCenterOffset / inImageSize * trackLengthInternal)));
int trackWidth = Padding * 2 + Thickness;
int trackWidth = (Padding * 2) + Thickness;
int thumbSideOffset = sideOffsetBase - Margin - Padding - Thickness;
int trackSideOffset = thumbSideOffset - Padding;
@ -183,10 +183,10 @@ private void Scroll(Point position)
int mousePositionLocal = inMousePosition - Margin - Padding;
int trackLength = inClientAreaSize - Margin * 2 - Padding * 2 - Thickness;
int trackLengthInternal = trackLength - Padding * 2;
int trackLength = inClientAreaSize - (Margin * 2) - (Padding * 2) - Thickness;
int trackLengthInternal = trackLength - (Padding * 2);
int centerOffsetNew = (int)((trackLengthInternal / 2.0f - mousePositionLocal) / trackLengthInternal * inImageSize);
int centerOffsetNew = (int)(((trackLengthInternal / 2.0f) - mousePositionLocal) / trackLengthInternal * inImageSize);
if (Orientation == Orientation.Horizontal)
{

View file

@ -44,7 +44,7 @@ public Point Position
{
position = value;
Rectangle = new Rectangle(position.X - (Size - 1) / 2, position.Y - (Size - 1) / 2, Size, Size);
Rectangle = new Rectangle(position.X - ((Size - 1) / 2), position.Y - ((Size - 1) / 2), Size, Size);
}
}

View file

@ -161,7 +161,7 @@ public virtual void OnCreating()
if (Options.IsFixedSize && ShapeCategory == ShapeCategory.Region)
{
Manager.IsMoving = true;
Rectangle = new Rectangle(new Point(pos.X - Options.FixedSize.Width / 2, pos.Y - Options.FixedSize.Height / 2), Options.FixedSize);
Rectangle = new Rectangle(new Point(pos.X - (Options.FixedSize.Width / 2), pos.Y - (Options.FixedSize.Height / 2)), Options.FixedSize);
}
else
{
@ -407,11 +407,11 @@ public virtual void OnNodeUpdate()
public virtual void OnNodePositionUpdate()
{
int xStart = Rectangle.X;
int xMid = Rectangle.X + Rectangle.Width / 2;
int xMid = Rectangle.X + (Rectangle.Width / 2);
int xEnd = Rectangle.X + Rectangle.Width - 1;
int yStart = Rectangle.Y;
int yMid = Rectangle.Y + Rectangle.Height / 2;
int yMid = Rectangle.Y + (Rectangle.Height / 2);
int yEnd = Rectangle.Y + Rectangle.Height - 1;
Manager.ResizeNodes[(int)NodePosition.TopLeft].Position = new Point(xStart, yStart);

View file

@ -139,7 +139,7 @@ protected void DrawFreehand(Graphics g, Color borderColor, int borderSize, Point
{
using (Brush brush = new SolidBrush(borderColor))
{
Rectangle rect = new Rectangle((int)(points[0].X - borderSize / 2f), (int)(points[0].Y - borderSize / 2f), borderSize, borderSize);
Rectangle rect = new Rectangle((int)(points[0].X - (borderSize / 2f)), (int)(points[0].Y - (borderSize / 2f)), borderSize, borderSize);
g.FillEllipse(brush, rect);
}
}

View file

@ -58,7 +58,7 @@ public void SetImage(Image img, bool centerImage)
if (centerImage)
{
location = new Point(Rectangle.X - size.Width / 2, Rectangle.Y - size.Height / 2);
location = new Point(Rectangle.X - (size.Width / 2), Rectangle.Y - (size.Height / 2));
}
else
{

View file

@ -116,12 +116,12 @@ private void CalculateRectangle()
if (Rectangle.Width < MinimumCollisionSize)
{
Rectangle = new Rectangle(Rectangle.X - MinimumCollisionSize / 2, Rectangle.Y, Rectangle.Width + MinimumCollisionSize, Rectangle.Height);
Rectangle = new Rectangle(Rectangle.X - (MinimumCollisionSize / 2), Rectangle.Y, Rectangle.Width + MinimumCollisionSize, Rectangle.Height);
}
if (Rectangle.Height < MinimumCollisionSize)
{
Rectangle = new Rectangle(Rectangle.X, Rectangle.Y - MinimumCollisionSize / 2, Rectangle.Width, Rectangle.Height + MinimumCollisionSize);
Rectangle = new Rectangle(Rectangle.X, Rectangle.Y - (MinimumCollisionSize / 2), Rectangle.Width, Rectangle.Height + MinimumCollisionSize);
}
}

View file

@ -53,7 +53,7 @@ public override void OnCreating()
{
Manager.IsMoving = true;
Point pos = InputManager.ClientMousePosition;
Rectangle = new Rectangle(new Point(pos.X - Rectangle.Width / 2, pos.Y - Rectangle.Height / 2), Rectangle.Size);
Rectangle = new Rectangle(new Point(pos.X - (Rectangle.Width / 2), pos.Y - (Rectangle.Height / 2)), Rectangle.Size);
}
public override void OnConfigLoad()
@ -96,7 +96,7 @@ protected void DrawNumber(Graphics g)
int padding = 3;
Point center = Rectangle.Center();
Rectangle = new Rectangle(center.X - maxSize / 2 - padding, center.Y - maxSize / 2 - padding, maxSize + padding * 2, maxSize + padding * 2);
Rectangle = new Rectangle(center.X - (maxSize / 2) - padding, center.Y - (maxSize / 2) - padding, maxSize + (padding * 2), maxSize + (padding * 2));
DrawEllipse(g);

View file

@ -162,7 +162,7 @@ public void AutoSize(bool center)
if (center)
{
location = new Point(Rectangle.X - size.Width / 2, Rectangle.Y - size.Height / 2);
location = new Point(Rectangle.X - (size.Width / 2), Rectangle.Y - (size.Height / 2));
}
else
{

View file

@ -1111,7 +1111,7 @@ private BaseShape CheckHover()
return new RectangleRegionShape()
{
Rectangle = new Rectangle(new Point(location.X - Options.FixedSize.Width / 2, location.Y - Options.FixedSize.Height / 2), Options.FixedSize)
Rectangle = new Rectangle(new Point(location.X - (Options.FixedSize.Width / 2), location.Y - (Options.FixedSize.Height / 2)), Options.FixedSize)
};
}
else

View file

@ -1106,7 +1106,7 @@ internal void UpdateMenuPosition()
}
else if (tsMain.Width < rectScreen.Width)
{
menuForm.Location = new Point(rectScreen.X + rectScreen.Width / 2 - tsMain.Width / 2, rectScreen.Y);
menuForm.Location = new Point(rectScreen.X + (rectScreen.Width / 2) - (tsMain.Width / 2), rectScreen.Y);
}
else
{

View file

@ -46,17 +46,17 @@ public override void OnUpdate()
if (confirmButton != null && cancelButton != null)
{
if (Rectangle.Bottom + buttonOffset + buttonSize.Height > Manager.Form.ClientArea.Bottom &&
Rectangle.Width > buttonSize.Width * 2 + buttonOffset * 3 &&
Rectangle.Height > buttonSize.Height + buttonOffset * 2)
Rectangle.Width > (buttonSize.Width * 2) + (buttonOffset * 3) &&
Rectangle.Height > buttonSize.Height + (buttonOffset * 2))
{
confirmButton.Rectangle = new Rectangle(Rectangle.Right - buttonOffset * 2 - buttonSize.Width * 2,
confirmButton.Rectangle = new Rectangle(Rectangle.Right - (buttonOffset * 2) - (buttonSize.Width * 2),
Rectangle.Bottom - buttonOffset - buttonSize.Height, buttonSize.Width, buttonSize.Height);
cancelButton.Rectangle = new Rectangle(Rectangle.Right - buttonOffset - buttonSize.Width,
Rectangle.Bottom - buttonOffset - buttonSize.Height, buttonSize.Width, buttonSize.Height);
}
else
{
confirmButton.Rectangle = new Rectangle(Rectangle.Right - buttonSize.Width * 2 - buttonOffset,
confirmButton.Rectangle = new Rectangle(Rectangle.Right - (buttonSize.Width * 2) - buttonOffset,
Rectangle.Bottom + buttonOffset, buttonSize.Width, buttonSize.Height);
cancelButton.Rectangle = new Rectangle(Rectangle.Right - buttonSize.Width,
Rectangle.Bottom + buttonOffset, buttonSize.Width, buttonSize.Height);

View file

@ -579,6 +579,9 @@
<PackageReference Include="ImageListView">
<Version>11.0.4</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -92,6 +92,11 @@
<Name>ShareX.HelpersLib</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</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.

View file

@ -74,6 +74,11 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</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.

View file

@ -207,7 +207,7 @@ private static string BytesToString(byte[] b)
for (int i = 0; i < b.Length; ++i)
{
res[2 * i] = IntToChar(b[i] >> 4);
res[2 * i + 1] = IntToChar(b[i] & 0xf);
res[(2 * i) + 1] = IntToChar(b[i] & 0xf);
}
return new string(res);
}

View file

@ -964,6 +964,9 @@
<PackageReference Include="SSH.NET">
<Version>2016.1.0</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View file

@ -149,7 +149,7 @@ private void UpdateStatus()
if (IsRunning && !IsDisposed)
{
timeleft = Math.Max(0, delay - (int)stopwatch.ElapsedMilliseconds);
percentage = (int)(100 - (double)timeleft / delay * 100);
percentage = (int)(100 - ((double)timeleft / delay * 100));
tspbBar.Value = percentage;
string secondsLeft = (timeleft / 1000f).ToString("0.0");
tsslStatus.Text = " " + string.Format(Resources.AutoCaptureForm_UpdateStatus_Timeleft___0_s___1____Total___2_, secondsLeft, percentage, count);

View file

@ -228,7 +228,7 @@ public void UpdateControls()
{
StartPosition = FormStartPosition.Manual;
Rectangle activeScreen = CaptureHelpers.GetActiveScreenBounds();
Location = new Point(activeScreen.Width / 2 - Size.Width / 2, activeScreen.Height / 2 - Size.Height / 2);
Location = new Point((activeScreen.Width / 2) - (Size.Width / 2), (activeScreen.Height / 2) - (Size.Height / 2));
}
}
else

View file

@ -80,8 +80,8 @@ public NotificationForm(int duration, int fadeDuration, ContentAlignment placeme
}
else if (!string.IsNullOrEmpty(config.Text))
{
textRenderSize = Helpers.MeasureText(config.Text, textFont, size.Width - textPadding * 2);
size = new Size(textRenderSize.Width + textPadding * 2, textRenderSize.Height + textPadding * 2 + 2);
textRenderSize = Helpers.MeasureText(config.Text, textFont, size.Width - (textPadding * 2));
size = new Size(textRenderSize.Width + (textPadding * 2), textRenderSize.Height + (textPadding * 2) + 2);
}
Point position = Helpers.GetPosition(placement, new Point(windowOffset, windowOffset), Screen.PrimaryScreen.WorkingArea.Size, size);

View file

@ -1559,6 +1559,9 @@
<PackageReference Include="Newtonsoft.Json">
<Version>11.0.2</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.0-beta007</Version>
</PackageReference>
<PackageReference Include="ZXing.Net">
<Version>0.16.4</Version>
</PackageReference>