From 9878acff9af93a9687af06bafe006eeec8dbb97a Mon Sep 17 00:00:00 2001 From: Andreas Rehm Date: Tue, 25 May 2010 18:56:49 +0200 Subject: [PATCH] Rewrite of new configuration creation to vb code * Translation of Connections and New Connections --- mRemoteV1/App/App.Runtime.vb | 44 ++++++++++++++++-------------------- mRemoteV1/CHANGELOG.TXT | 3 +++ mRemoteV1/Forms/frmMain.vb | 9 +++++++- mRemoteV1/confConsNew.xml | 2 -- mRemoteV1/mRemoteV1.vbproj | 5 +--- 5 files changed, 31 insertions(+), 32 deletions(-) delete mode 100644 mRemoteV1/confConsNew.xml diff --git a/mRemoteV1/App/App.Runtime.vb b/mRemoteV1/App/App.Runtime.vb index d52f52bcd..c57cd0d3a 100644 --- a/mRemoteV1/App/App.Runtime.vb +++ b/mRemoteV1/App/App.Runtime.vb @@ -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 diff --git a/mRemoteV1/CHANGELOG.TXT b/mRemoteV1/CHANGELOG.TXT index 81fead8c3..a59aa40cc 100644 --- a/mRemoteV1/CHANGELOG.TXT +++ b/mRemoteV1/CHANGELOG.TXT @@ -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 diff --git a/mRemoteV1/Forms/frmMain.vb b/mRemoteV1/Forms/frmMain.vb index fe482ab90..0a8bb46a4 100644 --- a/mRemoteV1/Forms/frmMain.vb +++ b/mRemoteV1/Forms/frmMain.vb @@ -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 diff --git a/mRemoteV1/confConsNew.xml b/mRemoteV1/confConsNew.xml deleted file mode 100644 index 6ab6e5cfd..000000000 --- a/mRemoteV1/confConsNew.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/mRemoteV1/mRemoteV1.vbproj b/mRemoteV1/mRemoteV1.vbproj index a592a2a82..66be03dee 100644 --- a/mRemoteV1/mRemoteV1.vbproj +++ b/mRemoteV1/mRemoteV1.vbproj @@ -3,7 +3,7 @@ Debug AnyCPU - 9.0.21022 + 9.0.30729 2.0 {4934A491-40BC-4E5B-9166-EA1169A220F6} WinExe @@ -439,9 +439,6 @@ - - PreserveNewest - PreserveNewest