-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert to hex.ps1
44 lines (33 loc) · 1.55 KB
/
convert to hex.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
[xml]$xaml = @"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Window" Title="Konwerter Hex na Dec" WindowStartupLocation = "CenterScreen" ResizeMode="NoResize"
Width = "313" Height = "280" ShowInTaskbar = "True" Background = "lightgray">
<StackPanel >
<Label Content='Wpisz wartość:' />
<TextBox x:Name="InputBox" Height = "50" AcceptsTab="True" AcceptsReturn="False" TextWrapping="Wrap" VerticalScrollBarVisibility = "Auto"/>
<StackPanel Orientation = 'Horizontal'>
<Button x:Name = "button1" Height = "75" Width = "100" Content = 'Oblicz i kopiuj' />
</StackPanel>
<Label Content='Wynik po konwersji i skopiowaniu:' />
<TextBox x:Name="OutputBox" IsReadOnly = "True" Height = "75" TextWrapping="Wrap" VerticalScrollBarVisibility = "Auto" Background="lightgray" />
</StackPanel>
</Window>
"@
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
$Window=[Windows.Markup.XamlReader]::Load( $reader )
$button1 = $Window.FindName('button1')
$button2 = $Window.FindName('button2')
$OutputBox = $Window.FindName('OutputBox')
$InputBox = $Window.FindName('InputBox')
$InputBox.Focus()
$button1.Add_Click({
$Hex = $InputBox.Text.Substring(2)
$Hex = [convert]::toint64($Hex,16)
Set-Clipboard -Value $Hex
$OutputBox.Text = "Wartość: "+$InputBox.Text+" przerobiono na "+$Hex
$InputBox.Clear()
})
$Window.ShowDialog() | Out-Null