using FastReport.Design.PageDesigners.Dialog;
using FastReport.Utils;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace FastReport.Design.RibbonDesigner
{
///
/// Represents the Ribbon report designer.
///
///
/// This control extends the control with
/// standard menu, status bar, and Ribbon.
///
[ToolboxItem(true), ToolboxBitmap(typeof(Report), "Resources.DesignerControl.bmp")]
public partial class DesignerControl : Designer
{
#region Fields
private StandardDesigner.DesignerMenu mainMenu;
private StandardDesigner.DesignerStatusBar statusBar;
private Ribbon ribbon;
private Panel ribbonPanel;
private bool showMainMenu;
private bool showStatusBar;
#endregion
#region Properties
///
/// Gets the main menu.
///
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public StandardDesigner.DesignerMenu MainMenu
{
get { return mainMenu; }
}
///
/// Gets or sets a value indicating whether the main menu should be displayed or not.
///
[SRCategory("Toolbars")]
[DefaultValue(true)]
public bool ShowMainMenu
{
get { return showMainMenu; }
set
{
showMainMenu = value;
mainMenu.Visible = value;
}
}
///
/// Gets or sets a value indicating whether the status bar should be displayed or not.
///
[SRCategory("Toolbars")]
[DefaultValue(true)]
public bool ShowStatusBar
{
get { return showStatusBar; }
set
{
showStatusBar = value;
statusBar.Visible = value;
}
}
#endregion
#region Private Methods
private void ribbonPanel_Paint(object sender, PaintEventArgs e)
{
var ct = UIStyleUtils.GetColorTable(UIStyle);
Rectangle rect = new Rectangle(0, 0, ribbonPanel.Width, ribbonPanel.Height);
using (var brush = new LinearGradientBrush(rect, ct.Ribbon.GradientBegin, ct.Ribbon.GradientEnd, LinearGradientMode.Vertical))
e.Graphics.FillRectangle(brush, rect);
}
#endregion
#region Protected Methods
///
protected override void InitPlugins()
{
base.InitPlugins();
ribbonPanel = new Panel();
ribbonPanel.Dock = DockStyle.Top;
ribbonPanel.Paint += ribbonPanel_Paint;
Controls.Add(ribbonPanel);
var shadow = ribbonPanel.SetShadow(DockStyle.Bottom);
UIStyleChanged += (s,e) => shadow.Color = UIStyleUtils.GetColorTable(UIStyle).Ribbon.BorderColor;
mainMenu = new StandardDesigner.DesignerMenu(this);
statusBar = new StandardDesigner.DesignerStatusBar(this);
ribbon = new Ribbon(this);
ribbon.AddQuickAccessControls(mainMenu);
ribbonPanel.Controls.Add(ribbon);
Plugins.AddRange(new IDesignerPlugin[] {
mainMenu, statusBar });
}
#endregion
#region Public Methods
///
public override void ShowStatus(string location, string size, string text, string locationRightBot)
{
statusBar.UpdateLocationAndSize(location, size, locationRightBot);
statusBar.UpdateText(text);
}
///
public override void UpdateUIStyle()
{
base.UpdateUIStyle();
ribbon.UpdateUIStyle(UIStyle);
ribbonPanel.Refresh();
}
///
public override void UpdateDpiDependencies(object sender)
{
base.UpdateDpiDependencies(sender);
ribbonPanel.Height = this.LogicalToDevice(90);
}
internal void UpdateFirstDialogPage()
{
// WPF bug: designer workspace is not initialized if the dialog form is the first page in a report (reason: visible designer form is needed)
if (ActiveReportTab != null && ActiveReportTab.ActivePageDesigner is DialogPageDesigner pd)
pd.UpdateDpiDependencies();
}
#endregion
///
/// Initializes a new instance of the class with default settings.
///
public DesignerControl()
{
ShowMainMenu = true;
ShowStatusBar = true;
}
}
}