Esempio n. 1
0
        // This opens the given file, returns null when failed
        public ScriptFileDocumentTab OpenFile(string filename)
        {
            ScriptConfiguration foundconfig = new ScriptConfiguration();

            // Find the most suitable script configuration to use
            foreach (ScriptConfiguration cfg in scriptconfigs)
            {
                foreach (string ext in cfg.Extensions)
                {
                    // Use this configuration if the extension matches
                    if (filename.EndsWith("." + ext, StringComparison.OrdinalIgnoreCase))
                    {
                        foundconfig = cfg;
                        break;
                    }
                }
            }

            // Create new document
            ScriptFileDocumentTab t = new ScriptFileDocumentTab(this, foundconfig);

            if (t.Open(filename))
            {
                //mxd
                ScriptType st = t.VerifyScriptType();
                if (st != ScriptType.UNKNOWN)
                {
                    foreach (ScriptConfiguration cfg in scriptconfigs)
                    {
                        if (cfg.ScriptType == st)
                        {
                            t.ChangeScriptConfig(cfg);
                            break;
                        }
                    }
                }

                // Mark any errors this script may have
                if (compilererrors != null)
                {
                    t.MarkScriptErrors(compilererrors);
                }

                // Add to tabs
                tabs.TabPages.Add(t);
                tabs.SelectedTab = t;

                // Done
                t.OnTextChanged      += tabpage_OnTextChanged;            //mxd
                t.Scintilla.UpdateUI += scintilla_OnUpdateUI;
                UpdateToolbar(true);
                return(t);
            }

            // Failed
            return(null);
        }
Esempio n. 2
0
        // This opens the given file, returns null when failed
        public ScriptFileDocumentTab OpenFile(string filename)
        {
            ScriptConfiguration foundconfig = new ScriptConfiguration();

            // Find the most suitable script configuration to use
            foreach (ScriptConfiguration cfg in scriptconfigs)
            {
                foreach (string ext in cfg.Extensions)
                {
                    // Use this configuration if the extension matches
                    if (filename.EndsWith("." + ext, true, CultureInfo.InvariantCulture))
                    {
                        foundconfig = cfg;
                        break;
                    }
                }
            }

            // Create new document
            ScriptFileDocumentTab t = new ScriptFileDocumentTab(this, foundconfig);

            if (t.Open(filename))
            {
                // Mark any errors this script may have
                if (compilererrors != null)
                {
                    t.MarkScriptErrors(compilererrors);
                }

                // Add to tabs
                tabs.TabPages.Add(t);
                tabs.SelectedTab = t;

                // Done
                UpdateToolbar(true);
                return(t);
            }
            else
            {
                // Failed
                return(null);
            }
        }