Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 81525733 authored by Kostis ANAGNOSTOPOULOS's avatar Kostis ANAGNOSTOPOULOS
Browse files

COMPLETE Switch Config-setings to JSON, separate config/ folder (recreated on...

COMPLETE Switch Config-setings to JSON, separate config/ folder (recreated on startup) from Declaration/ one

* Store WorkingDir as relative to App's Path.
* Selected Editor done via System.Diagnostics.Process.Start and  editor.exe instead of Shell and Path for notepad.exe.
* Minor GUI-work (set icons to dialogs)
parent 817c9759
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"
culture="neutral"/>
<bindingRedirect oldVersion="4.5.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>
......@@ -15,6 +16,21 @@
<MyType>WindowsForms</MyType>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
......@@ -24,7 +40,9 @@
<DefineTrace>true</DefineTrace>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>CSE.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</NoWarn>
<WarningsAsErrors>
</WarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
......@@ -34,7 +52,9 @@
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>CSE.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</NoWarn>
<WarningsAsErrors>
</WarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
......@@ -52,7 +72,8 @@
<ApplicationIcon>Resources\CSE.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libs\JSON.Net\Net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
......@@ -251,6 +272,28 @@
<ItemGroup>
<None Include="Resources\Licencefile.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
Imports Newtonsoft.Json.Linq
Option Strict Off
Imports Newtonsoft.Json.Linq
Imports Newtonsoft.Json.Schema
Public Class cSettings
......@@ -9,116 +11,124 @@ Public Class cSettings
End Function
' A 'true' | 'false' string used by json-schema validation, when false, more strict validation
Private schema_AllowsAdditionalProps As String
Public Json_Contents As JObject
Private Json_Contents As JObject
' Default-settings specified here.
Private ReadOnly JsonStr_Contents As String = <json>{
"Header": {
"FileVersion": "1.0"
},
"Body": {
"WorkingDir": null,
"WriteLog": true,
"LogSize": 2,
"LogLevel": 5,
"Editor": "notepad.exe",
}
}</json>.Value
Private JSchema As JsonSchema
Private ReadOnly JSchemaStr As String = <json>{
Function JsonStr_Contents() As String
Return <json>{
"Header": {
"FileVersion": "1.0",
"Strict": false,
},
"Body": {
"WorkingDir": null,
"WriteLog": true,
"LogSize": 2,
"LogLevel": 5,
"Editor": "notepad.exe",
}
}</json>.Value
End Function
''' <param name="allowsAdditionalProps">when false, more strict validation</param>
Function JSchemaStr(ByVal allowsAdditionalProps As Boolean) As String
Dim allowsAdditionalProps_str As String = IIf(allowsAdditionalProps, "false", "true")
Return <json>{
"title": "Vecto_cse-settings.ver1.0",
"type": "object", "AllowAdditionalProperties": <%= schema_AllowsAdditionalProps %>,
"required": ["Header", "Body"]
"type": "object", "AllowAdditionalProperties": <%= allowsAdditionalProps_str %>,
"properties": {
"Header": {
"type": "object", "AllowAdditionalProperties": <%= schema_AllowsAdditionalProps %>,
"required": ["FileVersion"]
"type": "object", "AllowAdditionalProperties": <%= allowsAdditionalProps_str %>,
"required": true,
"properties": {
"FileVersion": {"type": "string"}
"FileVersion": {
"type": "string",
"required": true,
},
"Strict": {
"type": "boolean",
"required": true,
"default": false,
}
}
},
"Body": {
"type": "object", "AllowAdditionalProperties": <%= schema_AllowsAdditionalProps %>,
"required": ["WorkingDir", "WriteLog", "LogSize", "LogLevel", "Editor"]
"type": "object", "AllowAdditionalProperties": <%= allowsAdditionalProps_str %>,
"required": true,
"properties": {
"WorkingDir": {
"type": "string",
"description": "Last used Working Directory Path for input/output files" (default: null - 'use app's dir')",
"type": ["string", "null"],
"required": false,
"default": null,
"description": "Last used Working Directory Path for input/output files, when null/empty, uses app's dir (default: null)",
},
"WriteLog": {
"type": "boolean",
"required": true,
"description": "Whether to write messages to log file (default: true)",
},
"LogSize": {
"type": "integer"
"type": "integer",
"required": true,
"description": "Allowed Log-file size limit [MiB] (default: 2)",
},
"LogLevel": {
"type": "integer"
"type": "integer",
"required": true,
"description": "Message Output Level (default: 5 - 'info')",
},
"Editor": {
"type": "string",
"required": true,
"description": "Path (or filename if in PATH) of some (text or JSON) editor (default: 'notepad.exe')",
},
}
}
}
}</json>.Value
End Function
''' <summary>
''' Reads from file or creates defaults
''' </summary>
''' <summary>Reads from file or creates defaults</summary>
''' <param name="inputFilePath">If unspecifed, default settings used, otherwise data read from file</param>
''' <param name="isStrict">when True, no additional json-properties allowed in the data</param>
''' <remarks></remarks>
Friend Sub New(Optional ByVal inputFilePath As String = Nothing, Optional ByVal isStrict As Boolean = False)
Me.schema_AllowsAdditionalProps = IIf(isStrict, "false", "true")
Me.JSchema = JsonSchema.Parse(JSchemaStr)
Dim validateMsgs As IList(Of String) = New List(Of String)
If (inputFilePath Is Nothing) Then '' Read defaults
ReadAndValidateJsonText(JsonStr_Contents, JSchema, validateMsgs)
Else '' Read from file
Me.Json_Contents = ReadAndValidateJsonFile(inputFilePath, JSchema, validateMsgs)
fInfWarErr(7, False, format("Read Settings({0}).", inputFilePath))
End If
If (validateMsgs.Any()) Then
Throw New SystemException(format("Invalid Settings({0}) due to: \n\i{1}", inputFilePath, String.Join(vbCrLf, validateMsgs)))
Sub New(Optional ByVal inputFilePath As String = Nothing)
If (inputFilePath Is Nothing) Then
Me.Json_Contents = JObject.Parse(JsonStr_Contents())
Else
Me.Json_Contents = ReadJsonFile(inputFilePath)
End If
End Sub
' Writing to the config file
''' <summary>Validates and Writing to the config file</summary>
Sub Store(ByVal settings_fpath As String)
Dim basedir As String = System.IO.Path.GetDirectoryName(settings_fpath)
Validate(Me.Strict)
WriteJsonFile(settings_fpath, Json_Contents)
End Sub
If (Not System.IO.Directory.Exists(basedir)) Then
System.IO.Directory.CreateDirectory(basedir)
End If
' Validate settings
'
Dim jschema As JsonSchema = JsonSchema.Parse(JSchemaStr)
Json_Contents.Validate(jschema)
''' <exception cref="SystemException">includes all validation errors</exception>
''' <param name="isStrict">when True, no additional json-properties allowed in the data, when nothing, use value from Header</param>
Friend Sub Validate(Optional ByVal isStrict As Boolean? = Nothing)
Dim allowsAdditionalProps As Boolean = IIf(isStrict Is Nothing, Me.Strict, Not isStrict)
Dim schema = JsonSchema.Parse(JSchemaStr(allowsAdditionalProps))
Dim validateMsgs As IList(Of String) = New List(Of String)
WriteJsonFile(settings_fpath, Json_Contents)
ValidateJson(Me.Json_Contents, schema, validateMsgs)
fInfWarErr(7, False, "Writting settings to file: " & settings_fpath)
If (validateMsgs.Any()) Then
Throw New SystemException(format("Invalid Settings due to: {0}", String.Join(vbCrLf, validateMsgs)))
End If
End Sub
Public Overrides Function Equals(ByVal obj As Object) As Boolean
If obj Is Nothing OrElse Not Me.GetType().Equals(obj.GetType()) Then
Return False
Else
Return Me.Json_Contents.Equals(obj.Json_Contents)
Return Me.Json_Contents.Equals(DirectCast(obj, cSettings).Json_Contents)
End If
End Function
......@@ -130,20 +140,58 @@ Public Class cSettings
End Get
End Property
Public ReadOnly Property Strict As Boolean
Get
Return Me.Json_Contents("Header")("Strict")
End Get
End Property
Public Property WorkingDir As String
Get
Dim value As String = Me.Json_Contents("Body")("WorkingDir")
If value Is Nothing Or value.Trim().Length = 0 Then
If value Is Nothing OrElse value.Trim().Length = 0 Then
value = MyPath
End If
Return value
End Get
Set(ByVal value As String)
If Not value Is Nothing And value.Trim().Length = 0 Then
value = Nothing
If value IsNot Nothing Then
'' Convert emtpy-paths into MyPath and store them as null.
''
value = value.Trim()
If value.Length = 0 Then
value = Nothing
Else
'' Convert MyPath-prefixed paths into relative ones.
''
Dim myPlainPath = IO.Path.GetFullPath(StripBackslash(MyPath))
value = IO.Path.GetFullPath(value)
If value.StartsWith(myPlainPath, StringComparison.OrdinalIgnoreCase) Then
value = value.Substring(myPlainPath.Length)
If (value.Last <> "\"c) Then
value = value & "\"
End If
If value.Length = 1 Then
value = Nothing
End If
End If
'' Store MyPath as null.
''
If String.Equals(value, MyPath, StringComparison.OrdinalIgnoreCase) Then
value = Nothing
End If
End If
End If
If value Is Nothing Then
Me.Json_Contents("Body")("WorkingDir") = Nothing
Else
Me.Json_Contents("Body")("WorkingDir") = value
End If
Me.Json_Contents("Body")("WorkingDir") = value
End Set
End Property
......@@ -179,6 +227,10 @@ Public Class cSettings
Return Me.Json_Contents("Body")("Editor")
End Get
Set(ByVal value As String)
If value Is Nothing OrElse value.Trim().Length = 0 Then
value = "notepad.exe"
End If
Me.Json_Contents("Body")("Editor") = value
End Set
End Property
......
......@@ -29,9 +29,11 @@ Public Class CSEMain
'
Dim settings_fpath = cSettings.SettingsPath()
Try
AppSettings = New cSettings(settings_fpath)
Dim fileSettings As New cSettings(settings_fpath)
fileSettings.Validate()
AppSettings = fileSettings
Catch ex As Exception
fInfWarErr(9, False, format("Failed reading Settings({0}) due to: {1}", settings_fpath, ex.Message))
fInfWarErr(9, False, format("Failed loading Settings({0}) due to: {1}", settings_fpath, ex.Message))
configL = False
End Try
......@@ -42,9 +44,8 @@ Public Class CSEMain
' Polling if the working dir exist (If not then generate the folder)
'
Dim wd_fPath As String = MyPath & AppSettings.WorkingDir
If Not IO.Directory.Exists(wd_fPath) Then
MkDir(wd_fPath)
If Not IO.Directory.Exists(AppSettings.WorkingDir) Then
IO.Directory.CreateDirectory(AppSettings.WorkingDir)
End If
' Write the beginning in the AppSettings.WriteLog
......@@ -61,8 +62,9 @@ Public Class CSEMain
If Not configL Then
Try
AppSettings.Store(settings_fpath)
fInfWarErr(7, False, format("Created Settings({0}).", settings_fpath))
Catch ex As Exception
fInfWarErr(9, False, format("Failed writting settings({0} due to: {1}", settings_fpath, ex.Message))
fInfWarErr(9, False, format("Failed storing Settings({0}) due to: {1}", settings_fpath, ex.Message))
End Try
End If
End Sub
......
......@@ -22,6 +22,7 @@ Partial Class CSE_Config
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(CSE_Config))
Me.TextBoxWorDir = New System.Windows.Forms.TextBox()
Me.ButtonSelectWorDir = New System.Windows.Forms.Button()
Me.GroupBoxWorDir = New System.Windows.Forms.GroupBox()
......@@ -164,8 +165,8 @@ Partial Class CSE_Config
'TabControl1
'
Me.TabControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.TabControl1.Controls.Add(Me.TabPage2)
Me.TabControl1.Location = New System.Drawing.Point(3, 3)
Me.TabControl1.Name = "TabControl1"
......@@ -195,7 +196,7 @@ Partial Class CSE_Config
Me.GroupBoxNotepad.Size = New System.Drawing.Size(490, 51)
Me.GroupBoxNotepad.TabIndex = 3
Me.GroupBoxNotepad.TabStop = False
Me.GroupBoxNotepad.Text = "Notepad Directory"
Me.GroupBoxNotepad.Text = "Editor"
'
'ButtonSelectNotepad
'
......@@ -214,7 +215,7 @@ Partial Class CSE_Config
Me.TextBoxNotepad.Size = New System.Drawing.Size(444, 20)
Me.TextBoxNotepad.TabIndex = 1
'
'VECTO_Config
'CSE_Config
'
Me.AcceptButton = Me.ButtonOK
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
......@@ -225,10 +226,11 @@ Partial Class CSE_Config
Me.Controls.Add(Me.ButtonCancel)
Me.Controls.Add(Me.ButtonOK)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.MinimumSize = New System.Drawing.Size(521, 294)
Me.Name = "VECTO_Config"
Me.Name = "CSE_Config"
Me.Text = "Settings"
Me.GroupBoxWorDir.ResumeLayout(False)
Me.GroupBoxWorDir.PerformLayout()
......
......@@ -117,4 +117,44 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAIA8AAAEAIADkBwAAFgAAACgAAAAgAAAAHgAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAD+/v6v////////////////v7/U/3Z2yP9OTsv/Tk7L/2Zmx/+qqs/////4////////////2NjY/7W1
tf+srKz/rKys/62trf+/v7//9PT0//////////////////X1+f+Ojsf/hYXK/4iIzP+IiMz/iIjM/4iI
zP+Cgsf/wsLj//7+/qP/////6eni/0lJuv8AANz/AAD+/wAA//8AAP//AAD//wAA7f8lJbn/6Ojo/7y8
uv+bm5v/u7u7/76+vv+7u7v/wMDA/7CwsP+Xl5f/0NDQ////////////iIi4/wAA4f8AAPf/AAD//wAA
//8AAP//AAD//wAA/v8zM8T//v7+o///+v8/P7j/AAD7/wAA//8AAOv/JCS+/zs7tP8tLbz/AADe/wAA
2v+3t8j/ra2m/6ampv+ampr/m5ub/6CgoP+ampr/vLy8/8XFxf+Wlpb/5+fn//////+Cgrv/AADx/wAA
//8WFsL/MzO7/zMzu/8zM7v/NDS7/4aGxv/+/v6juLjV/wAA4/8AAP//AADl/4qKvP/39+P////y//7+
6f/Dw8//XV2p/93d5//IyMb/q6ur/+Pj4//8/Pz//////+jo6P+ampr/xMTE/6Wlpf+4uLj//////4SE
u/8AAPD/AAD6/3BwrP////D////w////8P////D////9//7+9aNfX8j/AAD//wAA/f9MTLb////4////
////////////////////////////////////////////////////////+vr6/5iYmP/AwMD/rq6u/62t
rf//////hIS7/wAA8P8AAPr/b2+6////////////////////////////8vLZozY20f8AAP//AADo/5yc
vv///////////////////////////////////////////////////////Pz8/83Nzf+goKD/s7Oz/8fH
x/+jo6P/vLy8//////+EhLv/AADw/wAA+v9wcK3////x////8v////H////6///////c3MujIiLY/wAA
//8AANr/vr7H/////////////////////////////////////////////////9LS0v+bm5v/nJyc/7q6
uv/Jycn/ubm5/5qamv/y8vL//////4SEu/8AAO//AAD+/xsbwv9CQrj/Pz+9/zs7uv9VVa//+/v3/97e
zaMkJNf/AAD//wAA3f+2tsb////////////////////////////////////////////Dw8P/mZmZ/7u7
u//Kysr/vr6+/6Kiov+dnZ3/5eXl////////////hIS7/wAA7v8AAP//AAD//wAA+f8AAPn/AAD6/wAA
vf/z8+v/9fXcozk50P8AAP//AADp/5eXvv//////////////////////////////////////4eHh/5WV
lf/FxcX/w8PD/6Ojo/+ampr/v7+///j4+P////////////////+EhLv/AADv/wAA/f8zM67/d3e2/3Z2
uv9zc7j/kZG+/////f/+/vijamrI/wAA/f8AAPv/WFi2////+///////////////////////////////
//+3t7j/pqam/8bGxv+ioqL/wsLC//n5+f///////////////////////////4SEu/8AAPD/AAD6/3V1
tv////////////////////////////7+/qPJydr/AADc/wAA//8EBNv/sLDC////9//////////7/+Li
3v+Dg7L/7+/z/7y8u/+oqKj/wsLC/5WVlf/////////////////m5ub/5ubm////////////hIS7/wAA
8P8AAPr/dna2/////////////////////////////v7+o////f9QULj/AAD4/wAA//8DA9n/Vla1/3p6
uP9cXLX/ExPN/wAAy//Hx9L/4uLe/5iYmP/Ly8v/qamp/6qqqv+5ubn/p6en/5SUlP+YmJj/////////
//+Dg7v/AADw/wAA/f80NK//eXm4/3l5uP95ebj/eXm4/7W10f/+/v6j//////Dw5v9ISLv/AADi/wAA
//8AAP//AAD//wAA//8AAP//CgrA/93d2v//////ra2t/6Ghof/Dw8P/tra2/6ysrP+3t7f/tbW1/5ub
m//+/v7//////4CAt/8AAPD/AAD//wAA//8AAP3/AAD9/wAA/f8AAP3/OzvA//7+/q//////////////
//+ystP/WVnI/y4u1P8hIdv/NjbR/29vx//d3eb/////////////////z8/P/62trf+tra3/r6+v/6ys
rP+wsLD/8PDw////////////4ODr/1JSxf9DQ87/RkbR/0ZG0f9GRtH/RkbR/0FBzP+goNz//v7+aP7+
/qP+/v6j/v7+o/7+/qP+/vGj6enTo9nZy6Px8dij/v77o/7+/qP+/v6j/v7+o/7+/qP+/v6j8vLyo9DQ
0KPKysqj3t7eo/7+/qP+/v6j/v7+o/7+/qP+/v6j/v7to/7+4aP+/uOj/v7jo/7+46P+/uOj/v7ho/7+
/qMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAA
AAA=
</value>
</data>
</root>
\ No newline at end of file
......@@ -20,6 +20,7 @@ Public Class CSE_Config
Private Function settings_PopulateTo() As cSettings
Dim value = New cSettings()
value.Validate()
value.WorkingDir = Me.TextBoxWorDir.Text
value.Editor = Me.TextBoxNotepad.Text
......@@ -52,11 +53,11 @@ Public Class CSE_Config
' Message for the restart of VECTO
RestartN = True
fInfWarErr(7, False, "Settings changed. Please restart to use the new settings!") ' XXX: Why double-log for restartng-vecto here??
fInfWarErr(7, True, format("Settings changed. Please restart to use the new settings!\n Do you want to restart VECTO now?"))
fInfWarErr(7, False, "Settings changed. Please restart to use the new Settings!") ' XXX: Why double-log for restartng-vecto here??
fInfWarErr(7, True, format("Settings changed. Please restart to use the new Settings!\n Do you want to restart VECTO now?"))
Catch ex As Exception
fInfWarErr(9, False, format("Failed writting settings({0} due to: {1}", settings_fpath, ex.Message))
fInfWarErr(9, False, format("Failed storing Settings({0}) due to: {1} \n Settings left unmodified!", settings_fpath, ex.Message))
End Try
End If
......@@ -71,8 +72,8 @@ Public Class CSE_Config
' Select the Notepad path
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSelectNotepad.Click
If fbWorkDir.OpenDialog(Me.TextBoxWorDir.Text) Then
Me.TextBoxNotepad.Text = fbWorkDir.Files(0)
If fbExe.OpenDialog(Me.TextBoxWorDir.Text) Then
Me.TextBoxNotepad.Text = fbExe.Files(0)
End If
End Sub
......
......@@ -22,6 +22,7 @@ Partial Class CSE_Info
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(CSE_Info))
Me.Label1 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
......@@ -127,7 +128,7 @@ Partial Class CSE_Info
Me.Label8.Size = New System.Drawing.Size(158, 65)
Me.Label8.TabIndex = 3
Me.Label8.Text = "European Commission" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "DG CLIMA" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "and" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Joint Research Centre" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Sustainable Transport " & _
"Unit" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
"Unit" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
'
'PictureBoxJRC
'
......@@ -278,6 +279,7 @@ Partial Class CSE_Info
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximumSize = New System.Drawing.Size(480, 591)
Me.MinimumSize = New System.Drawing.Size(480, 591)
Me.Name = "CSE_Info"
......
......@@ -117,4 +117,44 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAIA8AAAEAIADkBwAAFgAAACgAAAAgAAAAHgAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAD+/v6v////////////////v7/U/3Z2yP9OTsv/Tk7L/2Zmx/+qqs/////4////////////2NjY/7W1
tf+srKz/rKys/62trf+/v7//9PT0//////////////////X1+f+Ojsf/hYXK/4iIzP+IiMz/iIjM/4iI
zP+Cgsf/wsLj//7+/qP/////6eni/0lJuv8AANz/AAD+/wAA//8AAP//AAD//wAA7f8lJbn/6Ojo/7y8
uv+bm5v/u7u7/76+vv+7u7v/wMDA/7CwsP+Xl5f/0NDQ////////////iIi4/wAA4f8AAPf/AAD//wAA
//8AAP//AAD//wAA/v8zM8T//v7+o///+v8/P7j/AAD7/wAA//8AAOv/JCS+/zs7tP8tLbz/AADe/wAA
2v+3t8j/ra2m/6ampv+ampr/m5ub/6CgoP+ampr/vLy8/8XFxf+Wlpb/5+fn//////+Cgrv/AADx/wAA
//8WFsL/MzO7/zMzu/8zM7v/NDS7/4aGxv/+/v6juLjV/wAA4/8AAP//AADl/4qKvP/39+P////y//7+
6f/Dw8//XV2p/93d5//IyMb/q6ur/+Pj4//8/Pz//////+jo6P+ampr/xMTE/6Wlpf+4uLj//////4SE
u/8AAPD/AAD6/3BwrP////D////w////8P////D////9//7+9aNfX8j/AAD//wAA/f9MTLb////4////
////////////////////////////////////////////////////////+vr6/5iYmP/AwMD/rq6u/62t
rf//////hIS7/wAA8P8AAPr/b2+6////////////////////////////8vLZozY20f8AAP//AADo/5yc
vv///////////////////////////////////////////////////////Pz8/83Nzf+goKD/s7Oz/8fH
x/+jo6P/vLy8//////+EhLv/AADw/wAA+v9wcK3////x////8v////H////6///////c3MujIiLY/wAA
//8AANr/vr7H/////////////////////////////////////////////////9LS0v+bm5v/nJyc/7q6
uv/Jycn/ubm5/5qamv/y8vL//////4SEu/8AAO//AAD+/xsbwv9CQrj/Pz+9/zs7uv9VVa//+/v3/97e
zaMkJNf/AAD//wAA3f+2tsb////////////////////////////////////////////Dw8P/mZmZ/7u7
u//Kysr/vr6+/6Kiov+dnZ3/5eXl////////////hIS7/wAA7v8AAP//AAD//wAA+f8AAPn/AAD6/wAA
vf/z8+v/9fXcozk50P8AAP//AADp/5eXvv//////////////////////////////////////4eHh/5WV
lf/FxcX/w8PD/6Ojo/+ampr/v7+///j4+P////////////////+EhLv/AADv/wAA/f8zM67/d3e2/3Z2
uv9zc7j/kZG+/////f/+/vijamrI/wAA/f8AAPv/WFi2////+///////////////////////////////
//+3t7j/pqam/8bGxv+ioqL/wsLC//n5+f///////////////////////////4SEu/8AAPD/AAD6/3V1
tv////////////////////////////7+/qPJydr/AADc/wAA//8EBNv/sLDC////9//////////7/+Li
3v+Dg7L/7+/z/7y8u/+oqKj/wsLC/5WVlf/////////////////m5ub/5ubm////////////hIS7/wAA
8P8AAPr/dna2/////////////////////////////v7+o////f9QULj/AAD4/wAA//8DA9n/Vla1/3p6
uP9cXLX/ExPN/wAAy//Hx9L/4uLe/5iYmP/Ly8v/qamp/6qqqv+5ubn/p6en/5SUlP+YmJj/////////
//+Dg7v/AADw/wAA/f80NK//eXm4/3l5uP95ebj/eXm4/7W10f/+/v6j//////Dw5v9ISLv/AADi/wAA
//8AAP//AAD//wAA//8AAP//CgrA/93d2v//////ra2t/6Ghof/Dw8P/tra2/6ysrP+3t7f/tbW1/5ub
m//+/v7//////4CAt/8AAPD/AAD//wAA//8AAP3/AAD9/wAA/f8AAP3/OzvA//7+/q//////////////
//+ystP/WVnI/y4u1P8hIdv/NjbR/29vx//d3eb/////////////////z8/P/62trf+tra3/r6+v/6ys
rP+wsLD/8PDw////////////4ODr/1JSxf9DQ87/RkbR/0ZG0f9GRtH/RkbR/0FBzP+goNz//v7+aP7+
/qP+/v6j/v7+o/7+/qP+/vGj6enTo9nZy6Px8dij/v77o/7+/qP+/v6j/v7+o/7+/qP+/v6j8vLyo9DQ
0KPKysqj3t7eo/7+/qP+/v6j/v7+o/7+/qP+/v6j/v7to/7+4aP+/uOj/v7jo/7+46P+/uOj/v7ho/7+
/qMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAA
AAA=
</value>
</data>
</root>
\ No newline at end of file
......@@ -29,18 +29,19 @@
' Declaration
Dim fiAss As New IO.FileInfo(joinPaths(Application.Info.DirectoryPath, Application.Info.AssemblyName & ".exe"))
' compile date
AppDate = fiAss.LastWriteTime.Date
' Path to the *.exe
MyPath = My.Application.Info.DirectoryPath & "\"
' Generateion of folder for the file history if not exists
FB_FilHisDir = joinPaths(MyPath, "config", "fileHistory\")
If Not IO.Directory.Exists(FB_FilHisDir) Then IO.Directory.CreateDirectory(FB_FilHisDir)
' compile date
AppDate = fiAss.LastWriteTime.Date
AppSettings = New cSettings()
''AppSettings.Validate() !!!Skip schema-validation here, or else app hangs as zombie! (do it instead when creating new for Dialog)
' Licencemodul
Lic.FilePath = joinPaths(MyPath, "License.dat")
Lic.AppVersion = AppVers
......@@ -52,6 +53,9 @@
fbTXT = New cFileBrowser("TXT")
fbTXT.Extensions = New String() {"txt"}
fbExe = New cFileBrowser("EXE")
fbExe.Extensions = New String() {"exe"}
fbCSV = New cFileBrowser("CSV")
fbCSV.Extensions = New String() {"csv", "txt"}
......
......@@ -64,6 +64,16 @@ Module Minor_routines
Return obj.Aggregate(Function(x, y) IO.Path.Combine(x.ToString(), y.ToString()))
End Function
Function StripBackslash(ByVal path As String) As String
If path Is Nothing Then
Return Nothing
ElseIf (path.Last = "\"c) Then
Return path.Substring(0, path.Length - 1)
Else
Return path
End If
End Function
#End Region ' File paths'
' Function for a linear interpolation
......@@ -266,7 +276,7 @@ Module Minor_routines
#End Region
#Region "Json IO"
#Region "Json"
Function ReadJsonFile(ByVal path As String) As JObject
Dim jobj As New JObject
......@@ -282,7 +292,7 @@ Module Minor_routines
Dim validator As New JsonValidatingReader(New JsonTextReader(reader))
validator.Schema = jschema
AddHandler validator.ValidationEventHandler, Sub(o, a) validationMsgs.Add(a.Message)
AddHandler validator.ValidationEventHandler, Sub(o, a) validationMsgs.Add(format("{0}-->{1}", a.Path, a.Message))
Dim jobj As JObject = JObject.ReadFrom(validator)
......@@ -295,7 +305,7 @@ Module Minor_routines
Dim validator As New JsonValidatingReader(New JsonTextReader(reader))
validator.Schema = jschema
AddHandler validator.ValidationEventHandler, Sub(o, a) validationMsgs.Add(a.Message)
AddHandler validator.ValidationEventHandler, Sub(o, a) validationMsgs.Add(format("{0}-->{1}", a.Path, a.Message))
Dim jobj As JObject = JObject.ReadFrom(validator)
......@@ -303,6 +313,10 @@ Module Minor_routines
End Using
End Function
Sub ValidateJson(ByVal json As JObject, ByVal jschema As JsonSchema, ByVal validationMsgs As IList(Of String))
json.Validate(jschema, Sub(o, a) validationMsgs.Add(format("{0}-->{1}", a.Path, a.Message)))
End Sub
Sub WriteJsonFile(ByVal path As String, ByVal content As Object, Optional ByVal formatting As Formatting = Formatting.Indented)
Dim jser As New JsonSerializer
jser.Formatting = formatting
......@@ -329,7 +343,7 @@ Module Minor_routines
Return value
End Function
#End Region ' "Json IO"
#End Region ' "Json"
#Region "Strings"
......
......@@ -88,7 +88,7 @@
Public GradC As Boolean = False ' Variable for the gradient correction
Public AppSettingsFName As String = "settings.json"
Public AppSettings As cSettings = New cSettings() ' Default settings
Public AppSettings As cSettings
'File browser
Public FB_Drives() As String
......@@ -101,6 +101,7 @@
Public fbCSV As cFileBrowser
Public fbDir As cFileBrowser
Public fbWorkDir As cFileBrowser
Public fbExe As cFileBrowser
Public fbVEH As cFileBrowser
Public fbAMB As cFileBrowser
Public fbALT As cFileBrowser
......
No preview for this file type
This diff is collapsed.
Json.NET
http://james.newtonking.com/projects/json-net.aspx
http://www.codeplex.com/json/
http://james.newtonking.com/json
http://www.codeplex.com/json
https://github.com/JamesNK/Newtonsoft.Json
......@@ -24,7 +24,7 @@ http://james.newtonking.com/projects/json/help/
Versions:
Json.NET has different libaries for the various .NET Framework versions.
Json.NET has different libraries for the various .NET Framework versions.
-Net45:
.NET latest (4.5)
......@@ -45,12 +45,10 @@ Json.NET has different libaries for the various .NET Framework versions.
.NET 4.5, Windows Phone 8, Windows 8 Store
-Portable40:
.NET 4.0, Windows Phone 7, Windows 8 Store, Silverlight 4
.NET 4.0, Windows Phone 8, Windows 8 Store, Silverlight 5, MonoTouch, MonoDroid
Notes:
Microsoft stopped support for the Compact Framework in Visual Studio 2010.
For a Compact Framework 3.5 build download Json.NET 3.5.
For a Silverlight 3.0 build download Json.NET 3.5.
\ No newline at end of file
For a Compact Framework 3.5 and Silverlight 3.0 builds download Json.NET 3.5
For a Silverlight 4.0 and Windows Phone 7 builds download Json.NET 5
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment