示例#1
0
        private void ProcessSelection(CodeTextBox codeTextbox, int selectionStart, int selectionLength, TreeView m_IntellisenseTree)
        {
            // Save the position
            int nPosition = selectionStart;

            codeTextbox.SelectionStart  = selectionStart;
            codeTextbox.SelectionLength = selectionLength;
            string text = codeTextbox.SelectedText;

            // Process the simpleVar
            ProcessRegex(codeTextbox, text, selectionStart, simpleVarRegexp, "simpleVar", "Property", m_IntellisenseTree);

            ProcessRegex(codeTextbox, text, selectionStart, simpleVarFonctionRegexp, "simpleVar", "Method", m_IntellisenseTree);

            // Process the string
            ProcessRegex(codeTextbox, text, selectionStart, chainesRegexp, "chaine", "Property", m_IntellisenseTree);

            ProcessRegex(codeTextbox, text, selectionStart, chainesFonctionRegexp, "chaine", "Method", m_IntellisenseTree);

            // Process the simpleVar
            ProcessRegex(codeTextbox, text, selectionStart, tableauRegexp, "tab", "Property", m_IntellisenseTree);

            ProcessRegex(codeTextbox, text, selectionStart, tableauFonctionRegexp, "tab", "Method", m_IntellisenseTree);

            // Process the string
            ProcessRegex(codeTextbox, text, selectionStart, voidFonctionRegexp, "fonctionVoid", "Method", m_IntellisenseTree);


            codeTextbox.SelectionStart  = nPosition;
            codeTextbox.SelectionLength = 0;
        }
        public void ProcessAllLines(CodeTextBox codeTextbox)
        {
            codeTextbox.EnablePainting = false;

            // Save the position and make the whole line black
            int nPosition = codeTextbox.SelectionStart;
            codeTextbox.SelectionStart = 0;
            codeTextbox.SelectionLength = codeTextbox.Text.Length;
            codeTextbox.SelectionColor = Color.Black;

            // Process the keywords
            ProcessRegex(codeTextbox, codeTextbox.Text, 0, keywordsRegexp, codeTextbox.CodeColor_Keyword);

            // Process cached type names
            ProcessRegex(codeTextbox, codeTextbox.Text, 0, typeNamesRegexp, codeTextbox.CodeColor_Type);

            //process functions
            ProcessRegex(codeTextbox, codeTextbox.Text, 0, functionsRegexp, codeTextbox.CodeColor_Function);

            // Process strings
            ProcessRegex(codeTextbox, codeTextbox.Text, 0, stringsRegexp, codeTextbox.CodeColor_PlainText);

            // Process comments
            if (codeTextbox.CodeWords_Comments.Count>0)
            {
                ProcessRegex(codeTextbox, codeTextbox.Text, 0, commentsRegexp, codeTextbox.CodeColor_Comment);
            }

            codeTextbox.SelectionStart = nPosition;
            codeTextbox.SelectionLength = 0;
            codeTextbox.SelectionColor = Color.Black;

            //suppressHightlighting = false;
            codeTextbox.EnablePainting = true;
        }
