123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- using FastReport.Design;
- using FastReport.DevComponents.DotNetBar;
- using FastReport.DevComponents.DotNetBar.Controls;
- using FastReport.Utils;
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace FastReport.Controls
- {
- public interface IToolbarItem
- {
- bool BeginGroup { get; set; }
- }
- public class ToolbarButton : ButtonItem, IToolbarItem
- {
- public bool CheckOnClick { get => AutoCheckOnClick; set => AutoCheckOnClick = value; }
- public string ToolTipText { get => Tooltip; set => Tooltip = value; }
- public ToolbarButton(string name, int imageIndex, EventHandler click)
- {
- Name = name;
- ImageIndex = imageIndex;
- Click += click;
- }
- }
- public class ToolbarDropDownButton : ButtonItem, IToolbarItem
- {
- /// <summary>
- /// Not relevant to this class.
- /// </summary>
- public Font Font { get; set; }
- /// <summary>
- /// Updates dropdown images on dpi change.
- /// </summary>
- /// <param name="designer">The designer.</param>
- public void UpdateDpiDependencies(Designer designer)
- {
- foreach (BaseItem item in SubItems)
- {
- ButtonItem b = item as ButtonItem;
- if (b != null && b.ImageIndex != -1)
- {
- // looks like this is the only way to completely refresh the image displayed (including disabled images).
- b.Image = designer.GetImage(b.ImageIndex);
- }
- }
- }
- /// <summary>
- /// Adds items to the dropdown menu.
- /// </summary>
- /// <param name="items">Items to add.</param>
- public void AddDropDownItems(params IToolbarItem[] items)
- {
- foreach (var item in items)
- {
- SubItems.Add(item as BaseItem);
- }
- }
- public ToolbarDropDownButton(string name, int imageIndex, EventHandler dropDownOpening)
- {
- Name = name;
- AutoExpandOnClick = true;
- ImageIndex = imageIndex;
- PopupOpen += (s, e) => dropDownOpening?.Invoke(this, EventArgs.Empty);
- }
- }
- internal class ToolbarColorButton : ColorButtonItem, IToolbarItem
- {
- public event EventHandler ButtonClick;
- public ToolbarColorButton(string name, int imageIndex, Color color, EventHandler click) : base(imageIndex, color)
- {
- Name = name;
- Click += click;
- }
- }
- internal class ToolbarLineWidthButton : LineWidthButtonItem, IToolbarItem
- {
- public ToolbarLineWidthButton(Control control, string name, int imageIndex, EventHandler widthSelected) : base()
- {
- Name = name;
- ImageIndex = imageIndex;
- WidthSelected += widthSelected;
- }
- }
- internal class ToolbarLineStyleButton : LineStyleButtonItem, IToolbarItem
- {
- public ToolbarLineStyleButton(Control control, string name, int imageIndex, EventHandler styleSelected) : base()
- {
- Name = name;
- ImageIndex = imageIndex;
- StyleSelected += styleSelected;
- }
- }
- internal class ToolbarOpenButton : OpenButtonItem, IToolbarItem
- {
- public ToolbarOpenButton(Designer designer, string name, int imageIndex) : base(designer)
- {
- Name = name;
- ImageIndex = imageIndex;
- }
- }
- internal class ToolbarUndoButton : UndoButtonItem, IToolbarItem
- {
- public ToolbarUndoButton(Designer designer, string name, int imageIndex) : base(designer)
- {
- Name = name;
- ImageIndex = imageIndex;
- }
- }
- internal class ToolbarRedoButton : RedoButtonItem, IToolbarItem
- {
- public ToolbarRedoButton(Designer designer, string name, int imageIndex) : base(designer)
- {
- Name = name;
- ImageIndex = imageIndex;
- }
- }
- internal class ToolbarStyleComboBox : StyleComboBoxItem, IToolbarItem
- {
- public int Width { get => ComboWidth; set => ComboWidth = value; }
- public ToolbarStyleComboBox(string name, EventHandler styleSelected)
- {
- Name = name;
- StyleSelected += styleSelected;
- }
- }
- internal class ToolbarFontComboBox : FontComboBoxItem, IToolbarItem
- {
- public int Width { get => ComboWidth; set => ComboWidth = value; }
- public ToolbarFontComboBox(string name, EventHandler fontSelected)
- {
- Name = name;
- FontSelected += fontSelected;
- }
- }
- internal class ToolbarFontSizeComboBox : FontSizeComboBoxItem, IToolbarItem
- {
- public int Width { get => ComboWidth; set => ComboWidth = value; }
- public ToolbarFontSizeComboBox(string name, EventHandler sizeSelected)
- {
- Name = name;
- SizeSelected += sizeSelected;
- }
- }
- internal class ToolbarTextAngleButton : TextAngleButtonItem, IToolbarItem
- {
- public ToolbarTextAngleButton(Designer designer, Control owner, string name, int imageIndex, EventHandler angleSelected) : base()
- {
- Name = name;
- ImageIndex = imageIndex;
- AngleChanged += angleSelected;
- }
- }
- internal class StyledComboBox : ComboBoxEx
- {
- public void SetStyle(UIStyle style)
- {
- Style = UIStyleUtils.GetDotNetBarStyle(style);
- }
- public StyledComboBox()
- {
- DisableInternalDrawing = true;
- }
- }
- internal class StyledListView : ListViewEx
- {
- public void SetStyle(UIStyle style)
- {
- }
- }
- }
|