• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TextArea类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TextArea的典型用法代码示例。如果您正苦于以下问题:C# TextArea类的具体用法?C# TextArea怎么用?C# TextArea使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: Execute

        public override void Execute(TextArea textArea)
        {
            Point position = textArea.Caret.Position;
            List<FoldMarker> foldings = textArea.Document.FoldingManager.GetFoldedFoldingsWithEnd(position.Y);
            FoldMarker justBeforeCaret = null;
            foreach (FoldMarker fm in foldings) {
                if (fm.EndColumn == position.X) {
                    justBeforeCaret = fm;
                    break; // the first folding found is the folding with the smallest Startposition
                }
            }

            if (justBeforeCaret != null) {
                position.Y = justBeforeCaret.StartLine;
                position.X = justBeforeCaret.StartColumn;
            } else {
                if (position.X > 0) {
                    --position.X;
                } else if (position.Y  > 0) {
                    LineSegment lineAbove = textArea.Document.GetLineSegment(position.Y - 1);
                    position = new Point(lineAbove.Length, position.Y - 1);
                }
            }

            textArea.Caret.Position = position;
            textArea.SetDesiredColumn();
        }
开发者ID:jumpinjackie,项目名称:fdotoolbox,代码行数:27,代码来源:CaretActions.cs


示例2: SmartIndentLine

    /// <summary>
    /// Indents the specified line.
    /// </summary>
    protected override int SmartIndentLine(TextArea textArea, int lineNr)
    {
      if (lineNr <= 0)
        return AutoIndentLine(textArea, lineNr);

      string oldText = textArea.Document.GetText(textArea.Document.GetLineSegment(lineNr));

      DocumentAccessor acc = new DocumentAccessor(textArea.Document, lineNr, lineNr);

      IndentationSettings set = new IndentationSettings();
      set.IndentString = Tab.GetIndentationString(textArea.Document);
      set.LeaveEmptyLines = false;
      CSharpIndentationReformatter r = new CSharpIndentationReformatter();

      r.Reformat(acc, set);

      string t = acc.Text;
      if (t.Length == 0)
      {
        // use AutoIndentation for new lines in comments / verbatim strings.
        return AutoIndentLine(textArea, lineNr);
      }
      else
      {
        int newIndentLength = t.Length - t.TrimStart().Length;
        int oldIndentLength = oldText.Length - oldText.TrimStart().Length;
        if (oldIndentLength != newIndentLength && lineNr == textArea.Caret.Position.Y)
        {
          // fix cursor position if indentation was changed
          int newX = textArea.Caret.Position.X - oldIndentLength + newIndentLength;
          textArea.Caret.Position = new TextLocation(Math.Max(newX, 0), lineNr);
        }
        return newIndentLength;
      }
    }
开发者ID:Finarch,项目名称:DigitalRune.Windows.TextEditor,代码行数:38,代码来源:HlslFormattingStrategy.cs


示例3: Execute

 public override void Execute(TextArea textArea)
 {
     foreach (FoldMarker fm in  textArea.Document.FoldingManager.FoldMarker) {
         fm.IsFolded = fm.FoldType == FoldType.MemberBody || fm.FoldType == FoldType.Region;
     }
     //textArea.Refresh();
 }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:7,代码来源:FoldActions.cs


