/*
Copyright (C) 2014-2019 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see .
*/
using System;
using System.Collections.Generic;
using System.Windows;
using dnlib.DotNet;
using dnSpy.Contracts.Text;
using dnSpy.Contracts.Text.Editor;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
namespace dnSpy.Contracts.Documents.Tabs.DocViewer {
///
/// Document viewer, it also derives from
///
public interface IDocumentViewer {
///
/// Gets the owner tab
///
IDocumentTab? DocumentTab { get; }
///
/// Gets the document viewer control
///
FrameworkElement UIObject { get; }
///
/// Sets new content. Returns true if the content got updated, false if the input was identical
/// to the current content.
///
/// New content
/// Content type or null
///
bool SetContent(DocumentViewerContent content, IContentType? contentType);
///
/// Adds data that is removed each time
/// gets called with new content.
///
/// Key
/// Value
void AddContentData(object key, object data);
///
/// Returns data added by or null if not found
///
/// Key
///
object? GetContentData(object key);
///
/// Shows a cancel button. Can be used when decompiling in another thread
///
/// Message to show to the user or null
/// Called if the user clicks the cancel button
void ShowCancelButton(string? message, Action onCancel);
///
/// Hides the cancel button shown by
///
void HideCancelButton();
///
/// Gets the text view host. Don't write to the text buffer directly, use
/// to write new text.
///
IDsWpfTextViewHost TextViewHost { get; }
///
/// Gets the text view. Don't write to the text buffer directly, use
/// to write new text.
///
IDsWpfTextView TextView { get; }
///
/// Gets the caret
///
ITextCaret Caret { get; }
///
/// Gets the selection
///
ITextSelection Selection { get; }
///
/// Gets the current content (set by )
///
DocumentViewerContent Content { get; }
///
/// Gets the reference collection ()
///
SpanDataCollection ReferenceCollection { get; }
///
/// Gets the reference at the caret or null if none
///
SpanData? SelectedReference { get; }
///
/// Gets all references intersecting with the selection
///
///
IEnumerable> GetSelectedReferences();
///
/// Moves the caret to a reference, this can be a ,
/// or a . Anything else isn't currently supported.
///
/// Reference
/// Options
void MoveCaretToReference(object? @ref, MoveCaretOptions options = MoveCaretOptions.Select | MoveCaretOptions.Focus);
///
/// Moves the caret to a position in the document
///
/// Position
/// Options
void MoveCaretToPosition(int position, MoveCaretOptions options = MoveCaretOptions.Focus);
///
/// Moves the caret to a span in the document and selects it
///
/// Position
/// Length of span
/// Options
void MoveCaretToSpan(int position, int length, MoveCaretOptions options = MoveCaretOptions.Select | MoveCaretOptions.Focus);
///
/// Moves the caret to a span in the document and selects it
///
/// Span
/// Options
void MoveCaretToSpan(Span span, MoveCaretOptions options = MoveCaretOptions.Select | MoveCaretOptions.Focus);
///
/// Moves the caret to a span in the document and selects it
///
/// Reference and span
/// Options
void MoveCaretToSpan(SpanData refInfo, MoveCaretOptions options = MoveCaretOptions.Select | MoveCaretOptions.Focus);
///
/// Saves current location relative to some reference in the code. Return value can be
/// passed to
///
///
object? SaveReferencePosition();
///
/// Restores location saved by
///
/// Saved position
///
bool RestoreReferencePosition(object? obj);
///
/// Raised after this instance got new content (its
/// method was called). It's only raised if the new content is different from the current
/// content. I.e., calling it twice in a row with the same content won't raise this event
/// the second time. This event is raised before
///
event EventHandler? GotNewContent;
///
/// Raised when this instance has been closed. This event is raised before
///
///
event EventHandler? Removed;
}
}