From d300dd9de457adc06eeb9b2e45ada739a0792c8f Mon Sep 17 00:00:00 2001 From: Robin Cornelius Date: Sat, 4 Feb 2017 17:46:27 +0000 Subject: [PATCH] Fix running from installed file and installer Installer missed out profiles/ also ensure that if profiles is missing an error message is displayed --- .gitignore | 1 + EDSTest/Form1.cs | 62 +++++++++++++++++++++++++++--------------------- setup.nsi | 5 ++++ 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 54e5e8b..a6989da 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /libEDSsharp/bin/Release /.vs/EDSTest/v14/*.suo /.vs/EDSEditor/v14/*.suo +edseditor-Setup.exe diff --git a/EDSTest/Form1.cs b/EDSTest/Form1.cs index 64cfa2d..8198fd3 100644 --- a/EDSTest/Form1.cs +++ b/EDSTest/Form1.cs @@ -61,42 +61,50 @@ private void loadprofiles() // load user profiles from the My Documents\.edseditor\profiles\ folder // Personal is my documents in windows and ~ in mono - List profilelist = Directory.GetFiles(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "Profiles").ToList(); - string homepath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".edseditor"); - homepath = Path.Combine(homepath, "profiles"); - - if (Directory.Exists(homepath)) + try { - profilelist.AddRange(Directory.GetFiles(homepath).ToList()); - } - int count = 0; - //some attempt to validate files + List profilelist = Directory.GetFiles(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "Profiles").ToList(); + string homepath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".edseditor"); + homepath = Path.Combine(homepath, "profiles"); - foreach (string file in profilelist) - { - if (Path.GetExtension(file) == ".xml") - count++; - } + if (Directory.Exists(homepath)) + { + profilelist.AddRange(Directory.GetFiles(homepath).ToList()); + } + + int count = 0; + //some attempt to validate files + + foreach (string file in profilelist) + { + if (Path.GetExtension(file) == ".xml") + count++; + } - ToolStripMenuItem[] items = new ToolStripMenuItem[count]; + ToolStripMenuItem[] items = new ToolStripMenuItem[count]; - int x = 0; - foreach(string file in profilelist) - { - if (Path.GetExtension(file) == ".xml") + int x = 0; + foreach (string file in profilelist) { - ToolStripMenuItem i = new ToolStripMenuItem(); - i.Name = Path.GetFileName(file); - i.Text = Path.GetFileName(file); - i.Click += ProfileAddClick; - i.Image = Properties.Resources.InsertColumn_5626; - items[x++] = i; + if (Path.GetExtension(file) == ".xml") + { + ToolStripMenuItem i = new ToolStripMenuItem(); + i.Name = Path.GetFileName(file); + i.Text = Path.GetFileName(file); + i.Click += ProfileAddClick; + i.Image = Properties.Resources.InsertColumn_5626; + items[x++] = i; + } } - } - insertToolStripMenuItem.DropDownItems.AddRange(items); + insertToolStripMenuItem.DropDownItems.AddRange(items); + } + catch (Exception e) + { + MessageBox.Show("Loading profiles has failed for the following reason :\n" + e.ToString()); + } } diff --git a/setup.nsi b/setup.nsi index 9456c36..ad5bb88 100644 --- a/setup.nsi +++ b/setup.nsi @@ -63,6 +63,9 @@ Section "OpenEdsEditor" Secopeneds ;No components page, name is not important File EDSTest\bin\Release\style.css File Index_8287_16x.ico File License-GPLv3.txt + + SetOutPath $INSTDIR\Profiles + File EDSTest\Profiles\* SetShellVarContext all CreateDirectory "$SMPROGRAMS\OpenEDSEditor" @@ -102,6 +105,8 @@ Section "Uninstall" ;ADD YOUR OWN FILES HERE... Delete "$INSTDIR\*" + Delete "$INSTDIR\Profiles\*" + RMDir "$INSTDIR\Profiles" RMDir "$INSTDIR" SetShellVarContext all