123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- using System;
- using System.Windows.Forms;
- using System.Drawing;
- using System.ComponentModel;
- using FastReport.Forms;
- using FastReport.Utils;
- using FastReport.Controls;
- namespace FastReport.Design.StandardDesigner
- {
- /// <summary>
- /// Represents the designer's statusbar.
- /// </summary>
- [ToolboxItem(false)]
- public class DesignerStatusBar : StatusStrip, IDesignerPlugin
- {
- #region Fields
- private Designer FDesigner;
- private ToolStripStatusLabel lblLocationRightBot;
- private ToolStripStatusLabel lblLocation;
- private ToolStripStatusLabel lblSize;
- private ToolStripStatusLabel lblText;
- private ToolStripZoomControl zoomControl;
- private bool updatingZoom;
- #endregion
- #region Properties
- private Designer Designer
- {
- get { return FDesigner; }
- }
- #endregion
- #region IDesignerPlugin
- /// <inheritdoc/>
- public string PluginName
- {
- get { return Name; }
- }
- /// <inheritdoc/>
- public void SaveState()
- {
- }
- /// <inheritdoc/>
- public void ReinitDpiSize()
- {
- }
- /// <inheritdoc/>
- public void RestoreState()
- {
- }
- /// <inheritdoc/>
- public void SelectionChanged()
- {
- UpdateContent();
- }
- /// <inheritdoc/>
- public void UpdateContent()
- {
- UpdateZoom();
- }
- /// <inheritdoc/>
- public void Lock()
- {
- }
- /// <inheritdoc/>
- public void Unlock()
- {
- UpdateContent();
- }
- /// <inheritdoc/>
- public void Localize()
- {
- UpdateContent();
- }
- /// <inheritdoc/>
- public DesignerOptionsPage GetOptionsPage()
- {
- return null;
- }
- /// <inheritdoc/>
- public void UpdateUIStyle()
- {
- Renderer = UIStyleUtils.GetToolStripRenderer(Designer.UIStyle);
- zoomControl.UIStyle = Designer.UIStyle;
- }
- private Image Rotate180(Image original)
- {
- var bitmap = new Bitmap(original.Width, original.Height);
- using (var g = Graphics.FromImage(bitmap))
- {
- g.TranslateTransform(bitmap.Width / 2, bitmap.Height / 2);
- g.RotateTransform(180);
- g.DrawImage(original, -bitmap.Width / 2, -bitmap.Height / 2);
- }
- return bitmap;
- }
- /// <inheritdoc/>
- public void UpdateDpiDependencies()
- {
- Font = Designer.LogicalToDevice(DrawUtils.DefaultFont);
- Height = Designer.LogicalToDevice(26);
- Padding = new Padding(6, 0, 0, 0);
- lblLocation.Size = Designer.LogicalToDevice(new Size(140, 26));
- lblLocationRightBot.Size = lblLocation.Size;
- lblSize.Size = lblLocation.Size;
- lblLocation.Image = Designer.GetImage(62);
- lblLocationRightBot.Image = Rotate180(Designer.GetImage(62));
- lblSize.Image = Designer.GetImage(63);
- zoomControl.Size = Designer.LogicalToDevice(new Size(280, 26));
- }
- #endregion
- #region Private Methods
- private void UpdateZoom()
- {
- updatingZoom = true;
- zoomControl.ZoomValue = Designer.Zoom;
- updatingZoom = false;
- }
- private void btnZoomPageWidth_Click(object sender, EventArgs e)
- {
- Designer.ZoomPageWidth();
- }
- private void btnZoomWholePage_Click(object sender, EventArgs e)
- {
- Designer.ZoomWholePage();
- }
- private void btnZoom100_Click(object sender, EventArgs e)
- {
- Designer.Zoom = 1;
- }
- private void slider_ValueChanged(object sender, EventArgs e)
- {
- if (updatingZoom)
- return;
- Designer.Zoom = zoomControl.ZoomValue;
- }
- #endregion
- #region Public Methods
- /// <summary>
- /// Updates the information about location and size.
- /// </summary>
- /// <param name="location">The location.</param>
- /// <param name="size">The size.</param>
- /// <param name="locationRightBot">The location of right bottom angle.</param>
- public void UpdateLocationAndSize(string location, string size, string locationRightBot)
- {
- lblLocation.Visible = !String.IsNullOrEmpty(location);
- lblLocation.Text = location;
- lblSize.Visible = !String.IsNullOrEmpty(size);
- lblSize.Text = size;
- lblLocationRightBot.Visible = !String.IsNullOrEmpty(locationRightBot);
- lblLocationRightBot.Text = locationRightBot;
- }
- /// <summary>
- /// Updates the name and text information.
- /// </summary>
- /// <param name="s">The text.</param>
- public void UpdateText(string s)
- {
- SelectedObjectCollection selection = FDesigner.SelectedObjects;
- string text = selection.Count == 0 ? "" : selection.Count > 1 ?
- String.Format(Res.Get("Designer,ToolWindow,Properties,NObjectsSelected"), selection.Count) :
- selection[0].Name;
- if (!String.IsNullOrEmpty(s))
- text += ": " + s.Replace('\r', ' ').Replace('\n', ' ');
- lblText.Text = text;
- }
- #endregion
- /// <summary>
- /// Initializes a new instance of the <see cref="DesignerStatusBar"/> class with default settings.
- /// </summary>
- /// <param name="designer">The report designer.</param>
- public DesignerStatusBar(Designer designer) : base()
- {
- Name = "StatusBar";
- FDesigner = designer;
- AutoSize = false;
- SizingGrip = false;
- lblLocation = new ToolStripStatusLabel();
- lblLocation.AutoSize = false;
- lblLocation.TextAlign = ContentAlignment.MiddleLeft;
- lblLocation.ImageAlign = ContentAlignment.MiddleLeft;
- lblLocationRightBot = new ToolStripStatusLabel();
- lblLocationRightBot.AutoSize = false;
- lblLocationRightBot.TextAlign = ContentAlignment.MiddleLeft;
- lblLocationRightBot.ImageAlign = ContentAlignment.MiddleLeft;
- lblSize = new ToolStripStatusLabel();
- lblSize.AutoSize = false;
- lblSize.TextAlign = ContentAlignment.MiddleLeft;
- lblSize.ImageAlign = ContentAlignment.MiddleLeft;
- lblText = new ToolStripStatusLabel();
- lblText.Spring = true;
- lblText.TextAlign = ContentAlignment.MiddleLeft;
- zoomControl = new ToolStripZoomControl();
- zoomControl.ZoomPageWidthClick += btnZoomPageWidth_Click;
- zoomControl.ZoomWholePageClick += btnZoomWholePage_Click;
- zoomControl.Zoom100Click += btnZoom100_Click;
- zoomControl.ValueChanged += slider_ValueChanged;
- Items.AddRange(new ToolStripItem[] { lblLocation, lblLocationRightBot, lblSize, lblText, zoomControl });
- Dock = DockStyle.Bottom;
- FDesigner.Controls.Add(this);
- UpdateDpiDependencies();
- }
- }
- }
|