示例4: GenerateCompletionData

		public ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped) {
			List<ICompletionData> completionData = new List<ICompletionData>();

			int column = Math.Max(0, textArea.Caret.Column - 1);
			LineSegment line = textArea.Document.GetLineSegment(textArea.Caret.Line);
			TextWord word = line.GetWord(column);

			string itemText = (word != null ? word.Word : "") + char.ToLower(charTyped);

			if (mScriptContent.CommandsFlat.ContainsKey(itemText) != false) {
				foreach (string key in mScriptContent.CommandsFlat[itemText]) {
					completionData.Add(new ScriptCompletionData(mScriptContent.Commands[key].Name, mScriptContent.Commands[key].Description, 0));
				}
			}
			if (mScriptContent.ConstantsFlat.ContainsKey(itemText) != false) {
				foreach (string key in mScriptContent.ConstantsFlat[itemText]) {
					completionData.Add(new ScriptCompletionData(mScriptContent.Constants[key].Name, mScriptContent.Constants[key].Description, 0));
				}
			}
			if (mScriptContent.Maps.ContainsKey(itemText) != false) {
				foreach (string key in mScriptContent.Maps[itemText]) {
					completionData.Add(new ScriptCompletionData(key, key, 0));
				}
			}

			return completionData.ToArray();
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:27,代码来源:ScriptCompletionProvider.cs


示例5: Execute

 public override void Execute(TextArea textArea)
 {
     List<FoldMarker> foldMarkers = textArea.Document.FoldingManager.GetFoldingsWithStart(textArea.Caret.Line);
     if (foldMarkers.Count != 0)
     {
         foreach (FoldMarker fm in foldMarkers)
             fm.IsFolded = !fm.IsFolded;
     }
     else
     {
         foldMarkers = textArea.Document.FoldingManager.GetFoldingsContainsLineNumber(textArea.Caret.Line);
         if (foldMarkers.Count != 0)
         {
             FoldMarker innerMost = foldMarkers[0];
             for (int i = 1; i < foldMarkers.Count; i++)
             {
                 if (new TextLocation(foldMarkers[i].StartColumn, foldMarkers[i].StartLine) >
                         new TextLocation(innerMost.StartColumn, innerMost.StartLine))
                 {
                     innerMost = foldMarkers[i];
                 }
             }
             innerMost.IsFolded = !innerMost.IsFolded;
         }
     }
     textArea.Document.FoldingManager.NotifyFoldingsChanged(EventArgs.Empty);
 }
开发者ID:KindDragon,项目名称:ICSharpCode.TextEditor.V4,代码行数:27,代码来源:FoldActions.cs


示例6: IndentLines

    /// <summary>
    /// This function sets the indentation level in a range of lines.
    /// </summary>
    /// <param name="textArea">The text area.</param>
    /// <param name="begin">The begin.</param>
    /// <param name="end">The end.</param>
    public override void IndentLines(TextArea textArea, int begin, int end)
    {
      if (textArea.Document.TextEditorProperties.IndentStyle != IndentStyle.Smart)
      {
        base.IndentLines(textArea, begin, end);
        return;
      }
      int cursorPos = textArea.Caret.Position.Y;
      int oldIndentLength = 0;

      if (cursorPos >= begin && cursorPos <= end)
        oldIndentLength = GetIndentation(textArea, cursorPos).Length;

      IndentationSettings set = new IndentationSettings();
      set.IndentString = Tab.GetIndentationString(textArea.Document);
      CSharpIndentationReformatter r = new CSharpIndentationReformatter();
      DocumentAccessor acc = new DocumentAccessor(textArea.Document, begin, end);
      r.Reformat(acc, set);

      if (cursorPos >= begin && cursorPos <= end)
      {
        int newIndentLength = GetIndentation(textArea, cursorPos).Length;
        if (oldIndentLength != newIndentLength)
        {
          // fix cursor position if indentation was changed
          int newX = textArea.Caret.Position.X - oldIndentLength + newIndentLength;
          textArea.Caret.Position = new TextLocation(Math.Max(newX, 0), cursorPos);
        }
      }
    }
开发者ID:Finarch,项目名称:DigitalRune.Windows.TextEditor,代码行数:36,代码来源:HlslFormattingStrategy.cs


示例7: Execute

        /// <summary>
        /// Executes the action on a certain <see cref="TextArea"/>.
        /// </summary>
        /// <param name="textArea">The text area on which to execute the action.</param>
        public override void Execute(TextArea textArea)
        {
            foreach (Fold fold in textArea.Document.FoldingManager.Folds)
            fold.IsFolded = _predicate(fold);

              textArea.Document.FoldingManager.NotifyFoldingChanged(EventArgs.Empty);
        }
开发者ID:cavaliercoder,项目名称:expression-lab,代码行数:11,代码来源:FoldActions.cs


示例8: Execute

 public override void Execute(TextArea textArea)
 {
     if (textArea.Caret.Line != 0 || textArea.Caret.Column != 0) {
         textArea.Caret.Position = new Point(0, 0);
         textArea.SetDesiredColumn();
     }
 }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:7,代码来源:HomeEndActions.cs


示例9: GetIndentationSmart

		/// <summary>
		/// Description
		/// </summary>
		private string GetIndentationSmart(TextArea textArea, int lineNumber) {
			if (lineNumber < 0 || lineNumber > textArea.Document.TotalNumberOfLines) {
				throw new ArgumentOutOfRangeException("lineNumber");
			}

			//! TODO:
			//			- search backward the last symbol
			//			- on { or ), indend by \t
			//			- think about more indentation style
			//			- remember last ) and set next indentation -1

			LineSegment lastLine = textArea.Document.GetLineSegment(lineNumber);
			if (lastLine == null || lastLine.Words.Count == 0) {
				// No text in the last line
				return "";
			}

			// Fetch leading space of last line
			string lastLeading = GetIndentation(textArea, lineNumber);
			TextWord lastWord = lastLine.Words[lastLine.Words.Count - 1];
			if (lastWord.Type != TextWordType.Word) {
				return lastLeading;
			}
			if (mIndentationChars.Contains(lastWord.Word.Trim()) == false) {
				return lastLeading;
			}

			return lastLeading + "\t";
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:32,代码来源:ScrptFormattingStrategy.cs


示例10: Execute

        /// <remarks>
        /// Executes this edit action
        /// </remarks>
        /// <param name="textArea">The <see cref="ItextArea"/> which is used for callback purposes</param>
        public override void Execute(TextArea textArea)
        {
            if (textArea.SelectionManager.HasSomethingSelected) {
                Delete.DeleteSelection(textArea);
            } else {
                if (textArea.Caret.Offset > 0 && !textArea.IsReadOnly(textArea.Caret.Offset - 1)) {
                    textArea.BeginUpdate();
                    int curLineNr     = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);
                    int curLineOffset = textArea.Document.GetLineSegment(curLineNr).Offset;

                    if (curLineOffset == textArea.Caret.Offset) {
                        LineSegment line = textArea.Document.GetLineSegment(curLineNr - 1);
                        int lineEndOffset = line.Offset + line.Length;
                        int lineLength = line.Length;
                        textArea.Document.Remove(lineEndOffset, curLineOffset - lineEndOffset);
                        textArea.Caret.Position = new TextLocation(lineLength, curLineNr - 1);
                        textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new TextLocation(0, curLineNr - 1)));
                    } else {
                        int caretOffset = textArea.Caret.Offset - 1;
                        textArea.Caret.Position = textArea.Document.OffsetToPosition(caretOffset);
                        textArea.Document.Remove(caretOffset, 1);

                        textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToLineEnd, new TextLocation(textArea.Caret.Offset - textArea.Document.GetLineSegment(curLineNr).Offset, curLineNr)));
                    }
                    textArea.EndUpdate();
                }
            }
        }
