Inheritance: BaseViewModel
 private void UnregisterPage(PageViewModel page)
 {
     page.FileSaved          -= Page_FileSaved;
     page.FileCloseRequested -= Page_CloseFileRequested;
 }
        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 void PerformOpenItem(ProjectItemViewModel item)
        {
            if (item != null)
            {
                if (!File.Exists(item.Path))
                {
                    return;
                }

                foreach (PageViewModel page in Editor.Items)
                {
                    if (page.Filename == item.Path)
                    {
                        page.IsActive = true;
                        return;
                    }
                }

                PageViewModel newpage = new PageViewModel(this, item);
                Editor.Items.Add(newpage);
            }
        }
 private void UnregisterPage(PageViewModel page)
 {
     page.FileSaved -= Page_FileSaved;
     page.FileCloseRequested -= Page_CloseFileRequested;
 }
Example #6
0
 private void UnregisterPage(PageViewModel page)
 {
     page.Selected -= Page_Selected;
     page.FileSaved -= Page_FileSaved;
     page.TextChanged -= Page_TextChanged;
 }
Example #7
0
 private void UnregisterPage(PageViewModel page)
 {
     page.Selected    -= Page_Selected;
     page.FileSaved   -= Page_FileSaved;
     page.TextChanged -= Page_TextChanged;
 }