Spaces:
Running
Running
File size: 9,795 Bytes
ea7379a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | csharp
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace SecureShell
{
public class SecureShellForm : Form
{
private Panel topPanel;
private Panel bottomPanel;
private FlowLayoutPanel appsPanel;
private Label titleLabel;
private Label timeLabel;
private Button adminButton;
private Timer clockTimer;
private const string AdminPassword = "secure123";
public SecureShellForm()
{
InitializeComponents();
SetupDarkTheme();
SetupClock();
CreateAppIcons();
}
private void InitializeComponents()
{
// Main form setup
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.BackColor = Color.FromArgb(30, 30, 30);
this.Text = "Secure Shell";
// Top panel
topPanel = new Panel();
topPanel.Dock = DockStyle.Top;
topPanel.Height = 60;
topPanel.BackColor = Color.FromArgb(43, 87, 154);
titleLabel = new Label();
titleLabel.Text = "ЗАЩИЩЕННАЯ ОБОЛОЧКА";
titleLabel.Font = new Font("Segoe UI", 14, FontStyle.Bold);
titleLabel.ForeColor = Color.White;
titleLabel.AutoSize = true;
titleLabel.Location = new Point(20, 20);
timeLabel = new Label();
timeLabel.Font = new Font("Segoe UI", 14, FontStyle.Bold);
timeLabel.ForeColor = Color.White;
timeLabel.AutoSize = true;
timeLabel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
topPanel.Controls.Add(titleLabel);
topPanel.Controls.Add(timeLabel);
this.Controls.Add(topPanel);
// Bottom panel
bottomPanel = new Panel();
bottomPanel.Dock = DockStyle.Bottom;
bottomPanel.Height = 60;
bottomPanel.BackColor = Color.FromArgb(43, 87, 154);
adminButton = new Button();
adminButton.Text = "АДМИН ДОСТУП";
adminButton.Font = new Font("Segoe UI", 10, FontStyle.Bold);
adminButton.ForeColor = Color.White;
adminButton.BackColor = Color.FromArgb(30, 30, 30);
adminButton.FlatStyle = FlatStyle.Flat;
adminButton.FlatAppearance.BorderSize = 0;
adminButton.Height = 40;
adminButton.Width = 150;
adminButton.Anchor = AnchorStyles.None;
adminButton.Click += AdminButton_Click;
bottomPanel.Controls.Add(adminButton);
this.Controls.Add(bottomPanel);
// Apps panel
appsPanel = new FlowLayoutPanel();
appsPanel.Dock = DockStyle.Fill;
appsPanel.Padding = new Padding(50);
appsPanel.BackColor = Color.FromArgb(30, 30, 30);
appsPanel.AutoScroll = true;
this.Controls.Add(appsPanel);
}
private void SetupDarkTheme()
{
this.BackColor = Color.FromArgb(30, 30, 30);
this.ForeColor = Color.White;
}
private void SetupClock()
{
clockTimer = new Timer();
clockTimer.Interval = 1000;
clockTimer.Tick += (s, e) => UpdateTime();
clockTimer.Start();
UpdateTime();
}
private void UpdateTime()
{
timeLabel.Text = DateTime.Now.ToString("HH:mm:ss");
timeLabel.Location = new Point(
topPanel.Width - timeLabel.Width - 20,
(topPanel.Height - timeLabel.Height) / 2
);
}
private void CreateAppIcons()
{
// Example apps - in real app you would load these from config
AddAppIcon("Notepad", "notepad.exe");
AddAppIcon("Calculator", "calc.exe");
AddAppIcon("Paint", "mspaint.exe");
AddAppIcon("Explorer", "explorer.exe");
AddAppIcon("CMD", "cmd.exe");
AddAppIcon("Browser", "iexplore.exe");
AddAppIcon("Word", "winword.exe");
AddAppIcon("Excel", "excel.exe");
AddAppIcon("PowerPoint", "powerpnt.exe");
}
private void AddAppIcon(string name, string exePath)
{
var iconButton = new Button();
iconButton.Width = 120;
iconButton.Height = 120;
iconButton.FlatStyle = FlatStyle.Flat;
iconButton.FlatAppearance.BorderSize = 0;
iconButton.Margin = new Padding(20);
iconButton.BackColor = Color.FromArgb(50, 50, 50);
iconButton.ForeColor = Color.White;
iconButton.Font = new Font("Segoe UI", 10, FontStyle.Regular);
iconButton.Text = name;
iconButton.TextAlign = ContentAlignment.BottomCenter;
iconButton.TextImageRelation = TextImageRelation.ImageAboveText;
try
{
var icon = Icon.ExtractAssociatedIcon(exePath);
iconButton.Image = icon.ToBitmap();
iconButton.ImageAlign = ContentAlignment.TopCenter;
}
catch
{
// Use default icon if extraction fails
iconButton.Image = SystemIcons.Application.ToBitmap();
}
iconButton.Click += (s, e) => LaunchApplication(exePath);
appsPanel.Controls.Add(iconButton);
}
private void LaunchApplication(string exePath)
{
try
{
Process.Start(exePath);
}
catch (Exception ex)
{
MessageBox.Show($"Error launching application: {ex.Message}",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void AdminButton_Click(object sender, EventArgs e)
{
using (var passwordForm = new PasswordForm())
{
if (passwordForm.ShowDialog() == DialogResult.OK)
{
if (passwordForm.Password == AdminPassword)
{
MessageBox.Show("Admin access granted!", "Success",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Invalid password!", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SecureShellForm());
}
}
public class PasswordForm : Form
{
private TextBox passwordBox;
private Button okButton;
private Button cancelButton;
public string Password { get; private set; }
public PasswordForm()
{
InitializeComponents();
SetupDarkTheme();
}
private void InitializeComponents()
{
this.Text = "Admin Access";
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.StartPosition = FormStartPosition.CenterScreen;
this.ClientSize = new Size(300, 150);
this.AcceptButton = okButton;
this.CancelButton = cancelButton;
var label = new Label();
label.Text = "Enter admin password:";
label.Location = new Point(20, 20);
label.AutoSize = true;
label.ForeColor = Color.White;
passwordBox = new TextBox();
passwordBox.Location = new Point(20, 50);
passwordBox.Size = new Size(260, 20);
passwordBox.PasswordChar = '*';
okButton = new Button();
okButton.Text = "OK";
okButton.Location = new Point(120, 90);
okButton.Size = new Size(75, 30);
okButton.DialogResult = DialogResult.OK;
okButton.Click += (s, e) =>
{
Password = passwordBox.Text;
this.Close();
};
cancelButton = new Button();
cancelButton.Text = "Cancel";
cancelButton.Location = new Point(205, 90);
cancelButton.Size = new Size(75, 30);
cancelButton.DialogResult = DialogResult.Cancel;
this.Controls.Add(label);
this.Controls.Add(passwordBox);
this.Controls.Add(okButton);
this.Controls.Add(cancelButton);
}
private void SetupDarkTheme()
{
this.BackColor = Color.FromArgb(30, 30, 30);
this.ForeColor = Color.White;
foreach (Control control in this.Controls)
{
if (control is Button button)
{
button.BackColor = Color.FromArgb(43, 87, 154);
button.ForeColor = Color.White;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 0;
}
else if (control is TextBox textBox)
{
textBox.BackColor = Color.FromArgb(50, 50, 50);
textBox.ForeColor = Color.White;
textBox.BorderStyle = BorderStyle.FixedSingle;
}
}
}
}
}
</html> |