开发者ID:umabiel,项目名称:WsdlUI,代码行数:32,代码来源:MiscActions.cs


示例11: GenerateRtf

		public static string GenerateRtf(TextArea textArea)
		{
			try {
				colors = new Hashtable();
				colorNum = 0;
				colorString = new StringBuilder();
				
				
				StringBuilder rtf = new StringBuilder();
				
				rtf.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1031");
				BuildFontTable(textArea.Document, rtf);
				rtf.Append('\n');
				
				string fileContent = BuildFileContent(textArea);
				BuildColorTable(textArea.Document, rtf);
				rtf.Append('\n');
				rtf.Append(@"\viewkind4\uc1\pard");
				rtf.Append(fileContent);
				rtf.Append("}");
				return rtf.ToString();
			} catch (Exception e) {
				Console.WriteLine(e.ToString());
			}
			return null;
		}
开发者ID:tangxuehua,项目名称:DataStructure,代码行数:26,代码来源:RtfWriter.cs


示例12: Initialize

        public override void Initialize()
        {
            base.Initialize();

            TextArea loveletter = new TextArea("Hello, World!", 1, 20);
            AddComponent(loveletter, 20, 200);
        }
开发者ID:Syderis,项目名称:CellSDK-Tutorials,代码行数:7,代码来源:MainScreen.cs


示例13: Execute

		/// <remarks>
		/// Executes this edit action
		/// </remarks>
		/// <param name="textArea">The <see cref="ItextArea"/> which is used for callback purposes</param>
		public override void Execute(TextArea textArea)
		{
			if (textArea.Document.ReadOnly) {
				return;
			}
			textArea.Document.UndoStack.StartUndoGroup();
			if (textArea.SelectionManager.HasSomethingSelected) {
				foreach (ISelection selection in textArea.SelectionManager.SelectionCollection) {
					int startLine = selection.StartPosition.Y;
					int endLine   = selection.EndPosition.Y;
					if (startLine != endLine) {
						textArea.BeginUpdate();
						InsertTabs(textArea.Document, selection, startLine, endLine);
						textArea.Document.UpdateQueue.Clear();
						textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.LinesBetween, startLine, endLine));
                        textArea.EndUpdate();
					} else {
						InsertTabAtCaretPosition(textArea);
						break;
					}
				}
				textArea.Document.CommitUpdate();
				textArea.AutoClearSelection = false;
			} else {
				InsertTabAtCaretPosition(textArea);
			}
			textArea.Document.UndoStack.EndUndoGroup();
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:32,代码来源:MiscActions.cs


示例14: Execute

        /// <summary>
        /// Executes the action on a certain <see cref="TextArea"/>.
        /// </summary>
        /// <param name="textArea">The text area on which to execute the action.</param>
        public override void Execute(TextArea textArea)
        {
            if (textArea.Document.ReadOnly)
            return;

              textArea.ClipboardHandler.Paste();
        }
开发者ID:cavaliercoder,项目名称:expression-lab,代码行数:11,代码来源:ClipBoardActions.cs