示例#3
0
        /// <summary>
        /// Processes syntax highlightning for a line.
        /// </summary>
        /// <param name="richTextbox"></param>
        /// <param name="syntaxSettings"></param>
        /// <param name="line"></param>
        /// <param name="lineStart"></param>
        private void ProcessLine(CodeTextBox codeTextbox, string line, int lineStart, TreeView m_IntellisenseTree)
        {
            // Save the position and make the whole line black
            int nPosition = codeTextbox.SelectionStart;

            codeTextbox.SelectionStart  = lineStart;
            codeTextbox.SelectionLength = line.Length;

            // Process the simpleVar
            ProcessRegex(codeTextbox, line, lineStart, simpleVarRegexp, "simpleVar", "Property", m_IntellisenseTree);

            ProcessRegex(codeTextbox, line, lineStart, simpleVarFonctionRegexp, "simpleVar", "Method", m_IntellisenseTree);

            // Process the string
            ProcessRegex(codeTextbox, line, lineStart, chainesRegexp, "chaine", "Property", m_IntellisenseTree);

            ProcessRegex(codeTextbox, line, lineStart, chainesFonctionRegexp, "chaine", "Method", m_IntellisenseTree);

            // Process the simpleVar
            ProcessRegex(codeTextbox, line, lineStart, tableauRegexp, "tab", "Property", m_IntellisenseTree);

            ProcessRegex(codeTextbox, line, lineStart, tableauFonctionRegexp, "tab", "Method", m_IntellisenseTree);

            // Process the string
            ProcessRegex(codeTextbox, line, lineStart, voidFonctionRegexp, "fonctionVoid", "Method", m_IntellisenseTree);

            codeTextbox.SelectionStart  = nPosition;
            codeTextbox.SelectionLength = 0;
        }
 public void Clean()
 {
     CodeTextBox.Text        = string.Empty;
     DescriptionTextBox.Text = string.Empty;
     PriceTextBox.Text       = string.Empty;
     CodeTextBox.Focus();
 }
        public void SetOffset(int offset, int count = 0)
        {
            //CCSProfix = String.Empty;
            if (count > 0)
            {
                CodeTextBox.Select(offset, count);
            }
            else
            {
                CodeTextBox.CaretOffset = offset;
            }
            int          line   = CodeTextBox.Row;
            int          column = CodeTextBox.Column;
            ScrollViewer sv     = CodeTextBox.ScrollViewer;

            if (sv == null)
            {
                return;
            }
            double y = line * 19 - 25 - sv.ViewportHeight / 2;

            y = Math.Max(0, y);
            sv.ScrollToVerticalOffset(y);
            double x = column * 16 - sv.ViewportWidth / 2;

            x = Math.Max(0, x);
            sv.ScrollToHorizontalOffset(x);
        }
示例#6
0
 //метод очистки
 private void ClearMethod()
 {
     EnterTextBox.Clear();
     CodeTextBox.Clear();
     MessWithourErrorTextBox.Clear();
     PositionMistakeTextBox.Clear();
 }
示例#7
0
        private async void SendCode_Click(object sender, RoutedEventArgs e)
        {
            ViewModel.ShowError = false;
            if (!Regex.IsMatch(ViewModel.Mobile, @"^\d{7,}$"))
            {
                ViewModel.ErrorText = "手机号输入格式不正确";
                ViewModel.ShowError = true;
            }
            else if (string.IsNullOrEmpty(ViewModel.ImageCode))
            {
                ViewModel.ErrorText = "请输入图片验证码";
                ViewModel.ShowError = true;
            }
            else
            {
                await ViewModel.SendCodeAsync();

                if (ViewModel.ShowError)
                {
                    ImageButton_Click(sender, e);
                    ImageCodeTextBox.Focus(FocusState.Programmatic);
                }
                else
                {
                    CodeTextBox.Focus(FocusState.Programmatic);
                }
            }
        }
        /// <summary>
        /// Processes a regex.
        /// </summary>
        /// <param name="richTextbox"></param>
        /// <param name="line"></param>
        /// <param name="lineStart"></param>
        /// <param name="regexp"></param>
        /// <param name="color"></param>
        private void ProcessRegex(CodeTextBox codeTextbox, string line, int lineStart, Regex regexp, Color color, Font font = null)
        {
            if (regexp == null)
            {
                // for uninitialized typename regexp
                return;
            }

            Match regMatch;

            for (regMatch = regexp.Match(line); regMatch.Success; regMatch = regMatch.NextMatch())
            {
                // Process the words
                int nStart  = lineStart + regMatch.Index;
                int nLenght = regMatch.Length;
                codeTextbox.SelectionStart  = nStart;
                codeTextbox.SelectionLength = nLenght;
                codeTextbox.SelectionColor  = color;

                if (font != null)
                {
                    codeTextbox.SelectionFont = font;
                }
            }
        }
示例#9
0
        private async void JoinClicked(object sender, RoutedEventArgs e)
        {
            (sender as Button).IsEnabled = false;

            optionsView.IsHitTestVisible = false;
            var optionCenterY = (float)optionsView.DesiredSize.Height / 2;
            var optionCenterX = (float)optionsView.DesiredSize.Width / 2;

            optionsView.Scale(0.8f, 0.8f, optionCenterX, optionCenterY).Fade(0).Start();


            var joinCenterY = (float)joinSection.DesiredSize.Height / 2;
            var joinCenterX = (float)joinSection.DesiredSize.Width / 2;

            joinSection.IsHitTestVisible = true;
            await joinSection.Scale(1.2f, 1.2f, joinCenterX, joinCenterY, 0)
            .Then().Scale(1, 1, joinCenterX, joinCenterY).Fade(1).StartAsync();

            CodeTextBox.Focus(FocusState.Keyboard);

            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;

            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;

            (sender as Button).IsEnabled = true;
        }
