Skip to content

Commit

Permalink
Bump 1.0.0.1
Browse files Browse the repository at this point in the history
UI  App now brings the existed instance to front if multi-instances of the UI App is created.
  • Loading branch information
evilhawk00 committed Sep 5, 2022
1 parent c06b2c0 commit 0867a65
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 29 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore



####Custom built files in InstallationFilesSourceDir for project Printhead Maintainer####
PrintheadMaintainerInstaller/InstallationFilesSourceDir/Microsoft.Toolkit.Uwp.Notifications.dll
PrintheadMaintainerInstaller/InstallationFilesSourceDir/PrintheadMaintainer.exe
PrintheadMaintainerInstaller/InstallationFilesSourceDir/PrintheadMaintainSvc.exe
PrintheadMaintainerInstaller/InstallationFilesSourceDir/System.ValueTuple.dll





# User-specific files
*.rsuser
*.suo
Expand Down
12 changes: 8 additions & 4 deletions PrintheadMaintainerInstaller/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="{9F0BB602-AFD5-4242-A073-38B724C60E12}" Name="Printhead Maintainer" Language="1033" Version="1.0.0.0" Manufacturer="evilhawk00" UpgradeCode="{836CF211-F067-43F8-A021-6BB3E007F9AF}">
<Product Id="*" Name="Printhead Maintainer" Language="1033" Version="1.0.0.1" Manufacturer="evilhawk00" UpgradeCode="{836CF211-F067-43F8-A021-6BB3E007F9AF}">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated" Platform="x86"/>

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes"/>

<Upgrade Id="{836CF211-F067-43F8-A021-6BB3E007F9AF}">
<UpgradeVersion Property="PREVIOUSVERSIONSINSTALLED" Minimum="1.0.0.0" IncludeMinimum='yes'/>
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>

<Feature Id='Complete' Title='Printhead Maintainer' Description='The complete package.' Display='expand' Level='1' ConfigurableDirectory='INSTALLFOLDER'>
<Feature Id='MainProgram' Title='Program' Description='The main executable.' Level='1'>
<ComponentGroupRef Id='MainProgramCompGroup' />
Expand Down Expand Up @@ -108,6 +114,4 @@
</ComponentGroup>
</Fragment>



