Index: Laser Gravering/nieuw/Laser Gravering_nieuw/Laser Gravering/Configs/ConfigXml/Configs.vb =================================================================== diff -u -r1940 -r1942 --- Laser Gravering/nieuw/Laser Gravering_nieuw/Laser Gravering/Configs/ConfigXml/Configs.vb (.../Configs.vb) (revision 1940) +++ Laser Gravering/nieuw/Laser Gravering_nieuw/Laser Gravering/Configs/ConfigXml/Configs.vb (.../Configs.vb) (revision 1942) @@ -28,17 +28,6 @@ Try Dim fs = New FileStream(_padNaarHoofdconfigBestand, FileMode.Open, FileAccess.Read, FileShare.Read) _configData = _xmlMapper.GetData(Of ConfigData)(fs) - - 'De properties die niet aanwezig waren wel initialiseren - For Each prop As PropertyInfo In _configData.GetType().GetProperties() - 'Enkel readable properties controleren - If prop.CanRead Then - If IsNothing(prop.GetValue(_configData, Nothing)) Then - 'Property was niet aanwezig, initialiseren - prop.SetValue(_configData, new ConfigProperty) - End If - End If - Next Catch ex As Exception Throw New Exception($"Kon configs niet laden{vbNewLine}{ex}") End Try @@ -53,7 +42,7 @@ For Each prop As PropertyInfo In type.GetProperties() 'Enkel readable properties controleren If prop.CanRead Then - dim val = DirectCast(prop.GetValue(_configData, Nothing), ConfigProperty).Waarde + Dim val = DirectCast(prop.GetValue(_configData, Nothing), ConfigProperty).Waarde If IsNothing(DirectCast(prop.GetValue(_configData, Nothing), ConfigProperty).Waarde) Then 'Lege property, toevoegen aan lijst nietGeconfigureerd.Add(prop.Name) @@ -95,6 +84,7 @@ Return ConverteerWaarde(Of String)(_configData.Scriptpad) End Get Set + ConfigUtil.PrepareForSetProperty(_configData.Scriptpad) ConfigUtil.StelNieuwFilePadIn(Value, _configData.Scriptpad) End Set End Property @@ -104,6 +94,7 @@ Return ConverteerWaarde(Of String)(_configData.BestandenMapPad) End Get Set + ConfigUtil.PrepareForSetProperty(_configData.Scriptpad) ConfigUtil.StelNieuwFolderPadIn(Value, _configData.BestandenMapPad) End Set End Property @@ -113,6 +104,7 @@ Return ConverteerWaarde(Of String)(_configData.JobControlExePad) End Get Set + ConfigUtil.PrepareForSetProperty(_configData.Scriptpad) ConfigUtil.StelNieuwFilePadIn(Value, _configData.JobControlExePad) End Set End Property @@ -122,12 +114,18 @@ Return ConverteerWaarde(Of String)(_configData.GraveerInstellingenXmlPad) End Get Set + ConfigUtil.PrepareForSetProperty(_configData.Scriptpad) ConfigUtil.StelNieuwFilePadIn(Value, _configData.GraveerInstellingenXmlPad) End Set End Property Private Class ConfigUtil + Public Shared sub PrepareForSetProperty(ByRef configP As ConfigProperty) + 'Initialiseren als property niet aanwezig was + If IsNothing(configP) Then configP = New ConfigProperty() + End sub + Public Shared Sub StelNieuwFilePadIn(value As String, ByRef configP As ConfigProperty) If Not IsNothing(value) AndAlso File.Exists(value) Then configP.Waarde = value Index: Laser Gravering/nieuw/Laser Gravering_nieuw/Laser Gravering/Formulieren/FormConfigsWijzigen.vb =================================================================== diff -u -r1940 -r1942 --- Laser Gravering/nieuw/Laser Gravering_nieuw/Laser Gravering/Formulieren/FormConfigsWijzigen.vb (.../FormConfigsWijzigen.vb) (revision 1940) +++ Laser Gravering/nieuw/Laser Gravering_nieuw/Laser Gravering/Formulieren/FormConfigsWijzigen.vb (.../FormConfigsWijzigen.vb) (revision 1942) @@ -13,22 +13,11 @@ _configs.InitInstellingen(My.Settings.PadNaarSettingsBestand) Catch mbcEx As MissingBaseConfigFileException - 'Laat de gebruiker een config bestand kiezen - If MessageBox.Show("Dit is waarschijnlijk de eerste keer dat u dit programma opstart. Gelieve een config bestand te selecteren.", "Nog geen config gekozen") <> DialogResult.OK Then Application.Exit() End If - - OpenFileDialog.Title = "Hoofd config bestand" - If OpenFileDialog.ShowDialog() = DialogResult.OK Then - My.Settings.PadNaarSettingsBestand = OpenFileDialog.FileName - My.Settings.Save() - Application.Restart() - Return - Else - Application.Exit() - Return - End If + 'Laat de gebruiker een config bestand kiezen + KiesHoofdConfig() Catch invC As InvalidConfigException If MessageBox.Show($"Er is een fout met een of meerdere configuraties: {vbNewLine}{invC.Message}") <> DialogResult.OK Then Application.Exit() @@ -37,6 +26,23 @@ ToonError(ex) End Try + ToonConfigs() + End Sub + + Private Sub KiesHoofdConfig() + OpenFileDialog.Title = "Hoofd config bestand" + If OpenFileDialog.ShowDialog() = DialogResult.OK Then + My.Settings.PadNaarSettingsBestand = OpenFileDialog.FileName + My.Settings.Save() + Application.Restart() + Return + Else + Application.Exit() + Return + End If + End Sub + + Private Sub ToonConfigs() Try TextBoxScriptPad.Text = If(_configs.ScriptPad, String.Empty) TextBoxBestandenMapPad.Text = If(_configs.BestandenMapPad, String.Empty)