From 174f7baa166f13060889bf778e8fba88ffe1da08 Mon Sep 17 00:00:00 2001 From: Alex Z Date: Sat, 7 Mar 2020 02:11:22 +0300 Subject: [PATCH] project removing fix --- .../Model/ViewModel/FormProjectViewModel.cs | 2 +- src/UniversalValveToolbox/UI/FormProfiles.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/UniversalValveToolbox/Model/ViewModel/FormProjectViewModel.cs b/src/UniversalValveToolbox/Model/ViewModel/FormProjectViewModel.cs index 8e01695..8e31c6c 100644 --- a/src/UniversalValveToolbox/Model/ViewModel/FormProjectViewModel.cs +++ b/src/UniversalValveToolbox/Model/ViewModel/FormProjectViewModel.cs @@ -34,7 +34,7 @@ namespace UniversalValveToolbox.Model.ViewModel { ForceUpdateField(value, ref selectProjectIndex); OnPropertyChanged(nameof(SelectProject)); - var index = Math.Max(engines.ToList().FindIndex(engine => engine.Appid == SelectProject.Engine), 0); + var index = Math.Max(engines.ToList().FindIndex(engine => engine.Appid == SelectProject?.Engine), -1); SelectEngineIndex = index; } diff --git a/src/UniversalValveToolbox/UI/FormProfiles.cs b/src/UniversalValveToolbox/UI/FormProfiles.cs index eadc5cb..b1deeae 100644 --- a/src/UniversalValveToolbox/UI/FormProfiles.cs +++ b/src/UniversalValveToolbox/UI/FormProfiles.cs @@ -85,7 +85,8 @@ namespace UniversalValveToolbox { } private void comboBoxEngine_SelectedIndexChanged(object sender, EventArgs e) { - model.SelectProject.Engine = ((EngineDtoModel)comboBoxEngine.SelectedItem).Appid; + if (model.SelectProject != null) + model.SelectProject.Engine = ((EngineDtoModel)comboBoxEngine.SelectedItem).Appid; } private void comboBox_Mod_SelectedIndexChanged(object sender, EventArgs e) {