示例15: Execute

        /// <remarks>
        /// Executes this edit action
        /// </remarks>
        /// <param name="textArea">The <see cref="ItextArea"/> which is used for callback purposes</param>
        public override void Execute(TextArea textArea)
        {
            if (textArea.Document.ReadOnly) {
                return;
            }
            if (textArea.SelectionManager.HasSomethingSelected) {
                textArea.BeginUpdate();
                textArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition;
                textArea.SelectionManager.RemoveSelectedText();
                textArea.ScrollToCaret();
                textArea.EndUpdate();
            } else {

                if (textArea.Caret.Offset < textArea.Document.TextLength) {
                    textArea.BeginUpdate();
                    int curLineNr   = textArea.Document.GetLineNumberForOffset(textArea.Caret.Offset);
                    LineSegment curLine = textArea.Document.GetLineSegment(curLineNr);

                    if (curLine.Offset + curLine.Length == textArea.Caret.Offset) {
                        if (curLineNr + 1 < textArea.Document.TotalNumberOfLines) {
                            LineSegment nextLine = textArea.Document.GetLineSegment(curLineNr + 1);

                            textArea.Document.Remove(textArea.Caret.Offset, nextLine.Offset - textArea.Caret.Offset);
                            textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToEnd, new Point(0, curLineNr)));
                        }
                    } else {
                        textArea.Document.Remove(textArea.Caret.Offset, 1);
            //						textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.PositionToLineEnd, new Point(textArea.Caret.Offset - textArea.Document.GetLineSegment(curLineNr).Offset, curLineNr)));
                    }
                    textArea.UpdateMatchingBracket();
                    textArea.EndUpdate();
                }
            }
        }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:38,代码来源:MiscActions.cs


示例16: Execute

		public override void Execute(TextArea textArea)
		{
			if (textArea.Document.ReadOnly) {
				return;
			}
			textArea.ClipboardHandler.Cut(null, null);
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:7,代码来源:ClipBoardActions.cs


示例17: Execute

		public override void Execute(TextArea textArea)
		{
			TextLocation oldCaretPos  = textArea.Caret.Position;
			base.Execute(textArea);
			textArea.AutoClearSelection = false;
			textArea.SelectionManager.ExtendSelection(oldCaretPos, textArea.Caret.Position);
		}
开发者ID:JodenSoft,项目名称:JodenSoft,代码行数:7,代码来源:SelectionActions.cs


示例18: Execute

		public override void Execute(TextArea textArea)
		{
			foreach (FoldMarker fm in  textArea.Document.FoldingManager.FoldMarker) {
				fm.IsFolded = fm.FoldType == FoldType.MemberBody || fm.FoldType == FoldType.Region;
			}
			textArea.Document.FoldingManager.NotifyFoldingsChanged(EventArgs.Empty);
		}
开发者ID:viticm,项目名称:pap2,代码行数:7,代码来源:FoldActions.cs


示例19: FormatLine

		/// <summary>
		/// This function formats a specific line after <code>ch</code> is pressed.
		/// </summary>
		/// <returns>
		/// the caret delta position the caret will be moved this number
		/// of bytes (e.g. the number of bytes inserted before the caret, or
		/// removed, if this number is negative)
		/// </returns>
		public virtual int FormatLine(TextArea textArea, int line, int cursorOffset, char ch)
		{
			if (ch == '\n') {
				return IndentLine(textArea, line);
			}
			return 0;
		}
开发者ID:stophun,项目名称:fdotoolbox,代码行数:15,代码来源:DefaultFormattingStrategy.cs


示例20: Execute

        /// <summary>
        /// Executes the action on a certain <see cref="TextArea"/>.
        /// </summary>
        /// <param name="textArea">The text area on which to execute the action.</param>
        public override void Execute(TextArea textArea)
        {
            LineSegment curLine;
              TextLocation newPos = textArea.Caret.Position;
              bool jumpedIntoFolding;
              do
              {
            curLine = textArea.Document.GetLineSegment(newPos.Y);
            newPos.X = curLine.Length;

            List<Fold> foldings = textArea.Document.FoldingManager.GetFoldsFromPosition(newPos.Y, newPos.X);
            jumpedIntoFolding = false;
            foreach (Fold fold in foldings)
            {
              if (fold.IsFolded)
              {
            newPos = new TextLocation(fold.EndColumn, fold.EndLine);
            jumpedIntoFolding = true;
            break;
              }
            }
              } while (jumpedIntoFolding);

              if (newPos != textArea.Caret.Position)
              {
            textArea.Caret.Position = newPos;
            textArea.SetDesiredColumn();
              }
        }
开发者ID:cavaliercoder,项目名称:expression-lab,代码行数:33,代码来源:HomeEndActions.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TextBlock类代码示例发布时间:2022-05-24
下一篇:
C# TextAnchor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap