private void mbQuestScript_Click(object sender, EventArgs e) { LuaEditor lua = NewLuaEditor(); lua.scintilla1.Text = Scripts.GetQuestScript(); lua.SetSaved(); }
public void OpenFile(string path) { if (!path.Contains(".lua")) { return; } // Check to see if the file is already opened and if so bring that tab to the front foreach (LuaEditor opened in dockPanel.Documents) { if (opened.Name == path) { opened.Activate(); return; } } // Open the file LuaEditor doc = NewLuaEditor(); doc.Name = path; doc.Text = path.Substring(path.LastIndexOf("\\") + 1); StreamReader reader = new StreamReader(path); doc.scintilla1.Text = reader.ReadToEnd(); reader.Close(); doc.scintilla1.UndoRedo.EmptyUndoBuffer(); doc.SetSaved(); doc.Show(dockPanel); }
private LuaEditor NewLuaEditor() { LuaEditor newLua = new LuaEditor(); // Set the closing even newLua.FormClosing += LuaEditor_FormClosing; newLua.scintilla1.KeyDown += LuaEditor_KeyDown; newLua.Name = null; newLua.Text = "Untitled Lua Script"; int count = 0; foreach (LuaEditor lua in dockPanel.Documents) { if (lua.Text.Contains(newLua.Text)) { count++; } } if (count > 0) { count++; newLua.Text += " " + count.ToString(); } if (!m_settings.ShowLineNumbers) { newLua.scintilla1.Margins.Margin0.Width = 0; } newLua.Show(dockPanel); return(newLua); }
private void LuaEditor_FormClosing(object sender, FormClosingEventArgs e) { if (sender is LuaEditor) { LuaEditor lua = sender as LuaEditor; if (lua.SaveNeeded) { DialogResult result = MessageBox.Show("Do you want to save changes to " + lua.Text + "?", "Save Changes?", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { Save(lua.Name, lua.scintilla1.Text); } if (result == DialogResult.Cancel) { e.Cancel = true; } } } }
private void tsbNew_Click(object sender, EventArgs e) { LuaEditor lua = NewLuaEditor(); lua.SetSaved(); }