using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using FastReport.Design;
using FastReport.Utils;
namespace FastReport
{
///
/// This class represents the context menu of the .
///
///
/// This class adds the "Can Break" menu item to the component context menu.
///
[ToolboxItem(false)]
public class BreakableComponentMenu : ReportComponentBaseMenu
{
private SelectedObjectCollection selection;
///
/// The "Can Break" menu item.
///
public ContextMenuItem miCanBreak;
private void miCanBreak_Click(object sender, EventArgs e)
{
foreach (Base c in selection)
{
if (c is BreakableComponent && !c.HasRestriction(Restrictions.DontModify))
(c as BreakableComponent).CanBreak = miCanBreak.Checked;
}
Change();
}
///
/// Initializes a new instance of the BreakableComponentMenu class with default settings.
///
public BreakableComponentMenu(Designer designer) : base(designer)
{
selection = Designer.SelectedObjects;
miCanBreak = CreateMenuItem(Res.Get("ComponentMenu,BreakableComponent,CanBreak"), new EventHandler(miCanBreak_Click));
miCanBreak.CheckOnClick = true;
int insertPos = Items.IndexOf(miCanShrink);
Items.Insert(insertPos + 1, miCanBreak);
if (selection[0] is BreakableComponent)
{
BreakableComponent component = selection[0] as BreakableComponent;
miCanBreak.Enabled = !component.HasRestriction(Restrictions.DontModify);
miCanBreak.Checked = component.CanBreak;
}
}
}
}