Quick access toolbar in the Blazor Image Editor Component
19 Jul 20232 minutes to read
The quick access toolbars in the Blazor Image Editor play a vital role in facilitating interactions with annotations like Rectangle, Ellipse, Line, Arrow, and Path. These toolbars offer a diverse array of tools and options that can be tailored to match the specific requirements and preferences associated with each annotation type. The toolbar is only displayed when an annotation is selected, ensuring a focused and contextual user experience. Users have the flexibility to add or remove items from the toolbar, allowing them to create a personalized set of tools. Additionally, users can also build a completely custom toolbar from the ground up, providing them with complete control over the available options and functionality.
Add a custom toolbar item
The quick access toolbar that appears when inserting annotations in the Blazor Image Editor component is customizable using the QuickAccessToolbarOpening
event. This event is triggered when the quick access toolbar is opened, allowing you to modify its contents. To add additional toolbar items to the quick access toolbar, you can access the ToolbarItems property of the QuickAccessToolbarEventArgs
object within the event handler. By adding or removing items from the ToolbarItems property based on the Item property, you can customize the options available in the quick access toolbar according to your needs. This gives you the ability to extend the functionality of the quick access toolbar and provide additional tools and options for working with inserted annotations.
Here is an example of adding the custom toolbar item to the quick access toolbar.
@using Syncfusion.Blazor.ImageEditor
@using Syncfusion.Blazor.Navigations
<SfImageEditor @ref="ImageEditor" Toolbar="customToolbarItem" Height="400">
<ImageEditorEvents Created="OpenAsync" QuickAccessToolbarOpening="QuickAccessToolbarOpening"></ImageEditorEvents>
</SfImageEditor>
@code {
SfImageEditor ImageEditor;
private List<ImageEditorToolbarItemModel> customToolbarItem = new List<ImageEditorToolbarItemModel>()
{
new ImageEditorToolbarItemModel { Name = "Annotation" },
new ImageEditorToolbarItemModel { Name = "Confirm" },
new ImageEditorToolbarItemModel { Name = "Reset" }
};
private async void OpenAsync()
{
await ImageEditor.OpenAsync("nature.png");
}
private void QuickAccessToolbarOpening(QuickAccessToolbarEventArgs args)
{
args.ToolbarItems = new List<ImageEditorToolbarItemModel>() { new ImageEditorToolbarItemModel { Name = "Clone" } };
}
}