From 74d57ccc121944b33fbb8b80307ba3b3488779ff Mon Sep 17 00:00:00 2001 From: Jaex Date: Mon, 31 Aug 2020 12:53:04 +0300 Subject: [PATCH] CodeFactor refactors --- ShareX.HelpersLib/Forms/ColorPickerForm.cs | 2 +- ShareX.HelpersLib/Helpers/ClipboardHelpersEx.cs | 2 +- ShareX.HelpersLib/Helpers/ImageHelpers.cs | 4 ++-- .../Settings/DPAPIEncryptedStringValueProvider.cs | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ShareX.HelpersLib/Forms/ColorPickerForm.cs b/ShareX.HelpersLib/Forms/ColorPickerForm.cs index 81c47f6bf..db6821f26 100644 --- a/ShareX.HelpersLib/Forms/ColorPickerForm.cs +++ b/ShareX.HelpersLib/Forms/ColorPickerForm.cs @@ -80,7 +80,7 @@ public bool CheckClipboard() { colorPicker.ChangeColor(clipboardColor); btnClipboardStatus.Text = "Clipboard: " + text; - btnClipboardStatus.Location = new Point(btnClipboardColorPicker.Left + btnClipboardColorPicker.Width / 2 - btnClipboardStatus.Width / 2, + btnClipboardStatus.Location = new Point(btnClipboardColorPicker.Left + (btnClipboardColorPicker.Width / 2) - (btnClipboardStatus.Width / 2), btnClipboardColorPicker.Top - btnClipboardStatus.Height - 5); clipboardStatusHider.Show(); return true; diff --git a/ShareX.HelpersLib/Helpers/ClipboardHelpersEx.cs b/ShareX.HelpersLib/Helpers/ClipboardHelpersEx.cs index 3752a0796..ef0df1d16 100644 --- a/ShareX.HelpersLib/Helpers/ClipboardHelpersEx.cs +++ b/ShareX.HelpersLib/Helpers/ClipboardHelpersEx.cs @@ -296,7 +296,7 @@ public static Bitmap BuildImage(byte[] sourceData, int width, int height, int st int targetStride = targetData.Stride; long scan0 = targetData.Scan0.ToInt64(); for (int y = 0; y < height; y++) - Marshal.Copy(sourceData, y * stride, new IntPtr(scan0 + y * targetStride), newDataWidth); + Marshal.Copy(sourceData, y * stride, new IntPtr(scan0 + (y * targetStride)), newDataWidth); newImage.UnlockBits(targetData); // Fix negative stride on BMP format. if (isFlipped) diff --git a/ShareX.HelpersLib/Helpers/ImageHelpers.cs b/ShareX.HelpersLib/Helpers/ImageHelpers.cs index e5070e140..bc35a30c8 100644 --- a/ShareX.HelpersLib/Helpers/ImageHelpers.cs +++ b/ShareX.HelpersLib/Helpers/ImageHelpers.cs @@ -551,7 +551,7 @@ private static float DistanceToThreshold(UnsafeBitmap unsafeBitmap, int x, int y int maxx = Math.Min(x + radius, unsafeBitmap.Width - 1); int miny = Math.Max(y - radius, 0); int maxy = Math.Min(y + radius, unsafeBitmap.Height - 1); - int dist2 = radius * radius + 1; + int dist2 = (radius * radius) + 1; for (int tx = minx; tx <= maxx; tx++) { @@ -563,7 +563,7 @@ private static float DistanceToThreshold(UnsafeBitmap unsafeBitmap, int x, int y { int dx = tx - x; int dy = ty - y; - int test_dist2 = dx * dx + dy * dy; + int test_dist2 = (dx * dx) + (dy * dy); if (test_dist2 < dist2) { dist2 = test_dist2; diff --git a/ShareX.HelpersLib/Settings/DPAPIEncryptedStringValueProvider.cs b/ShareX.HelpersLib/Settings/DPAPIEncryptedStringValueProvider.cs index 7839e0849..64c1bcd3b 100644 --- a/ShareX.HelpersLib/Settings/DPAPIEncryptedStringValueProvider.cs +++ b/ShareX.HelpersLib/Settings/DPAPIEncryptedStringValueProvider.cs @@ -52,7 +52,6 @@ public object GetValue(object target) catch { } - } return value;