using FastReport.Design; using FastReport.DevComponents.DotNetBar; using FastReport.Utils; using System.ComponentModel; namespace FastReport.Controls { /// /// Base class for all toolbars. /// [ToolboxItem(false)] public class ToolbarBase : Bar { #region Properties /// /// Gets the report designer. /// public Designer Designer { get; } private bool _fixed; /// /// Gets or sets a value that determines whether the toolbar is fixed, i.e. can't float. /// public bool Fixed { get => _fixed; set { _fixed = value; if (_fixed) { GrabHandleStyle = eGrabHandleStyle.None; RoundCorners = false; } else { GrabHandleStyle = eGrabHandleStyle.Office2003; RoundCorners = true; } } } internal CustomizeItem CustomizeItem { get; } #endregion #region Public Methods /// /// Updates UI style of the toolbar. /// public virtual void UpdateUIStyle() { Style = UIStyleUtils.GetDotNetBarStyle(Designer.UIStyle); } /// /// Updates layout on dpi change. /// public new virtual void UpdateDpiDependencies() { SuspendLayout(); Font = Designer.LogicalToDevice(DrawUtils.DefaultFont); base.UpdateDpiDependencies(); foreach (BaseItem item in Items) { 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); } } ResumeLayout(); } internal void SetItemText(BaseItem item, string text) { item.Tooltip = text; item.Text = text; } /// /// Adds items to this toolbar. /// /// Items to add. public void AddItems(params IToolbarItem[] items) { foreach (var item in items) { Items.Add(item as BaseItem); } if (!Fixed) Items.Add(CustomizeItem); } #endregion /// /// Initializes a new instance of the class with default settings. /// /// The report designer. public ToolbarBase(Designer designer) : base() { Designer = designer; GrabHandleStyle = eGrabHandleStyle.Office2003; CustomizeItem = new CustomizeItem(); CustomizeItem.CustomizeItemVisible = false; } } }