안녕하세요 여러분 저는 계산기를 만들려고 노력하고 있습니다. 지금까지 GUI가 완료되었습니다. 그러나 배경 기능에 대한 도움이 필요합니다. 예 : 버튼 5 + 6을 입력하십시오. 이제 "="를 누르면 TextBox의 입력을 변수로 설정 한 다음 계산해야합니다. 누군가 내가 어떻게 할 수 있는지 아이디어가 있습니다. (Powershell에 꽤 익숙했습니다). 내 나쁜 Englisch를위한 감사와 sry. 인사말 산드로
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
#Platfrom
$Taschenrechner = New-Object System.Windows.Forms.Form
$Taschenrechner.StartPosition = "CenterScreen"
$Taschenrechner.Size = New-Object System.Drawing.Size(470,400)
$Taschenrechner.Text = "Taschenrechner"
#Titel
$Titel = New-Object System.Windows.Forms.Label
$Titel.Location = New-Object System.Drawing.Size(70,10)
$Titel.Size = New-Object System.Drawing.Size(360,50)
$Font = New-Object System.Drawing.Font("Arial",30,[System.Drawing.FontStyle]::Regular)
$Titel.Font = $Font
$Titel.Text = "Taschenrechner"
$Titel.Name = "Taschenrechner"
$Taschenrechner.Controls.Add($Titel)
#Textfeld
$Textfeld= New-Object System.Windows.Forms.TextBox
$Textfeld.Location = New-Object System.Drawing.Size(25,100)
$Textfeld.Size = New-Object System.Drawing.Size(100,100)
$Textfeld.Width = (400)
$Taschenrechner.Controls.Add($Textfeld)
#1
$button1 = New-Object System.Windows.Forms.Button
$button1.Location = New-Object System.Drawing.Size(25,120)
$button1.Size = New-Object System.Drawing.Size(100,50)
$button1.Add_Click({$Textfeld.Text+='1'})
$button1.Text = "1"
$button1.Name = "1"
$Taschenrechner.Controls.Add($button1)
#2
$button2 = New-Object System.Windows.Forms.Button
$button2.Location = New-Object System.Drawing.Size(125,120)
$button2.Size = New-Object System.Drawing.Size(100,50)
$button2.Add_Click({$Textfeld.Text+='2'})
$button2.Text = "2"
$button2.Name = "2"
$Taschenrechner.Controls.Add($button2)
#3
$button3 = New-Object System.Windows.Forms.Button
$button3.Location = New-Object System.Drawing.Size(225,120)
$button3.Size = New-Object System.Drawing.Size(100,50)
$button3.Add_Click({$Textfeld.Text+='3'})
$button3.Text = "3"
$button3.Name = "3"
$Taschenrechner.Controls.Add($button3)
#4
$button4 = New-Object System.Windows.Forms.Button
$button4.Location = New-Object System.Drawing.Size(25,170)
$button4.Size = New-Object System.Drawing.Size(100,50)
$button4.Add_Click({$Textfeld.Text+='4'})
$button4.Text = "4"
$button4.Name = "4"
$Taschenrechner.Controls.Add($button4)
#5
$button5 = New-Object System.Windows.Forms.Button
$button5.Location = New-Object System.Drawing.Size(125,170)
$button5.Size = New-Object System.Drawing.Size(100,50)
$button5.Add_Click({$Textfeld.Text+='5'})
$button5.Text = "5"
$button5.Name = "5"
$Taschenrechner.Controls.Add($button5)
#6
$button6 = New-Object System.Windows.Forms.Button
$button6.Location = New-Object System.Drawing.Size(225,170)
$button6.Size = New-Object System.Drawing.Size(100,50)
$button6.Add_Click({$Textfeld.Text+='6'})
$button6.Text = "6"
$button6.Name = "6"
$Taschenrechner.Controls.Add($button6)
#7
$button7 = New-Object System.Windows.Forms.Button
$button7.Location = New-Object System.Drawing.Size(25,220)
$button7.Size = New-Object System.Drawing.Size(100,50)
$button7.Add_Click({$Textfeld.Text+='7'})
$button7.Text = "7"
$button7.Name = "7"
$Taschenrechner.Controls.Add($button7)
#8
$button8 = New-Object System.Windows.Forms.Button
$button8.Location = New-Object System.Drawing.Size(125,220)
$button8.Size = New-Object System.Drawing.Size(100,50)
$button8.Add_Click({$Textfeld.Text+='8'})
$button8.Text = "8"
$button8.Name = "8"
$Taschenrechner.Controls.Add($button8)
#9
$button9 = New-Object System.Windows.Forms.Button
$button9.Location = New-Object System.Drawing.Size(225,220)
$button9.Size = New-Object System.Drawing.Size(100,50)
$button9.Add_Click({$Textfeld.Text+='9'})
$button9.Text = "9"
$button9.Name = "9"
$Taschenrechner.Controls.Add($button9)
#0
$button0 = New-Object System.Windows.Forms.Button
$button0.Location = New-Object System.Drawing.Size(25,270)
$button0.Size = New-Object System.Drawing.Size(100,50)
$button0.Add_Click({$Textfeld.Text+='0'})
$button0.Text = "0"
$button0.Name = "0"
$Taschenrechner.Controls.Add($button0)
#Dezimalstelle
$Punkt = New-Object System.Windows.Forms.Button
$Punkt.Location = New-Object System.Drawing.Size(125,270)
$Punkt.Size = New-Object System.Drawing.Size(100,50)
$Punkt.Add_Click({$Textfeld.Text+='.'})
$Punkt.Text = "."
$Punkt.Name = "."
$Taschenrechner.Controls.Add($Punkt)
#Gleich
$gleich = New-Object System.Windows.Forms.Button
$gleich.Location = New-Object System.Drawing.Size(225,270)
$gleich.Size = New-Object System.Drawing.Size(100,50)
$gleich.Text = "="
$gleich.Name = "="
$Taschenrechner.Controls.Add($gleich)
#Durch
$durch = New-Object System.Windows.Forms.Button
$durch.Location = New-Object System.Drawing.Size(325,120)
$durch.Size = New-Object System.Drawing.Size(100,50)
$durch.Text = "/"
$durch.Name = "/"
$Taschenrechner.Controls.Add($durch)
#Mal
$mal = New-Object System.Windows.Forms.Button
$mal.Location = New-Object System.Drawing.Size(325,170)
$mal.Size = New-Object System.Drawing.Size(100,50)
$mal.Text = "x"
$mal.Name = "x"
$Taschenrechner.Controls.Add($mal)
#Minus
$minus = New-Object System.Windows.Forms.Button
$minus.Location = New-Object System.Drawing.Size(325,220)
$minus.Size = New-Object System.Drawing.Size(100,50)
$minus.Text = "-"
$minus.Name = "-"
$Taschenrechner.Controls.Add($minus)
#Plus
$plus = New-Object System.Windows.Forms.Button
$plus.Location = New-Object System.Drawing.Size(325,270)
$plus.Size = New-Object System.Drawing.Size(100,50)
$plus.Text = "+"
$plus.Name = "+"
$Taschenrechner.Controls.Add($plus)
[void] $Taschenrechner.ShowDialog()
1
PowerShell을 사용하여 이러한 묘기를 끄는 경우 "실제"C # 프로그램을 작성하십시오. 두통이 적고 Visual Studio를 사용하면 많은 것들 (IntelliSense 등)에 대한 GUI 도움이 많이 필요합니다. 당신이해야 할 일은 버튼의 이벤트에 바인딩하고 이벤트에 바인딩하는 기능이 입력 텍스트를 변경하게합니다.
—
세스