123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464 |
- using FastReport.Web.Toolbar;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- namespace FastReport.Web
- {
- public class ToolbarSettings
- {
- public static ToolbarSettings Default => new ToolbarSettings();
- public bool Show { get; set; } = true;
- #if DIALOGS
- public bool ShowOnDialogPage { get; set; } = true;
- #endif
- [Obsolete("Please, use Position")]
- public bool ShowBottomToolbar
- {
- get => Position == Positions.Bottom;
- set
- {
- if (value)
- {
- Position = Positions.Bottom;
- }
- else
- Position = default;
- }
- }
- /// <summary>
- /// ExportMenu settings
- /// </summary>
- public ExportMenuSettings Exports { get; set; } = ExportMenuSettings.Default;
- public bool ShowPrevButton { get; set; } = true;
- public bool ShowNextButton { get; set; } = true;
- public bool ShowFirstButton { get; set; } = true;
- public bool ShowLastButton { get; set; } = true;
- public bool ShowRefreshButton { get; set; } = true;
- public bool ShowZoomButton { get; set; } = true;
- /// <summary>
- /// Show Print menu
- /// </summary>
- public bool ShowPrint { get; set; } = true;
- public bool PrintInHtml { get; set; } = true;
- /// <summary>
- /// If enabled, the toolbar will follow the scrolling of the report.
- /// </summary>
- /// <remarks>
- /// Default value: false
- /// </remarks>
- public bool Sticky { get; set; } = false;
- #if !OPENSOURCE
- public bool PrintInPdf { get; set; } = true;
- #endif
- /// <summary>
- /// Use to change ToolbarColor,
- /// Default value Color.WhiteSmoke
- /// </summary>
- public Color Color { get; set; } = Color.WhiteSmoke;
- /// <summary>
- /// Use to change Toolbar DropDownMenuColor,
- /// Default value Color.White
- /// </summary>
- public Color DropDownMenuColor { get; set; } = Color.White;
- /// <summary>
- /// Use to change Toolbar DropDownMenuText Color,
- /// Default value Color.Black
- /// </summary>
- public Color DropDownMenuTextColor { get; set; } = Color.Black;
- /// <summary>
- /// Use to change Toolbar Position in report,
- /// Default value Position.Top
- /// </summary>
- public Positions Position { get; set; } = Positions.Top;
- /// <summary>
- /// Use to add Roundness to Toolbar,
- /// Default value RoundnessEnum.High
- /// </summary>
- public RoundnessEnum Roundness { get; set; } = RoundnessEnum.High;
- /// <summary>
- /// Use to change content position in Toolbar,
- /// Default value ContentPositions.Center
- /// </summary>
- public ContentPositions ContentPosition { get; set; } = ContentPositions.Center;
- /// <summary>
- /// Use to change Icons color in Toolbar,
- /// Default value IconColors.Black
- /// </summary>
- public IconColors IconColor { get; set; } = IconColors.Black;
- /// <summary>
- /// Use to add Transparency in icon Toolbar,
- /// Default value IconTransparencyEnum.None
- /// </summary>
- public IconTransparencyEnum IconTransperency { get; set; } = IconTransparencyEnum.None;
- /// <summary>
- /// Use to change Font in Toolbar,
- /// Default value null
- /// <para>Example syntax : new Font("Arial", 14 , FontStyle.Bold)</para>
- /// </summary>
- public Font FontSettings { get; set; } = null;
- public int Height { get; set; } = 40;
- internal List<ToolbarElement> Elements { get; set; } = new List<ToolbarElement>();
- /// <summary>
- /// Adds an item to the toolbar
- /// </summary>
- /// <param name="element">Any inheritor of ToolbarElement. Can be a TolbarButton, ToolbarSelect, or ToolbarInput</param>
- public void InsertToolbarElement(ToolbarElement element)
- {
- if (Elements.Any(x => x.Name == element.Name)) return;
- var index = Elements.FindIndex(x => x.Position > element.Position);
- if (index < 0 || element.Position == -1)
- {
- if (Elements.Count != 0)
- element.Position = Elements.Max(x => x.Position) + 1;
- else
- element.Position = 0;
- Elements.Add(element);
- }
- else
- {
- Elements.Insert(index, element);
- }
- }
- internal int ToolbarSlash
- {
- get
- {
- switch (Position)
- {
- case Positions.Left:
- case Positions.Right:
- return 90;
- default:
- return 20;
- }
- }
- }
-
- internal string StickyToolbarTags
- {
- get
- {
- if (Sticky)
- {
- string tags = "position: sticky; position: -webkit-sticky; ";
- if(TopOrBottom == -1)
- {
- if (Position == Positions.Left || Position == Positions.Right)
- {
- if (ContentPosition == ContentPositions.Right)
- tags += "bottom: 10px; left: 10px; right: 10px;";
- else if (ContentPosition == ContentPositions.Center)
- tags += "top: 10px; bottom: 10px; left: 10px; right: 10px;";
- }
- else
- tags += "top: 10px; left: 10px; right: 10px;";
- }
- else
- tags += "bottom: 10px; left: 10px; right: 10px;";
- return tags;
- }
- else
- return "";
- }
- }
- internal string StickyToolbarTabsTags
- {
- get
- {
- if (Sticky)
- {
- int paddingVertical = Height + 10;
- float paddingHorizontal = Height * 1.55f + 10;
- string tags = "position: sticky; position: -webkit-sticky; ";
- if (TopOrBottom == -1)
- {
- if (Position == Positions.Left || Position == Positions.Right)
- {
- if (ContentPosition == ContentPositions.Right)
- tags += $@"bottom: {paddingVertical}px; left: {paddingHorizontal}px; right: {paddingHorizontal}px;";
- else if (ContentPosition == ContentPositions.Center)
- tags += $@"top: {paddingVertical}px; bottom: {paddingVertical}px; left: {paddingHorizontal}px; right: {paddingHorizontal}px;";
- }
- else
- tags += $@"top: {paddingVertical}px; left: 10px; right: 10px;";
- }
- else
- tags += $@"bottom: {paddingVertical}px; left: 10px; right: 10px;";
- return tags;
- }
- else
- return "";
- }
- }
- internal string ModalContainerPosition => Sticky ? "position: fixed;" : "";
- internal string DropDownListPosition => Position == Positions.Bottom ? "bottom: 100%" : "";
- internal string DropDownListBorder => Position == Positions.Bottom ? "12px 12px 0px 0px" : "0px 0px 12px 12px";
- internal int ToolbarNarrow
- {
- get
- {
- switch (Position)
- {
- case Positions.Left:
- case Positions.Right:
- return 90;
- default:
- return 0;
- }
- }
- }
- internal string UserFontSettings
- {
- get
- {
- if (FontSettings != null)
- {
- return FontSettings.Size + "em " + FontSettings.OriginalFontName + " " + FontSettings.Style;
- }
- else
- return "15em Verdana,Arial sans-serif Regular";
- }
- }
-
- internal string VerticalToolbarHeight
- {
- get
- {
- switch (Position)
- {
- case Positions.Left:
- case Positions.Right:
- return "fit-content";
- default:
- return Height.ToString() + "px";
- }
- }
- }
-
- internal int TopOrBottom
- {
- get
- {
- switch (Position)
- {
- case Positions.Bottom:
- return 1;
- default:
- return -1;
- }
- }
- }
- internal string Vertical
- {
- get
- {
- switch (Position)
- {
- case Positions.Right:
- return "row-reverse";
- case Positions.Left:
- return "row";
- default:
- return "column";
- }
- }
- }
- internal int DropDownMenuPositionLeft
- {
- get
- {
- switch (Position)
- {
- case Positions.Left:
- case Positions.Right:
- return Height + 10;
- default:
- return 0;
- }
- }
- }
- internal int DropDownMenuPositionTops
- {
- get
- {
- switch (Position)
- {
- case Positions.Right:
- case Positions.Left:
- return 7;
- default:
- return 0;
- }
- }
- }
- internal string RowOrColumn
- {
- get
- {
- switch (Position)
- {
- case Positions.Left:
- case Positions.Right:
- return "column";
- default:
- return "row";
- }
- }
- }
- internal string Content
- {
- get
- {
- switch (ContentPosition)
- {
- case ContentPositions.Center:
- return "center";
- case ContentPositions.Right:
- return "flex-end";
- case ContentPositions.Left:
- return "flex-start";
- default:
- return "flex-start";
- }
- }
- }
- internal string DropDownMenuPosition
- {
- get
- {
- switch (Position)
- {
- case Positions.Left:
- return "left:" + Height + "px;" + "text-align:left;" + "top:8px;";
- case Positions.Right:
- return "right:" + Height + "px;" + "text-align:right;" + "top:8px;";
- case Positions.Bottom:
- return "bottom:" + Height + "px;";
- default:
- return "top:" + Height + "px;";
- }
- }
- }
- internal string TabsPositionSettings
- {
- get
- {
- switch (Position)
- {
- case Positions.Left:
- return "179px";
- case Positions.Right:
- return "179px";
- case Positions.Bottom:
- return "order:1;";
- default:
- return "auto";
- }
- }
- }
- internal int ToolbarRoundness
- {
- get
- {
- switch (Roundness)
- {
- case RoundnessEnum.High:
- return 10;
- case RoundnessEnum.Medium:
- return 5;
- case RoundnessEnum.Low:
- return 3;
- case RoundnessEnum.None:
- default:
- return 0;
- }
- }
- }
- internal int ColorIcon
- {
- get
- {
- switch (IconColor)
- {
- case IconColors.White:
- return 1;
- default:
- return 0;
- }
- }
- }
- internal string TransparencyIcon
- {
- get
- {
- switch (IconTransperency)
- {
- case IconTransparencyEnum.None:
- return "1";
- case IconTransparencyEnum.Low:
- return "0.9";
- case IconTransparencyEnum.Medium:
- return "0.7";
- case IconTransparencyEnum.Default:
- return "0.5";
- default:
- return "0.5";
- }
- }
- }
-
- }
- public enum IconColors
- {
- White, Black
- }
- public enum IconTransparencyEnum
- {
- Low, Medium, High, Default, None
- }
- public enum Positions
- {
- Top = 0,
- Bottom,
- Right,
- Left,
- }
- public enum ContentPositions
- {
- Left,
- Right,
- Center,
- }
- public enum RoundnessEnum
- {
- Low, Medium, High, None
- }
- }
|