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


C# FastColoredTextBox.AddHint方法代码示例

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


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

示例1: SetJavaCodeError

        /// <summary>
        /// Set Error marker on code for Java. returns True on success False otherwise.
        /// </summary>
        public static bool SetJavaCodeError(FastColoredTextBox code, Range message, bool focus = false)
        {
            try
            {
                //split data in parts separated by ':'
                string data = message.Text;
                string[] part = data.Split(new char[] { ':' });

                //usually row and col is on first two parts
                int row = int.Parse(part[0]) - 1; // <-- throws exception on failure

                //check if rest of the data is not empty
                string rest = string.Join(" ", part, 1, part.Length - 1);
                if (rest.Trim().Length == 0) return false;

                //get line by row number
                string line = code.Lines[row].TrimEnd();
                //get last of the message
                Place stop = new Place(line.Length, row);
                //we need to move start point where first  non-space character found
                int col = 0; while (col < line.Length && line[col] == ' ') ++col;
                Place start = new Place(col, row);
                //get range from start to stop
                Range range = code.GetRange(start, stop);

                //show zigzag lines under the errors
                range.SetStyle(HighlightSyntax.LineErrorStyle);

                //focus current and exit
                if (focus)
                {
                    code.ExpandBlock(row);
                    code.Selection = range;
                    code.DoRangeVisible(range, true);
                }

                // add hints
                if (Properties.Settings.Default.EditorShowHints)
                {
                    Hint hdat = code.AddHint(range, data, focus, true, true);
                    hdat.Tag = message;
                    hdat.BorderColor = Color.LightBlue;
                    hdat.BackColor = Color.AliceBlue;
                    hdat.BackColor2 = Color.PowderBlue;
                }

                return true;
            }
            catch { return false; }
        }
开发者ID:nocmnt,项目名称:UVA-Arena,代码行数:53,代码来源:HighlightSyntax.cs

示例2: SetCPPCodeError

        /// <summary>
        /// Set Error marker on code for C/C++. returns True on success False otherwise.
        /// </summary>
        public static bool SetCPPCodeError(FastColoredTextBox code, Range message, bool focus = false)
        {
            try
            {
                //split data in parts separated by ':'
                string data = message.Text;
                string[] part = data.Split(new char[] { ':' });

                //usually row and col is on first two parts
                int row, col;
                row = int.Parse(part[0]) - 1; // <-- throws exception on failure
                col = int.Parse(part[1]) - 1; // <-- throws exception on failure

                //get the type of message : there can be one and only one of these types
                bool error = Regex.IsMatch(data, " error:.*"); //check for error data type
                bool warn = Regex.IsMatch(data, " warning:.*"); //check for warning data type
                bool note = Regex.IsMatch(data, " note:.*"); //check for note data type
                if (!(error || warn || note)) return false; //for c++ do not proceed if not valid type

                //get line by row number
                string line = code.Lines[row];
                //get start the message
                Place start = new Place(col, row);
                //we need to cover the next word after start
                while (col < line.Length && char.IsLetterOrDigit(line[col])) ++col;
                //if no word of number is selected select all non-space chars instead
                if (start.iChar == col) { while (col < line.Length && ' ' != line[col]) ++col; }
                //now we found our stop position
                Place stop = new Place(col, row);
                //get range from start to stop
                Range range = code.GetRange(start, stop);

                //show zigzag lines under the errors
                if (error) range.SetStyle(HighlightSyntax.LineErrorStyle);
                else if (warn) range.SetStyle(HighlightSyntax.LineWarningStyle);
                else if (note) range.SetStyle(HighlightSyntax.LineNoteStyle);

                //focus current and exit
                if (focus && error)
                {
                    code.ExpandBlock(row);
                    code.Selection = range;
                    code.DoRangeVisible(range, true);
                }

                // add hints
                if (Properties.Settings.Default.EditorShowHints && error)
                {
                    Hint hdat = code.AddHint(range, data, focus, true, true);
                    hdat.Tag = message;
                    hdat.BackColor = Color.AliceBlue;
                    hdat.BackColor2 = Color.LightSkyBlue;
                }

                return true;
            }
            catch { return false; }
        }
开发者ID:nocmnt,项目名称:UVA-Arena,代码行数:61,代码来源:HighlightSyntax.cs


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