-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
751 lines (627 loc) · 30.6 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
751 lines (627 loc) · 30.6 KB
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
using System;
using System.Threading.Tasks;
using Microsoft.WindowsAPICodePack.Dialogs;
using System.Windows;
using System.Windows.Input;
using System.Diagnostics;
using System.IO;
using System.ComponentModel;
using ActiproSoftware.Text.Languages.CSharp.Implementation;
using ActiproSoftware.Text.Languages.VB.Implementation;
using ActiproSoftware.Text.Languages.Xml.Implementation;
using ActiproSoftware.Text.Languages.JavaScript.Implementation;
using ActiproSoftware.Windows.Themes;
using ActiproSoftware.Text;
using ActiproSoftware.Text.Implementation;
using Telerik.Windows.Controls;
using ActiproSoftware.Windows.Themes;
namespace ProCodeX
{
/// <summary>
/// Interaction logic for Welcome.xaml
/// </summary>
public partial class MainWindow
{
public string language = "";
string filename;
string filepath;
bool savedfirsttime = false;
bool cSharpcompiledfirsttime = false;
bool VBcompiledfirsttime = false;
public MainWindow()
{
InitializeComponent();
ThemesAeroThemeCatalogRegistrar.Register();
if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.cs"))
{
File.Delete(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.cs");
}
if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.exe"))
{
File.Delete(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.exe");
}
if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.vb"))
{
File.Delete(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.vb");
}
compilationtext.Visibility = Visibility.Hidden;
ActiproSoftware.Windows.Themes.ThemeManager.SetTheme(syntaxEditor, ThemeNames.Black);
ActiproSoftware.Windows.Themes.ThemeManager.SetAreNativeThemesEnabled(syntaxEditor, true);
MainWindow radWindow = new MainWindow();
radWindow.IconTemplate = this.Resources["WindowIconTemplate"] as DataTemplate;
}
public void start()
{
try
{
Process p2 = new Process();
p2.StartInfo.FileName = "compilation.exe";
p2.Start();
}
catch (Win32Exception e)
{
System.Windows.MessageBox.Show("E010" + e + Environment.NewLine + "Your code have some problems, Errors Written below", "ProCode is mad", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
}
private void MenuItem_GotFocus(object sender, RoutedEventArgs e)
{
}
private void DonateButton_LostFocus(object sender, RoutedEventArgs e)
{
}
private void RadMenuItem_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
}
private void OpenCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".cs";
dlg.Filter = "C# (*.cs)|*.cs|VB.NET (*.vb)|*.vb|HTML (*.html)|*.html|CSS (*.css)|*.css|SQL(*.csv) | *.csv";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
syntaxEditor.Document.LoadFile(dlg.FileName);
filename = System.IO.Path.GetFileName(dlg.FileName); ;
savedfirsttime = true;
}
}
public void saveascommand()
{
Microsoft.Win32.SaveFileDialog dlgs = new Microsoft.Win32.SaveFileDialog();
dlgs.FileName = "Document"; // Default file name
dlgs.DefaultExt = ".text"; // Default file extension
dlgs.Filter = "C# (.cs)|*.cs|VB.NET (.vb)|*.vb|HTML (.html)|*.html|JavaScript (.js)|*.js|XML (.xml)|*.xml|XAML (.xaml)|*.xaml|SQL (.sql)|*.sql"; // Filter files by extension
Nullable<bool> result = dlgs.ShowDialog();
if (result == true)
{
syntaxEditor.Document.SaveFile(dlgs.FileName, LineTerminator.CarriageReturnNewline);
filename = System.IO.Path.GetFileName(dlgs.FileName);
filepath = dlgs.FileName;
savedfirsttime = true;
}
}
public void SaveAsCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
saveascommand();
}
private void NewCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
Window win2 = new Window();
win2.Show();
}
public void SaveCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
if (savedfirsttime == false)
{
saveascommand();
}
else
{
if (syntaxEditor.Text == "")
{
System.Windows.MessageBox.Show("E002" + Environment.NewLine + "Yo, you can't save an empty file", "ProCode is mad", MessageBoxButton.OK, MessageBoxImage.Error);
}
else
{
syntaxEditor.Document.SaveFile(filename, LineTerminator.CarriageReturnNewline);
}
}
}
private void DonateButton_Click(object sender, RoutedEventArgs e)
{
Process.Start("https://www.patreon.com/atechgeek");
}
private void MenuItem_Click_1(object sender, RoutedEventArgs e)
{
Process.Start("https://www.youtube.com/channel/UCMr_qcjz9ru6gpnl-h88KUA?sub_confirmation=1");
}
private void csharpButton_Click(object sender, RoutedEventArgs e)
{
syntaxEditor.Document.Language = new CSharpSyntaxLanguage();
language = "C#";
}
private void syntaxEditor_TextInput(object sender, TextCompositionEventArgs e)
{
}
private void new_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
Window win2 = new Window();
win2.Show();
}
private void open_Click_2(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".cs";
dlg.Filter = "C# (*.cs)|*.cs|VB.NET (*.vb)|*.vb|HTML (*.html)|*.html|CSS (*.css)|*.css|SQL(*.csv) | *.csv";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
using (StreamReader reader = new StreamReader(dlg.FileName))
{
syntaxEditor.Document.LoadFile(dlg.FileName);
string filepath = dlg.FileName;
filename = System.IO.Path.GetFileName(dlg.FileName); ;
savedfirsttime = true;
}
}
}
public void VBNETbutton_Click(object sender, RoutedEventArgs e)
{
syntaxEditor.Document.Language = new VBSyntaxLanguage();
language = "VBNET";
}
private void HTMLbutton_Click(object sender, RoutedEventArgs e)
{
syntaxEditor.Document.Language = new XmlSyntaxLanguage();
language = "HTML";
}
private void syntaxEditor_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
}
private void save_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
}
private void javascriptButton_Click(object sender, RoutedEventArgs e)
{
syntaxEditor.Document.Language = new JavaScriptSyntaxLanguage();
language = "JAVASCRIPT";
}
private void XMLbutton_Click(object sender, RoutedEventArgs e)
{
syntaxEditor.Document.Language = new XmlSyntaxLanguage();
language = "XML";
}
private void XAMLbutton_Click(object sender, RoutedEventArgs e)
{
syntaxEditor.Document.Language = new XmlSyntaxLanguage();
language = "XAML";
}
private void SQLbutton_Click(object sender, RoutedEventArgs e)
{
SyntaxLanguageDefinitionSerializer serializer = new SyntaxLanguageDefinitionSerializer();
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\langdef\Sql.langdef";
ISyntaxLanguage language = serializer.LoadFromFile(path);
this.syntaxEditor.Document.Language = language;
}
private void RadMenuItem_Click_1(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
}
private void undoButton_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.Document.UndoHistory.Undo();
}
private void redoButton_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.Document.UndoHistory.Redo();
}
private void cutButton_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.ActiveView.CutToClipboard();
}
private void copyButton_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.ActiveView.CopyToClipboard();
}
private void pasteButton_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.ActiveView.PasteFromClipboard();
}
private void deleteButton_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
}
private void selectAll_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.ActiveView.Selection.SelectAll();
}
private void zoomIn_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
var level = syntaxEditor.ZoomLevel;
syntaxEditor.ZoomLevel = level + 1.0;
}
private void zoomOut_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
var level = syntaxEditor.ZoomLevel;
syntaxEditor.ZoomLevel = level - 0.1;
}
private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
var level = syntaxEditor.ZoomLevel;
syntaxEditor.ZoomLevel = level + 0.1;
}
private void CommandBinding_Executed_1(object sender, ExecutedRoutedEventArgs e)
{
var level = syntaxEditor.ZoomLevel;
syntaxEditor.ZoomLevel = level - 0.1;
}
private void RadMenuItem_Click_2(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
}
private void settingsButton_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
}
private void Button_Click(object sender, RoutedEventArgs e)
{
feedback fed = new feedback();
fed.Show();
}
private void minimizeButton_Click(object sender, Telerik.Windows.RadRoutedEventArgs e) {
Window win = new Window();
win.WindowState = System.Windows.WindowState.Minimized;
}
private void minimizeButton_Click_1(object sender, Telerik.Windows.RadRoutedEventArgs e) {
Window win = new Window();
win.WindowState = System.Windows.WindowState.Minimized;
}
private void aboutBtn_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
AboutScreen ab = new AboutScreen();
ab.Show();
}
private void CompileBtn_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
if (savedfirsttime == false)
{
System.Windows.MessageBox.Show("E003" + Environment.NewLine + "Yo, save the file b4 compiling", "ProCode is mad", MessageBoxButton.OK, MessageBoxImage.Error);
}
if (language == "")
{
System.Windows.MessageBox.Show("E004" + Environment.NewLine + "Yo, Choose a language b4 getting excited", "ProCode is mad", MessageBoxButton.OK, MessageBoxImage.Error);
}
if (language == "HTML")
{
System.Windows.MessageBox.Show("E005" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
}
if (language == "JAVASCRIPT")
{
System.Windows.MessageBox.Show("E005" + Environment.NewLine + "This Language isn't supported for exporting, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
}
if (language == "XML")
{
System.Windows.MessageBox.Show("E005" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
}
if (language == "XAML")
{
System.Windows.MessageBox.Show("E005" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
}
if (language == "SQL")
{
System.Windows.MessageBox.Show("E005" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
}
if (language == "C#")
{
if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.cs"))
{
File.Delete(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.cs");
}
if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.exe"))
{
File.Delete(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.exe");
}
if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.vb"))
{
File.Delete(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.vb");
}
string fileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.cs";
if (!File.Exists(fileName))
{
File.Create(fileName).Close();
using (StreamWriter sw = File.AppendText(fileName))
{
syntaxEditor.Document.SaveFile(fileName, LineTerminator.CarriageReturnNewline);
}
}
compilationtext.Visibility = Visibility.Visible;
hidebutton.Visibility = Visibility.Visible;
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "csc.exe";
p.StartInfo.Arguments = "compilation.cs"; //or your thing
p.Start();
p.WaitForExit();
string result = p.StandardOutput.ReadToEnd();
compilationtext.Text = result;
status.Content = "Status: Compilation Successful";
cSharpcompiledfirsttime = true;
}
if (language == "VBNET")
{
string fileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.vb";
if (!File.Exists(fileName))
{
File.Create(fileName).Close();
using (StreamWriter sw = File.AppendText(fileName))
{
syntaxEditor.Document.SaveFile(fileName, LineTerminator.CarriageReturnNewline);
}
}
compilationtext.Visibility = Visibility.Visible;
hidebutton.Visibility = Visibility.Visible;
status.Content = "Status: Compiling...";
Process p = new Process();
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "vbc.exe";
p.StartInfo.Arguments = "compilation.vb"; //or your thing
p.Start();
p.WaitForExit();
string result = p.StandardOutput.ReadToEnd();
compilationtext.Text = result;
status.Content = "Status: Compilation finished";
VBcompiledfirsttime = true;
}
}
private async void startButton_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
if (savedfirsttime == false)
{
System.Windows.MessageBox.Show("E003" + Environment.NewLine + "Yo, save the file b4 compiling", "ProCode is mad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (language == "")
{
System.Windows.MessageBox.Show("E004" + Environment.NewLine + "Yo, Choose a language b4 getting excited", "ProCode is mad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (language == "HTML")
{
System.Windows.MessageBox.Show("E005" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (language == "JAVASCRIPT")
{
System.Windows.MessageBox.Show("E005" + Environment.NewLine + "This Language isn't supported for exporting, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (language == "XML")
{
System.Windows.MessageBox.Show("E005" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (language == "XAML")
{
System.Windows.MessageBox.Show("E005" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (language == "SQL")
{
System.Windows.MessageBox.Show("E005" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (language == "C#")
{
if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.cs"))
{
File.Delete(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.cs");
}
if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.exe"))
{
File.Delete(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.exe");
}
if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.vb"))
{
File.Delete(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.vb");
}
string fileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.cs";
if (!File.Exists(fileName))
{
File.Create(fileName).Close();
syntaxEditor.Document.SaveFile(fileName, LineTerminator.CarriageReturnNewline);
}
compilationtext.Visibility = Visibility.Visible;
hidebutton.Visibility = Visibility.Visible;
status.Content = "Status: Compiling..";
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "csc.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.Arguments = "compilation.cs"; //or your thing
p.Start();
p.WaitForExit();
string result = p.StandardOutput.ReadToEnd();
compilationtext.Text = result;
status.Content = "Status: Compilation finished";
cSharpcompiledfirsttime = true;
await Task.Delay(1000);
start();
}
if (language == "VBNET")
{
string fileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.vb";
if (!File.Exists(fileName))
{
File.Create(fileName).Close();
syntaxEditor.Document.SaveFile(fileName, LineTerminator.CarriageReturnNewline);
}
compilationtext.Visibility = Visibility.Visible;
hidebutton.Visibility = Visibility.Visible;
status.Content = "Status: Compiling..";
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = "vbc.exe";
p.StartInfo.Arguments = "compilation.vb"; //or your thing
p.Start();
p.WaitForExit();
string result = p.StandardOutput.ReadToEnd();
compilationtext.Text = result;
status.Content = "Status: Compilation finished";
VBcompiledfirsttime = true;
await Task.Delay(1000);
start();
}
}
private void hidebutton_Click(object sender, RoutedEventArgs e)
{
compilationtext.Visibility = Visibility.Hidden;
hidebutton.Visibility = Visibility.Hidden;
}
private void publishBtn_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
if (language == "C#")
{
if (savedfirsttime == false)
{
System.Windows.MessageBox.Show("E003" + Environment.NewLine + "Yo, save the file b4 publishing", "ProCode is mad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (language == "")
{
System.Windows.MessageBox.Show("E004" + Environment.NewLine + "Yo, Choose a language b4 getting excited", "ProCode is mad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (language == "HTML")
{
System.Windows.MessageBox.Show("E004" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
else if (language == "JAVASCRIPT")
{
System.Windows.MessageBox.Show("E004" + Environment.NewLine + "This Language isn't supported for exporting, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
else if (language == "XML")
{
System.Windows.MessageBox.Show("E004" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
else if (language == "XAML")
{
System.Windows.MessageBox.Show("E004" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
else if (language == "SQL")
{
System.Windows.MessageBox.Show("E004" + Environment.NewLine + "This Language isn't a programming language, Go to File>Save As Instead", "ProCode is sad", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
else
{
string fileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.cs";
if (!File.Exists(fileName))
{
File.Create(fileName).Close();
using (StreamWriter sw = File.AppendText(fileName))
{
syntaxEditor.Document.SaveFile(fileName, LineTerminator.CarriageReturnNewline);
}
}
compilationtext.Visibility = Visibility.Visible;
hidebutton.Visibility = Visibility.Visible;
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "csc.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.Arguments = "compilation.cs"; //or your thing
p.Start();
p.WaitForExit();
string results = p.StandardOutput.ReadToEnd();
compilationtext.Text = results;
status.Content = "Status: Compilation Successful";
var dlgw = new CommonOpenFileDialog();
dlgw.Title = "Export your code:";
dlgw.IsFolderPicker = true;
dlgw.AddToMostRecentlyUsedList = false;
dlgw.AllowNonFileSystemItems = false;
dlgw.EnsureFileExists = true;
dlgw.EnsurePathExists = true;
dlgw.EnsureReadOnly = false;
dlgw.EnsureValidNames = true;
dlgw.Multiselect = false;
dlgw.ShowPlacesList = true;
if (dlgw.ShowDialog() == CommonFileDialogResult.Ok)
{
var folder = dlgw.FileName;
File.Copy(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.cs", folder + @"\compilation.cs");
File.Copy(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\compilation.exe", folder + @"\compilation.exe");
}
}
}
}
private void new_Click_1(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
Window mw = new Window();
mw.Show();
}
private void Window_Closing(object sender, CancelEventArgs e)
{
MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to save b4 exit?", "Warning", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.No)
{
}
if(result == MessageBoxResult.Yes){
if (savedfirsttime == false)
{
saveascommand();
}
else
{
if (syntaxEditor.Text == "")
{
System.Windows.MessageBox.Show("E002" + Environment.NewLine + "Yo, you can't save an empty file", "ProCode is mad", MessageBoxButton.OK, MessageBoxImage.Error);
}
else
{
syntaxEditor.Document.SaveFile(filename, LineTerminator.CarriageReturnNewline);
}
}
}
if(result == MessageBoxResult.Cancel)
{
e.Cancel = true;
}
}
private void syntaxEditor_DragOver(object sender, System.Windows.DragEventArgs e)
{
}
private void undoContext_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.Document.UndoHistory.Undo();
}
private void redoContext_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.Document.UndoHistory.Redo();
}
private void cutContext_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.ActiveView.CutToClipboard();
}
private void copyContext_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.ActiveView.CopyToClipboard();
}
private void pasteContext_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
syntaxEditor.ActiveView.PasteFromClipboard();
}
private void addButton_Click(object sender, RoutedEventArgs e)
{
}
}
}