示例#10
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            var n = new TabPage()
            {
                Text = "Query" + (tabControl1.Controls.Count + 1),
            };

            CodeTextBox c = new CodeTextBox()
            {
                AutoWordSelection = true,
                BackColor         = Color.White,
                BorderStyle       = System.Windows.Forms.BorderStyle.None,
                Dock      = System.Windows.Forms.DockStyle.Fill,
                Font      = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))),
                ForeColor = Color.Black,
                Location  = new System.Drawing.Point(3, 3),
                Size      = new System.Drawing.Size(431, 225),
                Name      = "codeTextBox" + (tabControl1.Controls.Count + 1),
                TabIndex  = 1,
            };

            c.GotFocus += delegate
            {
                ActiveEditor = c;
            };
            c.KeyDown         += C_KeyDown;
            c.ContextMenuStrip = CodeEditorStrip1;
            n.Controls.Add(c);
            tabControl1.Controls.Add(n);
            tabControl1.SelectTab((tabControl1.Controls.Count - 1));
            c.Focus();
            ActiveEditor = c;
            //tabControl1.Controls;
        }
示例#11
0
        private void RemoveInexistant(CodeTextBox codeTextbox, TreeView m_IntellisenseTree)
        {
            // Save the position
            int nPosition = codeTextbox.SelectionStart;

            codeTextbox.SelectionStart  = 0;
            codeTextbox.SelectionLength = codeTextbox.Text.Length;

            // Process the simpleVar
            RefreshRegex(codeTextbox, codeTextbox.Text, 0, simpleVarRegexp, "simpleVar", "Property", m_IntellisenseTree);

            RefreshRegex(codeTextbox, codeTextbox.Text, 0, simpleVarFonctionRegexp, "simpleVar", "Method", m_IntellisenseTree);

            // Process the string
            RefreshRegex(codeTextbox, codeTextbox.Text, 0, chainesRegexp, "chaine", "Property", m_IntellisenseTree);

            RefreshRegex(codeTextbox, codeTextbox.Text, 0, chainesFonctionRegexp, "chaine", "Method", m_IntellisenseTree);

            // Process the simpleVar
            RefreshRegex(codeTextbox, codeTextbox.Text, 0, tableauRegexp, "tab", "Property", m_IntellisenseTree);

            RefreshRegex(codeTextbox, codeTextbox.Text, 0, tableauFonctionRegexp, "tab", "Method", m_IntellisenseTree);

            // Process the string
            RefreshRegex(codeTextbox, codeTextbox.Text, 0, voidFonctionRegexp, "fonctionVoid", "Method", m_IntellisenseTree);

            codeTextbox.SelectionStart  = nPosition;
            codeTextbox.SelectionLength = 0;
        }
示例#12
0
        private async void TextBox_KeyUp(object sender, KeyRoutedEventArgs e)
        {
            errorBox.Opacity = 0;
            if (e.Key == Windows.System.VirtualKey.Back)
            {
                return;
            }


            if (CodeTextBox.Text.Count() == 6)
            {
                // join party
                CodeTextBox.IsEnabled = false;
                ShowLoading("joining party");
                if (await DataService.Instance.InitDataServiceAsClient(CodeTextBox.Text))
                {
                    Frame.Navigate(typeof(MainPage), false);
                }
                else
                {
                    HideLoading();
                    CodeTextBox.IsEnabled = true;
                    CodeTextBox.Focus(FocusState.Keyboard);
                    errorBox.Opacity = 1;
                    errorBox.Offset(10).Then().Offset(-10).Then().Offset(10).Then().Offset(-10).Then().Offset(0).SetDurationForAll(30).Start();
                }
            }
            else if (CodeTextBox.Text.Count() > 6)
            {
                CodeTextBox.Text = CodeTextBox.Text.Substring(0, 6);
                e.Handled        = true;
                CodeTextBox.Select(6, 0);
            }
        }
 public TextViewPosition?GetPosition(int offset = -1)
 {
     if (offset == -1)
     {
         offset = CodeTextBox.CaretOffset;
     }
     return(CodeTextBox.GetPositionFromOffset(offset));
 }
