Rewrite of new configuration creation to vb code

* Translation of Connections and New Connections
This commit is contained in:
Andreas Rehm
2010-05-25 18:56:49 +02:00
parent e874292016
commit 9878acff9a
5 changed files with 31 additions and 32 deletions

View File

@@ -2,6 +2,7 @@
Imports System.IO
Imports Crownwood
Imports System.Threading
Imports System.Xml
Namespace App
Public Class Runtime
@@ -640,37 +641,29 @@ Namespace App
#End Region
#Region "Connections Loading/Saving"
Public Shared Sub NewConnections()
Public Shared Sub NewConnections(ByVal filename As String)
Try
cL = New Connection.List
ctL = New Container.List
Dim conL As New Config.Connections.Load
If File.Exists(App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile) = False Then
If Directory.Exists(App.Info.Connections.DefaultConnectionsPath) = False Then
Directory.CreateDirectory(App.Info.Connections.DefaultConnectionsPath)
End If
My.Settings.LoadConsFromCustomLocation = False
File.Copy(My.Application.Info.DirectoryPath & "\" & App.Info.Connections.DefaultConnectionsFileNew, App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile)
conL.ConnectionFileName = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile
My.Settings.LoadConsFromCustomLocation = False
Else
Dim lD As SaveFileDialog = Tools.Controls.ConnectionsSaveAsDialog
If lD.ShowDialog = System.Windows.Forms.DialogResult.OK Then
File.Copy(My.Application.Info.DirectoryPath & "\" & App.Info.Connections.DefaultConnectionsFileNew, lD.FileName, True)
conL.ConnectionFileName = lD.FileName
Dim xW As New XmlTextWriter(filename, System.Text.Encoding.UTF8)
xW.Formatting = Formatting.Indented
xW.Indentation = 4
If conL.ConnectionFileName = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile Then
My.Settings.LoadConsFromCustomLocation = False
Else
My.Settings.LoadConsFromCustomLocation = True
My.Settings.CustomConsPath = conL.ConnectionFileName
End If
Else
Exit Sub
End If
End If
xW.WriteStartDocument()
xW.WriteStartElement(My.Resources.strConnections)
xW.WriteAttributeString("Export", "", "False")
xW.WriteAttributeString("Protected", "", "GiUis20DIbnYzWPcdaQKfjE2H5jh//L5v4RGrJMGNXuIq2CttB/d/BxaBP2LwRhY")
xW.WriteAttributeString("ConfVersion", "", "2.2")
xW.WriteEndElement()
xW.WriteEndDocument()
xW.Close()
conL.ConnectionList = cL
conL.ContainerList = ctL
@@ -680,6 +673,8 @@ Namespace App
conL.RootTreeNode = Windows.treeForm.tvConnections.Nodes(0)
' Load config
conL.ConnectionFileName = filename
conL.Load()
Catch ex As Exception
mC.AddMessage(Messages.MessageClass.ErrorMsg, My.Resources.strCouldNotCreateNewConnectionsFile & vbNewLine & ex.Message)
@@ -750,7 +745,7 @@ Namespace App
mC.AddMessage(Messages.MessageClass.WarningMsg, String.Format(My.Resources.strConnectionsFileCouldNotBeLoaded, conL.ConnectionFileName))
Else
mC.AddMessage(Messages.MessageClass.InformationMsg, String.Format(My.Resources.strConnectionsFileCouldNotBeLoadedNew, conL.ConnectionFileName))
App.Runtime.NewConnections()
App.Runtime.NewConnections(conL.ConnectionFileName)
End If
Exit Sub
@@ -765,7 +760,6 @@ Namespace App
End Try
End If
conL.ConnectionList = cL
conL.ContainerList = ctL

View File

@@ -1,5 +1,8 @@
1.64:
AR: Fixed translations, moved everything into resx, refactoring, namespace renamed to mRemoteNG
AR: Removed confConsNew.xml -> creating new files with vb code
AR: Fixed RD Gateway and other inheritance bugs, rewritten to use a List of String instead of a string for hiding properties
AR: Added locales to nsis installer
1.63:
New icon and logo

View File

@@ -18,11 +18,13 @@ Public Class frmMain
Startup.ParseCommandLineArgs()
' Create gui config load and save objects
sL = New Config.Settings.Load(Me)
sS = New Config.Settings.Save(Me)
Startup.CreateLogger()
' Load GUI Configuration
sL.Load()
mC = New Messages.Collector(Windows.errorsForm)
@@ -290,7 +292,12 @@ Public Class frmMain
End Sub
Private Sub mMenFileNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mMenFileNew.Click
NewConnections()
Dim lD As SaveFileDialog = Tools.Controls.ConnectionsSaveAsDialog
If lD.ShowDialog = System.Windows.Forms.DialogResult.OK Then
NewConnections(lD.FileName)
Else
Exit Sub
End If
End Sub
Private Sub mMenFileLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mMenFileLoad.Click

View File

@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Connections Name="Connections" Export="False" Protected="GiUis20DIbnYzWPcdaQKfjE2H5jh//L5v4RGrJMGNXuIq2CttB/d/BxaBP2LwRhY" ConfVersion="2.2" />

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4934A491-40BC-4E5B-9166-EA1169A220F6}</ProjectGuid>
<OutputType>WinExe</OutputType>
@@ -439,9 +439,6 @@
</None>
</ItemGroup>
<ItemGroup>
<Content Include="confConsNew.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Help\CMDSwitches.htm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>