From 8cab7caeb94caa1df2da7112ebdc1564af16d766 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 29 Dec 2014 23:44:39 +0000 Subject: [PATCH] added main window with console looking layout. Display functions written, and basic decoding started. --- mainWindow.Designer.cs | 89 ++++++++++++++++++++++++++++++ mainWindow.cs | 70 ++++++++++++++++++++++++ mainWindow.resx | 120 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 279 insertions(+) create mode 100644 mainWindow.Designer.cs create mode 100644 mainWindow.cs create mode 100644 mainWindow.resx diff --git a/mainWindow.Designer.cs b/mainWindow.Designer.cs new file mode 100644 index 0000000..14e3cd7 --- /dev/null +++ b/mainWindow.Designer.cs @@ -0,0 +1,89 @@ +namespace Pithos +{ + partial class mainWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.inputBox = new System.Windows.Forms.TextBox(); + this.output = new System.Windows.Forms.RichTextBox(); + this.executeButton = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // inputBox + // + this.inputBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.inputBox.Location = new System.Drawing.Point(12, 304); + this.inputBox.Name = "inputBox"; + this.inputBox.Size = new System.Drawing.Size(656, 23); + this.inputBox.TabIndex = 0; + // + // output + // + this.output.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.output.Location = new System.Drawing.Point(12, 12); + this.output.Name = "output"; + this.output.ReadOnly = true; + this.output.Size = new System.Drawing.Size(705, 286); + this.output.TabIndex = 1; + this.output.Text = ""; + // + // executeButton + // + this.executeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.executeButton.Location = new System.Drawing.Point(674, 301); + this.executeButton.Name = "executeButton"; + this.executeButton.Size = new System.Drawing.Size(43, 26); + this.executeButton.TabIndex = 2; + this.executeButton.Text = ">>"; + this.executeButton.UseVisualStyleBackColor = true; + this.executeButton.Click += new System.EventHandler(this.executeButton_Click); + // + // mainWindow + // + this.AcceptButton = this.executeButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(729, 339); + this.Controls.Add(this.executeButton); + this.Controls.Add(this.output); + this.Controls.Add(this.inputBox); + this.MaximizeBox = false; + this.Name = "mainWindow"; + this.Text = "Pithos - Main Window"; + this.Load += new System.EventHandler(this.mainWindow_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox inputBox; + private System.Windows.Forms.RichTextBox output; + private System.Windows.Forms.Button executeButton; + } +} \ No newline at end of file diff --git a/mainWindow.cs b/mainWindow.cs new file mode 100644 index 0000000..7360268 --- /dev/null +++ b/mainWindow.cs @@ -0,0 +1,70 @@ +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) { + 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; + text = decoder.injectVariables(text); //injects variables into string + 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) + { + display("Currently Logged in as: " + Environment.UserDomainName + "\\" + Environment.UserName, Color.Red); + } + + private void executeButton_Click(object sender, EventArgs e) + { + string input = inputBox.Text; + if (input == "") { return; } //if its empty, dont bother decoding + 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 + { + + } + else if (args[0] == "start") //runs a program (using cmd) + { + + } + else { decode.command(input); } //decode other commands + break; + case "¦": //admin commands + + break; + } + + if (input.Substring(0, 4).ToLower() == "echo") + { + display(input.Substring(5), Color.Green); + } + inputBox.Text = ""; //clear the contents after execution + } + } +} diff --git a/mainWindow.resx b/mainWindow.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/mainWindow.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file