Release for 1.0.15 to fix mutex + black out.

This commit is contained in:
Patrick Fic
2021-04-21 11:39:50 -07:00
parent 574c9f7823
commit fc70a94d5f
9 changed files with 59 additions and 29 deletions

View File

@@ -1,12 +1,16 @@
using Microsoft.Win32; using Hardcodet.Wpf.TaskbarNotification;
using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.Data; using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
namespace BodyshopPartner namespace BodyshopPartner
{ {
@@ -15,24 +19,32 @@ namespace BodyshopPartner
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
static Mutex mutex = new Mutex(false, "ImEX Online Partner");
App() App()
{ {
//System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-MX"); //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-MX");
//System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-CA"); //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-CA");
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; // Set to prevent Window black out from Material Desgin. https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/1620
Process proc = Process.GetCurrentProcess(); // Use a name unique to the application (eg include your company URL)
int count = Process.GetProcesses().Where(p => // Wait 2 seconds if contended in case another instance
p.ProcessName == proc.ProcessName).Count(); // of the program is in the process of shutting down.
if (!mutex.WaitOne(TimeSpan.FromSeconds(2), false))
if (count > 1)
{ {
MessageBox.Show("ImEX Online Partner is already running."); MessageBox.Show("ImEX Online Partner is already running.");
App.Current.Shutdown(); App.Current.Shutdown();
return;
} }
} }
private void Application_Exit(object sender, ExitEventArgs e) private void Application_Exit(object sender, ExitEventArgs e)
{ {
mutex.ReleaseMutex();
Utils.PowerModeEventHandler.DisposeEventHandler(); Utils.PowerModeEventHandler.DisposeEventHandler();
BodyshopPartner.Properties.Settings.Default.Save(); BodyshopPartner.Properties.Settings.Default.Save();
Utils.QuickBooksInterop.DisconnectFromQuickBooks(); Utils.QuickBooksInterop.DisconnectFromQuickBooks();

View File

@@ -118,12 +118,6 @@
<Reference Include="System.Xaml"> <Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework> <RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="ToastNotifications, Version=2.5.1.0, Culture=neutral, PublicKeyToken=e89d9d7314a7c797, processorArchitecture=MSIL">
<HintPath>..\packages\ToastNotifications.2.5.1\lib\net40\ToastNotifications.dll</HintPath>
</Reference>
<Reference Include="ToastNotifications.Messages, Version=2.5.1.0, Culture=neutral, PublicKeyToken=e89d9d7314a7c797, processorArchitecture=MSIL">
<HintPath>..\packages\ToastNotifications.Messages.2.5.1\lib\net40\ToastNotifications.Messages.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />

View File

@@ -51,7 +51,7 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.15.0")] [assembly: AssemblyVersion("1.0.16.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
//Setting Squirrel Aware Version. //Setting Squirrel Aware Version.
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")] [assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]

View File

@@ -222,6 +222,15 @@ namespace BodyshopPartner.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Show.
/// </summary>
public static string Label_Show {
get {
return ResourceManager.GetString("Label_Show", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Source System. /// Looks up a localized string similar to Source System.
/// </summary> /// </summary>

View File

@@ -171,6 +171,9 @@
<data name="Label_Restart" xml:space="preserve"> <data name="Label_Restart" xml:space="preserve">
<value>_Restart</value> <value>_Restart</value>
</data> </data>
<data name="Label_Show" xml:space="preserve">
<value>Show</value>
</data>
<data name="Label_SourceSystem" xml:space="preserve"> <data name="Label_SourceSystem" xml:space="preserve">
<value>Source System</value> <value>Source System</value>
</data> </data>

View File

@@ -25,3 +25,5 @@ B267713EE688D7AE11DF601300DD009BE489C3F7 ImEXOnlinePartner-1.0.11-delta.nupkg 91
B5D1B3BBD5962AE5AE9650B50956C8CF8C5EBEB9 ImEXOnlinePartner-1.0.13-full.nupkg 5147044 B5D1B3BBD5962AE5AE9650B50956C8CF8C5EBEB9 ImEXOnlinePartner-1.0.13-full.nupkg 5147044
AFC97D32A72155DDCDC9FA0C42E0E0309FD80E1A ImEXOnlinePartner-1.0.14-delta.nupkg 52030 AFC97D32A72155DDCDC9FA0C42E0E0309FD80E1A ImEXOnlinePartner-1.0.14-delta.nupkg 52030
3D90B05D7BF821194DF934A09DE33CD850350148 ImEXOnlinePartner-1.0.14-full.nupkg 5147961 3D90B05D7BF821194DF934A09DE33CD850350148 ImEXOnlinePartner-1.0.14-full.nupkg 5147961
8A9B92246C6518FE21644AADF548FDDD18548812 ImEXOnlinePartner-1.0.15-delta.nupkg 45479
08370231115AB8CBAF7F96F73096C76250BCB6DB ImEXOnlinePartner-1.0.15-full.nupkg 5148126

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
namespace BodyshopPartner.ViewModels namespace BodyshopPartner.ViewModels
@@ -32,8 +33,13 @@ namespace BodyshopPartner.ViewModels
{ {
_openMainWindowCommand = new RelayCommand( _openMainWindowCommand = new RelayCommand(
p => true, p => true,
p => Console.WriteLine("nada") p =>
); ; {
((Window)p).Show();
}
);
} }
return _openMainWindowCommand; return _openMainWindowCommand;
} }
@@ -81,7 +87,7 @@ namespace BodyshopPartner.ViewModels
_startFolderMonitorsCommand = new RelayCommand( _startFolderMonitorsCommand = new RelayCommand(
p => MonitoringPaths.Count > 0 && ActiveShop != null, p => MonitoringPaths.Count > 0 && ActiveShop != null,
p => StartAllFolderMonitors() p => StartAllFolderMonitors()
) ; );
} }
return _startFolderMonitorsCommand; return _startFolderMonitorsCommand;
} }

View File

@@ -56,11 +56,12 @@
<tb:TaskbarIcon DockPanel.Dock="Top" <tb:TaskbarIcon DockPanel.Dock="Top"
IconSource="../favicon.ico" IconSource="../favicon.ico"
DoubleClickCommand="{StaticResource OpenMainWindowCommand}" DoubleClickCommand="{Binding OpenMainWindowCommand}"
DoubleClickCommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
PopupActivation="LeftClick" PopupActivation="LeftClick"
MenuActivation="RightClick" MenuActivation="RightClick"
ToolTipText="Bodyshop Uploader"> >
<tb:TaskbarIcon.TrayPopup> <!--<tb:TaskbarIcon.TrayPopup>
<Border Background="{DynamicResource MaterialDesignPaper}" <Border Background="{DynamicResource MaterialDesignPaper}"
BorderBrush="Black" BorderBrush="Black"
BorderThickness="2"> BorderThickness="2">
@@ -95,9 +96,12 @@
</ItemsControl> </ItemsControl>
</DockPanel> </DockPanel>
</Border> </Border>
</tb:TaskbarIcon.TrayPopup> </tb:TaskbarIcon.TrayPopup>-->
<tb:TaskbarIcon.ContextMenu> <tb:TaskbarIcon.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="{x:Static p:Resources.Label_Show}"
Command="{Binding OpenMainWindowCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" />
<MenuItem Header="{x:Static p:Resources.Label_Restart}" <MenuItem Header="{x:Static p:Resources.Label_Restart}"
Command="{Binding StartFolderMonitorsCommand}" /> Command="{Binding StartFolderMonitorsCommand}" />
<MenuItem Header="{x:Static p:Resources.Label_StopAllMonitors}" <MenuItem Header="{x:Static p:Resources.Label_StopAllMonitors}"
@@ -133,7 +137,7 @@
Margin="8" Margin="8"
Content="{x:Static p:Resources.Label_StartWithWindows}" Content="{x:Static p:Resources.Label_StartWithWindows}"
Command="{Binding StartWithWindowsCommand}" Command="{Binding StartWithWindowsCommand}"
CommandParameter="{Binding Source={x:Static p:Settings.Default}, Path=StartWithWindows}"/> CommandParameter="{Binding Source={x:Static p:Settings.Default}, Path=StartWithWindows}" />
<Button Command="{Binding AddMonitoringPathCommand, UpdateSourceTrigger=PropertyChanged}" <Button Command="{Binding AddMonitoringPathCommand, UpdateSourceTrigger=PropertyChanged}"
Margin="8" Margin="8"

View File

@@ -32,10 +32,10 @@ namespace BodyshopPartner.Views
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
//e.Cancel = true ; e.Cancel = true;
//this.Hide(); this.Hide();
Utils.HTTPServer.tokenSource.Cancel(); //Utils.HTTPServer.tokenSource.Cancel();
Application.Current.Shutdown(); //Application.Current.Shutdown();
} }
private void TextBox_TextChanged(object sender, TextChangedEventArgs e) private void TextBox_TextChanged(object sender, TextChangedEventArgs e)