123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Windows.Forms;
- using System.ComponentModel;
- using FastReport.Design;
- using FastReport.Utils;
- namespace FastReport
- {
- /// <summary>
- /// This class represents the context menu of the <see cref="BreakableComponent"/>.
- /// </summary>
- /// <remarks>
- /// This class adds the "Can Break" menu item to the component context menu.
- /// </remarks>
- [ToolboxItem(false)]
- public class BreakableComponentMenu : ReportComponentBaseMenu
- {
- private SelectedObjectCollection selection;
- /// <summary>
- /// The "Can Break" menu item.
- /// </summary>
- 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();
- }
- /// <summary>
- /// Initializes a new instance of the <b>BreakableComponentMenu</b> class with default settings.
- /// </summary>
- 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;
- }
- }
- }
- }
|