Removed the DEM file system dependency
This commit is contained in:
@@ -12,6 +12,22 @@
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
function Show-Notification {
|
||||
param([string]$Title, [string]$Body)
|
||||
try {
|
||||
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
|
||||
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
|
||||
$xml = [Windows.Data.Xml.Dom.XmlDocument]::new()
|
||||
$escaped = [System.Security.SecurityElement]::Escape($Body)
|
||||
$xml.LoadXml("<toast><visual><binding template='ToastGeneric'><text>$Title</text><text>$escaped</text></binding></visual></toast>")
|
||||
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
|
||||
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('IT Screen Recorder').Show($toast)
|
||||
}
|
||||
catch {
|
||||
[System.Windows.Forms.MessageBox]::Show($Body, $Title, [System.Windows.Forms.MessageBoxButtons]::OK) | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
$saveScript = Join-Path $PSScriptRoot 'Invoke-ReplaySave.ps1'
|
||||
|
||||
# --- Tray icon ---
|
||||
@@ -33,10 +49,10 @@ $saveItem.Add_Click({
|
||||
$result = & powershell.exe -ExecutionPolicy Bypass -NonInteractive -File $saveScript
|
||||
|
||||
if ($result -eq $true) {
|
||||
$tray.ShowBalloonTip(4000, 'IT Screen Recorder', 'Replay saved.', [System.Windows.Forms.ToolTipIcon]::Info)
|
||||
Show-Notification -Title 'IT Screen Recorder' -Body 'Replay saved.'
|
||||
}
|
||||
else {
|
||||
$tray.ShowBalloonTip(4000, 'IT Screen Recorder', 'Could not save replay. Please contact the helpdesk.', [System.Windows.Forms.ToolTipIcon]::Error)
|
||||
Show-Notification -Title 'IT Screen Recorder' -Body 'Could not save replay. Please contact the helpdesk.'
|
||||
}
|
||||
|
||||
$saveItem.Text = 'Save Replay'
|
||||
|
||||
Reference in New Issue
Block a user