Compare commits
No commits in common. "main" and "lab2" have entirely different histories.
36
Components/Nonvisual/UserControlTableDocument.Designer.cs
generated
Normal file
36
Components/Nonvisual/UserControlTableDocument.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Components
|
||||
{
|
||||
partial class UserControlTableDocument
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
9
Components/SaveToPdfHelpers/PdfParagraph.cs
Normal file
9
Components/SaveToPdfHelpers/PdfParagraph.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Components.SaveToPdfHelpers
|
||||
{
|
||||
public class PdfParagraph
|
||||
{
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public string Style { get; set; } = string.Empty;
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
9
Components/SaveToPdfHelpers/PdfParagraphAlignmentType.cs
Normal file
9
Components/SaveToPdfHelpers/PdfParagraphAlignmentType.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Components.SaveToPdfHelpers
|
||||
{
|
||||
public enum PdfParagraphAlignmentType
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
}
|
@ -12,6 +12,12 @@ namespace Components.Visual
|
||||
public int Width { get; set; }
|
||||
public bool Visible { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string DataPropertyName { get; set; } = string.Empty;
|
||||
public ColumnInfo(string headerText, string name, int width, bool visible)
|
||||
{
|
||||
HeaderText = headerText;
|
||||
Name = name;
|
||||
Width = width;
|
||||
Visible = visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ namespace Components
|
||||
HeaderText = columnInfo[i].HeaderText,
|
||||
Width = columnInfo[i].Width,
|
||||
Visible = columnInfo[i].Visible,
|
||||
DataPropertyName = columnInfo[i].DataPropertyName,
|
||||
};
|
||||
dataGridViewTable.Columns.Add(column);
|
||||
}
|
||||
@ -53,22 +52,9 @@ namespace Components
|
||||
dataGridViewTable.Rows.Clear();
|
||||
}
|
||||
|
||||
public void AddList<T>(List<T> values)
|
||||
public void AddObjectList(List<object> os)
|
||||
{
|
||||
ClearRows();
|
||||
var props = typeof(T).GetProperties();
|
||||
|
||||
foreach (T value in values)
|
||||
{
|
||||
int newRowInd = dataGridViewTable.Rows.Add();
|
||||
foreach (DataGridViewColumn col in dataGridViewTable.Columns)
|
||||
{
|
||||
var prop = props.FirstOrDefault(x => x.Name == col.DataPropertyName)
|
||||
?? throw new InvalidOperationException($"No property {col.DataPropertyName} found in type {typeof(T).Name}");
|
||||
var val = prop.GetValue(value);
|
||||
dataGridViewTable.Rows[newRowInd].Cells[col.Index].Value = val;
|
||||
}
|
||||
}
|
||||
dataGridViewTable.DataSource = os ?? throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
public T GetObjectFromRow<T>()
|
||||
@ -88,10 +74,28 @@ namespace Components
|
||||
for (int i = 0; i < dataGridViewTable.ColumnCount; i++)
|
||||
{
|
||||
var curCell = cells[i];
|
||||
var prop = props.FirstOrDefault(x => x.Name == dataGridViewTable.Columns[i].DataPropertyName);
|
||||
var prop = props.FirstOrDefault(x => x.Name == dataGridViewTable.Columns[i].Name);
|
||||
prop?.SetValue(returnObject, curCell.Value);
|
||||
}
|
||||
return returnObject;
|
||||
}
|
||||
|
||||
public void AddList<T> (List<T> values)
|
||||
{
|
||||
ClearRows();
|
||||
var props = typeof(T).GetProperties();
|
||||
|
||||
foreach (T value in values)
|
||||
{
|
||||
int newRowInd = dataGridViewTable.Rows.Add(value);
|
||||
foreach (DataGridViewColumn col in dataGridViewTable.Columns)
|
||||
{
|
||||
var prop = props.FirstOrDefault(x => x.Name == col.Name)
|
||||
?? throw new InvalidOperationException($"No property {col.Name} found in type {typeof(T).Name}");
|
||||
var val = prop.GetValue(value);
|
||||
dataGridViewTable.Rows[newRowInd].Cells[col.Index].Value = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ VisualStudioVersion = 17.9.34728.123
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Components", "Components\Components.csproj", "{260D3E8C-3599-49F1-BF42-64A92DD0FB62}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestingForm", "TestingForm\TestingForm.csproj", "{4F4882A1-4DF1-4BC3-B022-9935E70E5552}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -15,6 +17,10 @@ Global
|
||||
{260D3E8C-3599-49F1-BF42-64A92DD0FB62}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{260D3E8C-3599-49F1-BF42-64A92DD0FB62}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{260D3E8C-3599-49F1-BF42-64A92DD0FB62}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F4882A1-4DF1-4BC3-B022-9935E70E5552}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F4882A1-4DF1-4BC3-B022-9935E70E5552}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F4882A1-4DF1-4BC3-B022-9935E70E5552}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F4882A1-4DF1-4BC3-B022-9935E70E5552}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
17
TestingForm/Program.cs
Normal file
17
TestingForm/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace TestingForm
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormMain());
|
||||
}
|
||||
}
|
||||
}
|
15
TestingForm/TestingForm.csproj
Normal file
15
TestingForm/TestingForm.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Components\Components.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user