Team Ai
Apppublic

GamiDPC/windows-secure-shell

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