当前位置: 首页>>代码示例>>C#>>正文


C# RichTextBox.ResumeLayout方法代码示例

本文整理汇总了C#中System.Windows.Forms.RichTextBox.ResumeLayout方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.ResumeLayout方法的具体用法?C# RichTextBox.ResumeLayout怎么用?C# RichTextBox.ResumeLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.RichTextBox的用法示例。


在下文中一共展示了RichTextBox.ResumeLayout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppendInternal

        public static void AppendInternal(RichTextBox richTextBox, Color colorFore, Color colorBack, FontStyle newStyle, string text)
        {
            if(richTextBox != null && !string.IsNullOrEmpty(text) && !richTextBox.IsDisposed)
            {
                if(richTextBox.InvokeRequired)
                {
                    richTextBox.BeginInvoke(new MethodInvoker(delegate() { AppendInternal(richTextBox, colorFore, colorBack, newStyle, text); }));
                }
                else
                {
                    lock(richTextBox)
                    {
                        richTextBox.SuspendLayout();

                        //Truncate as necessary
                        if(richTextBox.Text.Length + text.Length > _maxConsoleTextLength)
                        {
                            int truncateLength = _maxConsoleTextLength / 4;
                            int endmarker = richTextBox.Text.IndexOf('\n', truncateLength) + 1;
                            if(endmarker < truncateLength)
                                endmarker = truncateLength;
                            richTextBox.Select(0, endmarker);
                            richTextBox.Cut();
                        }

                        int originalTextEnd = richTextBox.Text.Length;
                        richTextBox.AppendText(text);
                        richTextBox.Select(originalTextEnd, text.Length);
                        if(colorFore != Color.Empty)
                            richTextBox.SelectionColor = colorFore;
                        if(colorBack != Color.Empty)
                            richTextBox.SelectionBackColor = colorBack;

                        //if(newStyle != richTextBox.Font.Style)
                        richTextBox.SelectionFont = new Font(richTextBox.Font, newStyle);

                        richTextBox.SelectionLength = 0;
                        richTextBox.ScrollToCaret();
                        richTextBox.ResumeLayout();
                        richTextBox.Update();
                    }
                }
            }
        }
开发者ID:jeoffman,项目名称:JkhSettings,代码行数:44,代码来源:RichTextBoxHelper.cs

示例2: AddTextToRTB

        /// <summary>
        /// Adds the text to RTB.
        /// </summary>
        /// <param name="richTextBox">The rich text box.</param>
        /// <param name="stackCard">The stack card.</param>
        /// <remarks>Documented by Dev08, 2009-05-12</remarks>
        private void AddTextToRTB(RichTextBox richTextBox, StackCard stackCard)
        {
            richTextBox.SuspendLayout();

            AnswerResult result = stackCard.Promoted ? AnswerResult.Correct : (stackCard.Result == AnswerResult.Almost ? AnswerResult.Almost : AnswerResult.Wrong);
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"<[^>]*>");  //to replace html code if any
            bool questionRTL = stackCard.QuestionCulture.TextInfo.IsRightToLeft;
            bool answerRTL = stackCard.AnswerCulture.TextInfo.IsRightToLeft;

            richTextBox.BackColor = StackCardBackColors.ContainsKey(result) ? StackCardBackColors[result] : SystemColors.Window;
            richTextBox.ForeColor = this.ForeColor;

            string text = Environment.NewLine;

            string questionRLE = (questionRTL ? Convert.ToString(Convert.ToChar(RLE)) : string.Empty);

            text += questionRLE + regex.Replace(stackCard.Question, String.Empty) + Environment.NewLine;
            text += questionRLE + regex.Replace(stackCard.QuestionExample, String.Empty) + Environment.NewLine;

            text += Environment.NewLine;

            string answerRLE = (answerRTL ? Convert.ToString(Convert.ToChar(RLE)) : string.Empty);

            if (stackCard.LearnMode == MLifter.BusinessLayer.LearnModes.Sentence && stackCard.AnswerExample.Length > 0)
            {
                text += answerRLE + regex.Replace(stackCard.AnswerExample, String.Empty) + Environment.NewLine;
                text += answerRLE + regex.Replace(stackCard.Answer, String.Empty) + Environment.NewLine;
            }
            else
            {
                text += answerRLE + regex.Replace(stackCard.Answer, String.Empty) + Environment.NewLine;
                text += answerRLE + regex.Replace(stackCard.AnswerExample, String.Empty) + Environment.NewLine;
            }
            richTextBox.Visible = true;
            richTextBox.Text = text;
            richTextBox.Font = this.Font;

            richTextBox.SelectAll();
            richTextBox.SelectionFont = this.Font;
            richTextBox.Select(0, 0);

            richTextBox.ResumeLayout();
        }
