本文整理汇总了C#中IWpfTextView类的典型用法代码示例。如果您正苦于以下问题:C# IWpfTextView类的具体用法?C# IWpfTextView怎么用?C# IWpfTextView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWpfTextView类属于命名空间,在下文中一共展示了IWpfTextView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BottomMargin
public BottomMargin(IWpfTextView textView, IClassifierAggregatorService classifier, ITextDocumentFactoryService documentService)
{
_textView = textView;
_classifier = classifier.GetClassifier(textView.TextBuffer);
_foregroundBrush = new SolidColorBrush((Color)FindResource(VsColors.CaptionTextKey));
_backgroundBrush = new SolidColorBrush((Color)FindResource(VsColors.ScrollBarBackgroundKey));
this.Background = _backgroundBrush;
this.ClipToBounds = true;
_lblEncoding = new TextControl("Encoding");
this.Children.Add(_lblEncoding);
_lblContentType = new TextControl("Content type");
this.Children.Add(_lblContentType);
_lblClassification = new TextControl("Classification");
this.Children.Add(_lblClassification);
_lblSelection = new TextControl("Selection");
this.Children.Add(_lblSelection);
UpdateClassificationLabel();
UpdateContentTypeLabel();
UpdateContentSelectionLabel();
if (documentService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _doc))
{
_doc.FileActionOccurred += FileChangedOnDisk;
UpdateEncodingLabel(_doc);
}
textView.Caret.PositionChanged += CaretPositionChanged;
}
示例2: GochiusaIDE
/// <summary>
/// Creates a square image and attaches an event handler to the layout changed event that
/// adds the the square in the upper right-hand corner of the TextView via the adornment layer
/// </summary>
/// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
public GochiusaIDE(IWpfTextView view)
{
_view = view;
InitImages();
eyeClosed = false;
cRandom = new Random();
building = false;
buildDone = false;
clean = false;
//Grab a reference to the adornment layer that this adornment should be added to
_adornmentLayer = view.GetAdornmentLayer("GochiusaIDE");
_adornmentBackgroundLayer = view.GetAdornmentLayer("GochiusaIDE_Background");
_adornmentBuildLayer = view.GetAdornmentLayer("GochiusaIDE_Build");
_adornmentBackgroundLayer.AddAdornment(AdornmentPositioningBehavior.ViewportRelative, null, null, _backgroundImage, null);
faceTimer = new DispatcherTimer(DispatcherPriority.Normal);
faceTimer.Interval = new TimeSpan(30000000);
faceTimer.Tick += new EventHandler(faceTimer_Tick);
faceTimer.Start();
buildTimer = new DispatcherTimer(DispatcherPriority.Normal);
buildTimer.Interval = new TimeSpan(5000000);
buildTimer.Tick += new EventHandler(buildTimer_Tick);
buildTimer.Start();
_view.ViewportHeightChanged += delegate { this.onSizeChange(); };
_view.ViewportWidthChanged += delegate { this.onSizeChange(); };
}
示例3: EditorDiffMargin
internal EditorDiffMargin(IWpfTextView textView, UnifiedDiff unifiedDiff, IMarginCore marginCore)
: base(textView)
{
ViewModel = new EditorDiffMarginViewModel(marginCore, unifiedDiff, UpdateDiffDimensions);
UserControl = new EditorDiffMarginControl {DataContext = ViewModel, Width = MarginWidth};
}
示例4: SubjectBuffersDisconnected
public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) {
foreach (var buffer in subjectBuffers) {
foreach (var document in buffer.GetRelatedDocuments()) {
buffer.GetWorkspace().CloseDocument(document.Id);
}
}
}
示例5: CommandFilter
public CommandFilter(IWpfTextView textView, ICompletionBroker broker)
{
_currentSession = null;
TextView = textView;
Broker = broker;
}
示例6: GetGraphics
/// <summary>
/// Creates a very long line at the bottom of bounds.
/// </summary>
public override GraphicsResult GetGraphics(IWpfTextView view, Geometry bounds)
{
Initialize(view);
var border = new Border()
{
BorderBrush = _graphicsTagBrush,
BorderThickness = new Thickness(0, 0, 0, bottom: 1),
Height = 1,
Width = view.ViewportWidth
};
EventHandler viewportWidthChangedHandler = (s, e) =>
{
border.Width = view.ViewportWidth;
};
view.ViewportWidthChanged += viewportWidthChangedHandler;
// Subtract rect.Height to ensure that the line separator is drawn
// at the bottom of the line, rather than immediately below.
// This makes the line separator line up with the outlining bracket.
Canvas.SetTop(border, bounds.Bounds.Bottom - border.Height);
return new GraphicsResult(border,
() => view.ViewportWidthChanged -= viewportWidthChangedHandler);
}
示例7: RemoveWhitespaceOnSave
public RemoveWhitespaceOnSave(IVsTextView textViewAdapter, IWpfTextView view, DTE2 dte, ITextDocument document)
{
textViewAdapter.AddCommandFilter(this, out _nextCommandTarget);
_view = view;
_dte = dte;
_document = document;
}
示例8: EnterFormat
public EnterFormat(IVsTextView adapter, IWpfTextView textView, IEditorFormatterProvider formatterProvider, ICompletionBroker broker)
: base(adapter, textView, typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, 3)
{
_tree = HtmlEditorDocument.FromTextView(textView).HtmlEditorTree;
_formatter = formatterProvider.CreateRangeFormatter();
_broker = broker;
}
示例9: CaretFisheyeLineTransformSource
private CaretFisheyeLineTransformSource(IWpfTextView textView)
{
_textView = textView;
//Sync to changing the caret position.
_textView.Caret.PositionChanged += OnCaretChanged;
}
示例10: InstantVisualStudio
public InstantVisualStudio (IWpfTextView view, ITextDocumentFactoryService textDocumentFactoryService)
{
this.view = view;
this.layer = view.GetAdornmentLayer("Instant.VisualStudio");
//Listen to any event that changes the layout (text changes, scrolling, etc)
this.view.LayoutChanged += OnLayoutChanged;
this.dispatcher = Dispatcher.CurrentDispatcher;
this.evaluator.EvaluationCompleted += OnEvaluationCompleted;
this.evaluator.Start();
this.dte.Events.BuildEvents.OnBuildProjConfigDone += OnBuildProjeConfigDone;
this.dte.Events.BuildEvents.OnBuildDone += OnBuildDone;
this.dte.Events.BuildEvents.OnBuildBegin += OnBuildBegin;
this.statusbar = (IVsStatusbar)this.serviceProvider.GetService (typeof (IVsStatusbar));
ITextDocument textDocument;
if (!textDocumentFactoryService.TryGetTextDocument (view.TextBuffer, out textDocument))
throw new InvalidOperationException();
this.document = this.dte.Documents.OfType<EnvDTE.Document>().FirstOrDefault (d => d.FullName == textDocument.FilePath);
InstantTagToggleAction.Toggled += OnInstantToggled;
}
示例11: Update
internal void Update(
string text,
ITextViewLine line,
IWpfTextView view,
TextRunProperties formatting,
double marginWidth,
double verticalOffset)
{
LineTag = line.IdentityTag;
if (_text == null || !string.Equals(_text, text, StringComparison.Ordinal))
{
_text = text;
_formattedText = new FormattedText(
_text,
CultureInfo.InvariantCulture,
FlowDirection.LeftToRight,
formatting.Typeface,
formatting.FontRenderingEmSize,
formatting.ForegroundBrush);
_horizontalOffset = Math.Round(marginWidth - _formattedText.Width);
InvalidateVisual();
}
var num = line.TextTop - view.ViewportTop + verticalOffset;
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (num == _verticalOffset) return;
_verticalOffset = num;
InvalidateVisual();
}
示例12: ClaudiaIDE
/// <summary>
/// Creates a square image and attaches an event handler to the layout changed event that
/// adds the the square in the upper right-hand corner of the TextView via the adornment layer
/// </summary>
/// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
/// <param name="imageProvider">The <see cref="IImageProvider"/> which provides bitmaps to draw</param>
/// <param name="setting">The <see cref="Setting"/> contains user image preferences</param>
public ClaudiaIDE(IWpfTextView view, List<IImageProvider> imageProvider, Setting setting)
{
try
{
_dispacher = Dispatcher.CurrentDispatcher;
_imageProviders = imageProvider;
_imageProvider = imageProvider.FirstOrDefault(x=>x.ProviderType == setting.ImageBackgroundType);
_setting = setting;
if (_imageProvider == null)
{
_imageProvider = new SingleImageProvider(_setting);
}
_view = view;
_image = new Image
{
Opacity = setting.Opacity,
IsHitTestVisible = false
};
_adornmentLayer = view.GetAdornmentLayer("ClaudiaIDE");
_view.ViewportHeightChanged += delegate { RepositionImage(); };
_view.ViewportWidthChanged += delegate { RepositionImage(); };
_view.ViewportLeftChanged += delegate { RepositionImage(); };
_setting.OnChanged += delegate { ReloadSettings(); };
_imageProviders.ForEach(x => x.NewImageAvaliable += delegate { InvokeChangeImage(); });
ChangeImage();
}
catch
{
}
}
示例13: InsertText
private static void InsertText(IWpfTextView view, DTE2 dte, string text)
{
try
{
dte.UndoContext.Open("Generate text");
using (var edit = view.TextBuffer.CreateEdit())
{
if (!view.Selection.IsEmpty)
{
edit.Delete(view.Selection.SelectedSpans[0].Span);
view.Selection.Clear();
}
edit.Insert(view.Caret.Position.BufferPosition, text);
edit.Apply();
}
}
catch (Exception ex)
{
Logger.Log(ex);
}
finally
{
dte.UndoContext.Close();
}
}
示例14: TextViewCreated
public void TextViewCreated(IWpfTextView textView)
{
IPresentationModeState state = PkgSource.PresentationMode;
textView.Properties.GetOrCreateSingletonProperty(
() => new PresentationMode(textView, state, Settings)
);
}
示例15: DropHandler
public DropHandler(IWpfTextView wpfTextView, IEnumerable<IDropInfoHandler> dropInfoHandlers, IDropAction dropAction)
{
_log.Debug("DropHandler.ctor");
_tgt = wpfTextView;
_dropInfoHandlers = dropInfoHandlers;
_dropAction = dropAction;
}