Exemplo n.º 1
0
        /// <summary>
        /// 构造函数,初始化控件初值;创建文本框
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            //-- syntax highlight text box
            mJsonTextBox = createTextBoxInTab(this.tabPageJson);
            ScintillaLexers.CreateLexer(mJsonTextBox, LexerEnumerations.LexerType.JavaScript);

            mXmlTextBox = createTextBoxInTab(this.tabPageXml);
            ScintillaLexers.CreateLexer(mXmlTextBox, LexerEnumerations.LexerType.Xml);

            mCSharpTextBox = createTextBoxInTab(this.tabCSharp);
            ScintillaLexers.CreateLexer(mCSharpTextBox, LexerEnumerations.LexerType.Cs);

            //-- button list
            mExportButtonList = new List <ToolStripButton>();
            mExportButtonList.Add(this.toolCopyJson);
            mExportButtonList.Add(this.toolSaveJson);
            mExportButtonList.Add(this.toolCopyXml);
            mExportButtonList.Add(this.toolSaveXml);
            mExportButtonList.Add(this.toolCopyCSharp);
            mExportButtonList.Add(this.toolSaveCSharp);
            enableExportButtons(false);

            //-- data manager
            mDataMgr = new DataManager();
            this.toolReimport.Enabled = false;
        }
Exemplo n.º 2
0
        private void mnuOpen_Click(object sender, EventArgs e)
        {
            if (odFile.ShowDialog() == DialogResult.OK)
            {
                scintilla.Text = File.ReadAllText(odFile.FileName);

//                string fileName = @"C:\Program Files (x86)\Notepad++\themes\Black board.xml";
                string fileName = @"C:\Program Files (x86)\Notepad++\stylers.model.xml";
//                string fileName = @"C:\Program Files (x86)\Notepad++\themes\Hello Kitty.xml";

                ScintillaLexers.CreateLexerFromFile(scintilla, odFile.FileName, fileName);
//                ScintillaLexers.CreateLexer(scintilla, odFile.FileName);
            }
        }
Exemplo n.º 3
0
        private void InitSyntaxColoring()
        {
            Scintilla.StyleResetDefault();
            Scintilla.Styles[Style.Default].Font      = "Consolas";
            Scintilla.Styles[Style.Default].Size      = 12;
            Scintilla.Styles[Style.Default].BackColor = Color.White;
            Scintilla.Styles[Style.Default].ForeColor = Color.Black;
            Scintilla.StyleClearAll();

            ScintillaLexers.CreateLexer(Scintilla, LexerEnumerations.LexerType.Java);

            Scintilla.SetKeywords(0,
                                  "abstract assert boolean break byte case catch char class const continue default do double else enum extends final finally float for goto if implements import instanceof int interface long native new package private protected public return short static strictfp super switch synchronized this throw throws transient try void volatile while");
            Scintilla.SetKeywords(1, "as fun in object is typeof typealias when val lateinit by var companion");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormScript"/> class.
        /// </summary>
        public FormScript()
        {
            // Add this form to be positioned..
            PositionForms.Add(this);

            // add positioning..
            PositionCore.Bind(ApplicationType.WinForms);

            InitializeComponent();

            DBLangEngine.DBName = "lang.sqlite"; // Do the VPKSoft.LangLib == translation..

            if (Utils.ShouldLocalize() != null)
            {
                DBLangEngine.InitializeLanguage("ScriptNotepad.Localization.Messages", Utils.ShouldLocalize(), false);
                return; // After localization don't do anything more..
            }

            suspendChangedEvent = true; // suspend the event handler as the contents of the script is about to change..

            // initialize the language/localization database..
            DBLangEngine.InitializeLanguage("ScriptNotepad.Localization.Messages");

            // localize the script type default names..
            defaultNameScriptTemplateText =
                DBLangEngine.GetMessage("msgDefaultScriptSnippetText", "A text script snippet|As in a script for manipulating Scintilla contents as text");

            defaultNameScriptTemplateLines =
                DBLangEngine.GetMessage("msgDefaultScriptSnippetLines", "A line script snippet|As in a script for manipulating Scintilla contents as lines");

            // localize the currently supported script types..
            tsbComboScriptType.Items.Clear();
            tsbComboScriptType.Items.Add(
                DBLangEngine.GetMessage("msgScriptTypeText", "Script text|As in the C# script type should be handling the Scintilla's contents as text")
                );

            tsbComboScriptType.Items.Add(
                DBLangEngine.GetMessage("msgScriptTypeLines", "Script lines|As in the C# script type should be handling the Scintilla's contents as lines")
                );

            tsbComboScriptType.SelectedItem =
                DBLangEngine.GetMessage("msgScriptTypeText", "Script text|As in the C# script type should be handling the Scintilla's contents as text");

            // set the default script for manipulating text..
            scintillaScript.Text = scriptRunnerText.CSharpScriptBase;

            // set the text for the default script snippet..
            tstScriptName.Text = defaultNameScriptTemplateText;

            CreateNewCodeSnippet(); // create a new CODE_SNIPPETS class instance..

            // set the lexer as C#..
            ScintillaLexers.CreateLexer(scintillaScript, LexerType.Cs);

            // highlight the braces..
            SetBraceHighlights();

            suspendChangedEvent = false; // "resume" the event handler..

            // track the instances of this form so the changes can be delegated to each other..
            FormScriptInstances.Add(this);
        }