Advertisement
cd62131

くじ

Oct 29th, 2016
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Add-Type -AssemblyName PresentationFramework
  2. [xml]$xaml = @'
  3. <Window
  4.  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5.  Title="くじ" Width="100" Height="150"
  6. >
  7.  <Grid>
  8.    <Grid.ColumnDefinitions>
  9.      <ColumnDefinition />
  10.      <ColumnDefinition />
  11.    </Grid.ColumnDefinitions>
  12.    <Grid.RowDefinitions>
  13.      <RowDefinition />
  14.      <RowDefinition />
  15.      <RowDefinition />
  16.      <RowDefinition />
  17.    </Grid.RowDefinitions>
  18.    <Label
  19.      Grid.Row="0" Grid.Column="0" Name="atariLabel" Content="当たり"
  20.    />
  21.    <TextBox
  22.      Grid.Row="0" Grid.Column="1" Name="atari" Text="1"
  23.    />
  24.    <Label
  25.      Grid.Row="1" Grid.Column="0" Name="hazureLabel" Content="はずれ"
  26.    />
  27.    <TextBox
  28.      Grid.Row="1" Grid.Column="1" Name="hazure" Text="2"
  29.    />
  30.    <Button
  31.      Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Name="calc" Content="計算"
  32.    />
  33.    <Label
  34.      Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Name="result" Content=""
  35.    />
  36.  </Grid>
  37. </Window>
  38. '@
  39. $reader = New-Object System.Xml.XmlNodeReader $xaml
  40. $window = [System.Windows.Markup.XamlReader]::Load($reader)
  41. $t1 = $window.FindName("atari")
  42. $t2 = $window.FindName("hazure")
  43. $b = $window.FindName("calc")
  44. $result = $window.FindName("result")
  45. $b.Add_Click({
  46.   $result.Content = [String]([Int32](([Int32]$t1.Text * 100) / ([Int32]$t1.Text + [Int32]$t2.Text))) + " %"
  47.   $window.Refresh
  48. })
  49.  
  50. $window.ShowDialog() | Out-Null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement