123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- using System;
- using System.Windows.Forms;
- using System.ComponentModel;
- using FastReport.Forms;
- using FastReport.Utils;
- using FastReport.DevComponents.DotNetBar;
- using FastReport.Design.PageDesigners.Page;
- using System.Drawing;
- namespace FastReport.Design.StandardDesigner
- {
- /// <summary>
- /// Represents the designer's statusbar.
- /// </summary>
- [ToolboxItem(false)]
- public class DesignerStatusBar : Bar, IDesignerPlugin
- {
- #region Fields
- private Designer designer;
- private LabelItem lblLocation;
- private LabelItem lbllocationRightBot;
- private LabelItem lblSize;
- private LabelItem lblText;
- private ItemContainer pnZoom;
- private ItemContainer pnZoomButtons;
- private ButtonItem btnZoomPageWidth;
- private ButtonItem btnZoomWholePage;
- private ButtonItem btnZoom100;
- private SliderItem slZoom;
- private bool updatingZoom;
- private Timer zoomTimer;
- private float zoomToUpdate;
- #endregion
- #region Properties
- private Designer Designer
- {
- get { return designer; }
- }
- #endregion
- #region Private Methods
- private void UpdateZoom()
- {
- updatingZoom = true;
- int zoom = (int)(Designer.Zoom * 100);
- slZoom.Text = zoom.ToString() + "%";
- if (zoom < 100)
- zoom = (int)Math.Round((zoom - 25) / 0.75f);
- else if (zoom > 100)
- zoom = (zoom - 100) / 4 + 100;
- slZoom.Value = 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 slZoom_ValueChanged(object sender, EventArgs e)
- {
- if (updatingZoom)
- return;
- int val = slZoom.Value;
- if (val < 100)
- val = (int)Math.Round(val * 0.75f) + 25;
- else
- val = (val - 100) * 4 + 100;
- slZoom.Text = val.ToString() + "%";
- zoomToUpdate = val / 100f;
- zoomTimer.Start();
- }
- private void FZoomTimer_Tick(object sender, EventArgs e)
- {
- zoomTimer.Stop();
- Designer.Zoom = zoomToUpdate;
- }
- #endregion
- #region IDesignerPlugin
- /// <inheritdoc/>
- public string PluginName
- {
- get { return Name; }
- }
- /// <inheritdoc/>
- public void SaveState()
- {
- }
- /// <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()
- {
- Style = UIStyleUtils.GetDotNetBarStyle(Designer.UIStyle);
- }
- /// <inheritdoc/>
- public new void UpdateDpiDependencies()
- {
- base.UpdateDpiDependencies();
- Font = Designer.Font;
- lblLocation.Image = Designer.GetImage(62);
- Image image = (Image)Designer.GetImage(62).Clone();
- image.RotateFlip(RotateFlipType.Rotate180FlipNone);
- lbllocationRightBot.Image = image;
- lblSize.Image = Designer.GetImage(63);
- btnZoomPageWidth.Image = Designer.GetImage(235);
- btnZoomWholePage.Image = Designer.GetImage(236);
- btnZoom100.Image = Designer.GetImage(237);
- lblLocation.Width = this.LogicalToDevice(120);
- lbllocationRightBot.Width = this.LogicalToDevice(120);
- lblSize.Width = this.LogicalToDevice(120);
- slZoom.UpdateDpiDependencies();
- }
- #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>
- 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 = designer.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";
- this.designer = designer;
- BarType = eBarType.StatusBar;
- GrabHandleStyle = eGrabHandleStyle.ResizeHandle;
- PaddingBottom = 2;
- PaddingTop = 3;
- //Style = FastReport.DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
- lblLocation = new LabelItem();
- lblLocation.Width = 160;
- lblLocation.Height = 19;
- lbllocationRightBot = new LabelItem();
- lbllocationRightBot.Width = 160;
- lbllocationRightBot.Height = 19;
- lblSize = new LabelItem();
- lblSize.Width = 160;
- lblSize.Height = 19;
- lblText = new LabelItem();
- lblText.Height = 19;
- lblText.Stretch = true;
- lblText.EnableMarkup = false;
- pnZoom = new ItemContainer();
- pnZoom.BackgroundStyle.Class = "Office2007StatusBarBackground2";
- pnZoomButtons = new ItemContainer();
- pnZoomButtons.BeginGroup = true;
- pnZoomButtons.VerticalItemAlignment = eVerticalItemsAlignment.Middle;
- btnZoomPageWidth = new ButtonItem();
- btnZoomPageWidth.Click += btnZoomPageWidth_Click;
- btnZoomWholePage = new ButtonItem();
- btnZoomWholePage.Click += btnZoomWholePage_Click;
- btnZoom100 = new ButtonItem();
- btnZoom100.Click += btnZoom100_Click;
- pnZoomButtons.SubItems.AddRange(new BaseItem[] { btnZoomPageWidth, btnZoomWholePage, btnZoom100 });
- slZoom = new SliderItem();
- slZoom.Maximum = 200;
- slZoom.Step = 5;
- slZoom.Text = "100%";
- slZoom.Value = 100;
- slZoom.Width = 120;
- slZoom.ValueChanged += slZoom_ValueChanged;
- pnZoom.SubItems.AddRange(new BaseItem[] { pnZoomButtons, slZoom });
- Items.AddRange(new BaseItem[] { lblLocation, lbllocationRightBot, lblSize, lblText, pnZoom });
- Dock = DockStyle.Bottom;
- this.designer.Controls.Add(this);
- zoomTimer = new Timer();
- zoomTimer.Interval = 50;
- zoomTimer.Tick += FZoomTimer_Tick;
- }
- }
- }
|