...
Add a new folder to the plugin project named Ribbon. In this folder, create a new WPF user control named VolumeModelRibbon.xaml and adapt the contents (in the designer) as shown below:
Note |
---|
Code Block |
---|
<UserControl x:Class="DeltaShell.Plugins.VolumeModel.Ribbon.VolumeModelRibbon" <UserControl x:Class="DeltaShell.Plugins.VolumeModel.Ribbon.VolumeModelRibbon" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:fluent="clr-namespace:Fluent;assembly=Fluent" mc:Ignorable="d" Height="145" Width="632"> <!--Create a ribbon control--> <fluent:Ribbon Name="VolumeModelRibbonControl" x:FieldModifier="private"> <!--Create a ribbon tab--> <fluent:RibbonTabItem Header="Volume model" fluent:KeyTip.Keys="E"> <!--Create a ribbon group box--> <fluent:RibbonGroupBox Header="Input"> <!--Create a ribbon button--> <fluent:Button x:Name="ButtonAddInputDataToVolumeModel" Header="Add input data" ToolTip="Add input data to the selected volume model" Click="ButtonAddInputDataToVolumeModel_OnClick" Size="Middle" SizeDefinition="Middle,Small,Small"/> </fluent:RibbonGroupBox> </fluent:RibbonTabItem> </fluent:Ribbon> </UserControl> |
Additionally, adapt the contents of VolumeModelRibbon.xaml.cs as shown below (right click the class | View Code).
Note |
---|
</UserControl>
|
Additionally, adapt the contents of VolumeModelRibbon.xaml.cs as shown below (right click the class | View Code).
Code Block |
---|
using System.Collections.Generic; using System.Windows; using DelftTools.Controls; using DelftTools.Shell.Gui; using DelftTools.Shell.Gui.Forms; using DeltaShell.Plugins.VolumeModel.Commands; namespace DeltaShell.Plugins.VolumeModel.Ribbon { /// <summary> /// Interaction logic for VolumeModelRibbon.xaml /// </summary> public partial class VolumeModelRibbon : IRibbonCommandHandler { private readonly IGuiCommand addInputDataToVolumeModelCommand = new AddInputDataToVolumeModelCommand(); // Instance of the implemented gui command /// <summary> /// Creates the Ribbon control /// </summary> public VolumeModelRibbon() { // Initialize the control (standard user control logic) InitializeComponent(); } /// <summary> /// Returns the volume model Ribbon control /// </summary> public object GetRibbonControl() { return VolumeModelRibbonControl; } /// <summary> /// Enabling/disabling actions to be performed while validating the Ribbon items (triggered by Delta Shell logic) /// </summary> public void ValidateItems() { ButtonAddInputDataToVolumeModel.IsEnabled = addInputDataToVolumeModelCommand.Enabled; } /// <summary> /// Whether or not the contextual tab should be visible /// </summary> public bool IsConextualTabVisibleIsContextualTabVisible(string tabGroupName, string tabName) { return false; } /// <summary> /// The (gui) commands of the Ribbon control /// </summary> public IEnumerable<ICommand> Commands { get { yield return addInputDataToVolumeModelCommand; } } /// <summary> /// Actions to be performed after clicking the AddInputDataToVolumeModel button /// </summary> private void ButtonAddInputDataToVolumeModel_OnClick(object sender, RoutedEventArgs e) { addInputDataToVolumeModelCommand.Execute(); } } } |
Info |
---|
The Ribbon control is derived from the IRibbonCommandHandler interface so that it can be registered in the gui plugin. The comments in the code should explain the different parts of the Ribbon control implementation. |
...