Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
  2. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
  3.  
  4. #This creates the path for the Json and also check if it is already there.
  5. If(!(Test-Path -Path C:Users$env:USERNAMEdocumentsJson))
  6. {
  7. New-Item c:users$env:USERNAMEdocuments -ItemType directory -Name Json
  8.  
  9. $path = "c:users$env:USERNAMEdocumentsJson"
  10.  
  11. }
  12. #creating the form
  13. $objForm = New-Object System.Windows.Forms.Form
  14. $objForm.Text = "Ofir`s script"
  15. $objForm.Size = New-Object System.Drawing.Size(480,200)
  16. $objForm.StartPosition = "CenterScreen"
  17.  
  18. #creating the label
  19. $objLabel = New-Object System.Windows.Forms.Label
  20. $objLabel.Location = New-Object System.Drawing.Size(20,20)
  21. $objLabel.Size = New-Object System.Drawing.Size(280,20)
  22. $objLabel.Text = "Please check the relevant boxes:"
  23. $objForm.Controls.Add($objLabel)
  24.  
  25. #This creates a checkbox called dsp.z
  26. $objDspCheckbox = New-Object System.Windows.Forms.Checkbox
  27. $objDspCheckbox.Location = New-Object System.Drawing.Size(20,40)
  28. $objDspCheckbox.Size = New-Object System.Drawing.Size(280,20)
  29. $objDspCheckbox.Text = "dsp.z"
  30. $objDspCheckbox.TabIndex = 0
  31. $objForm.Controls.Add($objDspCheckbox)
  32.  
  33. #This creates a checkbox called fpga.bin
  34. $objFpgaCheckbox = New-Object System.Windows.Forms.Checkbox
  35. $objFpgaCheckbox.Location = New-Object System.Drawing.Size(20,60)
  36. $objFpgaCheckbox.Size = New-Object System.Drawing.Size(280,20)
  37. $objFpgaCheckbox.Text = "fpga.bin"
  38. $objFpgaCheckbox.TabIndex = 1
  39. $objForm.Controls.Add($objFpgaCheckbox)
  40.  
  41. #This creates a checkbox called bootrom_uncmp.bin
  42. $objBootCheckbox = New-Object System.Windows.Forms.Checkbox
  43. $objBootCheckbox.Location = New-Object System.Drawing.Size(20,80)
  44. $objBootCheckbox.Size = New-Object System.Drawing.Size(280,20)
  45. $objBootCheckbox.Text = "bootrom_uncmp.bin"
  46. $objBootCheckbox.TabIndex = 2
  47. $objForm.Controls.Add($objBootCheckbox)
  48.  
  49. #This creates a label for the TextBox1
  50. $objLabel1 = New-Object System.Windows.Forms.Label
  51. $objLabel1.Location = New-Object System.Drawing.Size(300,20)
  52. $objLabel1.Size = New-Object System.Drawing.Size(280,20)
  53. $objLabel1.Text = "Change the name?:"
  54. $objForm.Controls.Add($objLabel1)
  55.  
  56. #This creates the TextBox1
  57. $objTextBox1 = New-Object System.Windows.Forms.TextBox
  58. $objTextBox1.Location = New-Object System.Drawing.Size(200,40)
  59. $objTextBox1.Size = New-Object System.Drawing.Size(200,20)
  60. $objTextBox1.TabIndex = 3
  61. $objForm.Controls.Add($objTextBox1)
  62.  
  63. #ok Button
  64. $OKButton = New-Object System.Windows.Forms.Button
  65. $OKButton.Location = New-Object System.Drawing.Size(40,120)
  66. $OKButton.Size = New-Object System.Drawing.Size(75,23)
  67. $OKButton.Text = "OK"
  68. $OKButton.Add_Click(
  69. {
  70. if ($objDspCheckbox.Checked -eq $true)
  71. {
  72. New-Item $path -itemtype file -name Dsp.json -value @"
  73. "{"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"}
  74. ],"BLACK_VA":[]
  75. }"
  76. "@ ;$objForm.close()
  77. }
  78.  
  79. elseif ($objFpgaCheckbox.Checked -eq $true)
  80. {
  81. New-Item $path -itemtype file -name Fpga.json -value @"
  82. "
  83. {"type":"4","type_descr":"FPGA file","tar_name":"FPGA.tar.gz","image_name":"fpga.z","CRC":"1234567","version":"01.01.01.02","metadata":"9730652"},
  84. "
  85. "@
  86.  
  87. ;$objForm.close()
  88. }
  89.  
  90. elseif ($objBootCheckbox.Checked -eq $true)
  91. {
  92. New-Item $path -itemtype file -name Boot.json -value "Hello3" ;$objForm.close()
  93. }
  94. })
  95.  
  96. $objForm.Controls.Add($OKButton)
  97.  
  98. #cancle Button
  99. $CancelButton = New-Object System.Windows.Forms.Button
  100. $CancelButton.Location = New-Object System.Drawing.Size(140,120)
  101. $CancelButton.Size = New-Object System.Drawing.Size(75,23)
  102. $CancelButton.Text = "Cancel"
  103. $CancelButton.Add_Click({$objForm.Close()})
  104. $objForm.Controls.Add($CancelButton)
  105.  
  106. #Parameters (Need to add)
  107. $dspname = $objTextBox1
  108.  
  109. #makes the form appear on top of the screen
  110. $objForm.Topmost = $True
  111.  
  112. $objForm.Add_Shown({$objForm.Activate()})
  113. [void] $objForm.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement