private void SyntaxEditorOpen()
{
if (Modified)//if any modification done to command scripts after last Save
{ //allow user to save changes before opening another command script
System.Windows.Forms.DialogResult dresult = System.Windows.Forms.MessageBox.Show(
"Do you want to save commands before loading new script?",
"Save & Close current command script?",
System.Windows.Forms.MessageBoxButtons.YesNoCancel,
System.Windows.Forms.MessageBoxIcon.Question);
if (dresult == System.Windows.Forms.DialogResult.Yes)//Yes Save- and Close
{
SyntaxEditorSaveAs();
}
else if (dresult == System.Windows.Forms.DialogResult.No)//No Save- but Close
{
}
else//no Save no Close
{
return;
}
}
const string FileNameFilter = "BSky R scripts, (*.bsr)|*.bsr"; //BSkyR
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = FileNameFilter;
bool? output = openFileDialog.ShowDialog(Application.Current.MainWindow);
if (output.HasValue && output.Value)
{
System.IO.StreamReader file = new System.IO.StreamReader(openFileDialog.FileName);
inputTextbox.Text = file.ReadToEnd();
file.Close();
}
Modified = false;//19Feb2013 Newly loaded script can only be modified after loading finishes.
Title = "Command Editor Window"; //19Feb2013
}