From a1680bce1d7ef16cc8e7cc619764d372386c09c6 Mon Sep 17 00:00:00 2001 From: Andrey Debolskiy <and.debol@gmail.com> Date: Tue, 22 Nov 2016 14:23:10 +0300 Subject: [PATCH] Added automated DotSpatial Extentions coping to executable path --- MES_Wind/Program.cs | 23 +++++++++++++++++++++++ MES_Wind/frmMain.cs | 12 ++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/MES_Wind/Program.cs b/MES_Wind/Program.cs index 7d8cb9c..ba2c360 100644 --- a/MES_Wind/Program.cs +++ b/MES_Wind/Program.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; +using System.IO; namespace MES_Wind { @@ -16,6 +17,28 @@ namespace MES_Wind Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); + } } + public static class CommUtils + { + public static DirectoryInfo CopyTo(this DirectoryInfo sourceDir, string destinationPath, bool overwrite = false) + { + var sourcePath = sourceDir.FullName; + + var destination = new DirectoryInfo(destinationPath); + + destination.Create(); + + foreach (var sourceSubDirPath in Directory.EnumerateDirectories(sourcePath, "*", SearchOption.AllDirectories)) + Directory.CreateDirectory(sourceSubDirPath.Replace(sourcePath, destinationPath)); + + foreach (var file in Directory.EnumerateFiles(sourcePath, "*", SearchOption.AllDirectories)) + File.Copy(file, file.Replace(sourcePath, destinationPath), overwrite); + + return destination; + } + + } + } diff --git a/MES_Wind/frmMain.cs b/MES_Wind/frmMain.cs index 2c73368..d8e5519 100644 --- a/MES_Wind/frmMain.cs +++ b/MES_Wind/frmMain.cs @@ -5,6 +5,7 @@ using System.Data; using System.Drawing; using System.Linq; using System.Text; +using System.IO; using System.Windows.Forms; using System.ComponentModel.Composition; using DotSpatial.Controls; @@ -25,6 +26,14 @@ namespace MES_Wind InitializeComponent(); if (DesignMode) return; Shell = this; + //check if needed extensions are in executable path + try + { + string extRelativeDir = "\\place_content_of_the_folder_to_bindebug"; + DirectoryInfo extDir = new DirectoryInfo(Directory.GetParent(Directory.GetParent(Environment.CurrentDirectory).FullName) + extRelativeDir); + extDir.CopyTo(Directory.GetCurrentDirectory()); + } + catch { } appManager1.LoadExtensions(); } #region @@ -76,7 +85,7 @@ namespace MES_Wind { string curDir = Environment.CurrentDirectory; string pathToTests = "\\MES_test_new\\"; - string file_path = System.IO.Directory.GetParent(System.IO.Directory.GetParent(curDir).FullName).FullName + pathToTests; + string file_path = Directory.GetParent(Directory.GetParent(curDir).FullName).FullName + pathToTests; string test = file_path + "u_test.asc"; map1.AddLayer(file_path + "newstats.shp"); @@ -329,5 +338,4 @@ namespace MES_Wind public double Y; public bool Ifbroken; } - } -- GitLab