123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- 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
- {
- /// <summary>
- /// Represents the Ribbon report designer.
- /// </summary>
- /// <remarks>
- /// This control extends the <see cref="FastReport.Design.Designer"/> control with
- /// standard menu, status bar, and Ribbon.
- /// </remarks>
- [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
- /// <summary>
- /// Gets the main menu.
- /// </summary>
- [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public StandardDesigner.DesignerMenu MainMenu
- {
- get { return mainMenu; }
- }
- /// <summary>
- /// Gets or sets a value indicating whether the main menu should be displayed or not.
- /// </summary>
- [SRCategory("Toolbars")]
- [DefaultValue(true)]
- public bool ShowMainMenu
- {
- get { return showMainMenu; }
- set
- {
- showMainMenu = value;
- mainMenu.Visible = value;
- }
- }
- /// <summary>
- /// Gets or sets a value indicating whether the status bar should be displayed or not.
- /// </summary>
- [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
- /// <inheritdoc/>
- 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
- /// <inheritdoc/>
- public override void ShowStatus(string location, string size, string text, string locationRightBot)
- {
- statusBar.UpdateLocationAndSize(location, size, locationRightBot);
- statusBar.UpdateText(text);
- }
- /// <inheritdoc/>
- public override void UpdateUIStyle()
- {
- base.UpdateUIStyle();
- ribbon.UpdateUIStyle(UIStyle);
- ribbonPanel.Refresh();
- }
- /// <inheritdoc/>
- 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
- /// <summary>
- /// Initializes a new instance of the <see cref="DesignerControl"/> class with default settings.
- /// </summary>
- public DesignerControl()
- {
- ShowMainMenu = true;
- ShowStatusBar = true;
- }
- }
- }
|