示例#14
0
 //метод очистки
 private void ClearMethod()
 {
     PolinomtextBox.Clear();
     CodeTextBox.Clear();
     ErrorTextBox.Clear();
     MessWithErrorTextBox.Clear();
     RecoveryTextBox.Clear();
 }
 private void AddProductView_Load(object sender, EventArgs e)
 {
     if (!DesignMode)
     {
         presenter = new AddProductPresenter(this);
         InvokeViewInitialized(EventArgs.Empty);
         CodeTextBox.Focus();
     }
 }
示例#16
0
 public RegisterForm(Client client)
 {
     this.client        = client;
     client.OnError    += OnError;
     client.OnRegister += OnRegister;
     InitializeComponent();
     SendBtn.Hide();
     CodeTextBox.Hide();
 }
示例#17
0
 public MainWindow()
 {
     InitializeComponent();
     lineTemplate = LineCounterLabel.Content.ToString();
     Load();
     _ = Saving();
     CodeTextBox.Focus();
     RefreshLineCounter();
 }
 public bool HandleKeypress(System.Windows.Forms.Keys key)
 {
     if (key == System.Windows.Forms.Keys.F1)
     {
         SampleGroupBindingSource.AddNew();
         CodeTextBox.Focus();
         return(true);
     }
     return(false);
 }
        public void DoSyntaxHightlight_Selection(CodeTextBox codeTextbox, int selectionStart, int selectionLength)
        {
            #region Compile regexs if necessary
            if (!compiled)
            {
                Update(codeTextbox);
            }
            #endregion

            ProcessSelection(codeTextbox, selectionStart, selectionLength);
        }
示例#20
0
        public void RefreshIntellisense(CodeTextBox codeTextbox, TreeView m_IntellisenseTree)
        {
            #region Compile regexs if necessary
            if (!compiled)
            {
                Update(codeTextbox);
            }
            #endregion

            RemoveInexistant(codeTextbox, m_IntellisenseTree);
        }
示例#21
0
        public void DoIntellisense_AllLines(CodeTextBox codeTextbox, TreeView m_IntellisenseTree)
        {
            #region Compile regexs if necessary
            if (!compiled)
            {
                Update(codeTextbox);
            }
            #endregion

            ProcessAllLines(codeTextbox, m_IntellisenseTree);
        }
示例#22
0
        public void DoSyntaxHightlight_AllLines(CodeTextBox codeTextbox)
        {
            #region Compile regexs if necessary
            if (!compiled)
            {
                Update(codeTextbox);
            }
            #endregion

            ProcessAllLines(codeTextbox);
        }
示例#23
0
        private void LexicalAnalyzerItem_Click(object sender, EventArgs e)
        {
            LexicalAnalyzer lexicalAnalyzer = new LexicalAnalyzer(this.CodeTextBox.Text);

            lexicalAnalyzer.Analyses(out tokenList, out errorList);
            int record_mouse = CodeTextBox.SelectionStart;

            ColorWord();
            CodeTextBox.Select(record_mouse, record_mouse);
            PrintResult(tokenList, errorList);
        }
示例#24
0
        public void DoSyntaxHightlight_Selection(CodeTextBox codeTextbox, int selectionStart, int selectionLength)
        {
            #region Compile regexs if necessary
            if (!compiled)
            {
                Update(codeTextbox);
            }
            #endregion

            ProcessSelection(codeTextbox, selectionStart, selectionLength);
        }
示例#25
0
        public void DoIntellisense_Selection(CodeTextBox codeTextbox, int selectionStart, int selectionLength, TreeView m_IntellisenseTree)
        {
            #region Compile regexs if necessary
            if (!compiled)
            {
                Update(codeTextbox);
            }
            #endregion

            ProcessSelection(codeTextbox, selectionStart, selectionLength, m_IntellisenseTree);
        }
        public void DoSyntaxHightlight_AllLines(CodeTextBox codeTextbox)
        {
            #region Compile regexs if necessary
            if (!compiled)
            {
                Update(codeTextbox);
            }
            #endregion

            ProcessAllLines(codeTextbox);
        }
        private void OnCurrentSampleGroupChanged()
        {
            if (_currentSampleGroup != null)
            {
                _currentSampleGroup.PropertyChanged += _currentSampleGroup_PropertyChanged;

                CodeTextBox.Focus();
            }

            panel3.Enabled = CurrentSampleGroup != null;
            UpdateTreeDefaults();
            TreeDefaultGridView.SelectedItems = CurrentSampleGroup?.TreeDefaultValues;
        }
        public void DoSyntaxHightlight_CurrentLine(CodeTextBox codeTextbox)
        {
            #region Compile regexs if necessary
            if (!compiled)
            {
                Update(codeTextbox);
            }
            #endregion

            string line = RichTextboxHelper.GetCurrentLine(codeTextbox);
            int lineStart = RichTextboxHelper.GetCurrentLineStartIndex(codeTextbox);

            ProcessLine(codeTextbox, line, lineStart);
        }
