From 08083419b258164c8eb3169ffa398cc6cb1875ca Mon Sep 17 00:00:00 2001 From: Elias Ruemmler Date: Thu, 7 Mar 2019 19:40:08 +0100 Subject: [PATCH] Bugfix invalid pumpdefinition.xml --- FlowCalc/Controller.cs | 13 +++++++++++-- FlowCalc/Form1.cs | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/FlowCalc/Controller.cs b/FlowCalc/Controller.cs index 064f462..9610e56 100644 --- a/FlowCalc/Controller.cs +++ b/FlowCalc/Controller.cs @@ -66,11 +66,20 @@ public Controller() #endregion Constructor #region Services - public void LoadPump(string path) + public bool LoadPump(string path) { - Pump = Pump.FromFile(path); + try + { + Pump = Pump.FromFile(path); + } + catch (Exception) + { + return false; + } + PumpDefinitionPath = path; + return true; } public double CalcFlowRate(double pressure) diff --git a/FlowCalc/Form1.cs b/FlowCalc/Form1.cs index 5002a40..c820ae3 100644 --- a/FlowCalc/Form1.cs +++ b/FlowCalc/Form1.cs @@ -39,7 +39,7 @@ public Form1() if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.PumpDefinitionPath) && File.Exists(Properties.Settings.Default.PumpDefinitionPath)) { - m_Controller.LoadPump(Properties.Settings.Default.PumpDefinitionPath); + if (m_Controller.LoadPump(Properties.Settings.Default.PumpDefinitionPath)) applyPumpDefinition(); } }