Skip to content

Commit

Permalink
Fixed a couple of bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Abbin44 committed Sep 23, 2021
1 parent 4914393 commit 237c78c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,5 @@ healthchecksdb
/CodeGraphData/Result_files/xml
/CodeGraphData
/CMD++.jpg
/logo.txt
/logo2.txt
23 changes: 16 additions & 7 deletions CustomShell/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Drawing;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using static CustomShell.Calculator;

Expand Down Expand Up @@ -35,7 +36,7 @@ public MainController()
Directory.CreateDirectory(@"C:\Users\" + Environment.UserName + @"\AppData\Local\CMD++");

if (!File.Exists(historyFilePath))
File.Create(historyFilePath);
File.Create(historyFilePath).Close();

if (controller != null)
throw new Exception("Only one instance of MainController may ever exist!");
Expand Down Expand Up @@ -113,8 +114,9 @@ public void AddCommandToConsole(string[] tokens)

public void UpdateHistoryFile(string command)
{
if(cmdHistory[cmdHistory.Length - 1] != command)//Check if the last command is the same as the current one so that there are no doubles in the history
File.AppendAllText(historyFilePath, command + "\n");
if(cmdHistory.Length > 0)
if(cmdHistory[cmdHistory.Length - 1] != command)//Check if the last command is the same as the current one so that there are no doubles in the history
File.AppendAllText(historyFilePath, command + "\n");

LoadHistoryFile();//Update history array
}
Expand Down Expand Up @@ -914,6 +916,8 @@ go out of bounds or change index by 2
*/
if (e.KeyCode == Keys.Up)
{
if (cmdHistory.Length == 0 || cmdHistory == null)
return;
e.Handled = true;
if (historyIndex > 0 && historyIndex <= cmdHistory.Length)
{
Expand All @@ -929,6 +933,8 @@ go out of bounds or change index by 2

if (e.KeyCode == Keys.Down)
{
if (cmdHistory.Length == 0 || cmdHistory == null)
return;
e.Handled = true;
if (historyIndex > 0 && historyIndex < cmdHistory.Length - 1)
{
Expand Down Expand Up @@ -965,9 +971,7 @@ private void inputBox_KeyUp(object sender, KeyEventArgs e)
private void wandTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.S)//Save and quit from Wand
{
wand.SaveAndExit();
}
else if (e.Control && e.KeyCode == Keys.H)//Toggle syntax highlighting
{
if (syntaxHighlight == true)
Expand All @@ -982,9 +986,7 @@ private void wandTextBox_KeyDown(object sender, KeyEventArgs e)
}
}
else if (e.Control && e.KeyCode == Keys.Q)//Quit without save Wand
{
wand.Exit();
}
}

private void MainController_FormClosing(object sender, FormClosingEventArgs e)
Expand All @@ -993,8 +995,15 @@ private void MainController_FormClosing(object sender, FormClosingEventArgs e)
ftpController = null;

if(sshClient != null)
{
if (sshClient.client.IsConnected)
sshClient.TerminateConnection();

sshClient = null;
}

if (systemInfo != null)
systemInfo = null;
}
}
}
34 changes: 32 additions & 2 deletions CustomShell/SystemInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,26 @@ class SystemInformation
*/
public SystemInformation()
{
GetIcon();
}

private void CompileInformation()
{
string os = string.Empty;
string cpu = string.Empty;
string gpu = string.Empty;
string ram = string.Empty;
string uptime = string.Empty;

GetOS();
GetCPU();
GetGPU();
GetRAM();

}

private string GetOS()
{
//searcher = new ManagementObjectSearcher("select * from " + Key);

string os = string.Empty;

return os;
Expand Down Expand Up @@ -96,5 +109,22 @@ private string GetRAM()
}
return ram;
}

private void GetIcon()
{
//This is too large, needs to be replaced
string icon =
$@"________ /\\\\\\\\\_ __/\\\\____________ /\\\\_ __/\\\\\\\\\\\\____ _______________ _______________
_____ /\\\////////__ _\/\\\\\\________/\\\\\\_ _\/\\\////////\\\__ _______________ _______________
___ /\\\/ __________ _\/\\\//\\\____/\\\//\\\_ _\/\\\______\//\\\_ ______/\\\_____ ______/\\\_____
__ /\\\_____________ _\/\\\\///\\\/\\\/_\/\\\_ _\/\\\_______\/\\\_ _____\/\\\_____ _____\/\\\_____
_\/\\\_____________ _\/\\\__\///\\\/___\/\\\_ _\/\\\_______\/\\\_ __/\\\\\\\\\\\_ __/\\\\\\\\\\\_
_\//\\\____________ _\/\\\____\///_____\/\\\_ _\/\\\_______\/\\\_ _\/////\\\///__ _\/////\\\///__
__\///\\\__________ _\/\\\_____________\/\\\_ _\/\\\_______/\\\__ _____\/\\\_____ _____\/\\\_____
____\////\\\\\\\\\_ _\/\\\_____________\/\\\_ _\/\\\\\\\\\\\\/___ _____\///______ _____\///______
_______\/////////__ _\///______________\///__ _\////////////_____ _______________ _______________";

MainController.controller.outputBox.AppendText(icon);
}
}
}

0 comments on commit 237c78c

Please sign in to comment.