Skip to content

Commit

Permalink
Add Ctrl+S shortcut to save file
Browse files Browse the repository at this point in the history
Add access keys on font & save buttons
  • Loading branch information
nwalkewicz committed Jun 26, 2023
1 parent cc79f59 commit a05b826
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ namespace invoice_generator
{
public partial class form : Form
{
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.S))
{
savePdf();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}

private string FONT_FAMILY = "Inter";
private string GRAND_TOTAL = "$0.00";

Expand Down Expand Up @@ -109,15 +119,16 @@ private void updateGrandTotal()

private void button_save_Click(object sender, EventArgs e)
{
saveFileDialog.FileName = "invoice.pdf";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
savePdf(saveFileDialog.FileName);
}
savePdf();
}

private void savePdf(string filename)
private void savePdf()
{
saveFileDialog.FileName = "invoice.pdf";
saveFileDialog.Filter = "PDF Document|*.pdf";
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
string filename = saveFileDialog.FileName;

string FROM = input_from.Text;
string ID = input_id.Text != string.Empty ? "#" + input_id.Text : string.Empty;
string TO = input_to.Text;
Expand Down

0 comments on commit a05b826

Please sign in to comment.