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
{
///
/// Not relevant to this class.
///
public Font Font { get; set; }
///
/// Updates dropdown images on dpi change.
///
/// The designer.
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);
}
}
}
///
/// Adds items to the dropdown menu.
///
/// Items to add.
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)
{
}
}
}