本文整理汇总了C#中ISegment类的典型用法代码示例。如果您正苦于以下问题:C# ISegment类的具体用法?C# ISegment怎么用?C# ISegment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISegment类属于命名空间,在下文中一共展示了ISegment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Complete
public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
{
var instance = ServiceLocator.Current.GetInstance<MainViewModel>();
var text = instance.ActiveEditor.TextBox.FindWord();
var offset = completionSegment.Offset - text.Length;
textArea.Document.Replace(offset, text.Length, Text);
}
示例2: SegmentReader
public SegmentReader(ISegment segment, IWebReader webReader, IWebMetadataFactory webMetadataFactory, IRetryManager retryManager, IPlatformServices platformServices)
{
if (null == segment)
throw new ArgumentNullException(nameof(segment));
if (null == webReader)
throw new ArgumentNullException(nameof(webReader));
if (null == webMetadataFactory)
throw new ArgumentNullException(nameof(webMetadataFactory));
if (null == retryManager)
throw new ArgumentNullException(nameof(retryManager));
if (null == platformServices)
throw new ArgumentNullException(nameof(platformServices));
_segment = segment;
_webReader = webReader;
_webMetadataFactory = webMetadataFactory;
_retryManager = retryManager;
_platformServices = platformServices;
if ((segment.Offset >= 0) && (segment.Length > 0))
{
_startOffset = segment.Offset;
_endOffset = segment.Offset + segment.Length - 1;
}
}
示例3: IsInOriginal
public bool IsInOriginal (ISegment segment)
{
if (segment == null)
throw new ArgumentNullException ("segment");
return segment.Contains(Offset) && segment.Contains (Offset + Length);
}
示例4: PackMessage
internal static Sequence PackMessage(VersionCode version, ISegment header, SecurityParameters parameters, ISegment scope, IPrivacyProvider privacy)
{
if (scope == null)
{
throw new ArgumentNullException("scope");
}
if (parameters == null)
{
throw new ArgumentNullException("parameters");
}
if (header == null)
{
throw new ArgumentNullException("header");
}
if (privacy == null)
{
throw new ArgumentNullException("privacy");
}
ISnmpData[] collection = new ISnmpData[4]
{
new Integer32((int)version),
header.GetData(version),
parameters.GetData(version),
privacy.Encrypt(scope.GetData(version), parameters)
};
return new Sequence(collection);
}
示例5: CreateHtmlFragment
/// <summary>
/// Creates a HTML fragment from a part of a document.
/// </summary>
/// <param name="document">The document to create HTML from.</param>
/// <param name="highlighter">The highlighter used to highlight the document. <c>null</c> is valid and will create HTML without any highlighting.</param>
/// <param name="segment">The part of the document to create HTML for. You can pass <c>null</c> to create HTML for the whole document.</param>
/// <param name="options">The options for the HTML creation.</param>
/// <returns>HTML code for the document part.</returns>
public static string CreateHtmlFragment(TextDocument document, IHighlighter highlighter, ISegment segment, HtmlOptions options)
{
if (document == null)
throw new ArgumentNullException("document");
if (options == null)
throw new ArgumentNullException("options");
if (highlighter != null && highlighter.Document != document)
throw new ArgumentException("Highlighter does not belong to the specified document.");
if (segment == null)
segment = new SimpleSegment(0, document.TextLength);
StringBuilder html = new StringBuilder();
int segmentEndOffset = segment.EndOffset;
DocumentLine line = document.GetLineByOffset(segment.Offset);
while (line != null && line.Offset < segmentEndOffset) {
HighlightedLine highlightedLine;
if (highlighter != null)
highlightedLine = highlighter.HighlightLine(line.LineNumber);
else
highlightedLine = new HighlightedLine(document, line);
SimpleSegment s = segment.GetOverlap(line);
if (html.Length > 0)
html.AppendLine("<br>");
html.Append(highlightedLine.ToHtml(s.Offset, s.EndOffset, options));
line = line.NextLine;
}
return html.ToString();
}
示例6: Complete
public virtual void Complete(TextArea textArea, ISegment completionSegment,
EventArgs insertionRequestEventArgs)
{
textArea.Document.Replace(completionSegment, Action == null ? this.Text : Action.Invoke());
if (CaretOffset != 0)
textArea.Caret.Offset += CaretOffset;
}
示例7: SimpleSelection
/// <summary>
/// Creates a new SimpleSelection instance.
/// </summary>
public SimpleSelection(ISegment segment)
{
if (segment == null)
throw new ArgumentNullException("segment");
this.startOffset = segment.Offset;
this.endOffset = startOffset + segment.Length;
}
示例8: CodeSegmentPreviewWindow
public CodeSegmentPreviewWindow (TextEditor editor, bool hideCodeSegmentPreviewInformString, ISegment segment, int width, int height) : base (Gtk.WindowType.Popup)
{
this.HideCodeSegmentPreviewInformString = hideCodeSegmentPreviewInformString;
this.editor = editor;
this.AppPaintable = true;
layout = PangoUtil.CreateLayout (this);
informLayout = PangoUtil.CreateLayout (this);
informLayout.SetText (CodeSegmentPreviewInformString);
fontDescription = Pango.FontDescription.FromString (editor.Options.FontName);
fontDescription.Size = (int)(fontDescription.Size * 0.8f);
layout.FontDescription = fontDescription;
layout.Ellipsize = Pango.EllipsizeMode.End;
// setting a max size for the segment (40 lines should be enough),
// no need to markup thousands of lines for a preview window
int startLine = editor.Document.OffsetToLineNumber (segment.Offset);
int endLine = editor.Document.OffsetToLineNumber (segment.EndOffset);
const int maxLines = 40;
bool pushedLineLimit = endLine - startLine > maxLines;
if (pushedLineLimit)
segment = new Segment (segment.Offset, editor.Document.GetLine (startLine + maxLines).Offset - segment.Offset);
layout.Ellipsize = Pango.EllipsizeMode.End;
layout.SetMarkup (editor.Document.SyntaxMode.GetMarkup (editor.Document,
editor.Options,
editor.ColorStyle,
segment.Offset,
segment.Length,
true) + (pushedLineLimit ? Environment.NewLine + "..." : ""));
CalculateSize ();
}
示例9: GetSegmentComment
public List<string> GetSegmentComment(ISegment segment)
{
_Comments.Clear();
VisitChildren(segment);
return _Comments;
}
示例10: AddSegment
/// <summary>
/// Adds the specified segment to the geometry.
/// </summary>
public void AddSegment(TextView textView, ISegment segment)
{
if (textView == null)
throw new ArgumentNullException(nameof(textView));
Size pixelSize = PixelSnapHelpers.GetPixelSize(textView);
foreach (Rect r in GetRectsForSegment(textView, segment, ExtendToFullWidthAtLineEnd))
{
if (AlignToWholePixels)
{
AddRectangle(PixelSnapHelpers.Round(r.Left, pixelSize.Width),
PixelSnapHelpers.Round(r.Top + 1, pixelSize.Height),
PixelSnapHelpers.Round(r.Right, pixelSize.Width),
PixelSnapHelpers.Round(r.Bottom + 1, pixelSize.Height));
}
else if (AlignToMiddleOfPixels)
{
AddRectangle(PixelSnapHelpers.PixelAlign(r.Left, pixelSize.Width),
PixelSnapHelpers.PixelAlign(r.Top + 1, pixelSize.Height),
PixelSnapHelpers.PixelAlign(r.Right, pixelSize.Width),
PixelSnapHelpers.PixelAlign(r.Bottom + 1, pixelSize.Height));
}
else
{
AddRectangle(r.Left, r.Top + 1, r.Right, r.Bottom + 1);
}
}
}
示例11: GetPlainText
// Returns the plain text representation of a segment.
// If the includeTagText parameter is true, the returned string will
// also contain the tag content for each tag.
public string GetPlainText(ISegment segment, bool includeTagText)
{
PlainText = new StringBuilder(string.Empty);
IncludeTagText = includeTagText;
VisitChildren(segment);
return PlainText.ToString();
}
示例12: NumberVerifierMessageUI
public NumberVerifierMessageUI(MessageEventArgs messageEventArgs, IBilingualDocument bilingualDocument, ISegment sourceSegment, ISegment targetSegment)
{
MessageEventArgs = messageEventArgs;
BilingualDocument = bilingualDocument;
SourceSegment = sourceSegment;
TargetSegment = targetSegment;
InitializeComponent();
_sourceSegmentControl.Dock = DockStyle.Fill;
_sourceSegmentControl.IsReadOnly = false;
_sourceSegmentControl.ReplaceDocumentSegment(sourceSegment.Clone() as ISegment);
panel_Source.Controls.Add(_sourceSegmentControl);
_sourceSegmentControl.ReplaceDocumentSegment(sourceSegment);
_targetSegmentControl.Dock = DockStyle.Fill;
_targetSegmentControl.IsReadOnly = false;
_targetSegmentControl.ReplaceDocumentSegment(targetSegment.Clone() as ISegment);
panel_Target.Controls.Add(_targetSegmentControl);
_targetSegmentControl.ReplaceDocumentSegment((ISegment)targetSegment.Clone());
_targetSegmentControl.SegmentContentChanged += OnSegmentContentChanged;
_hasSegmentChanged = false;
UpdateMessage(messageEventArgs);
}
示例13: ShowCompletionWindow
/// <summary>
/// Shows completion window for passed functions.
/// </summary>
/// <param name="identifierSegment">optional segment that should be included in the progressive search: eg. part of an identifier that's already typed before code completion was started</param>
/// <param name="functions"></param>
public void ShowCompletionWindow(ISegment identifierSegment, IList<Function> functions)
{
FunctionCompletionData first = null;
_completionWindow = new CompletionWindow(textEditor.TextArea);
foreach (var function in functions)
{
var tooltip = string.IsNullOrWhiteSpace(function.Definition) ? function.Description : string.Format("{0}\n\n{1}", function.Definition.Replace("|", Environment.NewLine), function.Description);
var item = new FunctionCompletionData(function.Name, tooltip);
if (first == null) first = item;
_completionWindow.CompletionList.CompletionData.Add(item);
}
_completionWindow.StartOffset = identifierSegment.Offset;
_completionWindow.EndOffset = identifierSegment.EndOffset;
if (first != null)
{
_completionWindow.CompletionList.SelectedItem = first;
}
_completionWindow.Show();
_completionWindow.Closed += (sender, args) => _completionWindow = null;
_completionWindow.PreviewTextInput += (sender, args) =>
{
if (args.Text == "(")
{
_completionWindow.CompletionList.RequestInsertion(EventArgs.Empty);
}
var c = args.Text[args.Text.Length - 1];
args.Handled = !char.IsLetterOrDigit(c) && c != '_';
};
}
示例14: Process
public void Process(ISegment segment)
{
_plainText = new StringBuilder();
_comments.Clear();
_tokens.Clear();
VisitChildren(segment);
}
示例15: CustomMessageControl
/// <summary>
/// Constructor that takes the given message event args, bilingual document, source segment and target segment.
/// </summary>
/// <param name="messageEventArgs">message event arguments</param>
/// <param name="bilingualDocument">bilingual document</param>
/// <param name="sourceSegment">source segment</param>
/// <param name="targetSegment">target segment</param>
public CustomMessageControl(MessageEventArgs messageEventArgs, IBilingualDocument bilingualDocument, ISegment sourceSegment, ISegment targetSegment)
{
MessageEventArgs = messageEventArgs;
BilingualDocument = bilingualDocument;
SourceSegment = sourceSegment;
TargetSegment = targetSegment;
InitializeComponent();
_sourceSegmentControl.Dock = DockStyle.Fill;
_sourceSegmentPanel.Controls.Add(_sourceSegmentControl);
_targetSegmentControl.Dock = DockStyle.Fill;
_targetSegmentPanel.Controls.Add(_targetSegmentControl);
UpdateMessage(messageEventArgs);
UpdateSourceSegment(sourceSegment);
UpdateTargetSegment((ISegment)targetSegment.Clone());
UpdateProblemDescription(messageEventArgs);
UpdateSuggestions(messageEventArgs);
// make the target segment editable
_targetSegmentControl.IsReadOnly = false;
_suggestionsList.SelectedIndexChanged += _suggestionsList_SelectedIndexChanged;
}