public void PerformRunScript() { PageViewModel page = Editor.SelectedItem; if (page == null || page.Type == Models.PageType.Output) { return; } PerformSaveAll(); string code = BuildScript(page.Filename); if (code != page.Content.Text) { string tempfile = GetTempFile(); string tempname = String.Format("{0} - Results View", page.Header); File.Write(tempfile, code); PageViewModel newpage = new PageViewModel(this, tempname, tempfile) { IsReadOnly = true }; newpage.Content.Text = code; Editor.Items.Add(newpage); page = newpage; } if (page != null) { Interop.InGameScript script = new Interop.InGameScript(code); string filename = page.Filename; Output.Clear(); if (script.CompileErrors.Count > 0) { foreach (string error in script.CompileErrors) { string message = error; Match full = _ErrorRegex.Match(error); if (full.Groups.Count > 1) { int diff = Gilgame.SEWorkbench.Interop.InGameScript.HeaderSize; int line = Convert.ToInt32(full.Groups[2].Value) - diff; int col = Convert.ToInt32(full.Groups[3].Value); string errno = full.Groups[4].Value; string errmsg = full.Groups[5].Value; Models.OutputItem item = new Models.OutputItem() { Line = line, Column = col, Error = errno, Message = errmsg, Filename = filename }; Output.AddItem(item); } else { Match match = _LineColRegex.Match(error); if (match.Groups.Count > 1) { int line = Convert.ToInt32(match.Groups[2].Value) - 9; int col = Convert.ToInt32(match.Groups[3].Value); message = message.Replace(match.Groups[0].Value, ""); Output.AddItem(new Models.OutputItem() { Line = line, Column = col, Message = message, Filename = filename }); } else { Output.AddItem(new Models.OutputItem() { Message = message, Filename = filename }); } } } } else { Services.MessageBox.ShowMessage("The program compiled without any errors."); } RaiseScriptRunning(); } }
public void PerformRunScript() { PageViewModel page = Editor.SelectedItem; if (page == null || page.Type == Models.PageType.Output) { return; } PerformSaveAll(); string code = BuildScript(page.Filename); if (code != page.Content.Text) { string tempfile = GetTempFile(); string tempname = String.Format("{0} - Results View", page.Header); File.Write(tempfile, code); PageViewModel newpage = new PageViewModel(this, tempname, tempfile) { IsReadOnly = true }; newpage.Content.Text = code; Editor.Items.Add(newpage); page = newpage; } if (page != null) { Interop.InGameScript script = new Interop.InGameScript(code); string filename = page.Filename; Output.Clear(); if (script.CompileErrors.Count > 0) { foreach(string error in script.CompileErrors) { string message = error; Match full = _ErrorRegex.Match(error); if (full.Groups.Count > 1) { int diff = Gilgame.SEWorkbench.Interop.InGameScript.HeaderSize; int line = Convert.ToInt32(full.Groups[2].Value) - diff; int col = Convert.ToInt32(full.Groups[3].Value); string errno = full.Groups[4].Value; string errmsg = full.Groups[5].Value; Models.OutputItem item = new Models.OutputItem() { Line = line, Column = col, Error = errno, Message = errmsg, Filename = filename }; Output.AddItem(item); } else { Match match = _LineColRegex.Match(error); if (match.Groups.Count > 1) { int line = Convert.ToInt32(match.Groups[2].Value) - 9; int col = Convert.ToInt32(match.Groups[3].Value); message = message.Replace(match.Groups[0].Value, ""); Output.AddItem(new Models.OutputItem() { Line = line, Column = col, Message = message, Filename = filename }); } else { Output.AddItem(new Models.OutputItem() { Message = message, Filename = filename }); } } } } else { Services.MessageBox.ShowMessage("The program compiled without any errors."); } RaiseScriptRunning(); } }
public OutputItemViewModel(Models.OutputItem item, BaseViewModel parent) : base(parent) { _Model = item; }
public void AddItem(Models.OutputItem model) { OutputItemViewModel item = new OutputItemViewModel(model, this); Items.Add(item); }