Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add-Type -AssemblyName PresentationFramework
- [xml]$xaml = @'
- <Window
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="くじ" Width="100" Height="150"
- >
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition />
- <ColumnDefinition />
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition />
- <RowDefinition />
- <RowDefinition />
- <RowDefinition />
- </Grid.RowDefinitions>
- <Label
- Grid.Row="0" Grid.Column="0" Name="atariLabel" Content="当たり"
- />
- <TextBox
- Grid.Row="0" Grid.Column="1" Name="atari" Text="1"
- />
- <Label
- Grid.Row="1" Grid.Column="0" Name="hazureLabel" Content="はずれ"
- />
- <TextBox
- Grid.Row="1" Grid.Column="1" Name="hazure" Text="2"
- />
- <Button
- Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Name="calc" Content="計算"
- />
- <Label
- Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Name="result" Content=""
- />
- </Grid>
- </Window>
- '@
- $reader = New-Object System.Xml.XmlNodeReader $xaml
- $window = [System.Windows.Markup.XamlReader]::Load($reader)
- $t1 = $window.FindName("atari")
- $t2 = $window.FindName("hazure")
- $b = $window.FindName("calc")
- $result = $window.FindName("result")
- $b.Add_Click({
- $result.Content = [String]([Int32](([Int32]$t1.Text * 100) / ([Int32]$t1.Text + [Int32]$t2.Text))) + " %"
- $window.Refresh
- })
- $window.ShowDialog() | Out-Null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement