/* 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.Threading; using dnSpy.Contracts.Documents.Tabs.DocViewer; using dnSpy.Contracts.Settings; namespace dnSpy.Contracts.Documents.Tabs { /// /// A tab /// public interface IDocumentTab { /// /// Current instance /// DocumentTabContent Content { get; } /// /// Current /// DocumentTabUIContext UIContext { get; } /// /// Gets the owner /// IDocumentTabService DocumentTabService { get; } /// /// Deserializes UI settings serialized by /// /// Serialized data void DeserializeUI(ISettingsSection tabContentUI); /// /// Serializes UI settings /// /// Target section void SerializeUI(ISettingsSection tabContentUI); /// /// true if this is the active tab /// bool IsActiveTab { get; } /// /// true if can execute /// bool CanNavigateBackward { get; } /// /// Navigates backward in history /// void NavigateBackward(); /// /// true if can execute /// bool CanNavigateForward { get; } /// /// Navigates forward in history /// void NavigateForward(); /// /// Follows a reference /// /// Reference /// Source content or null /// Called after the content has been shown. Can be null. void FollowReference(object @ref, DocumentTabContent? sourceContent = null, Action? onShown = null); /// /// Follows a reference in a new tab /// /// Reference /// Called after the content has been shown. Can be null. void FollowReferenceNewTab(object @ref, Action? onShown = null); /// /// Follows a reference /// /// Reference /// true to open a new tab /// Called after the content has been shown. Can be null. void FollowReference(object @ref, bool newTab, Action? onShown = null); /// /// Shows the tab content /// /// Tab content /// UI state (passed to ) or null /// Called after the output has been shown on the screen void Show(DocumentTabContent tabContent, object? uiState, Action? onShown); /// /// Sets focus to the focused element if this is the active tab /// void TrySetFocus(); /// /// Closes this tab /// void Close(); /// /// true if hasn't finished executing /// bool IsAsyncExecInProgress { get; } /// /// Executes new code, cancelling any other started call /// /// Executed in the current thread before the async code has started /// Executed in a new thread /// Executed in the current thread after /// has finished executing void AsyncExec(Action preExec, Action asyncAction, Action postExec); } /// /// Extension methods /// public static class DocumentTabExtensions { /// /// Returns the tab's or null if it's not visible /// /// Tab /// public static IDocumentViewer? TryGetDocumentViewer(this IDocumentTab? tab) => tab?.UIContext as IDocumentViewer; } }