-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhotoViewer.ps1
72 lines (69 loc) · 3.48 KB
/
PhotoViewer.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Start-Process -FilePath "powershell" -WindowStyle Hidden -WorkingDirectory $PSScriptRoot -Verb runAs `
-ArgumentList "-NoProfile -ExecutionPolicy Bypass -File $PSCommandPath"
return
}
Import-LocalizedData -BaseDirectory $PSScriptRoot\Locales -BindingVariable Messages
Import-Module -Name (Join-Path -Path $PSScriptRoot\Modules -ChildPath Set-PhotoViewer)
Remove-Variable -Name Wpf*
[xml] $Xaml = @"
<Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication3"
mc:Ignorable="d"
Title="MainWindow">
<Grid>
<Grid HorizontalAlignment="Left" Margin="10,10,10,10" VerticalAlignment="Top">
<Label x:Name="label0" Content="Label" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Grid>
<Grid Margin="10" HorizontalAlignment="Right" VerticalAlignment="Bottom">
<Button x:Name="button0" Content="Button" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="75"/>
<Button x:Name="button1" Content="Button" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="75" Margin="-80,0,80,0"/>
<Button x:Name="button2" Content="Button" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="75" Margin="-160,0,160,0"/>
</Grid>
</Grid>
</Window>
"@ -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
Add-Type -AssemblyName PresentationCore,PresentationFramework,WindowsBase,System.Windows.Forms
$Form = [Windows.Markup.XamlReader]::Load((New-Object -TypeName System.Xml.XmlNodeReader -ArgumentList $Xaml))
$Xaml.SelectNodes("//*[@Name]") | ForEach-Object { Set-Variable -Name "Wpf.$($_.Name)" -Value $Form.FindName($_.Name) }
Set-Location -Path $PSScriptRoot
${Wpf.button0}.Content = $messages."Close"
${Wpf.button0}.add_Click({
$Form.Close()
})
${Wpf.button1}.add_Click({
Set-PhotoViewer -Action Activate
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$Result = [System.Windows.Forms.MessageBox]::Show(
"PhotoViewer Verwendung aktiviert.",
"PhotoViewer", 0, [System.Windows.Forms.MessageBoxIcon]::Information
)
$Form.Close()
})
${Wpf.button2}.add_Click({
Set-PhotoViewer -Action Default
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$Result = [System.Windows.Forms.MessageBox]::Show(
"PhotoViewer Einstellungen auf den Werkszustand gesetzt.",
"PhotoViewer", 0, [System.Windows.Forms.MessageBoxIcon]::Information
)
$Form.Close()
})
${Wpf.button1}.Content = $messages."Activate"
${Wpf.button2}.Content = $messages."Restore"
${Wpf.button2}.Width = 120
${Wpf.label0}.Content = "Aktiviert das Fotoanzeigeprogramm PhotoViewer unter Windows 10.`n`nVerwenden Sie Wiederherstellen um auf den Werkszustand zur$([char]0x00FC)ckzusetzten."
${Wpf.label0}.Height = 180
$Form.Title = "PhotoViewer"
$Form.Height = 190
$Form.MinHeight = 190
$Form.MaxHeight = 190
$Form.Width = 450
$Form.MinWidth = 450
$Form.MaxWidth = 450
$Form.ResizeMode = "NoResize"
$Form.ShowDialog() | Out-Null