开发者ID:hmehr,项目名称:OSS,代码行数:49,代码来源:StackFlow.cs

示例3: ParseLine


//.........这里部分代码省略.........

                String[] tokens = r.Split(line);
                bool inProperty = false;
                bool inDeclare = false;
                bool inComment = false;
                bool inValue = false;
                int startComment = -1;
                String token = "";

                for (int tokenIndex = 0; tokenIndex < tokens.Count(); tokenIndex++)
                {
                    token = tokens[tokenIndex];

                    if (token.Trim().Equals("")) {
                        selectedIndex += token.Length;
                        continue;
                    }

                    if (token.StartsWith("/*") || token.Contains("/*"))
                    {
                        startComment = selectedIndex;
                        inComment = true;
                    } else if (inComment && token.Contains("*/")) {
                        int closeComment = token.IndexOf("*/") + 1;
                        inComment = false;
                        int commentLength = (selectedIndex - startComment) + closeComment;
                        m_rtb.SelectionStart = startComment;
                        m_rtb.SelectionLength = commentLength;
                        m_rtb.SelectionColor = Color.Green;
                        token = token.Substring(closeComment);
                        selectedIndex += closeComment;
                    } else if (token.Equals(";") && !inComment)
                    {
                        inValue = false;
                        inProperty = false;
                    }
                    else if (token.Equals("{") && !inComment)
                    {
                        inDeclare = true;
                    }
                    else if (token.Equals("}") && !inComment)
                    {
                        inDeclare = false;
                    } else if (!inComment && token.Equals(":")) {
                        m_rtb.SelectionStart = selectedIndex;
                        m_rtb.SelectionLength = token.Length;
                        m_rtb.SelectionColor = Color.Black;
                        m_rtb.SelectedText = token;
                        inProperty = false;
                        inValue = true;
                    } else if (inValue && !inComment) {
                        if (token.StartsWith("#")) { //hex colors only
                            Regex hexColorCheck = new Regex(@"(^[#][A-Fa-f0-9]{3}$|^[#][A-Fa-f0-9]{6}$)");

                            if (hexColorCheck.IsMatch(token)) {
                                string colorToken = token;
                                if(token.Length == 4) { //a short 3 double color
                                    colorToken = "#" + token[1] + token[1] + token[2] + token[2] + token[3] + token[3];
                                }
                                ColorConverter hexConvert = new ColorConverter();
                                Color hexColor = (Color) hexConvert.ConvertFromString(colorToken);
                                m_rtb.SelectionStart = selectedIndex;
                                m_rtb.SelectionLength = token.Length;
                                m_rtb.SelectionColor = hexColor;
                                m_rtb.SelectedText = token;
                            }
                        }
                    } else if (FormLanguage.tokenList.ContainsKey(token) && !inProperty && !inComment) {
                        SyntaxToken keyword = (SyntaxToken)FormLanguage.tokenList[token];
                        m_rtb.SelectionStart = selectedIndex;
                        m_rtb.SelectionLength = token.Length;
                        m_rtb.SelectionColor = keyword.Color;
                        m_rtb.SelectedText = token;
                        inProperty = true;
                    }
                    selectedIndex += token.Length;

                    if (selectedIndex >= endingIndex) break;
                }
            }
            finally
            {

                m_rtb.SelectionStart = endIndex;
                m_rtb.SelectionColor = Color.Black;

                // turn on events
                SendMessage(m_rtb.Handle, EM_SETEVENTMASK, 0, eventMask);
                // turn on redrawing
                SendMessage(m_rtb.Handle, WM_SETREDRAW, 1, IntPtr.Zero);

                m_rtb.SelectionStart = startCursor;
                m_rtb.SelectionLength = 0;
                m_rtb.ResumeLayout();
            }

            SetScrollPos(ScrollPoint, m_rtb.Handle);
            m_rtb.VScroll += new EventHandler(newEditor_VScroll);
            m_rtb.TextChanged += new EventHandler(newEditor_TextChanged);
        }
开发者ID:blindsight,项目名称:CSSControl,代码行数:101,代码来源:EditorForm.cs


注:本文中的System.Windows.Forms.RichTextBox.ResumeLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。