-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
166 lines (161 loc) · 6.84 KB
/
Form1.cs
File metadata and controls
166 lines (161 loc) · 6.84 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
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;
using System.IO;
namespace Code_Checker
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Task build = new Task(calling);
build.Start();
if (!Directory.Exists("template")) Directory.CreateDirectory("template");
if (!File.Exists("template/codeCheck.cpp")) using (StreamWriter tw = new StreamWriter("template/codeCheck.cpp")) { tw.Write(""); }
if (!File.Exists("template/codeAccepted.cpp")) using (StreamWriter tw = new StreamWriter("template/codeAccepted.cpp")){ tw.Write("");}
if (!File.Exists("template/codeGen.cpp")) using (StreamWriter tw = new StreamWriter("template/codeGen.cpp")){ tw.Write("");}
editorCodeCheck.Text = System.IO.File.ReadAllText(@"template\codeCheck.cpp");
editorAccepted.Text = System.IO.File.ReadAllText(@"template\codeAccepted.cpp");
editorTest.Text = System.IO.File.ReadAllText(@"template\codeGen.cpp");
}
private void calling()
{
if (Directory.Exists("processing")) Directory.Delete("processing", true);
if (Directory.Exists("temp")) Directory.Delete("temp", true);
if (Directory.Exists("external")) Directory.Delete("external", true);
string[] srcInp = Directory.GetFiles(".", "*.inp", SearchOption.AllDirectories);
string[] srcOut = Directory.GetFiles(".", "*.out", SearchOption.AllDirectories);
foreach (string filePath in srcInp)
{
File.Delete(filePath);
while (!File.Exists(filePath)) break;
}
foreach (string filePath in srcOut)
{
File.Delete(filePath);
while (!File.Exists(filePath)) break;
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
Timer time = new Timer();
time.Interval = 1;
time.Tick += new EventHandler(countwordRefesh);
time.Enabled = true;
}
private void countwordRefesh(object sender, EventArgs e)
{
int cur = 0;
if (TabEditor.SelectedIndex == 0) cur = editorCodeCheck.SelectionStart;
if (TabEditor.SelectedIndex == 1) cur = editorAccepted.SelectionStart;
if (TabEditor.SelectedIndex == 2) cur = editorTest.SelectionStart;
position.Text = "Pos: " + cur.ToString();
}
private void importCodeCheckToolStripMenuItem_Click(object sender, EventArgs e)
{
Stream stream;
importCodeCheck.Title = "Import Code Check";
importCodeCheck.Filter = "C++ files|*.cpp";
if(importCodeCheck.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if((stream = importCodeCheck.OpenFile()) != null)
{
editorCodeCheck.Text = File.ReadAllText(importCodeCheck.FileName);
TabEditor.SelectedIndex = 0;
editorCodeCheck.Zoom = 100;
stream.Close();
}
}
private void importAcceptedCodeToolStripMenuItem_Click(object sender, EventArgs e)
{
Stream stream;
importAccepted.Title = "Import Accepted Code";
importAccepted.Filter = "C++ files|*.cpp";
if (importAccepted.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if ((stream = importAccepted.OpenFile()) != null)
{
editorAccepted.Text = File.ReadAllText(importAccepted.FileName);
TabEditor.SelectedIndex = 1;
editorAccepted.Zoom = 100;
stream.Close();
}
}
private void importTestGeratorToolStripMenuItem_Click(object sender, EventArgs e)
{
Stream stream;
importTest.Title = "Import Test Generator";
importTest.Filter = "C++ files|*.cpp";
if (importTest.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if ((stream = importTest.OpenFile()) != null)
{
editorTest.Text = File.ReadAllText(importTest.FileName);
TabEditor.SelectedIndex = 2;
editorTest.Zoom = 100;
stream.Close();
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void saveFileToolStripMenuItem_Click(object sender, EventArgs e)
{
saveFile.Title = "Export file";
saveFile.Filter = "C++ files|*.cpp";
saveFile.FileName = "main.cpp";
if (saveFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Stream stream = saveFile.OpenFile();
StreamWriter strw = new StreamWriter(stream);
if(TabEditor.SelectedIndex == 0) strw.Write(editorCodeCheck.Text);
if(TabEditor.SelectedIndex == 1) strw.Write(editorAccepted.Text);
if(TabEditor.SelectedIndex == 2) strw.Write(editorTest.Text);
strw.Close();
stream.Close();
}
}
string test = "";
string time = "1000";
private void buildAndRunToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 child = new Form2(editorCodeCheck.Text, editorAccepted.Text, editorTest.Text, test, time);
child.StartPosition = FormStartPosition.CenterParent;
child.ShowDialog();
test = child.opentest;
time = child.opentime;
}
private void showCodeCheckTabToolStripMenuItem_Click(object sender, EventArgs e)
{
TabEditor.SelectedIndex = 0;
}
private void showAcceptedCodeTabToolStripMenuItem_Click(object sender, EventArgs e)
{
TabEditor.SelectedIndex = 1;
}
private void showTestGeneratorTabToolStripMenuItem_Click(object sender, EventArgs e)
{
TabEditor.SelectedIndex = 2;
}
private void aboutCodeCheckerToolStripMenuItem_Click(object sender, EventArgs e)
{
Form4 child = new Form4();
child.StartPosition = FormStartPosition.CenterParent;
child.ShowDialog();
}
}
public class Global
{
public static string lastCC = "";
public static string lastAC = "";
public static string lastTG = "";
public static string checkerpath = "";
public static bool usechecker = false;
}
}