forked from jadaradix/dsgamemaker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEditCode.cs
More file actions
106 lines (92 loc) · 3.78 KB
/
EditCode.cs
File metadata and controls
106 lines (92 loc) · 3.78 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
namespace DS_Game_Maker
{
public partial class EditCode
{
public string ReturnableCode = string.Empty;
public byte CodeMode = 0;
public bool ImportExport = false;
public EditCode()
{
InitializeComponent();
}
private void EditCode_Load(object sender, EventArgs e)
{
MainToolStrip.Renderer = new clsToolstripRenderer();
LoadInButton.Enabled = ImportExport;
SaveOutButton.Enabled = ImportExport;
string NewCode = ReturnableCode;
if (!(CodeMode == 1))
{
NewCode = NewCode.Replace("<br|>", Constants.vbCrLf).Replace("<com>", ",").Replace("<sem>", ";");
}
MainTextBox.Text = NewCode;
UpdateLineStats();
}
public void UpdateLineStats()
{
//InfoLabel.Text = "Ln " + MainTextBox.Caret.LineNumber.ToString() + " : ";
//InfoLabel.Text += MainTextBox.Lines.Count.ToString() + " Col " + MainTextBox.GetColumn(MainTextBox.CurrentPos).ToString();
//InfoLabel.Text += " Sel " + MainTextBox.Selection.Start.ToString();
}
private void MainTextBox_KeyDown(object sender, EventArgs e)
{
UpdateLineStats();
}
private void DAcceptButton_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Normal;
//ReturnableCode = MainTextBox.Text.Replace(Constants.vbCrLf, "<br|>").Replace(",", "<com>").Replace(";", "<sem>");
DialogResult = DialogResult.OK;
Close();
}
private void UndoButton_Click(object sender, EventArgs e)
{
if (MainTextBox.CanUndo)
MainTextBox.Undo();
}
private void RedoButton_Click(object sender, EventArgs e)
{
if (MainTextBox.CanRedo)
MainTextBox.Redo();
}
private void LoadInButton_Click(object sender, EventArgs e)
{
DialogResult MsgResponse = MessageBox.Show("Importing a Script will erase and replace the current code." + Constants.vbCrLf + Constants.vbCrLf + "Would you like to Continue?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (MsgResponse == DialogResult.No)
{
return;
}
string Response = DSGMlib.OpenFile(string.Empty, "Dynamic Basic Files|*.dbas");
if (Response.Length == 0)
return;
string Content = DSGMlib.PathToString(Response);
string FinalContent = string.Empty;
foreach (string X in DSGMlib.StringToLines(Content))
{
if (X.StartsWith("SCRIPTARG "))
continue;
FinalContent += X;
}
// If FinalContent.Length > 0 Then FinalContent = FinalContent.Substring(0, FinalContent.Length - 1)
MainTextBox.Text = FinalContent;
}
private void SaveOutButton_Click(object sender, EventArgs e)
{
string Response = DSGMlib.SaveFile(string.Empty, "Dynamic Basic Files|*.dbas", "Expoted Code.dbas");
if (Response.Length == 0)
return;
string ToWrite = MainTextBox.Text;
// If ToWrite.Length > 0 Then ToWrite = ToWrite.Substring(0, ToWrite.Length - 1)
System.IO.File.WriteAllText(Response, ToWrite);
}
private void MainTextBox_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e)
{
//if (!(e.Ch == '\r'))
// return;
ScintillaNET.Scintilla argTheControl = (ScintillaNET.Scintilla)sender;
DSGMlib.IntelliSense(ref argTheControl);
sender = argTheControl;
}
}
}