Загрузка данных


[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::InputEncoding = [System.Text.Encoding]::UTF8

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

# ------------------- НАСТРОЙКИ -------------------
$AlertTitle = "ЭКСТРЕННОЕ ОПОВЕЩЕНИЕ"
$AlertMessage = @"
Срочно покиньте помещение
"@
$SoundRepeat = $true               # Воспроизводить звук каждую секунду
# -------------------------------------------------

# Создаем форму
$Form = New-Object System.Windows.Forms.Form
$Form.Text = $AlertTitle
$Form.StartPosition = "CenterScreen"
$Form.FormBorderStyle = "FixedDialog"
$Form.ControlBox = $false
$Form.TopMost = $true
$Form.WindowState = "Maximized"
$Form.BackColor = [System.Drawing.Color]::FromArgb(192, 0, 0)
$Form.KeyPreview = $true

# Запрещаем закрытие через Alt+F4
#$Form.Add_KeyDown({
#    if ($_.KeyCode -eq "F4" -and $_.Alt) {
#        $_.SuppressKeyPress = $true
#    }
#})

# ---------- ЗАГОЛОВОК (по центру сверху) ----------
$LabelTitle = New-Object System.Windows.Forms.Label
#$LabelTitle.Text = $AlertTitle
$LabelTitle.Text = "БЕСПИЛОТНАЯ ОПАСНОСТЬ"
$LabelTitle.Font = New-Object System.Drawing.Font("Arial", 32, [System.Drawing.FontStyle]::Bold)
$LabelTitle.ForeColor = [System.Drawing.Color]::White
$LabelTitle.AutoSize = $true
$LabelTitle.TextAlign = "MiddleCenter"

# Центрируем по горизонтали и вертикали (20% от высоты экрана)
$Form.Add_Shown({
    $LabelTitle.Left = ($Form.ClientSize.Width - $LabelTitle.Width) / 2
    $LabelTitle.Top = ($Form.ClientSize.Height * 0.15) - ($LabelTitle.Height / 2)
})
$Form.Controls.Add($LabelTitle)

# ---------- ОСНОВНОЙ ТЕКСТ (строго по центру) ----------
$LabelMessage = New-Object System.Windows.Forms.Label
$LabelMessage.Text = $AlertMessage
$LabelMessage.Font = New-Object System.Drawing.Font("Arial", 20)
$LabelMessage.ForeColor = [System.Drawing.Color]::White
$LabelMessage.AutoSize = $true
$LabelMessage.TextAlign = "MiddleCenter"

# Центрируем по горизонтали и вертикали
$Form.Add_Shown({
    $LabelMessage.Left = ($Form.ClientSize.Width - $LabelMessage.Width) / 2
    $LabelMessage.Top = ($Form.ClientSize.Height / 2) - ($LabelMessage.Height / 2)
})
$Form.Controls.Add($LabelMessage)

# ---------- КНОПКА (по центру внизу) ----------
$ButtonOk = New-Object System.Windows.Forms.Button
$ButtonOk.Text = "ПОДТВЕРЖДАЮ"
$ButtonOk.Font = New-Object System.Drawing.Font("Arial", 18, [System.Drawing.FontStyle]::Bold)
$ButtonOk.Size = New-Object System.Drawing.Size(300, 80)
$ButtonOk.BackColor = [System.Drawing.Color]::White
$ButtonOk.ForeColor = [System.Drawing.Color]::DarkRed
$ButtonOk.FlatStyle = "Popup"

# Центрируем по горизонтали, вертикально — внизу (80% от высоты)
$Form.Add_Shown({
    $ButtonOk.Left = ($Form.ClientSize.Width - $ButtonOk.Width) / 2
    $ButtonOk.Top = ($Form.ClientSize.Height * 0.78) - ($ButtonOk.Height / 2)
})
$ButtonOk.Add_Click({
    $Form.Close()
    $Global:AlertClosed = $true
})
$Form.Controls.Add($ButtonOk)

# ---------- ФУТЕР (по центру в самом низу) ----------
$LabelFooter = New-Object System.Windows.Forms.Label
$LabelFooter.Text = "Ждите дальнейших указаний"
$LabelFooter.Font = New-Object System.Drawing.Font("Arial", 12, [System.Drawing.FontStyle]::Italic)
$LabelFooter.ForeColor = [System.Drawing.Color]::LightGray
$LabelFooter.AutoSize = $true
$LabelFooter.TextAlign = "MiddleCenter"

$Form.Add_Shown({
    $LabelFooter.Left = ($Form.ClientSize.Width - $LabelFooter.Width) / 2
    $LabelFooter.Top = ($Form.ClientSize.Height * 0.92) - ($LabelFooter.Height / 2)
})
$Form.Controls.Add($LabelFooter)

# ---------- ЗВУКОВОЙ ПОВТОР ----------
if ($SoundRepeat) {
    $Timer = New-Object System.Windows.Forms.Timer
    $Timer.Interval = 10000
    $Timer.Add_Tick({
        [System.Console]::Beep(800, 500)
    })
    $Timer.Start()
}

# ---------- ПОКАЗЫВАЕМ ФОРМУ ----------
$Global:AlertClosed = $false
$Form.ShowDialog()

# Очистка ресурсов
$Form.Dispose()