Третий компонент вроде работает
This commit is contained in:
parent
1cbc55bbe9
commit
e43bb439a2
36
CheckedListBoxLibrary/Components/PdfDiagram/PdfDiagram.Designer.cs
generated
Normal file
36
CheckedListBoxLibrary/Components/PdfDiagram/PdfDiagram.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace MyUserControls.Components.PdfDiagram
|
||||
{
|
||||
partial class PdfDiagram
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
46
CheckedListBoxLibrary/Components/PdfDiagram/PdfDiagram.cs
Normal file
46
CheckedListBoxLibrary/Components/PdfDiagram/PdfDiagram.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using MyUserControls.Components.office_package.HelperEnums;
|
||||
using MyUserControls.Components.office_package.HelperModels;
|
||||
using MyUserControls.Components.office_package.Implements;
|
||||
using MyUserControls.Components.office_package;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MyUserControls.Components.PdfDiagram
|
||||
{
|
||||
public partial class PdfDiagram : Component
|
||||
{
|
||||
ISaveToPdf SaveToPdf = new SaveToPdf();
|
||||
|
||||
public PdfDiagram()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public PdfDiagram(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateDiagram(PdfDiagramInfo info)
|
||||
{
|
||||
info.CheckFields();
|
||||
SaveToPdf.CreatePdf(info);
|
||||
SaveToPdf.CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = info.Title,
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
SaveToPdf.CreatePieChart(info);
|
||||
SaveToPdf.SavePdf(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
using MyUserControls.Components.office_package.HelperEnums;
|
||||
using MyUserControls.Components.office_package.HelperModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MyUserControls.Components.PdfDiagram
|
||||
{
|
||||
public class PdfDiagramInfo : IPdfInfo, IPdfPieChartParameters
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string ChartTitle { get; set; } = string.Empty;
|
||||
public PdfDiagramLegendLocation LegendLocation { get; set; } = PdfDiagramLegendLocation.Right;
|
||||
public PdfDiagramSeries Series { get; set; } = new();
|
||||
|
||||
public void CheckFields()
|
||||
{
|
||||
if (string.IsNullOrEmpty(FileName))
|
||||
throw new ArgumentNullException(nameof(FileName), "File path and name cannot be null or empty.");
|
||||
if (string.IsNullOrEmpty(Title))
|
||||
throw new ArgumentNullException(nameof(Title), "Title cannot be null or empty.");
|
||||
if (Series == null)
|
||||
throw new ArgumentNullException(nameof(Series), "Series cannot be null or empty.");
|
||||
}
|
||||
}
|
||||
}
|
@ -11,8 +11,4 @@
|
||||
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Components\PdfDiagram\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
BIN
WinFormsApp1/Documents/PdfWithPieDiagram.pdf
Normal file
BIN
WinFormsApp1/Documents/PdfWithPieDiagram.pdf
Normal file
Binary file not shown.
19
WinFormsApp1/Form1.Designer.cs
generated
19
WinFormsApp1/Form1.Designer.cs
generated
@ -41,6 +41,8 @@
|
||||
createPdfImages = new Button();
|
||||
pdfTable = new MyUserControls.Components.PdfTable.PdfTable(components);
|
||||
createTable = new Button();
|
||||
pdfDiagram = new MyUserControls.Components.PdfDiagram.PdfDiagram(components);
|
||||
createDiagram = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// smartCheckedListBox1
|
||||
@ -110,13 +112,13 @@
|
||||
createPdfImages.Name = "createPdfImages";
|
||||
createPdfImages.Size = new Size(184, 29);
|
||||
createPdfImages.TabIndex = 8;
|
||||
createPdfImages.Text = "Создать пдф";
|
||||
createPdfImages.Text = "Создать картинки пдф";
|
||||
createPdfImages.UseVisualStyleBackColor = true;
|
||||
createPdfImages.Click += createPdfImages_Click;
|
||||
//
|
||||
// createTable
|
||||
//
|
||||
createTable.Location = new Point(330, 316);
|
||||
createTable.Location = new Point(330, 305);
|
||||
createTable.Name = "createTable";
|
||||
createTable.Size = new Size(184, 31);
|
||||
createTable.TabIndex = 9;
|
||||
@ -124,11 +126,22 @@
|
||||
createTable.UseVisualStyleBackColor = true;
|
||||
createTable.Click += createTable_Click;
|
||||
//
|
||||
// createDiagram
|
||||
//
|
||||
createDiagram.Location = new Point(331, 351);
|
||||
createDiagram.Name = "createDiagram";
|
||||
createDiagram.Size = new Size(185, 29);
|
||||
createDiagram.TabIndex = 10;
|
||||
createDiagram.Text = "Создать диаграмму пдф";
|
||||
createDiagram.UseVisualStyleBackColor = true;
|
||||
createDiagram.Click += createDiagram_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1120, 474);
|
||||
Controls.Add(createDiagram);
|
||||
Controls.Add(createTable);
|
||||
Controls.Add(createPdfImages);
|
||||
Controls.Add(chooseImage);
|
||||
@ -157,5 +170,7 @@
|
||||
private Button createPdfImages;
|
||||
private MyUserControls.Components.PdfTable.PdfTable pdfTable;
|
||||
private Button createTable;
|
||||
private MyUserControls.Components.PdfDiagram.PdfDiagram pdfDiagram;
|
||||
private Button createDiagram;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using MyUserControls;
|
||||
using MyUserControls.Components.office_package.Implements;
|
||||
using MyUserControls.Components.PdfDiagram;
|
||||
using MyUserControls.Components.PdfImage;
|
||||
using MyUserControls.Components.PdfTable;
|
||||
using System.ComponentModel;
|
||||
@ -183,5 +184,40 @@ namespace WinFormsApp1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createDiagram_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string currentDirectory = Directory.GetCurrentDirectory();
|
||||
|
||||
string filePath = Path.Combine(currentDirectory, @"..\..\..\Documents\PdfWithPieDiagram.pdf");
|
||||
|
||||
pdfDiagram.CreateDiagram(new PdfDiagramInfo
|
||||
{
|
||||
FileName = filePath,
|
||||
Title = "Title",
|
||||
ChartTitle = "OS 2024",
|
||||
LegendLocation = MyUserControls.Components.office_package.HelperEnums.PdfDiagramLegendLocation.Bottom,
|
||||
Series = new MyUserControls.Components.office_package.HelperModels.PdfDiagramSeries
|
||||
{
|
||||
SeriesName = "DesctopOperatingSystemAugust2024",
|
||||
Data = new Dictionary<string, double>
|
||||
{
|
||||
{ "Windows", 71.5 },
|
||||
{ "OS X", 15.5 },
|
||||
{ "Linux", 4.5 },
|
||||
{ "Others", 8.5 },
|
||||
}
|
||||
}
|
||||
});
|
||||
MessageBox.Show("PDF óñïåøíî ñîçäàí!", "ïäô ñîçäàí");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"íå óäàëîñü ñîçäàòü ïäô: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -126,4 +126,7 @@
|
||||
<metadata name="pdfTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>304, 17</value>
|
||||
</metadata>
|
||||
<metadata name="pdfDiagram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>418, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -12,8 +12,4 @@
|
||||
<ProjectReference Include="..\CheckedListBoxLibrary\MyUserControls.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Documents\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user