Skip to content

Part 2, UI Customization #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/Data-Dashboard-CSharp-SQL-WinForms/v16/.suo
Binary file not shown.
Binary file added .vs/DataDashboardApp/v16/.suo
Binary file not shown.
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
7 changes: 7 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\DataDashboardApp.sln",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
353 changes: 257 additions & 96 deletions DataDashboardApp/Form1.Designer.cs

Large diffs are not rendered by default.

86 changes: 74 additions & 12 deletions DataDashboardApp/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public partial class Form1 : Form
{
//Fields
private Dashboard model;
private Button currentButton;

//Constructor
public Form1()
Expand All @@ -24,7 +25,7 @@ public Form1()
dtpStartDate.Value = DateTime.Today.AddDays(-7);
dtpEndDate.Value = DateTime.Now;
btnLast7Days.Select();

SetDataMenuButtonsUI(btnLast7Days);
model = new Dashboard();
LoadData();
}
Expand Down Expand Up @@ -60,11 +61,39 @@ private void LoadData()
}
else Console.WriteLine("View not loaded, same query");
}
private void DisableCustomDates()
private void SetDataMenuButtonsUI(object button)
{
dtpStartDate.Enabled = false;
dtpEndDate.Enabled = false;
btnOkCustomDate.Visible = false;
var btn = (Button)button;
//Highligh button
btn.BackColor = btnLast30Days.FlatAppearance.BorderColor;
btn.ForeColor = Color.White;
//Unhighlight button
if (currentButton != null&&currentButton!=btn)
{
currentButton.BackColor = this.BackColor;
currentButton.ForeColor = Color.FromArgb(124, 141, 181);
}
currentButton = btn;//Set current button

//Enable custom dates
if(btn==btnCustomDate)
{
dtpStartDate.Enabled = true;
dtpEndDate.Enabled = true;
btnOkCustomDate.Visible = true;
lblStartDate.Cursor = Cursors.Hand;
lblEndDate.Cursor = Cursors.Hand;
}
//Disable custom dates
else
{
dtpStartDate.Enabled = false;
dtpEndDate.Enabled = false;
btnOkCustomDate.Visible = false;
lblStartDate.Cursor = Cursors.Default;
lblEndDate.Cursor = Cursors.Default;
}

}

//Event methods
Expand All @@ -73,43 +102,76 @@ private void btnToday_Click(object sender, EventArgs e)
dtpStartDate.Value = DateTime.Today;
dtpEndDate.Value = DateTime.Now;
LoadData();
DisableCustomDates();
SetDataMenuButtonsUI(sender);
}

private void btnLast7Days_Click(object sender, EventArgs e)
{
dtpStartDate.Value = DateTime.Today.AddDays(-7);
dtpEndDate.Value = DateTime.Now;
LoadData();
DisableCustomDates();
SetDataMenuButtonsUI(sender);
}

private void btnLast30Days_Click(object sender, EventArgs e)
{
dtpStartDate.Value = DateTime.Today.AddDays(-30);
dtpEndDate.Value = DateTime.Now;
LoadData();
DisableCustomDates();
SetDataMenuButtonsUI(sender);
}

private void btnThisMonth_Click(object sender, EventArgs e)
{
dtpStartDate.Value = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
dtpEndDate.Value = DateTime.Now;
LoadData();
DisableCustomDates();
SetDataMenuButtonsUI(sender);
}

private void btnCustomDate_Click(object sender, EventArgs e)
{
dtpStartDate.Enabled = true;
dtpEndDate.Enabled = true;
btnOkCustomDate.Visible = true;
SetDataMenuButtonsUI(sender);
}

private void btnOkCustomDate_Click(object sender, EventArgs e)
{
LoadData();
}

private void lblStartDate_Click(object sender, EventArgs e)
{
if (currentButton == btnCustomDate)
{
dtpStartDate.Select();
SendKeys.Send("%{DOWN}");
}
}

private void lblEndDate_Click(object sender, EventArgs e)
{
if (currentButton == btnCustomDate)
{
dtpEndDate.Select();
SendKeys.Send("%{DOWN}");
}
}

private void dtpStartDate_ValueChanged(object sender, EventArgs e)
{
lblStartDate.Text = dtpStartDate.Text;
}

private void dtpEndDate_ValueChanged(object sender, EventArgs e)
{
lblEndDate.Text = dtpEndDate.Text;
}

private void Form1_Load(object sender, EventArgs e)
{
lblStartDate.Text = dtpStartDate.Text;
lblEndDate.Text = dtpEndDate.Text;
dgvUnderstock.Columns[1].Width = 50;
}
}
}
Binary file modified DataDashboardApp/bin/Debug/DashboardApp.exe
Binary file not shown.
Binary file modified DataDashboardApp/bin/Debug/DashboardApp.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ D:\RJ Code Advance\Source Code C#\2022\DataDashboardApp\DataDashboardApp\obj\Deb
D:\RJ Code Advance\Source Code C#\2022\DataDashboardApp\DataDashboardApp\obj\Debug\DashboardApp.exe
D:\RJ Code Advance\Source Code C#\2022\DataDashboardApp\DataDashboardApp\obj\Debug\DashboardApp.pdb
D:\RJ Code Advance\Source Code C#\2022\DataDashboardApp\DataDashboardApp\obj\Debug\DashboardApp.Form1.resources
D:\GitHub\repo\Data-Dashboard-CSharp-SQL-WinForms\DataDashboardApp\obj\Debug\DashboardApp.csproj.AssemblyReference.cache
D:\GitHub\repo\Data-Dashboard-CSharp-SQL-WinForms\DataDashboardApp\obj\Debug\DashboardApp.Form1.resources
D:\GitHub\repo\Data-Dashboard-CSharp-SQL-WinForms\DataDashboardApp\obj\Debug\DashboardApp.Properties.Resources.resources
D:\GitHub\repo\Data-Dashboard-CSharp-SQL-WinForms\DataDashboardApp\obj\Debug\DashboardApp.csproj.GenerateResource.cache
D:\GitHub\repo\Data-Dashboard-CSharp-SQL-WinForms\DataDashboardApp\obj\Debug\DashboardApp.csproj.CoreCompileInputs.cache
D:\GitHub\repo\Data-Dashboard-CSharp-SQL-WinForms\DataDashboardApp\obj\Debug\DashboardApp.exe
D:\GitHub\repo\Data-Dashboard-CSharp-SQL-WinForms\DataDashboardApp\obj\Debug\DashboardApp.pdb
D:\GitHub\repo\Data-Dashboard-CSharp-SQL-WinForms\DataDashboardApp\bin\Debug\DashboardApp.exe.config
D:\GitHub\repo\Data-Dashboard-CSharp-SQL-WinForms\DataDashboardApp\bin\Debug\DashboardApp.exe
D:\GitHub\repo\Data-Dashboard-CSharp-SQL-WinForms\DataDashboardApp\bin\Debug\DashboardApp.pdb
Binary file not shown.
Binary file modified DataDashboardApp/obj/Debug/DashboardApp.exe
Binary file not shown.
Binary file modified DataDashboardApp/obj/Debug/DashboardApp.pdb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]