Logo Pastebin.fr
Pastebin

Retrouvez, créez et partagez vos snippets en temps réel.

crea

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

function Show-SecureLogin {
    $formLogin = New-Object System.Windows.Forms.Form
    $formLogin.Text = ""
    $formLogin.Size = New-Object System.Drawing.Size(480,280)
    $formLogin.StartPosition = "CenterScreen"
    $formLogin.FormBorderStyle = "None"   # 🔥 Supprime la barre et les bordures

    # --- Dégradé vert anis → vert foncé ---
    $formLogin.Add_Paint({
        $brush = New-Object System.Drawing.Drawing2D.LinearGradientBrush(
            $formLogin.ClientRectangle,
            [System.Drawing.Color]::LimeGreen,   # vert anis
            [System.Drawing.Color]::DarkGreen,   # vert foncé
            [System.Drawing.Drawing2D.LinearGradientMode]::Vertical
        )
        $_.Graphics.FillRectangle($brush, $formLogin.ClientRectangle)
        $brush.Dispose()
    })

    # --- Bouton Fermer (croix en haut à droite) ---
    $closeButton = New-Object System.Windows.Forms.Button
    $closeButton.Text = "✖"
    $closeButton.Font = New-Object System.Drawing.Font("Segoe UI",12,[System.Drawing.FontStyle]::Bold)
    $closeButton.BackColor = [System.Drawing.Color]::Transparent
    $closeButton.ForeColor = [System.Drawing.Color]::White
    $closeButton.FlatStyle = "Flat"
    $closeButton.Location = New-Object System.Drawing.Point(440,10)
    $closeButton.Width = 30
    $closeButton.Height = 30
    $formLogin.Controls.Add($closeButton)

    $closeButton.Add_Click({
        $formLogin.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
        $formLogin.Close()
    })

    # --- Bandeau titre ---
    $titleLabel = New-Object System.Windows.Forms.Label
    $titleLabel.Text = "Agence Assurance Star"
    $titleLabel.Font = New-Object System.Drawing.Font("Segoe UI",18,[System.Drawing.FontStyle]::Bold)
    $titleLabel.ForeColor = [System.Drawing.Color]::White
    $titleLabel.BackColor = [System.Drawing.Color]::Transparent
    $titleLabel.AutoSize = $true
    $titleLabel.Location = New-Object System.Drawing.Point(100,25)
    $formLogin.Controls.Add($titleLabel)

    # --- Champ utilisateur ---
    $userLabel = New-Object System.Windows.Forms.Label
    $userLabel.Text = "Utilisateur"
    $userLabel.Font = New-Object System.Drawing.Font("Segoe UI",12)
    $userLabel.ForeColor = [System.Drawing.Color]::White
    $userLabel.BackColor = [System.Drawing.Color]::Transparent
    $userLabel.Location = New-Object System.Drawing.Point(60,90)
    $userLabel.AutoSize = $true
    $formLogin.Controls.Add($userLabel)

    $textBoxUser = New-Object System.Windows.Forms.TextBox
    $textBoxUser.Location = New-Object System.Drawing.Point(180,88)
    $textBoxUser.Width = 220
    $textBoxUser.Font = New-Object System.Drawing.Font("Segoe UI",12)
    $formLogin.Controls.Add($textBoxUser)

    # --- Champ mot de passe ---
    $passLabel = New-Object System.Windows.Forms.Label
    $passLabel.Text = "Mot de passe"
    $passLabel.Font = New-Object System.Drawing.Font("Segoe UI",12)
    $passLabel.ForeColor = [System.Drawing.Color]::White
    $passLabel.BackColor = [System.Drawing.Color]::Transparent
    $passLabel.Location = New-Object System.Drawing.Point(60,130)
    $passLabel.AutoSize = $true
    $formLogin.Controls.Add($passLabel)

    $textBoxPass = New-Object System.Windows.Forms.TextBox
    $textBoxPass.Location = New-Object System.Drawing.Point(180,128)
    $textBoxPass.Width = 180
    $textBoxPass.Font = New-Object System.Drawing.Font("Segoe UI",12)
    $textBoxPass.UseSystemPasswordChar = $true
    $formLogin.Controls.Add($textBoxPass)

    # --- Bouton œil moderne ---
    $eyeButton = New-Object System.Windows.Forms.Button
    $eyeButton.Text = "👁️"
    $eyeButton.Font = New-Object System.Drawing.Font("Segoe UI Emoji",12)
    $eyeButton.BackColor = [System.Drawing.Color]::Transparent
    $eyeButton.ForeColor = [System.Drawing.Color]::White
    $eyeButton.FlatStyle = "Flat"
    $eyeButton.Location = New-Object System.Drawing.Point(370,128)
    $eyeButton.Width = 40
    $eyeButton.Height = 30
    $formLogin.Controls.Add($eyeButton)

    $eyeButton.Add_Click({
        if ($textBoxPass.UseSystemPasswordChar) {
            $textBoxPass.UseSystemPasswordChar = $false
            $eyeButton.Text = "🙈"
            $eyeButton.ForeColor = [System.Drawing.Color]::LimeGreen
        } else {
            $textBoxPass.UseSystemPasswordChar = $true
            $eyeButton.Text = "👁️"
            $eyeButton.ForeColor = [System.Drawing.Color]::White
        }
    })

    # --- Bouton connexion avec glow ---
    $okButton = New-Object System.Windows.Forms.Button
    $okButton.Text = "Connexion"
    $okButton.Font = New-Object System.Drawing.Font("Segoe UI",12,[System.Drawing.FontStyle]::Bold)
    $okButton.BackColor = [System.Drawing.Color]::LimeGreen
    $okButton.ForeColor = [System.Drawing.Color]::White
    $okButton.FlatStyle = "Flat"
    $okButton.Location = New-Object System.Drawing.Point(180,180)
    $okButton.Width = 220
    $okButton.Height = 40
    $formLogin.Controls.Add($okButton)

    $okButton.Add_Paint({
        $pen = New-Object System.Drawing.Pen([System.Drawing.Color]::LimeGreen,2)
        $_.Graphics.DrawRectangle($pen,0,0,$okButton.Width-1,$okButton.Height-1)
        $pen.Dispose()
    })

    # --- Validation ---
    $okButton.Add_Click({
        if ($textBoxUser.Text -eq "agentstar" -and $textBoxPass.Text -eq "assurance2026") {
            $formLogin.DialogResult = [System.Windows.Forms.DialogResult]::OK
            $formLogin.Close()
        } else {
            [System.Windows.Forms.MessageBox]::Show("Accès refusé","Erreur",
                [System.Windows.Forms.MessageBoxButtons]::OK,
                [System.Windows.Forms.MessageBoxIcon]::Error)
        }
    })

    $result = $formLogin.ShowDialog()
    if ($result -eq [System.Windows.Forms.DialogResult]::OK) {
        return $textBoxUser.Text
    } else {
        return $null
    }
}

# --- Programme principal ---
$Currentuser = Show-SecureLogin
if ($Currentuser) {
    [System.Windows.Forms.MessageBox]::Show("Bienvenue $Currentuser !","Échéancier",
        [System.Windows.Forms.MessageBoxButtons]::OK,
        [System.Windows.Forms.MessageBoxIcon]::Information)

    . 'C:\Users\walid\Desktop\123\initial 20-01-2026with func.ps1'
}

Créé il y a 3 semaines.

Rechercher un Pastebin

Aucun paste trouvé.