diff --git a/SchematicDrawing/SchematicDrawingCtrl.cs b/SchematicDrawing/SchematicDrawingCtrl.cs index 85766c456..c7a8564db 100644 --- a/SchematicDrawing/SchematicDrawingCtrl.cs +++ b/SchematicDrawing/SchematicDrawingCtrl.cs @@ -140,13 +140,7 @@ namespace SchematicDrawing } set { pipesS.Clear(); - if (value != null) - { - foreach (var pStr in value) - { - pipesS.Add(new Pipe(pStr, Sz.S, Id2Item)); - } - } + if (value != null) foreach (var pStr in value) pipesS.Add(new Pipe(pStr, Sz.S, Id2Item)); if (!supressRedraws) { @@ -158,22 +152,14 @@ namespace SchematicDrawing /// public string[] PipesM { - get - { + get { string[] retv = new string[pipesM.Count]; for (int i = 0; i < pipesM.Count; i++) retv[i] = pipesM[i].ToString(); return retv; } - set - { + set { pipesM.Clear(); - if (value != null) - { - foreach (var pStr in value) - { - pipesM.Add(new Pipe(pStr, Sz.M, Id2Item)); - } - } + if (value != null) foreach (var pStr in value) pipesM.Add(new Pipe(pStr, Sz.M, Id2Item)); if (!supressRedraws) { @@ -192,13 +178,7 @@ namespace SchematicDrawing } set { pipesL.Clear(); - if (value != null) - { - foreach (var pStr in value) - { - pipesL.Add(new Pipe(pStr, Sz.L, Id2Item)); - } - } + if (value != null) foreach (var pStr in value) pipesL.Add(new Pipe(pStr, Sz.L, Id2Item)); if (!supressRedraws) { @@ -217,13 +197,7 @@ namespace SchematicDrawing } set { pipesXL.Clear(); - if (value != null) - { - foreach (var pStr in value) - { - pipesXL.Add(new Pipe(pStr, Sz.XL, Id2Item)); - } - } + if (value != null) foreach (var pStr in value) pipesXL.Add(new Pipe(pStr, Sz.XL, Id2Item)); if (!supressRedraws) { @@ -669,7 +643,7 @@ namespace SchematicDrawing if (dshape.Shape == Shape.Scale) { Rectangle r = dshape.GetRotatedFlippedImageRectangle(item); - int level = (int)Math.Round((r.Height - 2) * msrdVal / itm.MsrdValLimHi); + int level = (int)Math.Round((r.Height - 2) * Math.Max(0, Math.Min(msrdVal, itm.MsrdValLimHi)) / itm.MsrdValLimHi); e.Graphics.FillRectangle(brushWater, r.X + 2, r.Y + r.Height - 2 - level, r.Width - 4, level); } @@ -720,10 +694,10 @@ namespace SchematicDrawing { string strVal = string.IsNullOrEmpty(its.SetpFormat) ? setpoint.ToString() : string.Format(its.SetpFormat, setpoint); SizeF size = (its.SetpUnit != Common.Unit.Pct) ? e.Graphics.MeasureString(strVal, setpointFont) - : e.Graphics.MeasureString(string.Format(its.SetpFormat, 100.0), setpointFont); + : e.Graphics.MeasureString(string.Format(its.SetpFormat, 100.0), setpointFont); Rectangle rect = new Rectangle(its.X + its.SetpX, its.Y + its.SetpY, (int)Math.Round(size.Width) + 4, (int)Math.Round(size.Height) + 2); ItemElementRectangles.Add(new ItemElementRect(item, Element.Setpoint, rect)); - int barLen = (int)Math.Round(rect.Width * setpoint / 100.0); + int barLen = (int)Math.Round(rect.Width * Math.Max(0, Math.Min(setpoint, 100.0)) / 100.0); e.Graphics.FillRectangle(setpointBackColor, rect.X, rect.Y, barLen, rect.Height); e.Graphics.DrawRectangle(thinBlackPen, rect); e.Graphics.DrawString(strVal, setpointFont, setpointBrush, rect.X + 2, rect.Y + 2); diff --git a/TBF/Rig/Modbus/PumpFM/DanfossVLT/Pump.cs b/TBF/Rig/Modbus/PumpFM/DanfossVLT/Pump.cs index fbf73d85c..5c061de96 100644 --- a/TBF/Rig/Modbus/PumpFM/DanfossVLT/Pump.cs +++ b/TBF/Rig/Modbus/PumpFM/DanfossVLT/Pump.cs @@ -164,14 +164,7 @@ namespace TBF.Rig.Modbus.PumpFM.DanfossVLT { if (args.Name == Name) { - if (args.Increase) - { - IncreaseSetpoint(); - } - else - { - DecreaseSetpoint(); - } + if (args.Increase) IncreaseSetpoint(); else DecreaseSetpoint(); } }; }