</Wix>
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -79,11 +79,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "evilhawk00"
VALUE "FileDescription", "Printhead Maintenance Service"
VALUE "FileVersion", "1.0.0.0"
VALUE "LegalCopyright", "Copyright (C) 2021 YAN-LIN, CHEN"
VALUE "FileVersion", "1.0.0.1"
VALUE "LegalCopyright", "Copyright (C) 2022 YAN-LIN, CHEN"
VALUE "OriginalFilename", "PrintheadMaintainSvc.exe"
VALUE "ProductName", "Printhead Maintainer"
VALUE "ProductVersion", "1.0.0.0"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int intIfPrinterHasError(const std::wstring& wsPrinterName) {
//printer handle is no longer needed
ClosePrinter(hPrinter);

for (int i = 0; i < dwJobsReturned; i++)
for (unsigned int i = 0; i < dwJobsReturned; i++)
{
if (pJobs[i].Status & JOB_STATUS_PRINTING)
{
Expand Down Expand Up @@ -350,7 +350,7 @@ int intIfJobStillInQueueWithOptionalDelete(const std::wstring& wsDocumentNameDis
return -1;
}

for (int i = 0; i < dwJobsInQueue; i++)
for (unsigned int i = 0; i < dwJobsInQueue; i++)
{
if (pJobs[i].pDocument == wsDocumentNameDisplayedInQueue)
{
Expand Down
42 changes: 33 additions & 9 deletions PrintheadMaintainerUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,23 @@ namespace PrintheadMaintainerUI
/// </summary>
public partial class App : Application
{
#pragma warning disable IDE0052
private static Mutex _mutex = null;
#pragma warning restore IDE0052
private EventWaitHandle _eventWaitHandle;

public bool bStartupMinimized = false;
protected override void OnStartup(StartupEventArgs e)
{
const string appName = "PrintheadMaintainer";
bool createdNew;
const string strAppName = "PrintheadMaintainer";
const string strUniqueEventName = "{2C4150D2-F22B-4F1D-97FC-7B68EE70FEA6}";

bool bCreatedNew;

_mutex = new Mutex(true, strAppName, out bCreatedNew);
_eventWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, strUniqueEventName);

_mutex = new Mutex(true, appName, out createdNew);


for (int i = 0; i != e.Args.Length; ++i)
{
if (e.Args[i] == "/silent")
Expand All @@ -45,14 +51,32 @@ protected override void OnStartup(StartupEventArgs e)
}
}



if (!createdNew)
if (bCreatedNew)
{
//app is already running! Exiting the application
Current.Shutdown();
//create a thread to wait for the event
Thread thread = new Thread(
() =>
{
while (_eventWaitHandle.WaitOne())
{
_ = Current.Dispatcher.BeginInvoke(
(System.Action)(() => ((MainWindow)Current.MainWindow).Void_Public_Restore_Window()));
}
});

//Mark it as background otherwise it will prevent app from exiting.
thread.IsBackground = true;

thread.Start();
return;
}

//Tell other instance to bring window to front.
_ = _eventWaitHandle.Set();

//Terminate this instance.
Shutdown();

base.OnStartup(e);
}

Expand Down
15 changes: 10 additions & 5 deletions PrintheadMaintainerUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,7 @@ private void VoidCreateTrayIcon()
niNotifyIcon.DoubleClick +=
delegate (object sender, EventArgs args)
{
//switch back to home first
Mediator.Notify("SwitchToHome", "");

Show();
WindowState = WindowState.Normal;
VoidRestoreWindow(sender, args);

};

Expand All @@ -171,13 +167,22 @@ private void VoidCloseApplication(object Sender, EventArgs e)
Close();
}

public void Void_Public_Restore_Window()
{
VoidRestoreWindow(null, null);
}

private void VoidRestoreWindow(object Sender, EventArgs e)
{
//switch back to home first
Mediator.Notify("SwitchToHome", "");

Show();
WindowState = WindowState.Normal;

//make this window to top
_ = Activate();

}

private void VoidMinimizeWindowToTray(object sender, RoutedEventArgs e) {
Expand Down
6 changes: 3 additions & 3 deletions PrintheadMaintainerUI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("evilhawk00")]
[assembly: AssemblyProduct("Printhead Maintainer")]
[assembly: AssemblyCopyright("Copyright © 2021 YAN-LIN, CHEN")]
[assembly: AssemblyCopyright("Copyright © 2022 YAN-LIN, CHEN")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down Expand Up @@ -51,5 +51,5 @@
// 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號
// 設為預設,如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
2 changes: 1 addition & 1 deletion PrintheadMaintainerUI/Views/AboutView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.

<TextBlock Grid.Column="0" FontSize="18.5" FontWeight="SemiBold" HorizontalAlignment="Center" Margin="0" Grid.Row="0" TextWrapping="Wrap" Text="Version" VerticalAlignment="Center"/>
<TextBlock Grid.Column="0" FontSize="18.5" FontWeight="SemiBold" HorizontalAlignment="Center" Margin="0" Grid.Row="1" TextWrapping="Wrap" Text="Developer" VerticalAlignment="Center" RenderTransformOrigin="-0.021,-0.577"/>
<TextBlock Grid.Column="1" FontSize="18.5" FontWeight="SemiBold" HorizontalAlignment="Center" Height="auto" Margin="0" Grid.Row="0" TextWrapping="Wrap" Text="1.0.0.0" VerticalAlignment="Center" />
<TextBlock Grid.Column="1" FontSize="18.5" FontWeight="SemiBold" HorizontalAlignment="Center" Height="auto" Margin="0" Grid.Row="0" TextWrapping="Wrap" Text="1.0.0.1" VerticalAlignment="Center" />



Expand Down

0 comments on commit 0867a65

Please sign in to comment.