diff --git a/ShareX.DesktopBridgeHelper/ShareX.DesktopBridgeHelper.csproj b/ShareX.DesktopBridgeHelper/ShareX.DesktopBridgeHelper.csproj index 887fdf083..0fa4610bb 100644 --- a/ShareX.DesktopBridgeHelper/ShareX.DesktopBridgeHelper.csproj +++ b/ShareX.DesktopBridgeHelper/ShareX.DesktopBridgeHelper.csproj @@ -48,5 +48,10 @@ + + + 1.1.0-beta007 + + \ No newline at end of file diff --git a/ShareX.HelpersLib/ColorMatrixManager.cs b/ShareX.HelpersLib/ColorMatrixManager.cs index 74a7c8285..9ef6d2249 100644 --- a/ShareX.HelpersLib/ColorMatrixManager.cs +++ b/ShareX.HelpersLib/ColorMatrixManager.cs @@ -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 } }); diff --git a/ShareX.HelpersLib/Colors/ColorBox.cs b/ShareX.HelpersLib/Colors/ColorBox.cs index 3f2b99c12..b7fa01a60 100644 --- a/ShareX.HelpersLib/Colors/ColorBox.cs +++ b/ShareX.HelpersLib/Colors/ColorBox.cs @@ -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)) { diff --git a/ShareX.HelpersLib/Colors/ColorSlider.cs b/ShareX.HelpersLib/Colors/ColorSlider.cs index ee34511b4..3a952aef2 100644 --- a/ShareX.HelpersLib/Colors/ColorSlider.cs +++ b/ShareX.HelpersLib/Colors/ColorSlider.cs @@ -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)) { diff --git a/ShareX.HelpersLib/Colors/ColorUserControl.cs b/ShareX.HelpersLib/Colors/ColorUserControl.cs index ce7e3f4a3..325fadac4 100644 --- a/ShareX.HelpersLib/Colors/ColorUserControl.cs +++ b/ShareX.HelpersLib/Colors/ColorUserControl.cs @@ -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: diff --git a/ShareX.HelpersLib/Controls/ColorButton.cs b/ShareX.HelpersLib/Controls/ColorButton.cs index a11ca396b..40744f99b 100644 --- a/ShareX.HelpersLib/Controls/ColorButton.cs +++ b/ShareX.HelpersLib/Controls/ColorButton.cs @@ -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; diff --git a/ShareX.HelpersLib/Controls/MenuButton.cs b/ShareX.HelpersLib/Controls/MenuButton.cs index a0b3ba824..e4269efc1 100644 --- a/ShareX.HelpersLib/Controls/MenuButton.cs +++ b/ShareX.HelpersLib/Controls/MenuButton.cs @@ -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) }; diff --git a/ShareX.HelpersLib/Controls/ToolStripButtonCounter.cs b/ShareX.HelpersLib/Controls/ToolStripButtonCounter.cs index 9d972af43..277b34222 100644 --- a/ShareX.HelpersLib/Controls/ToolStripButtonCounter.cs +++ b/ShareX.HelpersLib/Controls/ToolStripButtonCounter.cs @@ -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)) diff --git a/ShareX.HelpersLib/Extensions/Extensions.cs b/ShareX.HelpersLib/Extensions/Extensions.cs index e37c251dd..9280e3153 100644 --- a/ShareX.HelpersLib/Extensions/Extensions.cs +++ b/ShareX.HelpersLib/Extensions/Extensions.cs @@ -131,9 +131,9 @@ public static T Last(this List 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 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) diff --git a/ShareX.HelpersLib/Extensions/GraphicsExtensions.cs b/ShareX.HelpersLib/Extensions/GraphicsExtensions.cs index 83acff858..557ebde3b 100644 --- a/ShareX.HelpersLib/Extensions/GraphicsExtensions.cs +++ b/ShareX.HelpersLib/Extensions/GraphicsExtensions.cs @@ -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); } diff --git a/ShareX.HelpersLib/Extensions/GraphicsPathExtensions.cs b/ShareX.HelpersLib/Extensions/GraphicsPathExtensions.cs index 98bddbce9..a35344dff 100644 --- a/ShareX.HelpersLib/Extensions/GraphicsPathExtensions.cs +++ b/ShareX.HelpersLib/Extensions/GraphicsPathExtensions.cs @@ -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; } diff --git a/ShareX.HelpersLib/Extensions/NumberExtensions.cs b/ShareX.HelpersLib/Extensions/NumberExtensions.cs index 3ce920b45..ad25dd008 100644 --- a/ShareX.HelpersLib/Extensions/NumberExtensions.cs +++ b/ShareX.HelpersLib/Extensions/NumberExtensions.cs @@ -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) diff --git a/ShareX.HelpersLib/GIF/AnimatedGifCreator.cs b/ShareX.HelpersLib/GIF/AnimatedGifCreator.cs index f2e2f54d5..0e81f5ca7 100644 --- a/ShareX.HelpersLib/GIF/AnimatedGifCreator.cs +++ b/ShareX.HelpersLib/GIF/AnimatedGifCreator.cs @@ -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 diff --git a/ShareX.HelpersLib/Helpers/CaptureHelpers.cs b/ShareX.HelpersLib/Helpers/CaptureHelpers.cs index d85198878..0a318d173 100644 --- a/ShareX.HelpersLib/Helpers/CaptureHelpers.cs +++ b/ShareX.HelpersLib/Helpers/CaptureHelpers.cs @@ -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)); } diff --git a/ShareX.HelpersLib/Helpers/ClipboardHelpers.cs b/ShareX.HelpersLib/Helpers/ClipboardHelpers.cs index 0a7f7bf00..65a44bc17 100644 --- a/ShareX.HelpersLib/Helpers/ClipboardHelpers.cs +++ b/ShareX.HelpersLib/Helpers/ClipboardHelpers.cs @@ -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); } diff --git a/ShareX.HelpersLib/Helpers/ColorHelpers.cs b/ShareX.HelpersLib/Helpers/ColorHelpers.cs index f3be540c4..6b34565f2 100644 --- a/ShareX.HelpersLib/Helpers/ColorHelpers.cs +++ b/ShareX.HelpersLib/Helpers/ColorHelpers.cs @@ -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) diff --git a/ShareX.HelpersLib/Helpers/Helpers.cs b/ShareX.HelpersLib/Helpers/Helpers.cs index d8b10699c..d6cfab82a 100644 --- a/ShareX.HelpersLib/Helpers/Helpers.cs +++ b/ShareX.HelpersLib/Helpers/Helpers.cs @@ -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; diff --git a/ShareX.HelpersLib/Helpers/ImageHelpers.cs b/ShareX.HelpersLib/Helpers/ImageHelpers.cs index 528e39b77..b6cee7ff3 100644 --- a/ShareX.HelpersLib/Helpers/ImageHelpers.cs +++ b/ShareX.HelpersLib/Helpers/ImageHelpers.cs @@ -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); diff --git a/ShareX.HelpersLib/Helpers/MathHelpers.cs b/ShareX.HelpersLib/Helpers/MathHelpers.cs index 7f42b266f..0286f6051 100644 --- a/ShareX.HelpersLib/Helpers/MathHelpers.cs +++ b/ShareX.HelpersLib/Helpers/MathHelpers.cs @@ -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) diff --git a/ShareX.HelpersLib/Native/NativeStructs.cs b/ShareX.HelpersLib/Native/NativeStructs.cs index 11497a72d..9a5021ed2 100644 --- a/ShareX.HelpersLib/Native/NativeStructs.cs +++ b/ShareX.HelpersLib/Native/NativeStructs.cs @@ -656,7 +656,7 @@ public uint OffsetToPixels { if (biCompression == BI_COMPRESSION.BI_BITFIELDS) { - return biSize + 3 * 4; + return biSize + (3 * 4); } return biSize; diff --git a/ShareX.HelpersLib/ShareX.HelpersLib.csproj b/ShareX.HelpersLib/ShareX.HelpersLib.csproj index 60f754158..bad74283c 100644 --- a/ShareX.HelpersLib/ShareX.HelpersLib.csproj +++ b/ShareX.HelpersLib/ShareX.HelpersLib.csproj @@ -1312,6 +1312,9 @@ 11.0.2 + + 1.1.0-beta007 +