Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
- #This creates the path for the Json and also check if it is already there.
- If(!(Test-Path -Path C:Users$env:USERNAMEdocumentsJson))
- {
- New-Item c:users$env:USERNAMEdocuments -ItemType directory -Name Json
- $path = "c:users$env:USERNAMEdocumentsJson"
- }
- #creating the form
- $objForm = New-Object System.Windows.Forms.Form
- $objForm.Text = "Ofir`s script"
- $objForm.Size = New-Object System.Drawing.Size(480,200)
- $objForm.StartPosition = "CenterScreen"
- #creating the label
- $objLabel = New-Object System.Windows.Forms.Label
- $objLabel.Location = New-Object System.Drawing.Size(20,20)
- $objLabel.Size = New-Object System.Drawing.Size(280,20)
- $objLabel.Text = "Please check the relevant boxes:"
- $objForm.Controls.Add($objLabel)
- #This creates a checkbox called dsp.z
- $objDspCheckbox = New-Object System.Windows.Forms.Checkbox
- $objDspCheckbox.Location = New-Object System.Drawing.Size(20,40)
- $objDspCheckbox.Size = New-Object System.Drawing.Size(280,20)
- $objDspCheckbox.Text = "dsp.z"
- $objDspCheckbox.TabIndex = 0
- $objForm.Controls.Add($objDspCheckbox)
- #This creates a checkbox called fpga.bin
- $objFpgaCheckbox = New-Object System.Windows.Forms.Checkbox
- $objFpgaCheckbox.Location = New-Object System.Drawing.Size(20,60)
- $objFpgaCheckbox.Size = New-Object System.Drawing.Size(280,20)
- $objFpgaCheckbox.Text = "fpga.bin"
- $objFpgaCheckbox.TabIndex = 1
- $objForm.Controls.Add($objFpgaCheckbox)
- #This creates a checkbox called bootrom_uncmp.bin
- $objBootCheckbox = New-Object System.Windows.Forms.Checkbox
- $objBootCheckbox.Location = New-Object System.Drawing.Size(20,80)
- $objBootCheckbox.Size = New-Object System.Drawing.Size(280,20)
- $objBootCheckbox.Text = "bootrom_uncmp.bin"
- $objBootCheckbox.TabIndex = 2
- $objForm.Controls.Add($objBootCheckbox)
- #This creates a label for the TextBox1
- $objLabel1 = New-Object System.Windows.Forms.Label
- $objLabel1.Location = New-Object System.Drawing.Size(300,20)
- $objLabel1.Size = New-Object System.Drawing.Size(280,20)
- $objLabel1.Text = "Change the name?:"
- $objForm.Controls.Add($objLabel1)
- #This creates the TextBox1
- $objTextBox1 = New-Object System.Windows.Forms.TextBox
- $objTextBox1.Location = New-Object System.Drawing.Size(200,40)
- $objTextBox1.Size = New-Object System.Drawing.Size(200,20)
- $objTextBox1.TabIndex = 3
- $objForm.Controls.Add($objTextBox1)
- #ok Button
- $OKButton = New-Object System.Windows.Forms.Button
- $OKButton.Location = New-Object System.Drawing.Size(40,120)
- $OKButton.Size = New-Object System.Drawing.Size(75,23)
- $OKButton.Text = "OK"
- $OKButton.Add_Click(
- {
- if ($objDspCheckbox.Checked -eq $true)
- {
- New-Item $path -itemtype file -name Dsp.json -value @"
- "{"sys_ver":"01.01.01.02","RED":[],"RED_VA":[],"BLACK": [{"type":"6","type_descr":"DSP file","tar_name":"dsp.tar.gz","image_name":"dsp.z","CRC":"1234567","version":"01.01.01.02","metadata":"62056"}
- ],"BLACK_VA":[]
- }"
- "@ ;$objForm.close()
- }
- elseif ($objFpgaCheckbox.Checked -eq $true)
- {
- New-Item $path -itemtype file -name Fpga.json -value @"
- "
- {"type":"4","type_descr":"FPGA file","tar_name":"FPGA.tar.gz","image_name":"fpga.z","CRC":"1234567","version":"01.01.01.02","metadata":"9730652"},
- "
- "@
- ;$objForm.close()
- }
- elseif ($objBootCheckbox.Checked -eq $true)
- {
- New-Item $path -itemtype file -name Boot.json -value "Hello3" ;$objForm.close()
- }
- })
- $objForm.Controls.Add($OKButton)
- #cancle Button
- $CancelButton = New-Object System.Windows.Forms.Button
- $CancelButton.Location = New-Object System.Drawing.Size(140,120)
- $CancelButton.Size = New-Object System.Drawing.Size(75,23)
- $CancelButton.Text = "Cancel"
- $CancelButton.Add_Click({$objForm.Close()})
- $objForm.Controls.Add($CancelButton)
- #Parameters (Need to add)
- $dspname = $objTextBox1
- #makes the form appear on top of the screen
- $objForm.Topmost = $True
- $objForm.Add_Shown({$objForm.Activate()})
- [void] $objForm.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement