-
-
Save binh12A3/d7abc83ec96b0732c763334a11f5cbf7 to your computer and use it in GitHub Desktop.
ModernDashboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
using System.Windows.Forms; | |
using System.Runtime.InteropServices; | |
namespace Dashboard | |
{ | |
public partial class Form1 : Form | |
{ | |
//Dùng để bo tròn 4 góc màn hình | |
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")] | |
private static extern IntPtr CreateRoundRectRgn | |
( | |
int nLeftRect, | |
int nTopRect, | |
int nRightRect, | |
int nBottomRect, | |
int nWidthEllipse, | |
int nHeightEllipse | |
); | |
public Form1() | |
{ | |
InitializeComponent(); | |
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 25, 25)); | |
panelNavigator.Height = btnDashboard.Height; | |
panelNavigator.Top = btnDashboard.Top; | |
panelNavigator.Left = btnDashboard.Left; | |
} | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
//Select Dashboard screen as default when init | |
btnDashboard.PerformClick();//btnDashboard.BackColor = Color.FromArgb(46, 51, 73); | |
unDisplayButton(btnDashboard); | |
} | |
void displayButton(string displayedString, Button selectedButton, Form selectedForm) | |
{ | |
panelNavigator.Height = selectedButton.Height; | |
panelNavigator.Top = selectedButton.Top; | |
panelNavigator.Left = selectedButton.Left; | |
selectedButton.BackColor = Color.FromArgb(46, 51, 73); | |
labelTitle.Text = displayedString; | |
this.panelFormLoader.Controls.Clear(); | |
selectedForm.FormBorderStyle = FormBorderStyle.None; | |
this.panelFormLoader.Controls.Add(selectedForm); | |
selectedForm.Show(); | |
} | |
void unDisplayButton(Button selectedButton) | |
{ | |
selectedButton.BackColor = Color.FromArgb(24, 30, 54); | |
} | |
private void btnDashboard_Click(object sender, EventArgs e) | |
{ | |
FormDashboard frmDashboard = new FormDashboard() { Dock = DockStyle.Fill, TopLevel = false, TopMost = true }; | |
displayButton("Dashboard", btnDashboard, frmDashboard); | |
} | |
private void btnAnalytics_Click(object sender, EventArgs e) | |
{ | |
FormAnalytics frmAnalytics = new FormAnalytics() { Dock = DockStyle.Fill, TopLevel = false, TopMost = true }; | |
displayButton("Analytics", btnAnalytics, frmAnalytics); | |
} | |
private void btnCalendar_Click(object sender, EventArgs e) | |
{ | |
FormCalendar frmCalendar = new FormCalendar() { Dock = DockStyle.Fill, TopLevel = false, TopMost = true }; | |
displayButton("Calendar", btnCalendar, frmCalendar); | |
} | |
private void btnContactUs_Click(object sender, EventArgs e) | |
{ | |
FormContactUs frmContactUs = new FormContactUs() { Dock = DockStyle.Fill, TopLevel = false, TopMost = true }; | |
displayButton("Contact Us", btnContactUs, frmContactUs); | |
} | |
private void btnSettings_Click(object sender, EventArgs e) | |
{ | |
FormSettings frmSettings = new FormSettings() { Dock = DockStyle.Fill, TopLevel = false, TopMost = true }; | |
displayButton("Settings", btnSettings, frmSettings); | |
} | |
private void btnDashboard_Leave(object sender, EventArgs e) | |
{ | |
unDisplayButton(btnDashboard); | |
} | |
private void btnAnalytics_Leave(object sender, EventArgs e) | |
{ | |
unDisplayButton(btnAnalytics); | |
} | |
private void btnCalendar_Leave(object sender, EventArgs e) | |
{ | |
unDisplayButton(btnCalendar); | |
} | |
private void btnContactUs_Leave(object sender, EventArgs e) | |
{ | |
unDisplayButton(btnContactUs); | |
} | |
private void btnSettings_Leave(object sender, EventArgs e) | |
{ | |
unDisplayButton(btnSettings); | |
} | |
private void btnExit_Click(object sender, EventArgs e) | |
{ | |
Application.Exit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment