Files
radzen-blazor/Radzen.Blazor/Spreadsheet/DeleteChartCommand.cs
Atanas Korchev ce0eae2037 Add RadzenSpreadsheet feature toggles, async command pipeline and custom ribbon
ReadOnly, ShowToolbar, ShowFormulaBar, ShowSheetTabs, and 15 Allow* parameters
gate workbook mutations and grey out the matching tools. Each ICommand declares
its SpreadsheetFeature so ExecuteAsync routes through one chokepoint.

Execute is now async (Task<bool>) so CommandExecuting handlers can await before
calling PreventDefault to veto a command. Tool bindings move from setter-style
dispatch to Value=/ValueChanged= async methods.

ChildContent replaces the built-in ribbon; the host cascades the active
Worksheet so tools in custom content don't need to track sheet-tab changes.
TableDesignTab is a new public component for the contextual tab.

Tests: 76 new (parameter rendering, ExecuteAsync gating per Allow* flag,
CommandExecuting + PreventDefault, ICommand.Feature mapping, ChildContent).
Also fixes two pre-existing SheetViewTests that hardcoded the old 24px row
default after it changed to 22px in 2e79dd7d.
2026-06-15 18:45:14 +03:00

34 lines
728 B
C#

using Radzen.Documents.Spreadsheet;
namespace Radzen.Blazor.Spreadsheet;
/// <summary>
/// Command to delete a chart from a sheet.
/// </summary>
public class DeleteChartCommand(Worksheet sheet, SheetChart chart) : ICommand
{
/// <inheritdoc/>
public SpreadsheetFeature? Feature => SpreadsheetFeature.Charts;
private readonly Worksheet sheet = sheet;
private readonly SheetChart chart = chart;
/// <inheritdoc/>
public bool Execute()
{
sheet.RemoveChart(chart);
if (sheet.SelectedChart == chart)
{
sheet.SelectedChart = null;
}
return true;
}
/// <inheritdoc/>
public void Unexecute()
{
sheet.AddChart(chart);
}
}