/*
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.ComponentModel.Composition;
using dnSpy.Contracts.Images;
namespace dnSpy.Contracts.ToolBars {
///
/// A button in the toolbar
///
public interface IToolBarButton : IToolBarItem {
///
/// Returns true if the toolbar item is enabled and its
/// method can be called.
///
/// Context
///
bool IsEnabled(IToolBarItemContext context);
///
/// Executes the command
///
/// Context
void Execute(IToolBarItemContext context);
///
/// Gets the header or null to use the header from the attribute
///
/// Context
///
string? GetHeader(IToolBarItemContext context);
///
/// Gets the icon or null to use the icon from the attribute
///
/// Context
///
ImageReference? GetIcon(IToolBarItemContext context);
///
/// Gets the tooltip or null to use the tooltip from the attribute
///
/// Context
///
string? GetToolTip(IToolBarItemContext context);
}
/// Metadata
public interface IToolBarButtonMetadata : IToolBarItemMetadata {
/// See
string? Header { get; }
/// See
string? Icon { get; }
/// See
string? ToolTip { get; }
/// See
bool IsToggleButton { get; }
}
///
/// Exports a toolbar button ()
///
[MetadataAttribute, AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public sealed class ExportToolBarButtonAttribute : ExportToolBarItemAttribute, IToolBarButtonMetadata {
/// Constructor
public ExportToolBarButtonAttribute()
: base(typeof(IToolBarButton)) {
}
///
/// Toolbar button header property value
///
public string? Header { get; set; }
///
/// Icon name
///
public string? Icon { get; set; }
///
/// Tooltip
///
public string? ToolTip { get; set; }
///
/// true if it's a toggle button. If true, you must implement .
///
public bool IsToggleButton { get; set; }
}
}