
################################################################

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

################################################################

$currentDir = Get-Location

# Note: An absolute path must be set for ImagePath.
$WindowTitle = "ご注意"
$ImagePath   = "$currentDir\$stellarium_version\setup\sshot_defender_app.ann.ja.gif"
$MessageText = "ISC初回起動時に、上記のダイアログ２つが出現します。`r`nどちらも必ず「アクセスを許可する」をクリックしてください！"

# Check for existence of image file
if ( -not (Test-Path $ImagePath ) ) {
  Write-Error "File not found: $ImagePath"
  exit
}

$Form                 = New-Object System.Windows.Forms.Form
$Form.Text            = $WindowTitle
$Form.Size            = New-Object System.Drawing.Size(651, 538)
$Form.StartPosition   = "CenterScreen"
$Form.FormBorderStyle = "FixedDialog"
$Form.MaximizeBox     = $false
$Form.MinimizeBox     = $false

$PictureBox          = New-Object System.Windows.Forms.PictureBox
$PictureBox.Image    = [System.Drawing.Image]::FromFile($ImagePath)
$PictureBox.Location = New-Object System.Drawing.Point(10, 10)
$PictureBox.Size     = New-Object System.Drawing.Size(615, 435)
$PictureBox.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::Normal
$Form.Controls.Add($PictureBox)

$Label           = New-Object System.Windows.Forms.Label
$Label.Text      = $MessageText
$Label.Location  = New-Object System.Drawing.Point(20, 453)
$Label.Size      = New-Object System.Drawing.Size(512, 40)
$Label.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter
$Label.Font      = New-Object System.Drawing.Font("MS Gothic", 12)
$Form.Controls.Add($Label)

$OkButton              = New-Object System.Windows.Forms.Button
$OkButton.Text         = "OK"
$OkButton.Location     = New-Object System.Drawing.Point(551, 457)
$OkButton.Size         = New-Object System.Drawing.Size(54, 30)
$OkButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$Form.Controls.Add($OkButton)

# To enable closing the window using the Enter or Esc key.
$Form.AcceptButton = $OkButton
$Form.CancelButton = $OkButton

# Show Dialog
$junk = $Form.ShowDialog()

# Free memory, Unlock image file
$PictureBox.Image.Dispose()
$Form.Dispose()