示例#29
0
        public void DoSyntaxHightlight_CurrentLine(CodeTextBox codeTextbox)
        {
            #region Compile regexs if necessary
            if (!compiled)
            {
                Update(codeTextbox);
            }
            #endregion

            string line      = RichTextboxHelper.GetCurrentLine(codeTextbox);
            int    lineStart = RichTextboxHelper.GetCurrentLineStartIndex(codeTextbox);

            ProcessLine(codeTextbox, line, lineStart);
        }
示例#30
0
        /// <summary>
        /// Compiles the necessary regexps
        /// </summary>
        /// <param name="syntaxSettings"></param>
        public void Update(CodeTextBox codeTextbox)
        {
            //bool|byte|sbyte|char|decimal|double|float|int|uint|long|ulong|object|short|ushort
            chainesRegexp           = new Regex(@"string ([a-z0-9_]*?)[^a-z0-9_\(]", RegexOptions.Compiled | RegexOptions.Multiline);
            chainesFonctionRegexp   = new Regex(@"string ([a-z0-9_]*\(.*\))", RegexOptions.Compiled | RegexOptions.Multiline);
            tableauRegexp           = new Regex(@"\[\] ([a-z0-9_]*?)[^a-z0-9_\(] ", RegexOptions.Compiled | RegexOptions.Multiline);
            tableauFonctionRegexp   = new Regex(@"\[\] ([a-z0-9_]*\(.*\))", RegexOptions.Compiled | RegexOptions.Multiline);
            simpleVarRegexp         = new Regex(@"bool([a-z0-9_]*?)[^a-z0-9_\(]|byte ([a-z0-9_]*?)[^a-z0-9_\(]|sbyte ([a-z0-9_]*?)[^a-z0-9_\(]|char ([a-z0-9_]*?)[^a-z0-9_\(]|decimal ([a-z0-9_]*?)[^a-z0-9_\(]|double ([a-z0-9_]*?)[^a-z0-9_\(]|float ([a-z0-9_]*?)[^a-z0-9_\(]|int ([a-z0-9_]*?)[^a-z0-9_\(]|uint ([a-z0-9_]*?)[^a-z0-9_\(]|long ([a-z0-9_]*?)[^a-z0-9_\(]|ulong ([a-z0-9_]*?)[^a-z0-9_\(]|object ([a-z0-9_]*?)[^a-z0-9_\(]|short ([a-z0-9_]*?)[^a-z0-9_\(]|ushort ([a-z0-9_]*?)[^a-z0-9_\(]", RegexOptions.Compiled | RegexOptions.Multiline);
            simpleVarFonctionRegexp = new Regex(@"bool ([a-z0-9_]*\(.*\))|byte ([a-z0-9_]*\(.*\))|sbyte ([a-z0-9_]*\(.*\))|char ([a-z0-9_]*\(.*\))|decimal ([a-z0-9_]*\(.*\))|double ([a-z0-9_]*\(.*\))|float ([a-z0-9_]*\(.*\))|int ([a-z0-9_]*\(.*\))|uint ([a-z0-9_]*\(.*\))|long ([a-z0-9_]*\(.*\))|ulong ([a-z0-9_]*\(.*\))|object ([a-z0-9_]*\(.*\))|short ([a-z0-9_]*\(.*\))|ushort ([a-z0-9_]*\(.*\))", RegexOptions.Compiled | RegexOptions.Multiline);
            voidFonctionRegexp      = new Regex(@"void ([a-z0-9_]*\(.*\))", RegexOptions.Compiled | RegexOptions.Multiline);

            //Set compiled flag to true
            compiled = true;
        }
