Skip to content
Merged
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
2 changes: 1 addition & 1 deletion CAPBuilds/0.0.4/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog

### Added

- Added keyboard shortcuts

### Changed

Expand Down
1 change: 1 addition & 0 deletions CSV Analyzer Pro/CSV Analyzer Pro/CSV Analyzer Pro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@
<Compile Include="Search.Designer.cs">
<DependentUpon>Search.cs</DependentUpon>
</Compile>
<Compile Include="ShortcutHandler.cs" />
<Compile Include="UpdateAvailable.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
26 changes: 24 additions & 2 deletions CSV Analyzer Pro/CSV Analyzer Pro/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public partial class Form1 : Form{
DataSet ds = new DataSet();

BackgroundWorker worker;

ShortcutHandler shortcutHandler;

string path = "";

bool _exiting = false;
Expand All @@ -48,6 +49,11 @@ public Form1(){

//Enable Progress Reorting
worker.WorkerReportsProgress = true;

tabControl1.KeyUp += new KeyEventHandler(KeyUpReporter);
tabControl1.KeyDown += new KeyEventHandler(KeyDownReporter);
tabControl1.KeyDown += new KeyEventHandler(ShortcutChecker);
shortcutHandler = new ShortcutHandler();
}

private void Form1_Load(object sender, EventArgs e) {
Expand Down Expand Up @@ -181,6 +187,22 @@ private void OnKeyCommands(object sender,KeyEventArgs e) {
//Psuedo code
}

private void KeyDownReporter(object sender, KeyEventArgs e) {
shortcutHandler.ReportKeyDown(e.KeyCode.ToString());
}

private void KeyUpReporter(object sender, KeyEventArgs e) {
shortcutHandler.ReportKeyUp(e.KeyCode.ToString());
}

private void ShortcutChecker(object sender, KeyEventArgs e) {
switch (shortcutHandler.CheckShortcuts()) {
case ShortcutHandler.shortcuts.NewWindow:
NewWindow();
break;
}
}

private void Model_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e) {
if (e.Style.CellType != "ColumnHeaderCell" && (e.RowIndex % 2 == 0))
e.Style.BackColor = Color.LightCyan;
Expand Down Expand Up @@ -229,7 +251,7 @@ private void Browse() {
DataTable dt = ds.Tables.Add(index.ToString());
path = csvSearch.FileName;
tabControl1.SelectedTab.Text = csvSearch.FileName;
OpenCSVFile();
Open(csvSearch.FileName);
}
}

Expand Down
77 changes: 77 additions & 0 deletions CSV Analyzer Pro/CSV Analyzer Pro/ShortcutHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CSV_Analyzer_Pro {
class ShortcutHandler {

public enum shortcuts { NoShortcut, NewWindow };
Dictionary<string, bool> keyStates = new Dictionary<string, bool>();

public ShortcutHandler() {

}

public bool CheckKeyDown(string key) {

bool keyDown;
bool keyInDict;

keyInDict = keyStates.TryGetValue(key, out keyDown);

if (!keyInDict) {
keyDown = false; // Assuming key is up if it has not previously been set as down
keyStates.Add(key, keyDown);
}

return keyDown;

}

public void ReportKeyUp(string key) {

bool keyInDict;

keyInDict = keyStates.ContainsKey(key);

if (!keyInDict) {
keyStates.Add(key, false);
}
else {
keyStates[key] = false;
}

}

public void ReportKeyDown(string key) {

bool keyInDict;

keyInDict = keyStates.ContainsKey(key);

if (!keyInDict) {
keyStates.Add(key, true);
}
else {
keyStates[key] = true;
}

}

public shortcuts CheckShortcuts() {

shortcuts shortcut = shortcuts.NoShortcut;

if (CheckKeyDown(Keys.ControlKey.ToString()) && CheckKeyDown(Keys.N.ToString())) {
shortcut = shortcuts.NewWindow;
}

return shortcut;

}

}
}