From c4acd5e5bdc18c86c417880e01685d7cf28902aa Mon Sep 17 00:00:00 2001 From: AdmAlexus Date: Sat, 28 Oct 2017 16:00:30 +0500 Subject: Fix V3029 warnings from PVS-Studio Static Analyzer Hi! I'm a member of the Pinguem.ru competition on finding errors in open source projects. A bug, found using PVS-Studio. Warnings with low priority: --- Histacom2.Engine/Template/WinClassic.cs | 65 ++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/Histacom2.Engine/Template/WinClassic.cs b/Histacom2.Engine/Template/WinClassic.cs index 25cbfaa..39c7468 100644 --- a/Histacom2.Engine/Template/WinClassic.cs +++ b/Histacom2.Engine/Template/WinClassic.cs @@ -88,8 +88,11 @@ namespace Histacom2.Engine.Template { var toDraw = resizer.ToDraw; if (resizable) { - if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X); - if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.X = Cursor.Position.X; + if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) + { + toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X); + toDraw.X = Cursor.Position.X; + } } resizer.ToDraw = toDraw; } @@ -100,8 +103,11 @@ namespace Histacom2.Engine.Template if (e.Button == MouseButtons.Left) { var toDraw = resizer.ToDraw; - if (resizable) toDraw.Y = this.Location.Y; - if (resizable) toDraw.Height = MousePosition.Y - this.Location.Y; + if (resizable) + { + toDraw.Y = this.Location.Y; + toDraw.Height = MousePosition.Y - this.Location.Y; + } resizer.ToDraw = toDraw; } } @@ -111,8 +117,13 @@ namespace Histacom2.Engine.Template if (e.Button == MouseButtons.Left) { var toDraw = resizer.ToDraw; - if (resizable) if (MousePosition.X - this.Location.X > progContent.MinimumSize.Width + 8) toDraw.Width = MousePosition.X - this.Location.X; - if (resizable) toDraw.Height = MousePosition.Y - this.Location.Y; + if (resizable) + { + if (MousePosition.X - this.Location.X > progContent.MinimumSize.Width + 8) + toDraw.Width = MousePosition.X - this.Location.X; + toDraw.Height = MousePosition.Y - this.Location.Y; + } + resizer.ToDraw = toDraw; } } @@ -122,9 +133,15 @@ namespace Histacom2.Engine.Template if (e.Button == MouseButtons.Left) { var toDraw = resizer.ToDraw; - if (resizable) if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.Width = ((toDraw.Width + toDraw.Location.X) - Cursor.Position.X); - if (resizable) toDraw.Height = Cursor.Position.Y - this.Location.Y; - if (resizable) if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.X = Cursor.Position.X; + if (resizable) + { + if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) + { + toDraw.Width = ((toDraw.Width + toDraw.Location.X) - Cursor.Position.X); + toDraw.X = Cursor.Position.X; + } + toDraw.Height = Cursor.Position.Y - this.Location.Y; + } resizer.ToDraw = toDraw; } } @@ -134,10 +151,16 @@ namespace Histacom2.Engine.Template if (e.Button == MouseButtons.Left) { var toDraw = resizer.ToDraw; - if (resizable) if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X); - if (resizable) if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.X = Cursor.Position.X; - if (resizable) toDraw.Height = ((this.Height + this.Location.Y) - Cursor.Position.Y); - if (resizable) toDraw.Y = Cursor.Position.Y; + if (resizable) + { + if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) + { + toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X); + toDraw.X = Cursor.Position.X; + } + toDraw.Height = ((this.Height + this.Location.Y) - Cursor.Position.Y); + toDraw.Y = Cursor.Position.Y; + } resizer.ToDraw = toDraw; } } @@ -147,8 +170,11 @@ namespace Histacom2.Engine.Template if(e.Button == MouseButtons.Left) { var toDraw = resizer.ToDraw; - if (resizable) toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y); - if (resizable) toDraw.Y = Cursor.Position.Y; + if (resizable) + { + toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y); + toDraw.Y = Cursor.Position.Y; + } resizer.ToDraw = toDraw; } } @@ -158,9 +184,12 @@ namespace Histacom2.Engine.Template if (e.Button == MouseButtons.Left) { var toDraw = resizer.ToDraw; - if (resizable) if (MousePosition.X - this.Location.X > progContent.MinimumSize.Width + 8) toDraw.Width = MousePosition.X - this.Location.X; - if (resizable) toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y); - if (resizable) toDraw.Y = Cursor.Position.Y; + if (resizable) + { + if (MousePosition.X - this.Location.X > progContent.MinimumSize.Width + 8) toDraw.Width = MousePosition.X - this.Location.X; + toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y); + toDraw.Y = Cursor.Position.Y; + } resizer.ToDraw = toDraw; } } -- cgit v1.2.3