示例#31
0
        public void DoIntellisense_CurrentLine(CodeTextBox codeTextbox, TreeView m_IntellisenseTree)
        {
            #region Compile regexs if necessary
            if (!compiled)
            {
                Update(codeTextbox);
            }
            #endregion

            string line      = RichTextboxHelper.GetCurrentLine(codeTextbox);
            int    lineStart = RichTextboxHelper.GetCurrentLineStartIndex(codeTextbox);

            ProcessLine(codeTextbox, line, lineStart, m_IntellisenseTree);
        }
示例#32
0
        private void OpenFileItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter = "text(*.txt)|*.txt|(*.yz)|*.yz";
            openFile.ShowDialog();
            filename = openFile.FileName;
            try
            {
                CodeTextBox.Text = File.ReadAllText(filename, System.Text.Encoding.Default).Replace("\r", "");
            }
            catch { }
            CodeTextBox.Select(0, 0);
        }
        private void AddCourseButton_Click(object sender, RoutedEventArgs e)
        {
            mytrimer();
            if (CheckIfThereIsEmptyTextBox())
            {
                MessageBox.Show("Some textbox is missing.");
            }
            else
            {
                if (CheckNumberOfStudentsTextBoxes() && CheckGradesTextBoxes() && CheckHoursTextBox() && CheckAllTheRemainingTextBoxes())
                {
                    string Code          = CodeTextBox.Text;
                    string CourseName    = CourseNameTextBox.Text;
                    int    MaximumNumber = int.Parse(MaximumNumberOfStudentsTextBox.Text);
                    int    CurrentNumber = int.Parse(CurrentNumberOfStudentsTextBox.Text);
                    int    PassingGrade  = int.Parse(PassingGradeTextBox.Text);
                    int    CourseGrade   = int.Parse(CourseGradeTextBox.Text);
                    int    Hours         = int.Parse(HoursTextBox.Text);
                    string Instructor    = InstructorTextBox.Text;
                    string Description   = DescriptionTextBox.Text;
                    CoursePrerequstiesTmp = new List <string>();

                    if (WelcomePage.AllCoursesDictionary.ContainsKey(CourseName))
                    {
                        MessageBox.Show("This course already exists.");
                    }
                    else
                    {
                        AddNewCourseSecondStep nw = new AddNewCourseSecondStep();
                        nw.ShowDialog();
                        Course newcourse = new Course(Code, CourseName, MaximumNumber, CurrentNumber, PassingGrade, CourseGrade, Hours, Instructor, Description, CoursePrerequstiesTmp);
                        WelcomePage.AllCoursesDictionary[CourseName] = newcourse;
                        CodeTextBox.Clear();
                        CourseNameTextBox.Clear();
                        MaximumNumberOfStudentsTextBox.Clear();
                        //CurrentNumberOfStudentsTextBox.Clear();
                        PassingGradeTextBox.Clear();
                        CourseGradeTextBox.Clear();
                        HoursTextBox.Clear();
                        InstructorTextBox.Clear();
                        DescriptionTextBox.Clear();
                    }
                }
            }
        }
