Advertisement
wetyukmnbxc

Untitled

Mar 5th, 2023
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #region Variables $button1 = "Button 1" $button2 = "Button 2" $button3 = "Button 3" $button4 = "Button 4" $textDisplay = "Text Display" #endregion #region Main Function Main { #Create the window and display it $window = New-Object -TypeName System.Windows.Window $window.Title = "Window Title" $window.Width = 300 $window.Height = 200 $window.ResizeMode = "Canvas" $window.Closed += (New-Object System.EventHandler) {$_ = $Window.Close} $window.Show() #Create the buttons and add them to the window $button1 = New-Object -TypeName System.Windows.Button $button1.Width = 100 $button1.Height = 25 $button1.Location = New-Object System.Drawing.Point(10,10) $button1.Text = $button1.Name $button1.Font = "Arial" $button1.ForeColor = "Blue" $button2 = New-Object -TypeName System.Windows.Button $button2.Width = 100 $button2.Height = 25 $button2.Location = New-Object System.Drawing.Point(120,10) $button2.Text = $button2.Name $button2.Font = "Arial" $button2.ForeColor = "Blue" $button3 = New-Object -TypeName System.Windows.Button $button3.Width = 100 $button3.Height = 25 $button3.Location = New-Object System.Drawing.Point(220,10) $button3.Text = $button3.Name $button3.Font = "Arial" $button3.ForeColor = "Blue" $button4 = New-Object -TypeName System.Windows.Button $button4.Width = 100 $button4.Height = 25 $button4.Location = New-Object System.Drawing.Point(320,10) $button4.Text = $button4.Name $button4.Font = "Arial" $button4.ForeColor = "Blue" #Bind the buttons to their respective functions $button1.Click += (New-Object System.EventHandler) {$button1.Text = "Button 1" $button1.ForeColor = "Red"} $button2.Click += (New-Object System.EventHandler) {$button2.Text = "Button 2" $button2.ForeColor = "Red"} $button3.Click += (New-Object System.EventHandler) {$button3.Text = "Button 3" $button3.ForeColor = "Red"} $button4.Click += (New-Object System.EventHandler) {$button4.Text = "Button 4" $button4.ForeColor = "Red"} #Update the text display $textDisplay.Text = "Button 1: " + $button1.Text + "
  2.  
  3. Button 2: " + $button2.Text + "
  4.  
  5. Button 3: " + $button3.Text + "
  6.  
  7. Button 4: " + $button4.Text } #endregion Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement