Esempio n. 1
0
        /// <summary>
        /// Load souce code from file into the text editor
        /// </summary>
        private bool ShowSourceCode()
        {
            try
            {
                SourceCodeTextEditor.Text =
                    _openedDslFile.IsFile
                    ? File.ReadAllText(_openedDslFile.FilePath)
                    : _openedDslFile.CodeText;

                ShowCodeLocation(0, 0);

                //move caret to start text
                SourceCodeTextEditor.Selection.Start = Place.Empty;
                SourceCodeTextEditor.DoCaretVisible();
                SourceCodeTextEditor.ClearUndo();

                SetEditorTextChangedStatus(false);

                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);

                return(false);
            }
        }
Esempio n. 2
0
        private void ShowCodeLocation(LanguageCodeLocation location, int length)
        {
            ChangeOpenedSourceFile(location.CodeUnit);

            SourceCodeTextEditor.SelectionStart  = location.CharacterNumber;
            SourceCodeTextEditor.SelectionLength = length;
            SourceCodeTextEditor.DoSelectionVisible();
        }
Esempio n. 3
0
        private void InitializeTextEditorStyles()
        {
            SourceCodeTextEditor.ClearStylesBuffer();

            ////styles
            //private TextStyle BlueStyle = new TextStyle(Brushes.Blue, null, FontStyle.Regular);
            //private TextStyle BoldStyle = new TextStyle(null, null, FontStyle.Bold);// | FontStyle.Underline);
            //private TextStyle GrayStyle = new TextStyle(Brushes.Gray, null, FontStyle.Regular);
            //private TextStyle MagentaStyle = new TextStyle(Brushes.Magenta, null, FontStyle.Regular);
            //private TextStyle GreenStyle = new TextStyle(Brushes.Green, null, FontStyle.Italic);
            //private TextStyle BrownStyle = new TextStyle(Brushes.Brown, null, FontStyle.Italic);
            //private TextStyle MaroonStyle = new TextStyle(Brushes.Maroon, null, FontStyle.Regular);

            //add this style explicitly for drawing under other styles
            SourceCodeTextEditor.AddStyle(_sameWordsStyle);
        }
Esempio n. 4
0
        /// <summary>
        /// Ask user to save text editor code into file
        /// </summary>
        /// <returns></returns>
        private bool AskSaveSourceCode()
        {
            if (!SourceCodeModified)
            {
                return(true);
            }

            var result = MessageBox.Show(@"Save code to file first?", @"Source Code", MessageBoxButtons.YesNoCancel);

            if (result == DialogResult.Yes && SaveSourceCode())
            {
                UpdateInterface_EnableControls();

                SourceCodeTextEditor.Focus();
            }
            else if (result == DialogResult.Cancel)
            {
                SourceCodeTextEditor.Focus();

                return(false);
            }

            return(true);
        }
Esempio n. 5
0
 private void ShowCodeLocation(int absoluteLocation, int length)
 {
     SourceCodeTextEditor.SelectionStart  = absoluteLocation;
     SourceCodeTextEditor.SelectionLength = length;
     SourceCodeTextEditor.DoSelectionVisible();
 }