示例#34
0
 void OnRegister(bool mailNeeded)
 {
     Invoke(new Action(() =>
     {
         if (mailNeeded)
         {
             CodeTextBox.Show();
             SendBtn.Show();
             Size = new Size(251, Size.Height);
             MessageBox.Show("Please Enter Code");
         }
         else
         {
             MessageBox.Show("Registered!");
             Close();
         }
     }));
 }
        private void ProcessSelection(CodeTextBox codeTextbox, int selectionStart, int selectionLength)
        {
            codeTextbox.EnablePainting = false;

            // Save the position and make the whole line black
            int nPosition = selectionStart;

            codeTextbox.SelectionStart = selectionStart;
            codeTextbox.SelectionLength = selectionLength;
            string text = codeTextbox.SelectedText;

            codeTextbox.SelectionColor = Color.Black;

            // Process the keywords
            ProcessRegex(codeTextbox, text, selectionStart, keywordsRegexp, codeTextbox.CodeColor_Keyword);

            // Process cached type names
            ProcessRegex(codeTextbox, text, selectionStart, typeNamesRegexp, codeTextbox.CodeColor_Type);

            //process functions
            ProcessRegex(codeTextbox, text, selectionStart, functionsRegexp, codeTextbox.CodeColor_Function);

            //process strings
            ProcessRegex(codeTextbox, text, selectionStart, stringsRegexp, codeTextbox.CodeColor_PlainText);

            // Process comments
            if (codeTextbox.CodeWords_Comments.Count > 0)
            {
                ProcessRegex(codeTextbox, text, selectionStart, commentsRegexp, codeTextbox.CodeColor_Comment);
            }

            codeTextbox.SelectionStart = nPosition;
            codeTextbox.SelectionLength = 0;
            codeTextbox.SelectionColor = Color.Black;

            codeTextbox.EnablePainting = true;
        }
        /// <summary>
        /// Compiles the necessary regexps
        /// </summary>
        /// <param name="syntaxSettings"></param>
        public void Update(CodeTextBox codeTextbox)
        {
            string keywords = string.Empty;
            string functions = string.Empty;
            string typeNames = string.Empty;
            string comments = string.Empty;

            #region Build the strings above for regexs
            #region Build keywords
            for (int i = 0; i < codeTextbox.CodeWords_Keywords.Count; i++)
            {
                string strKeyword = codeTextbox.CodeWords_Keywords[i];

                if (i == codeTextbox.CodeWords_Keywords.Count - 1)
                    keywords += "\\b" + strKeyword + "\\b";
                else
                    keywords += "\\b" + strKeyword + "\\b|";
            }
            #endregion

            #region Build functions
            for (int i = 0; i < codeTextbox.CodeWords_Functions.Count; i++)
            {
                string strFunction = codeTextbox.CodeWords_Functions[i];

                if (i == codeTextbox.CodeWords_Functions.Count - 1)
                    functions += "\\b" + strFunction + "\\b";
                else
                    functions += "\\b" + strFunction + "\\b|";
            }
            #endregion

            #region Build typeNames
            for (int i = 0; i < codeTextbox.CodeWords_Types.Count; i++)
            {
                string strType = codeTextbox.CodeWords_Types[i];

                if (i == codeTextbox.CodeWords_Types.Count - 1)
                    typeNames += "\\b" + strType + "\\b";
                else
                    typeNames += "\\b" + strType + "\\b|";
            }
            #endregion

            #region Build comments
            for (int i = 0; i < codeTextbox.CodeWords_Comments.Count; i++)
            {
                string strComments = codeTextbox.CodeWords_Comments[i];

                if (i == codeTextbox.CodeWords_Comments.Count - 1)
                    comments += "" + strComments + ".*$";
                else
                    comments += "" + strComments + ".*$|";
            }
            #endregion
            #endregion

            keywordsRegexp = new Regex(keywords, RegexOptions.Compiled | RegexOptions.Multiline);
            typeNamesRegexp = new Regex(typeNames, RegexOptions.Compiled | RegexOptions.Multiline);
            functionsRegexp = new Regex(functions, RegexOptions.Compiled | RegexOptions.Multiline);
            commentsRegexp = new Regex(comments, RegexOptions.Compiled | RegexOptions.Multiline);
            stringsRegexp = new Regex("\"[^\"\\\\\\r\\n]*(?:\\\\.[^\"\\\\\\r\\n]*)*\"", RegexOptions.Compiled | RegexOptions.Multiline);

            //commentsRegexp = new Regex(syntaxSettings.CommentString + ".*$", RegexOptions.Compiled | RegexOptions.Multiline);

            //Set compiled flag to true
            compiled = true;
        }
        /// <summary>
        /// Processes a regex.
        /// </summary>
        /// <param name="richTextbox"></param>
        /// <param name="line"></param>
        /// <param name="lineStart"></param>
        /// <param name="regexp"></param>
        /// <param name="color"></param>
        private void ProcessRegex(CodeTextBox codeTextbox, string line, int lineStart, Regex regexp, Color color)
        {
            if (regexp == null)
            {
                // for uninitialized typename regexp
                return;
            }

            Match regMatch;

            for (regMatch = regexp.Match(line); regMatch.Success; regMatch = regMatch.NextMatch())
            {
                // Process the words
                int nStart = lineStart + regMatch.Index;
                int nLenght = regMatch.Length;
                codeTextbox.SelectionStart = nStart;
                codeTextbox.SelectionLength = nLenght;
                codeTextbox.SelectionColor = color;
            }
        }