diff --git a/Suplanus.Sepla/Application/EplanOffline.cs b/Suplanus.Sepla/Application/EplanOffline.cs
index dc1f6a3..e5a7073 100644
--- a/Suplanus.Sepla/Application/EplanOffline.cs
+++ b/Suplanus.Sepla/Application/EplanOffline.cs
@@ -1,5 +1,4 @@
using System;
-using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
@@ -9,208 +8,209 @@
namespace Suplanus.Sepla.Application
{
+ ///
+ /// EplanOffline class to use EPLAN Offline Application
+ ///
+ public class EplanOffline
+ {
///
- /// EplanOffline class to use EPLAN Offline Application
+ /// Returns if the EPLAN-Application is running
///
- public class EplanOffline
+ public bool IsRunning
{
- ///
- /// EPLAN Application
- ///
- public EplApplication Application;
-
- ///
- /// EPLAN Bin path e.g.: C:\Program Files\EPLAN\Platform\2.6.3\Bin
- ///
- public string BinPath;
-
- ///
- /// LicenseFile to start with given package
- ///
- public string LicenseFile;
-
- ///
- /// SystemConfiguration with environment paths
- ///
- public string SystemConfiguration;
-
- ///
- /// Init EPLAN with given bin path and license file (optional)
- ///
- ///
- ///
- ///
- public EplanOffline(string binPath,string systemConfiguration, string licenseFile = null)
- {
- BinPath = binPath;
- SystemConfiguration = systemConfiguration;
- LicenseFile = licenseFile;
- }
+ get
+ {
+ var running = Application != null;
+ return running;
+ }
+ }
- ///
- /// Starts EPLAN in ConsoleApplication
- /// You have to set Attribut [STAThread] for Main void
- ///
- public void StartWithoutGui()
- {
- Start();
- }
+ ///
+ /// EPLAN Application
+ ///
+ public EplApplication Application;
+
+ ///
+ /// EPLAN Bin path e.g.: C:\Program Files\EPLAN\Platform\2.6.3\Bin
+ ///
+ public string BinPath;
+
+ ///
+ /// LicenseFile to start with given package
+ ///
+ public string LicenseFile;
+
+ ///
+ /// SystemConfiguration with environment paths
+ ///
+ public string SystemConfiguration;
+
+ ///
+ /// Init EPLAN with given bin path and license file (optional)
+ ///
+ ///
+ ///
+ ///
+ public EplanOffline(string binPath, string systemConfiguration, string licenseFile = null)
+ {
+ BinPath = binPath;
+ SystemConfiguration = systemConfiguration;
+ LicenseFile = licenseFile;
+ }
+
+ ///
+ /// Starts EPLAN in ConsoleApplication
+ /// You have to set Attribut [STAThread] for Main void
+ ///
+ public void StartWithoutGui()
+ {
+ Start();
+ }
+
+ ///
+ /// Starts EPLAN with the last version of Electric P8 and attach to (WPF) window
+ ///
+ ///
+ public void StartWpf(Window window)
+ {
+ IntPtr handle = new WindowInteropHelper(window).Handle;
+ Start(handle);
+ }
+
+ ///
+ /// Starts EPLAN with the last version of Electric P8 and attach to (WPF) window
+ ///
+ ///
+ public Task StartWpfAsync(Window window)
+ {
+ IntPtr handle = new WindowInteropHelper(window).Handle;
+
+ var tcs = new TaskCompletionSource();
+ Thread thread = new Thread(() =>
+ {
+ Start(handle);
+ tcs.SetResult(true);
+ });
+ thread.SetApartmentState(ApartmentState.STA);
+ thread.Start();
+
+ tcs.Task.Wait();
+ return tcs.Task;
+ }
- ///
- /// Starts EPLAN with the last version of Electric P8 and attach to (WPF) window
- ///
- ///
- public void StartWpf(Window window)
+ public static Task StartSTATask(Func func)
+ {
+ var tcs = new TaskCompletionSource();
+ Thread thread = new Thread(() =>
+ {
+ try
{
- IntPtr handle = new WindowInteropHelper(window).Handle;
- Start(handle);
+ tcs.SetResult(func());
}
-
- ///
- /// Starts EPLAN with the last version of Electric P8 and attach to (WPF) window
- ///
- ///
- public Task StartWpfAsync(Window window)
+ catch (Exception e)
{
- IntPtr handle = new WindowInteropHelper(window).Handle;
-
- var tcs = new TaskCompletionSource();
- Thread thread = new Thread(() =>
- {
- Start(handle);
- tcs.SetResult(true);
- });
- thread.SetApartmentState(ApartmentState.STA);
- thread.Start();
-
- tcs.Task.Wait();
- return tcs.Task;
+ tcs.SetException(e);
}
+ });
+ thread.SetApartmentState(ApartmentState.STA);
+ thread.Start();
+ return tcs.Task;
+ }
+
+ ///
+ /// Starts EPLAN with the last version of Electric P8 and attach to (WF) form
+ ///
+ ///
+ public void StartWindowsForms(Form form)
+ {
+ IntPtr handle = form.Handle;
+ Start(handle);
+ }
- public static Task StartSTATask(Func func)
+ ///
+ /// Starts the application
+ ///
+ ///
+ private void Start(IntPtr handle)
+ {
+ if (!IsRunning)
+ {
+ try
{
- var tcs = new TaskCompletionSource();
- Thread thread = new Thread(() =>
- {
- try
- {
- tcs.SetResult(func());
- }
- catch (Exception e)
- {
- tcs.SetException(e);
- }
- });
- thread.SetApartmentState(ApartmentState.STA);
- thread.Start();
- return tcs.Task;
+ EplApplication eplApplication = new EplApplication();
+ eplApplication.EplanBinFolder = BinPath;
+ if (!string.IsNullOrEmpty(SystemConfiguration))
+ {
+ eplApplication.SystemConfiguration = SystemConfiguration;
+ }
+ eplApplication.QuietMode = EplApplication.QuietModes.ShowAllDialogs;
+ eplApplication.SetMainFrame(handle);
+ if (!string.IsNullOrEmpty(LicenseFile))
+ {
+ eplApplication.LicenseFile = LicenseFile; // Set specific license
+ }
+ eplApplication.Init("", true, true);
+ Application = eplApplication;
}
-
- ///
- /// Starts EPLAN with the last version of Electric P8 and attach to (WF) form
- ///
- ///
- public void StartWindowsForms(Form form)
+ catch
{
- IntPtr handle = form.Handle;
- Start(handle);
+ Application = null;
}
+ }
+ }
- ///
- /// Returns if the EPLAN-Application is running
- ///
- public bool IsRunning
+ ///
+ /// Starts the application without Gui
+ ///
+ private void Start()
+ {
+ if (!IsRunning)
+ {
+ try
{
- get
- {
- var running = Application != null;
- return running;
- }
+ EplApplication eplApplication = new EplApplication();
+ eplApplication.EplanBinFolder = BinPath;
+ if (!string.IsNullOrEmpty(SystemConfiguration))
+ {
+ eplApplication.SystemConfiguration = SystemConfiguration;
+ }
+ if (!string.IsNullOrEmpty(LicenseFile))
+ {
+ eplApplication.LicenseFile = LicenseFile; // Set specific licence
+ }
+ eplApplication.QuietMode = EplApplication.QuietModes.ShowAllDialogs;
+ eplApplication.Init("", true, true);
+ Application = eplApplication;
}
-
- ///
- /// Starts the application
- ///
- ///
- private void Start(IntPtr handle)
+ catch
{
- if (!IsRunning)
- {
- try
- {
- EplApplication eplApplication = new EplApplication();
- eplApplication.EplanBinFolder = BinPath;
- if (!string.IsNullOrEmpty(SystemConfiguration))
- {
- eplApplication.SystemConfiguration = SystemConfiguration;
- }
- eplApplication.QuietMode = EplApplication.QuietModes.ShowAllDialogs;
- eplApplication.SetMainFrame(handle);
- if (!string.IsNullOrEmpty(LicenseFile))
- {
- eplApplication.LicenseFile = LicenseFile; // Set specific licence
- }
- eplApplication.Init("", true, true);
- Application = eplApplication;
- }
- catch
- {
- Application = null;
- }
- }
+ Application = null;
}
+ }
+ }
- ///
- /// Starts the application without Gui
- ///
- private void Start()
+ ///
+ /// Release all objects
+ ///
+ /// Needed for eplan runtime exceptions, there is a known issue (T1094381), EPLAN says Microsoft should fix this
+ /// problem
+ /// Workaround: Enable native code debugging in visual studio
+ ///
+ ///
+ public void Close()
+ {
+ // T1094381: There is a known problem with console applications, that visual studio not quit the debugging session, workaround: enable native code debugging in project
+ if (Application != null)
+ {
+ try
{
- if (!IsRunning)
- {
- try
- {
- EplApplication eplApplication = new EplApplication();
- eplApplication.EplanBinFolder = BinPath;
- if (!string.IsNullOrEmpty(SystemConfiguration))
- {
- eplApplication.SystemConfiguration = SystemConfiguration;
- }
- if (!string.IsNullOrEmpty(LicenseFile))
- {
- eplApplication.LicenseFile = LicenseFile; // Set specific licence
- }
- eplApplication.QuietMode = EplApplication.QuietModes.ShowAllDialogs;
- eplApplication.Init("", true, true);
- Application = eplApplication;
- }
- catch
- {
- Application = null;
- }
- }
+ Application.Exit();
}
-
- ///
- /// Release all objects
- ///
- /// Needed for eplan runtime exceptions, there is a known issue (T1094381), EPLAN says Microsoft should fix this problem
- /// Workaround: Enable native code debugging in visual studio
- ///
- ///
- public void Close()
+ finally
{
- // T1094381: There is a known problem with console applications, that visual studio not quit the debugging session, workaround: enable native code debugging in project
- if (Application != null)
- {
- try
- {
- Application.Exit();
- }
- finally
- {
- Application = null;
- }
- }
+ Application = null;
}
+ }
}
-}
+ }
+}
\ No newline at end of file
diff --git a/Suplanus.Sepla/Helper/PageUtility.cs b/Suplanus.Sepla/Helper/PageUtility.cs
index f708d12..3f96bba 100644
--- a/Suplanus.Sepla/Helper/PageUtility.cs
+++ b/Suplanus.Sepla/Helper/PageUtility.cs
@@ -7,86 +7,86 @@
namespace Suplanus.Sepla.Helper
{
- public class PageUtility
+ public class PageUtility
+ {
+ public enum PageCounterAlphabetical
{
- public enum PageCounterAlphabetical
- {
- A = 0,
- B = 1,
- C = 2,
- D = 3,
- E = 4,
- F = 5,
- G = 6,
- H = 7,
- I = 8,
- J = 9,
- K = 10,
- L = 11,
- M = 12,
- N = 13,
- P = 14,
- }
+ A = 0,
+ B = 1,
+ C = 2,
+ D = 3,
+ E = 4,
+ F = 5,
+ G = 6,
+ H = 7,
+ I = 8,
+ J = 9,
+ K = 10,
+ L = 11,
+ M = 12,
+ N = 13,
+ P = 14,
+ }
- public static void OpenPageAndSyncInNavigator(Page page)
- {
- new Edit().OpenPageWithName(page.Project.ProjectLinkFilePath, page.IdentifyingName); // Open in GED
- new CommandLineInterpreter().Execute("XGedSelectPageAction"); // Select page
- new CommandLineInterpreter().Execute("XEsSyncPDDsAction"); // Sync selection
- new CommandLineInterpreter().Execute("XGedEscapeAction"); // Escape (page selection)
- }
+ public static void OpenPageAndSyncInNavigator(Page page)
+ {
+ new Edit().OpenPageWithName(page.Project.ProjectLinkFilePath, page.IdentifyingName); // Open in GED
+ new CommandLineInterpreter().Execute("XGedSelectPageAction"); // Select page
+ new CommandLineInterpreter().Execute("XEsSyncPDDsAction"); // Sync selection
+ new CommandLineInterpreter().Execute("XGedEscapeAction"); // Escape (page selection)
+ }
- public static WindowMacro.Enums.RepresentationType GetMacroRepresentationTypeFromPage(Page page)
- {
- switch (page.PageType)
- {
- case DocumentTypeManager.DocumentType.CircuitFluid: return WindowMacro.Enums.RepresentationType.Fluid_MultiLine;
- case DocumentTypeManager.DocumentType.Circuit: return WindowMacro.Enums.RepresentationType.MultiLine;
- case DocumentTypeManager.DocumentType.CircuitSingleLine: return WindowMacro.Enums.RepresentationType.SingleLine;
- case DocumentTypeManager.DocumentType.Overview: return WindowMacro.Enums.RepresentationType.Overview;
- case DocumentTypeManager.DocumentType.Graphics: return WindowMacro.Enums.RepresentationType.Graphics;
- case DocumentTypeManager.DocumentType.ProcessAndInstrumentationDiagram: return WindowMacro.Enums.RepresentationType.PI_FlowChart;
- case DocumentTypeManager.DocumentType.PanelLayout: return WindowMacro.Enums.RepresentationType.ArticlePlacement;
- case DocumentTypeManager.DocumentType.Topology: return WindowMacro.Enums.RepresentationType.Cabling;
- case DocumentTypeManager.DocumentType.Planning: return WindowMacro.Enums.RepresentationType.Planning;
- default: return WindowMacro.Enums.RepresentationType.Default;
- }
- }
+ public static WindowMacro.Enums.RepresentationType GetMacroRepresentationTypeFromPage(Page page)
+ {
+ switch (page.PageType)
+ {
+ case DocumentTypeManager.DocumentType.CircuitFluid: return WindowMacro.Enums.RepresentationType.Fluid_MultiLine;
+ case DocumentTypeManager.DocumentType.Circuit: return WindowMacro.Enums.RepresentationType.MultiLine;
+ case DocumentTypeManager.DocumentType.CircuitSingleLine: return WindowMacro.Enums.RepresentationType.SingleLine;
+ case DocumentTypeManager.DocumentType.Overview: return WindowMacro.Enums.RepresentationType.Overview;
+ case DocumentTypeManager.DocumentType.Graphics: return WindowMacro.Enums.RepresentationType.Graphics;
+ case DocumentTypeManager.DocumentType.ProcessAndInstrumentationDiagram: return WindowMacro.Enums.RepresentationType.PI_FlowChart;
+ case DocumentTypeManager.DocumentType.PanelLayout: return WindowMacro.Enums.RepresentationType.ArticlePlacement;
+ case DocumentTypeManager.DocumentType.Topology: return WindowMacro.Enums.RepresentationType.Cabling;
+ case DocumentTypeManager.DocumentType.Planning: return WindowMacro.Enums.RepresentationType.Planning;
+ default: return WindowMacro.Enums.RepresentationType.Default;
+ }
+ }
- public static DocumentTypeManager.DocumentType GetPageRepresentationTypeFromMacro(WindowMacro.Enums.RepresentationType representationType)
- {
- switch (representationType)
- {
- case WindowMacro.Enums.RepresentationType.Default: return DocumentTypeManager.DocumentType.Undefined;
- case WindowMacro.Enums.RepresentationType.Neutral: return DocumentTypeManager.DocumentType.Undefined;
- case WindowMacro.Enums.RepresentationType.MultiLine: return DocumentTypeManager.DocumentType.Circuit;
- case WindowMacro.Enums.RepresentationType.SingleLine: return DocumentTypeManager.DocumentType.CircuitSingleLine;
- case WindowMacro.Enums.RepresentationType.PairCrossReference: return DocumentTypeManager.DocumentType.PairCrossReference;
- case WindowMacro.Enums.RepresentationType.Overview: return DocumentTypeManager.DocumentType.Overview;
- case WindowMacro.Enums.RepresentationType.Graphics: return DocumentTypeManager.DocumentType.Graphics;
- case WindowMacro.Enums.RepresentationType.ArticlePlacement: return DocumentTypeManager.DocumentType.PanelLayout;
- case WindowMacro.Enums.RepresentationType.PI_FlowChart: return DocumentTypeManager.DocumentType.ProcessAndInstrumentationDiagram;
- case WindowMacro.Enums.RepresentationType.Fluid_MultiLine: return DocumentTypeManager.DocumentType.CircuitFluid;
- case WindowMacro.Enums.RepresentationType.Cabling: return DocumentTypeManager.DocumentType.Topology;
- case WindowMacro.Enums.RepresentationType.ArticlePlacement3D: return DocumentTypeManager.DocumentType.ModelView;
- case WindowMacro.Enums.RepresentationType.Functional: return DocumentTypeManager.DocumentType.Functional;
- case WindowMacro.Enums.RepresentationType.Planning: return DocumentTypeManager.DocumentType.Planning;
- default: throw new ArgumentOutOfRangeException();
- }
- }
+ public static DocumentTypeManager.DocumentType GetPageRepresentationTypeFromMacro(WindowMacro.Enums.RepresentationType representationType)
+ {
+ switch (representationType)
+ {
+ case WindowMacro.Enums.RepresentationType.Default: return DocumentTypeManager.DocumentType.Undefined;
+ case WindowMacro.Enums.RepresentationType.Neutral: return DocumentTypeManager.DocumentType.Undefined;
+ case WindowMacro.Enums.RepresentationType.MultiLine: return DocumentTypeManager.DocumentType.Circuit;
+ case WindowMacro.Enums.RepresentationType.SingleLine: return DocumentTypeManager.DocumentType.CircuitSingleLine;
+ case WindowMacro.Enums.RepresentationType.PairCrossReference: return DocumentTypeManager.DocumentType.PairCrossReference;
+ case WindowMacro.Enums.RepresentationType.Overview: return DocumentTypeManager.DocumentType.Overview;
+ case WindowMacro.Enums.RepresentationType.Graphics: return DocumentTypeManager.DocumentType.Graphics;
+ case WindowMacro.Enums.RepresentationType.ArticlePlacement: return DocumentTypeManager.DocumentType.PanelLayout;
+ case WindowMacro.Enums.RepresentationType.PI_FlowChart: return DocumentTypeManager.DocumentType.ProcessAndInstrumentationDiagram;
+ case WindowMacro.Enums.RepresentationType.Fluid_MultiLine: return DocumentTypeManager.DocumentType.CircuitFluid;
+ case WindowMacro.Enums.RepresentationType.Cabling: return DocumentTypeManager.DocumentType.Topology;
+ case WindowMacro.Enums.RepresentationType.ArticlePlacement3D: return DocumentTypeManager.DocumentType.ModelView;
+ case WindowMacro.Enums.RepresentationType.Functional: return DocumentTypeManager.DocumentType.Functional;
+ case WindowMacro.Enums.RepresentationType.Planning: return DocumentTypeManager.DocumentType.Planning;
+ default: throw new ArgumentOutOfRangeException();
+ }
+ }
- public static PointD[] GetLogicalAreaofPage(Page page)
- {
- PlotFrame frame = page.PlotFrame;
- PointD ptSize = frame.Size;
- int xStart = frame.Properties.FRAME_EVALUATION_AREA_START_POINT_X;
- double xEnd = xStart + ptSize.X - xStart;
- int yStart = frame.Properties.FRAME_EVALUATION_AREA_START_POINT_Y;
- double yEnd = yStart + ptSize.Y - yStart - 5; // 5mm fix of plotframe
+ public static PointD[] GetLogicalAreaofPage(Page page)
+ {
+ PlotFrame frame = page.PlotFrame;
+ PointD ptSize = frame.Size;
+ int xStart = frame.Properties.FRAME_EVALUATION_AREA_START_POINT_X;
+ double xEnd = xStart + ptSize.X - xStart;
+ int yStart = frame.Properties.FRAME_EVALUATION_AREA_START_POINT_Y;
+ double yEnd = yStart + ptSize.Y - yStart - 5; // 5mm fix of plotframe
- PointD lowerLeft = new PointD(xStart, yStart);
- PointD upperRight = new PointD(xEnd, yEnd);
- return new[] { lowerLeft, upperRight };
- }
+ PointD lowerLeft = new PointD(xStart, yStart);
+ PointD upperRight = new PointD(xEnd, yEnd);
+ return new[] { lowerLeft, upperRight };
}
+ }
}
\ No newline at end of file
diff --git a/Suplanus.Sepla/Helper/ProjectUtility.cs b/Suplanus.Sepla/Helper/ProjectUtility.cs
index a34e4ab..f8f9bf0 100644
--- a/Suplanus.Sepla/Helper/ProjectUtility.cs
+++ b/Suplanus.Sepla/Helper/ProjectUtility.cs
@@ -51,6 +51,13 @@ public static Project Create(string projectLinkFilePath, string projectTemplateF
// New
if (!projectManager.ExistsProject(projectLinkFilePath) || overwrite == true)
{
+ // Close if project exists and should be overwritten
+ var existingProject = projectManager.OpenProjects.FirstOrDefault(p => p.ProjectLinkFilePath.Equals(projectLinkFilePath));
+ if (existingProject != null)
+ {
+ existingProject.Close();
+ }
+
// Remove project if exists: Removing on file layer is much faster than via EPLAN API
DeleteProject(projectLinkFilePath, projectManager);
project = projectManager.CreateProject(projectLinkFilePath, projectTemplateFilePath);
diff --git a/Suplanus.Sepla/Suplanus.Sepla.csproj b/Suplanus.Sepla/Suplanus.Sepla.csproj
index aacb82d..04a3330 100644
--- a/Suplanus.Sepla/Suplanus.Sepla.csproj
+++ b/Suplanus.Sepla/Suplanus.Sepla.csproj
@@ -2,7 +2,7 @@
- Release
+ Sign
AnyCPU
{A3AC82B1-6EA9-4127-80C8-0E09C49B1CC0}
Library
@@ -13,6 +13,17 @@
512
+ True
+ False
+ True
+ True
+ True
+ False
+ SettingsVersion
+ None
+ None.None.None.None
+ None.None.None.None
+ None.None.None.None
true
@@ -237,6 +248,7 @@
+