57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
|
using ShabComponentsLibrary.OfficePackage.HelperEnums;
|
|||
|
using ShabComponentsLibrary.OfficePackage.HelperModels;
|
|||
|
using ShabComponentsLibrary.OfficePackage;
|
|||
|
using System.ComponentModel;
|
|||
|
using ShabComponentsLibrary.Enums;
|
|||
|
|
|||
|
namespace ShabComponentsLibrary
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Невизуальный компонент для создания документа с гистограммой
|
|||
|
/// </summary>
|
|||
|
public partial class ShabDiagramComponent : Component
|
|||
|
{
|
|||
|
public ShabDiagramComponent()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
public ShabDiagramComponent(IContainer Container)
|
|||
|
{
|
|||
|
Container.Add(this);
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
public void CreateDocument(string Filename, string Title, string ChartTitle, LegendPosition LegendPosition,
|
|||
|
Dictionary<string, int[]> Data)
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(Filename))
|
|||
|
throw new ArgumentException("Filename cannot be empty");
|
|||
|
if (string.IsNullOrEmpty(Title))
|
|||
|
throw new ArgumentException("Title cannot be empty");
|
|||
|
if (string.IsNullOrEmpty(ChartTitle))
|
|||
|
throw new ArgumentException("Chart title cannot be empty");
|
|||
|
if (Data.Count == 0)
|
|||
|
throw new ArgumentException("Data cannot be empty");
|
|||
|
|
|||
|
SaveToPdf Pdf = new SaveToPdf();
|
|||
|
Pdf.CreatePdf();
|
|||
|
Pdf.CreateParagraph(new PdfParagraph
|
|||
|
{
|
|||
|
Text = Title,
|
|||
|
Style = "NormalTitle",
|
|||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
|||
|
});
|
|||
|
|
|||
|
Pdf.CreateChart(new PdfChartParameters
|
|||
|
{
|
|||
|
Data = Data,
|
|||
|
Title = ChartTitle,
|
|||
|
LegendPosition = LegendPosition,
|
|||
|
});
|
|||
|
|
|||
|
Pdf.SavePdf(Filename);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|