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


C# TextArea.Refresh方法代码示例

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


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

示例1: MarkRegisterUsage

        private void MarkRegisterUsage(string word, IDocument document, TextArea text)
        {
            if (_formatter == null) return;

            var hadRegisterMarks = _registerMarkers.Count > 0;
            if (hadRegisterMarks)
            {
                foreach(var m in _registerMarkers)
                    document.MarkerStrategy.RemoveMarker(m);
            }

            if (word == null || !Regex.IsMatch(word, "^[rp][0-9]+$"))
            {
                if (hadRegisterMarks)
                    text.Refresh();
                return;
            }

            foreach (var line in document.LineSegmentCollection)
            foreach (var w in line.Words)
            {
                if (w.Word != word)
                    continue;

                var marker = new TextMarker(line.Offset + w.Offset, w.Length, TextMarkerType.SolidBlock,
                                            Color.LightSalmon);
                document.MarkerStrategy.AddMarker(marker);
                _registerMarkers.Add(marker);
            }

            if (_registerMarkers.Count > 0 || hadRegisterMarks)
            {
                text.Refresh();
            }

        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:36,代码来源:DexMethodDefinitionNode.cs

示例2: MarkBranchTargets

        private void MarkBranchTargets(string word, string lineText, TextLocation pos, IDocument document, TextArea text)
        {
            if (_branchMarkers.Count > 0)
            {
                foreach(var marker in _branchMarkers)
                    document.MarkerStrategy.RemoveMarker(marker);
                _branchMarkers.Clear();
                text.Refresh();
            }

            if (word == null)
                return;

            bool couldBeJump = Regex.IsMatch(word, "^[0-9a-fA-F]{3,4}$");
            
            if (!couldBeJump)
                return;
            
            int wordIdx;
            GetWordAtColumn(lineText, pos.Column, out wordIdx);

            bool isFirstWord = lineText.IndexOf(word, StringComparison.Ordinal) == wordIdx;
            bool isJumpInstruction = false;

            if (!isFirstWord)
            {
                var words = GetWordAndPrevious(lineText, pos.Column);
                isJumpInstruction = words != null && words[0] == MethodDisassembly.JumpMarker;
            }

            if (!isFirstWord && !isJumpInstruction)
                return;

            HashSet<string> exceptionTargetOffsets = new HashSet<string>();

            if (isFirstWord)
            {
                int offset = int.Parse(word, NumberStyles.HexNumber);
                foreach (var ex in _methodDef.Body.Exceptions)
                {
                    if (offset >= ex.TryStart.Offset && offset <= ex.TryEnd.Offset)
                    {
                        foreach(var c in ex.Catches)
                            exceptionTargetOffsets.Add(MethodDisassembly.FormatOffset(c.Instruction.Offset).Trim());
                        if(ex.CatchAll != null)
                            exceptionTargetOffsets.Add(MethodDisassembly.FormatOffset(ex.CatchAll.Offset).Trim());
                    }
                }
            }

            LineSegment mainLine = null;
            int jumpMarkerLen = MethodDisassembly.JumpMarker.Length;
            // jump target?
            foreach (var line in document.LineSegmentCollection)
            {
                bool isLineFirstWord = true;

                string curLine = document.GetText(line);

                int curOffset = 0;
                
                foreach (var curWord in SplitAndKeep(curLine, SplitCharacters))
                {
                    if (curWord.Trim() == "")
                    {
                        curOffset += curWord.Length;
                        continue;
                    }
                    // mark all words matching the jump instruction
                    if (curWord == word)
                    {
                        if (isLineFirstWord && mainLine == null)
                        {
                            mainLine = line;
                        }
                        else
                        {
                            // add marker.
                            if (curOffset > 4 && curLine.Substring(curOffset - jumpMarkerLen - 1, jumpMarkerLen) == MethodDisassembly.JumpMarker)
                            {
                                AddBranchMarker(document, line.Offset + curOffset - jumpMarkerLen - 1,
                                              curWord.Length + jumpMarkerLen + 1);
                            }
                            else
                            {
                                AddBranchMarker(document, line.Offset + curOffset, curWord.Length);
                            }
                        }
                    }
                    else if (/*isLineFirstWord &&*/ exceptionTargetOffsets.Contains(curWord))
                    {
                        if (!isLineFirstWord)
                        {
                            AddBranchMarker(document, line.Offset + curOffset, curWord.Length, true);
                        }
                        else
                        {
                            AddBranchMarker(document, line.Offset, line.TotalLength, true);
                        }
                    }
//.........这里部分代码省略.........
开发者ID:Xtremrules,项目名称:dot42,代码行数:101,代码来源:DexMethodDefinitionNode.cs

示例3: InsertString

        /// <summary>
        /// Insert a string of text into the specified text area at the current
        /// cursor location.
        /// </summary>
        /// <param name="textArea">The text area to use</param>
        /// <param name="text">The text to insert</param>
        public static void InsertString(TextArea textArea, string text)
        {
            int offset = textArea.Caret.Offset;

            textArea.BeginUpdate();

            try
            {
                textArea.Document.UndoStack.StartUndoGroup();

                // If inserted in a selection, replace the selection.
                // Otherwise, clear it.
                if(textArea.SelectionManager.HasSomethingSelected)
                    if(textArea.SelectionManager.SelectionCollection[0].ContainsOffset(offset))
                    {
                        offset = textArea.SelectionManager.SelectionCollection[0].Offset;
                        textArea.SelectionManager.RemoveSelectedText();
                    }
                    else
                        textArea.SelectionManager.ClearSelection();

                textArea.Document.Insert(offset, text);
                textArea.Caret.Position = textArea.Document.OffsetToPosition(offset + text.Length);
                textArea.Refresh();
                textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
            }
            finally
            {
                textArea.Document.UndoStack.EndUndoGroup();
                textArea.EndUpdate();
            }
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:38,代码来源:ContentEditorControl.cs

示例4: SetText

		void SetText(TextArea textArea, string resourceName, string oldText)
		{
			// ensure caret is at start of selection
			textArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition;
			// deselect text
			textArea.SelectionManager.ClearSelection();
			// replace the selected text with the new text:
			// Replace() takes the arguments: start offset to replace, length of the text to remove, new text
			textArea.Document.Replace(textArea.Caret.Offset,
			                          oldText.Length,
			                          "$" + "{res:" + resourceName + "}");
			// Redraw:
			textArea.Refresh();
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:14,代码来源:Command.cs

示例5: InsertAction

		public override bool InsertAction(TextArea textArea, char ch)
		{
			ClassFinder context = new ClassFinder(ParserService.GetParseInformation(textArea.MotherTextEditorControl.FileName),
			                                      textArea.Caret.Line + 1, textArea.Caret.Column + 1);
			int caretPosition = textArea.Caret.Offset;
			LineSegment line = textArea.Document.GetLineSegment(textArea.Caret.Line);
			string lineText = textArea.Document.GetText(line.Offset, caretPosition - line.Offset);
			foreach (char c in lineText) {
				if (!char.IsWhiteSpace(c) && !char.IsLetterOrDigit(c)) {
					return base.InsertAction(textArea, ch);
				}
			}
			string indentation = lineText.Substring(0, lineText.Length - lineText.TrimStart().Length);
			
			CodeGenerator codeGen = ParserService.CurrentProjectContent.Language.CodeGenerator;
			
			string text = codeGen.GenerateCode(codeGen.GetOverridingMethod(member, context), indentation);
			text = text.TrimEnd(); // remove newline from end
			textArea.Document.Replace(line.Offset, caretPosition - line.Offset, text);
			
			int endPos = line.Offset + text.Length;
			int endLine = textArea.Document.GetLineNumberForOffset(endPos);
			line = textArea.Document.GetLineSegment(endLine);
			textArea.MotherTextAreaControl.JumpTo(endLine, endPos - line.Offset);
			textArea.Refresh();
			return true;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:27,代码来源:OverrideCompletionDataProvider.cs

示例6: FormatLineInternal

		void FormatLineInternal(TextArea textArea, int lineNr, int cursorOffset, char ch)
		{
			LineSegment curLine   = textArea.Document.GetLineSegment(lineNr);
			LineSegment lineAbove = lineNr > 0 ? textArea.Document.GetLineSegment(lineNr - 1) : null;
			string terminator = textArea.TextEditorProperties.LineTerminator;
			
			//// local string for curLine segment
			string curLineText="";
			if (ch == '/') {
				curLineText   = textArea.Document.GetText(curLine);
				string lineAboveText = lineAbove == null ? "" : textArea.Document.GetText(lineAbove);
				if (curLineText != null && curLineText.EndsWith("///") && (lineAboveText == null || !lineAboveText.Trim().StartsWith("///"))) {
					string indentation = base.GetIndentation(textArea, lineNr);
					object member = GetMemberAfter(textArea, lineNr);
					if (member != null) {
						StringBuilder sb = new StringBuilder();
						sb.Append(" <summary>");
						sb.Append(terminator);
						sb.Append(indentation);
						sb.Append("/// ");
						sb.Append(terminator);
						sb.Append(indentation);
						sb.Append("/// </summary>");
						
						if (member is IMethod) {
							IMethod method = (IMethod)member;
							if (method.Parameters != null && method.Parameters.Count > 0) {
								for (int i = 0; i < method.Parameters.Count; ++i) {
									sb.Append(terminator);
									sb.Append(indentation);
									sb.Append("/// <param name=\"");
									sb.Append(method.Parameters[i].Name);
									sb.Append("\"></param>");
								}
							}
							if (method.ReturnType != null && !method.IsConstructor && method.ReturnType.FullyQualifiedName != "System.Void") {
								sb.Append(terminator);
								sb.Append(indentation);
								sb.Append("/// <returns></returns>");
							}
						}
						textArea.Document.Insert(cursorOffset, sb.ToString());
						
						textArea.Refresh();
						textArea.Caret.Position = textArea.Document.OffsetToPosition(cursorOffset + indentation.Length + "/// ".Length + " <summary>".Length + terminator.Length);
					}
				}
				return;
			}
			
			if (ch != '\n' && ch != '>') {
				if (IsInsideStringOrComment(textArea, curLine, cursorOffset)) {
					return;
				}
			}
			switch (ch) {
				case '>':
					if (IsInsideDocumentationComment(textArea, curLine, cursorOffset)) {
						curLineText  = textArea.Document.GetText(curLine);
						int column = textArea.Caret.Offset - curLine.Offset;
						int index = Math.Min(column - 1, curLineText.Length - 1);
						
						while (index >= 0 && curLineText[index] != '<') {
							--index;
							if(curLineText[index] == '/')
								return; // the tag was an end tag or already
						}
						
						if (index > 0) {
							StringBuilder commentBuilder = new StringBuilder("");
							for (int i = index; i < curLineText.Length && i < column && !Char.IsWhiteSpace(curLineText[i]); ++i) {
								commentBuilder.Append(curLineText[ i]);
							}
							string tag = commentBuilder.ToString().Trim();
							if (!tag.EndsWith(">")) {
								tag += ">";
							}
							if (!tag.StartsWith("/")) {
								textArea.Document.Insert(textArea.Caret.Offset, "</" + tag.Substring(1));
							}
						}
					}
					break;
				case ':':
				case ')':
				case ']':
				case '}':
				case '{':
					if (textArea.Document.TextEditorProperties.IndentStyle == IndentStyle.Smart) {
						textArea.Document.FormattingStrategy.IndentLine(textArea, lineNr);
					}
					break;
				case '\n':
					string  lineAboveText = lineAbove == null ? "" : textArea.Document.GetText(lineAbove);
					//// curLine might have some text which should be added to indentation
					curLineText = "";
					if (curLine.Length > 0) {
						curLineText = textArea.Document.GetText(curLine);
					}
					
//.........这里部分代码省略.........
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:101,代码来源:CSharpFormattingStrategy.cs


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