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 { /// /// Represents the designer's statusbar. /// [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 /// public string PluginName { get { return Name; } } /// public void SaveState() { } /// public void ReinitDpiSize() { } /// public void RestoreState() { } /// public void SelectionChanged() { UpdateContent(); } /// public void UpdateContent() { UpdateZoom(); } /// public void Lock() { } /// public void Unlock() { UpdateContent(); } /// public void Localize() { UpdateContent(); } /// public DesignerOptionsPage GetOptionsPage() { return null; } /// 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; } /// 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 /// /// Updates the information about location and size. /// /// The location. /// The size. /// The location of right bottom angle. 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; } /// /// Updates the name and text information. /// /// The text. 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 /// /// Initializes a new instance of the class with default settings. /// /// The report designer. 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(); } } }