-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
114 lines (96 loc) · 3.81 KB
/
Form1.cs
File metadata and controls
114 lines (96 loc) · 3.81 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
using Scheduller.Logic;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Scheduller
{
public partial class Form1 : Form
{
private string[] inputCode;
public Form1()
{
InitializeComponent();
inputCode = new string[10000];
}
private void addFile_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.DefaultExt = "ins";
openFileDialog1.Filter = "INS files (*.ins)|*.ins|All files (*.*)|*.*";
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string filePath = openFileDialog1.FileName;
try
{
string[] lines = File.ReadAllLines(filePath);
inputTextBox.Lines = lines;
inputCode = lines;
}
catch (Exception ex)
{
MessageBox.Show($"Error reading file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void transformButton_Click(object sender, EventArgs e)
{
string[] codeCopy = inputCode.ToArray();
if (codeCopy[0] == null)
{
return;
}
if (movMergingCheck.Checked)
{
ITransform movMerging = new MovMergingTransform();
movMerging.Transform(codeCopy);
}
if (immediateMergingCheck.Checked)
{
ITransform movReabsortion = new ImmediateMergingTransform();
movReabsortion.Transform(codeCopy);
}
if (movReabsorptionCheck.Checked)
{
ITransform movReabsortion = new MovReabsorptionTransform();
movReabsortion.Transform(codeCopy);
}
outputTextBox.Lines = codeCopy;
for (int i = 0; i < outputTextBox.Lines.Length; i++)
{
string line = outputTextBox.Lines[i];
int tildeIndexSimple = line.IndexOf('~');
int tildeIndexDouble = line.IndexOf("~~");
int tildeIndexTriple = line.IndexOf("~~~");
if (tildeIndexSimple != -1 && tildeIndexDouble == -1 && tildeIndexTriple == -1)
{
outputTextBox.SelectionStart = outputTextBox.GetFirstCharIndexFromLine(i) + tildeIndexSimple + 1;
outputTextBox.SelectionLength = line.Length - tildeIndexSimple - 1;
outputTextBox.SelectionColor = Color.Red;
outputTextBox.SelectionLength = 0;
}
else if (tildeIndexDouble != -1 && tildeIndexTriple == -1)
{
outputTextBox.SelectionStart = outputTextBox.GetFirstCharIndexFromLine(i) + tildeIndexDouble + 2;
outputTextBox.SelectionLength = line.Length - tildeIndexDouble - 2;
outputTextBox.SelectionColor = Color.Green;
outputTextBox.SelectionLength = 0;
}
else if (tildeIndexTriple != -1)
{
outputTextBox.SelectionStart = outputTextBox.GetFirstCharIndexFromLine(i) + tildeIndexTriple + 3;
outputTextBox.SelectionLength = line.Length - tildeIndexTriple - 3;
outputTextBox.SelectionColor = Color.Blue;
outputTextBox.SelectionLength = 0;
}
}
}
}
}