From ef24521f35a9430c4a307c5225594376f7bf82bb Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 15 Aug 2020 05:25:07 +0300 Subject: Working on file association handlers.. --- Software/Graphics/FSE/Installer/procedure_dde.ico | Bin 0 -> 105959 bytes Software/Graphics/FSE/Installer/procedure_dde.png | Bin 0 -> 2305 bytes Software/Graphics/FSE/Installer/procedures_dde.ico | Bin 0 -> 126856 bytes Software/Graphics/FSE/procedures_dde.png | Bin 0 -> 26852 bytes .../Advanced Installer Projects/FSE Installer.aip | 30 ++++++++++++++------- .../Help/proc-doc.chm | Bin 206271 -> 206257 bytes .../ViewModels/ProcedureRunnerViewVM.cs | 29 ++++++++++++++------ .../FileAssociation/FileAssociationPackage.cs | 13 +++++++++ .../FileAssociation/IFileAssociationProvider.cs | 13 +++++++++ .../FSE/Tango.FSE.Common/Tango.FSE.Common.csproj | 2 ++ .../Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs | 22 +++++++++++++++ .../DefaultFileAssociationHandler.cs | 24 +++++++++++++++++ .../FSE/Tango.FSE.UI/Tango.FSE.UI.csproj | 1 + 13 files changed, 116 insertions(+), 18 deletions(-) create mode 100644 Software/Graphics/FSE/Installer/procedure_dde.ico create mode 100644 Software/Graphics/FSE/Installer/procedure_dde.png create mode 100644 Software/Graphics/FSE/Installer/procedures_dde.ico create mode 100644 Software/Graphics/FSE/procedures_dde.png create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/FileAssociation/FileAssociationPackage.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/FileAssociation/IFileAssociationProvider.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationHandler.cs diff --git a/Software/Graphics/FSE/Installer/procedure_dde.ico b/Software/Graphics/FSE/Installer/procedure_dde.ico new file mode 100644 index 000000000..a14b94f01 Binary files /dev/null and b/Software/Graphics/FSE/Installer/procedure_dde.ico differ diff --git a/Software/Graphics/FSE/Installer/procedure_dde.png b/Software/Graphics/FSE/Installer/procedure_dde.png new file mode 100644 index 000000000..0f65a3d9d Binary files /dev/null and b/Software/Graphics/FSE/Installer/procedure_dde.png differ diff --git a/Software/Graphics/FSE/Installer/procedures_dde.ico b/Software/Graphics/FSE/Installer/procedures_dde.ico new file mode 100644 index 000000000..76d4332fe Binary files /dev/null and b/Software/Graphics/FSE/Installer/procedures_dde.ico differ diff --git a/Software/Graphics/FSE/procedures_dde.png b/Software/Graphics/FSE/procedures_dde.png new file mode 100644 index 000000000..272fbdd89 Binary files /dev/null and b/Software/Graphics/FSE/procedures_dde.png differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/FSE Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/FSE Installer.aip index aaa691524..4d7250d8e 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/FSE Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/FSE Installer.aip @@ -267,7 +267,7 @@ - + @@ -314,7 +314,7 @@ - + @@ -652,20 +652,20 @@ - - - - - - + + + + + + @@ -808,6 +808,9 @@ + + + @@ -1067,18 +1070,19 @@ - - + + + @@ -1134,6 +1138,9 @@ + + + @@ -1157,6 +1164,9 @@ + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm index bbd743180..861555098 100644 Binary files a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm and b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures.Documentation/Help/proc-doc.chm differ diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ViewModels/ProcedureRunnerViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ViewModels/ProcedureRunnerViewVM.cs index c9c94a9a4..d69ba63f8 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ViewModels/ProcedureRunnerViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Procedures/ViewModels/ProcedureRunnerViewVM.cs @@ -125,6 +125,12 @@ namespace Tango.FSE.Procedures.ViewModels { try { + if (IsRunning) + { + await NotificationProvider.ShowError("Cannot execute a procedure while another procedure is running."); + return; + } + IsRunning = true; FailedError = null; ResultsViewVM.Results = new List(); @@ -188,14 +194,21 @@ namespace Tango.FSE.Procedures.ViewModels if (_isFromDesigner) { - RunningProcedureProject = _designerProject; - RaisePropertyChanged(nameof(HasProcedureInputs)); - ProjectRunner = new ProjectRunner(RunningProcedureProject); - ProjectRunner.StateChanged += (x, e) => InvalidateRelayCommands(); - Status = "Ready"; - InvalidateRelayCommands(); - SelectedView = RunnerView.ProcedureRunnerExecutionView; - StartProject(); + if (!IsRunning) + { + RunningProcedureProject = _designerProject; + RaisePropertyChanged(nameof(HasProcedureInputs)); + ProjectRunner = new ProjectRunner(RunningProcedureProject); + ProjectRunner.StateChanged += (x, e) => InvalidateRelayCommands(); + Status = "Ready"; + InvalidateRelayCommands(); + SelectedView = RunnerView.ProcedureRunnerExecutionView; + StartProject(); + } + else + { + NotificationProvider.ShowError("Cannot execute a procedure while another procedure is running."); + } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FileAssociation/FileAssociationPackage.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FileAssociation/FileAssociationPackage.cs new file mode 100644 index 000000000..106c37f16 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FileAssociation/FileAssociationPackage.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.Common.FileAssociation +{ + public class FileAssociationPackage + { + public String File { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FileAssociation/IFileAssociationProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FileAssociation/IFileAssociationProvider.cs new file mode 100644 index 000000000..6b4440f41 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FileAssociation/IFileAssociationProvider.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.Common.FileAssociation +{ + public interface IFileAssociationProvider + { + void RegisterFileAssociationHandler(String targetName, Action handler); + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj index 6c7ffb7ed..0584d2e0b 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Tango.FSE.Common.csproj @@ -179,6 +179,8 @@ + + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs index 8f0b97d2b..196978f69 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs @@ -33,6 +33,7 @@ namespace Tango.FSE.UI public static bool IsStartedAfterCrash { get; private set; } public static String StartedAfterCrashError { get; private set; } + private static Mutex mutex = new Mutex(true, "{8F6F0AC4-B9A1-45fd-A8CF-72F0TANGOFSE}"); public App() : base() { @@ -50,6 +51,27 @@ namespace Tango.FSE.UI protected override void OnStartup(StartupEventArgs e) { + if (e.Args != null) + { + if (e.Args.Length == 3) + { + if (e.Args[0] == "-file") + { + if (mutex.WaitOne(TimeSpan.Zero, true)) + { + mutex.ReleaseMutex(); + MessageBox.Show($"Run Procedure {e.Args[2]} on this instance."); + } + else + { + MessageBox.Show($"Run Procedure {e.Args[2]} on another instance."); + Environment.Exit(0); + return; + } + } + } + } + //Set culture info. var enUSCulture = new CultureInfo("en-US"); diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationHandler.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationHandler.cs new file mode 100644 index 000000000..88f4fff05 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileAssociation/DefaultFileAssociationHandler.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.FSE.Common.FileAssociation; + +namespace Tango.FSE.UI.FileAssociation +{ + public class DefaultFileAssociationHandler : IFileAssociationProvider + { + private Dictionary> _handlers; + + public DefaultFileAssociationHandler() + { + _handlers = new Dictionary>(); + } + + public void RegisterFileAssociationHandler(string targetName, Action handler) + { + _handlers.Add(targetName.ToLower(), handler); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj index 5c6885c2e..44a163326 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj @@ -271,6 +271,7 @@ + -- cgit v1.3.1