123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- using System.Threading.Tasks;
- using System.Linq;
- using FastReport.Web.Application;
- using System.Drawing;
- namespace FastReport.Web
- {
- public partial class WebReport
- {
- private int numberNextTab = 1;
- private int currentTabIndex;
- #region Public Properties
- /// <summary>
- /// Active report tab
- /// </summary>
- public ReportTab CurrentTab
- {
- get => Tabs[CurrentTabIndex];
- set => Tabs[CurrentTabIndex] = value;
- }
- /// <summary>
- /// Active tab index
- /// </summary>
- public int CurrentTabIndex
- {
- get
- {
- if (currentTabIndex >= Tabs.Count)
- currentTabIndex = Tabs.Count - 1;
- if (currentTabIndex < 0)
- currentTabIndex = 0;
- return currentTabIndex;
- }
- set => currentTabIndex = value;
- }
- /// <summary>
- /// Shows different ReportPage in tabs.
- /// Default value: false.
- /// </summary>
- public bool SplitReportPagesInTabs { get; set; } = false;
- /// <summary>
- /// List of report tabs
- /// </summary>
- public ReportTabCollection Tabs { get; } = new ReportTabCollection() { new ReportTab() { Report = new Report(), Closeable = false } };
- // for Tabs max-width
- internal int ReportMaxWidth { get; set; } = 800;
- #endregion
- /// <summary>
- /// Add report pages in tabs after load report
- /// </summary>
- internal void SplitReportPagesByTabs()
- {
- if (SplitReportPagesInTabs)
- {
- var report = Report;
-
- for (int pageN = 0; pageN < report.Pages.Count; pageN++)
- {
- var page = report.Pages[pageN];
- if (page is ReportPage reportPage)
- {
- if (pageN == 0)
- {
- Tabs[0].Name = reportPage.Name;
- Tabs[0].MinPageIndex = 0;
-
- continue;
- }
-
- if (!reportPage.Visible)
- continue;
- int numberPage = 0;
- for (int i = 0; i < report.PreparedPages.Count; i++)
- {
- var preparedPage = report.PreparedPages.GetPage(i);
- if (preparedPage.OriginalComponent.Name == reportPage.Name)
- {
- numberPage = i;
- break;
- }
- }
-
- Tabs.Add(new ReportTab()
- {
- Closeable = false,
- CurrentPageIndex = numberPage,
- MinPageIndex = numberPage,
- Name = reportPage.Name,
- NeedParent = false,
- Report = report//,
- });
- }
- }
- }
- }
- internal string GetCurrentTabName()
- {
- if (SplitReportPagesInTabs)
- return Report.GetReportName;
- return GetTabName(CurrentTabIndex);
- }
- internal string GetTabName(int i)
- {
- if (String.IsNullOrEmpty(Tabs[i].Name))
- {
- string s = Tabs[i].Report.ReportInfo.Name;
- if (String.IsNullOrEmpty(s))
- s = Path.GetFileNameWithoutExtension(Tabs[i].Report.FileName);
- if (String.IsNullOrEmpty(s))
- s = (i + 1).ToString();
- return s;
- }
- else
- return Tabs[i].Name;
- }
- #region Navigation
- internal void SetTab(int value)
- {
- CurrentTabIndex = value;
- if (CurrentTabIndex < Tabs.Count - 1)
- numberNextTab = value + 1;
- else
- numberNextTab = value;
- //CurrentPageIndex = CurrentTab.MinPageIndex;
- }
- #endregion
- }
- }
|