2014-12-29 23:44:39 +00:00
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Data ;
using System.Drawing ;
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
using System.Windows.Forms ;
namespace Pithos
{
public partial class mainWindow : Form
{
private decode decoder = new decode ( ) ;
public bool adminMode = false ;
public mainWindow ( )
{
InitializeComponent ( ) ;
}
public void display ( string text , Color colour ) {
2015-01-04 22:25:01 +00:00
/ * Message Color Codes :
* Green : User Messages ( Mainly Echo )
* Orange : Admin Commands
* Black : General text / Date
* Red : Error Messages
* Blue : Messages from Program
* /
2014-12-29 23:44:39 +00:00
if ( output . TextLength ! = 0 ) { output . AppendText ( "\n[" + DateTime . Now . ToString ( "hh:mm:ss" ) + "] " ) ; } //so that the first line isnt a new line for no reason. (although its extra code)
else { output . AppendText ( "[" + DateTime . Now . ToString ( "hh:mm:ss" ) + "] " ) ; }
int length = output . TextLength ;
2015-01-04 22:25:01 +00:00
text = decoder . injectVariables ( text ) ;
2014-12-29 23:44:39 +00:00
output . AppendText ( text ) ;
output . SelectionStart = length ;
output . SelectionLength = text . Length ;
output . SelectionColor = colour ;
output . SelectionStart = length + text . Length ;
output . SelectionColor = Color . Black ;
}
private void mainWindow_Load ( object sender , EventArgs e )
{
2015-01-04 22:25:01 +00:00
display ( "Currently Logged in as: " + Environment . UserDomainName + "\\" + Environment . UserName , Color . Blue ) ;
2014-12-29 23:44:39 +00:00
}
private void executeButton_Click ( object sender , EventArgs e )
{
2015-01-04 22:25:01 +00:00
bool valid = true ;
2014-12-29 23:44:39 +00:00
string input = inputBox . Text ;
2015-01-04 22:25:01 +00:00
if ( input = = "" ) { display ( "Error: No command given." , Color . Red ) ; return ; } //if its empty, dont bother decoding
2014-12-29 23:44:39 +00:00
string initChar = input . Substring ( 0 , 1 ) ; //gets the first character in the input
string [ ] args = input . Substring ( 1 ) . Split ( ' ' ) ; //splits the input by spaces, and removes init character
switch ( initChar )
{
case "/" :
if ( args [ 0 ] = = "exec" ) //runs a pithos program
{
2014-12-30 22:39:01 +00:00
pithosPrograms . decodeInput ( input ) ;
return ;
2014-12-29 23:44:39 +00:00
}
else if ( args [ 0 ] = = "start" ) //runs a program (using cmd)
{
}
2015-01-04 22:25:01 +00:00
else { valid = decoder . command ( input ) ; } //decode other commands
2014-12-29 23:44:39 +00:00
break ;
case "¦" : //admin commands
2015-01-04 22:25:01 +00:00
privateFunctions . adminCommands ( input ) ;
2014-12-29 23:44:39 +00:00
break ;
}
if ( input . Substring ( 0 , 4 ) . ToLower ( ) = = "echo" )
{
display ( input . Substring ( 5 ) , Color . Green ) ;
}
inputBox . Text = "" ; //clear the contents after execution
}
}
}