using System.Collections.Generic; using System.Windows; using Core.Common.Controls.Commands; using Core.Common.Gui.Forms; using Fluent; namespace Core.Plugins.OxyPlot { /// /// This class represents the ribbon interaction which has to do with charting. /// public partial class ChartingRibbon : IRibbonCommandHandler { /// /// Creates a new instance of . /// public ChartingRibbon() { InitializeComponent(); } /// /// Sets the command used when the open chart button is clicked. /// public ICommand OpenChartViewCommand { private get; set; } /// /// Sets the command used when the toggle legend view button is clicked. /// public ICommand ToggleLegendViewCommand { private get; set; } /// /// Sets the command used when the enable panning button is clicked. /// public ICommand TogglePanningCommand { private get; set; } public IEnumerable Commands { get { if (OpenChartViewCommand != null) { yield return OpenChartViewCommand; } if (ToggleLegendViewCommand != null) { yield return ToggleLegendViewCommand; } if (TogglePanningCommand != null) { yield return TogglePanningCommand; } } } /// /// Shows the charting contextual tab. /// public void ShowChartingTab() { ChartingContextualGroup.Visibility = Visibility.Visible; } /// /// Hides the charting contextual tab. /// public void HideChartingTab() { ChartingContextualGroup.Visibility = Visibility.Collapsed; } public Ribbon GetRibbonControl() { return RibbonControl; } public void ValidateItems() { ToggleLegendViewButton.IsChecked = ToggleLegendViewCommand.Checked; } public bool IsContextualTabVisible(string tabGroupName, string tabName) { // TODO: Required only because this method is called each time ValidateItems is called in MainWindow // Once ValidateItems isn't responsible for showing/hiding contextual tabs, then this method can return false, // but more ideally be removed. return ChartingContextualGroup.Name == tabGroupName && ChartingContextualGroup.Visibility == Visibility.Visible; } private void ButtonOpenChartView_Click(object sender, RoutedEventArgs e) { OpenChartViewCommand.Execute(); } private void ButtonToggleLegend_Click(object sender, RoutedEventArgs e) { ToggleLegendViewCommand.Execute(); } private void ButtonTogglePanning_Click(object sender, RoutedEventArgs e) { TogglePanningCommand.Execute(); } } }