diff --git a/BodyshopUploader/App.xaml.cs b/BodyshopUploader/App.xaml.cs index 3a7440a..4fdd4b2 100644 --- a/BodyshopUploader/App.xaml.cs +++ b/BodyshopUploader/App.xaml.cs @@ -1,12 +1,16 @@ -using Microsoft.Win32; +using Hardcodet.Wpf.TaskbarNotification; +using Microsoft.Win32; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Diagnostics; using System.Linq; +using System.Threading; using System.Threading.Tasks; using System.Windows; +using System.Windows.Interop; +using System.Windows.Media; namespace BodyshopPartner { @@ -15,24 +19,32 @@ namespace BodyshopPartner /// public partial class App : Application { + static Mutex mutex = new Mutex(false, "ImEX Online Partner"); + App() { //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-MX"); //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-CA"); - - Process proc = Process.GetCurrentProcess(); - int count = Process.GetProcesses().Where(p => - p.ProcessName == proc.ProcessName).Count(); - - if (count > 1) + RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; // Set to prevent Window black out from Material Desgin. https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/1620 + // Use a name unique to the application (eg include your company URL) + // Wait 2 seconds if contended – in case another instance + // of the program is in the process of shutting down. + if (!mutex.WaitOne(TimeSpan.FromSeconds(2), false)) { MessageBox.Show("ImEX Online Partner is already running."); App.Current.Shutdown(); + return; } + } + + private void Application_Exit(object sender, ExitEventArgs e) { + + + mutex.ReleaseMutex(); Utils.PowerModeEventHandler.DisposeEventHandler(); BodyshopPartner.Properties.Settings.Default.Save(); Utils.QuickBooksInterop.DisconnectFromQuickBooks(); diff --git a/BodyshopUploader/ImEXOnlinePartner.csproj b/BodyshopUploader/ImEXOnlinePartner.csproj index 2fd86c3..4b35216 100644 --- a/BodyshopUploader/ImEXOnlinePartner.csproj +++ b/BodyshopUploader/ImEXOnlinePartner.csproj @@ -118,12 +118,6 @@ 4.0 - - ..\packages\ToastNotifications.2.5.1\lib\net40\ToastNotifications.dll - - - ..\packages\ToastNotifications.Messages.2.5.1\lib\net40\ToastNotifications.Messages.dll - diff --git a/BodyshopUploader/Properties/AssemblyInfo.cs b/BodyshopUploader/Properties/AssemblyInfo.cs index 5c4b85b..7bcd34b 100644 --- a/BodyshopUploader/Properties/AssemblyInfo.cs +++ b/BodyshopUploader/Properties/AssemblyInfo.cs @@ -51,7 +51,7 @@ using System.Windows; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.15.0")] +[assembly: AssemblyVersion("1.0.16.0")] [assembly: AssemblyFileVersion("1.0.0.0")] //Setting Squirrel Aware Version. [assembly: AssemblyMetadata("SquirrelAwareVersion", "1")] \ No newline at end of file diff --git a/BodyshopUploader/Properties/Resources.Designer.cs b/BodyshopUploader/Properties/Resources.Designer.cs index d259576..fd4105d 100644 --- a/BodyshopUploader/Properties/Resources.Designer.cs +++ b/BodyshopUploader/Properties/Resources.Designer.cs @@ -222,6 +222,15 @@ namespace BodyshopPartner.Properties { } } + /// + /// Looks up a localized string similar to Show. + /// + public static string Label_Show { + get { + return ResourceManager.GetString("Label_Show", resourceCulture); + } + } + /// /// Looks up a localized string similar to Source System. /// diff --git a/BodyshopUploader/Properties/Resources.resx b/BodyshopUploader/Properties/Resources.resx index c9f99f9..418131f 100644 --- a/BodyshopUploader/Properties/Resources.resx +++ b/BodyshopUploader/Properties/Resources.resx @@ -171,6 +171,9 @@ _Restart + + Show + Source System diff --git a/BodyshopUploader/Releases/RELEASES b/BodyshopUploader/Releases/RELEASES index eaffdd7..6bda954 100644 --- a/BodyshopUploader/Releases/RELEASES +++ b/BodyshopUploader/Releases/RELEASES @@ -24,4 +24,6 @@ B267713EE688D7AE11DF601300DD009BE489C3F7 ImEXOnlinePartner-1.0.11-delta.nupkg 91 11E3C5D192C4832CFBE46243BB7AA36B27BF3C4C ImEXOnlinePartner-1.0.13-delta.nupkg 29519 B5D1B3BBD5962AE5AE9650B50956C8CF8C5EBEB9 ImEXOnlinePartner-1.0.13-full.nupkg 5147044 AFC97D32A72155DDCDC9FA0C42E0E0309FD80E1A ImEXOnlinePartner-1.0.14-delta.nupkg 52030 -3D90B05D7BF821194DF934A09DE33CD850350148 ImEXOnlinePartner-1.0.14-full.nupkg 5147961 \ No newline at end of file +3D90B05D7BF821194DF934A09DE33CD850350148 ImEXOnlinePartner-1.0.14-full.nupkg 5147961 +8A9B92246C6518FE21644AADF548FDDD18548812 ImEXOnlinePartner-1.0.15-delta.nupkg 45479 +08370231115AB8CBAF7F96F73096C76250BCB6DB ImEXOnlinePartner-1.0.15-full.nupkg 5148126 \ No newline at end of file diff --git a/BodyshopUploader/ViewModels/MainViewModel.commands.cs b/BodyshopUploader/ViewModels/MainViewModel.commands.cs index 84d8254..26635d7 100644 --- a/BodyshopUploader/ViewModels/MainViewModel.commands.cs +++ b/BodyshopUploader/ViewModels/MainViewModel.commands.cs @@ -1,4 +1,5 @@ using System; +using System.Windows; using System.Windows.Input; namespace BodyshopPartner.ViewModels @@ -32,8 +33,13 @@ namespace BodyshopPartner.ViewModels { _openMainWindowCommand = new RelayCommand( p => true, - p => Console.WriteLine("nada") - ); ; + p => + { + ((Window)p).Show(); + + + } + ); } return _openMainWindowCommand; } @@ -81,7 +87,7 @@ namespace BodyshopPartner.ViewModels _startFolderMonitorsCommand = new RelayCommand( p => MonitoringPaths.Count > 0 && ActiveShop != null, p => StartAllFolderMonitors() - ) ; + ); } return _startFolderMonitorsCommand; } @@ -148,7 +154,7 @@ namespace BodyshopPartner.ViewModels async p => { await InstallUpdates(); - + }); } return _installUpdatesCommand; diff --git a/BodyshopUploader/Views/Main.xaml b/BodyshopUploader/Views/Main.xaml index a35c743..2b97e29 100644 --- a/BodyshopUploader/Views/Main.xaml +++ b/BodyshopUploader/Views/Main.xaml @@ -56,11 +56,12 @@ - + > + + + CommandParameter="{Binding Source={x:Static p:Settings.Default}, Path=StartWithWindows}" />