From 0fba5967709c252c4ed829f1cff456725074cbec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=B5=D1=80?= =?UTF-8?q?=D0=B3=D1=83=D0=BD=D0=BE=D0=B2?= Date: Wed, 29 Nov 2023 18:00:55 +0400 Subject: [PATCH] Adding method & smth else --- .../MyVisualComponents/ListBoxObjects.cs | 5 ++ .../ColumnParameters.cs | 21 +++++ .../DataHistogramm.cs | 24 ++++++ .../EnumLegends.cs | 17 ++++ .../MyHistogramm.cs | 30 ++++++++ .../ZhelovanovNonVisualComponents/MyTable.cs | 22 ++++++ .../MyTableWithHead.cs | 35 +++++++++ .../WordHistogramm.Designer.cs | 2 +- .../WordHistogramm.cs | 2 +- .../TextBoxComponent.Designer.cs | 2 +- .../TextBoxComponent.cs | 2 +- Library/LibraryView/FormBook.Designer.cs | 24 +++--- Library/LibraryView/FormBook.cs | 10 +-- Library/LibraryView/FormMain.Designer.cs | 2 +- Library/LibraryView/FormMain.cs | 77 ++++++++++++++----- Library/LibraryView/LibraryView.csproj | 2 + Library/LibraryView/Program.cs | 36 ++++++++- 17 files changed, 269 insertions(+), 44 deletions(-) create mode 100644 Library/CustomComponents/ZhelovanovNonVisualComponents/ColumnParameters.cs create mode 100644 Library/CustomComponents/ZhelovanovNonVisualComponents/DataHistogramm.cs create mode 100644 Library/CustomComponents/ZhelovanovNonVisualComponents/EnumLegends.cs create mode 100644 Library/CustomComponents/ZhelovanovNonVisualComponents/MyHistogramm.cs create mode 100644 Library/CustomComponents/ZhelovanovNonVisualComponents/MyTable.cs create mode 100644 Library/CustomComponents/ZhelovanovNonVisualComponents/MyTableWithHead.cs diff --git a/Library/CustomComponents/MyVisualComponents/ListBoxObjects.cs b/Library/CustomComponents/MyVisualComponents/ListBoxObjects.cs index d1c8ddd..d350117 100644 --- a/Library/CustomComponents/MyVisualComponents/ListBoxObjects.cs +++ b/Library/CustomComponents/MyVisualComponents/ListBoxObjects.cs @@ -94,5 +94,10 @@ namespace CustomComponents listBox.Items.Add(str); } + + public void deleteAll() + { + listBox.Items.Clear(); + } } } diff --git a/Library/CustomComponents/ZhelovanovNonVisualComponents/ColumnParameters.cs b/Library/CustomComponents/ZhelovanovNonVisualComponents/ColumnParameters.cs new file mode 100644 index 0000000..183ad71 --- /dev/null +++ b/Library/CustomComponents/ZhelovanovNonVisualComponents/ColumnParameters.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomComponents.ZhelovanovNonVisualComponents +{ + public class ColumnParameters + { + public string _nameColumn { get; set; } = string.Empty; + + public string _nameField { get; set; } = string.Empty; + + public ColumnParameters(string nameColumn, string nameField) + { + _nameColumn = nameColumn; + _nameField = nameField; + } + } +} diff --git a/Library/CustomComponents/ZhelovanovNonVisualComponents/DataHistogramm.cs b/Library/CustomComponents/ZhelovanovNonVisualComponents/DataHistogramm.cs new file mode 100644 index 0000000..c7eb5a7 --- /dev/null +++ b/Library/CustomComponents/ZhelovanovNonVisualComponents/DataHistogramm.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomComponents.ZhelovanovNonVisualComponents +{ + public class DataHistogramm + { + + + public string _nameData { get; set; } = string.Empty; + + public double _data { get; set; } + + public DataHistogramm(string nameData, int data) + { + + _nameData = nameData; + _data = data; + } + } +} diff --git a/Library/CustomComponents/ZhelovanovNonVisualComponents/EnumLegends.cs b/Library/CustomComponents/ZhelovanovNonVisualComponents/EnumLegends.cs new file mode 100644 index 0000000..96f55a6 --- /dev/null +++ b/Library/CustomComponents/ZhelovanovNonVisualComponents/EnumLegends.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomComponents.ZhelovanovNonVisualComponents +{ + public enum EnumLegends + { + None = 0, + Left = 1, + Right = 2, + Top = 3, + Bottom = 4 + } +} diff --git a/Library/CustomComponents/ZhelovanovNonVisualComponents/MyHistogramm.cs b/Library/CustomComponents/ZhelovanovNonVisualComponents/MyHistogramm.cs new file mode 100644 index 0000000..5cb2fe7 --- /dev/null +++ b/Library/CustomComponents/ZhelovanovNonVisualComponents/MyHistogramm.cs @@ -0,0 +1,30 @@ +using DocumentFormat.OpenXml.Drawing; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomComponents.ZhelovanovNonVisualComponents +{ + public class MyHistogramm + { + public string _filePath = string.Empty; + + public string _fileHeader = string.Empty; + + public string _histogramName = string.Empty; + + public EnumLegends _legends; + + public List _dataList = new(); + public MyHistogramm(string filePath, string fileHeader, string histogramName, EnumLegends legends, List dataList) { + _filePath = filePath; + _fileHeader = fileHeader; + _histogramName = histogramName; + _legends = legends; + _dataList = dataList; + } + + } +} diff --git a/Library/CustomComponents/ZhelovanovNonVisualComponents/MyTable.cs b/Library/CustomComponents/ZhelovanovNonVisualComponents/MyTable.cs new file mode 100644 index 0000000..b39873a --- /dev/null +++ b/Library/CustomComponents/ZhelovanovNonVisualComponents/MyTable.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomComponents.ZhelovanovNonVisualComponents +{ + public class MyTable + { + public string _filePath = string.Empty; + + public string _fileHeader = string.Empty; + public List _dataList = new(); + public MyTable(string filePath, string fileHeader, List dataList) { + _filePath = filePath; + _fileHeader = fileHeader; + _dataList = dataList; + } + + } +} diff --git a/Library/CustomComponents/ZhelovanovNonVisualComponents/MyTableWithHead.cs b/Library/CustomComponents/ZhelovanovNonVisualComponents/MyTableWithHead.cs new file mode 100644 index 0000000..f3a86d0 --- /dev/null +++ b/Library/CustomComponents/ZhelovanovNonVisualComponents/MyTableWithHead.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomComponents.ZhelovanovNonVisualComponents +{ + public class MyTableWithHead + { + public string _filePath = string.Empty; + + public string _fileHeader = string.Empty; + + public List _heightRow = new(); + + public List _widthCol = new(); + + public List _dataList; + + + public Dictionary _columnsSettings; + + public MyTableWithHead(string filePath, string fileHeader, List heightRow, + List widthCol, List dataList, Dictionary columnsSettings) + { + _filePath = filePath; + _fileHeader = fileHeader; + _heightRow = heightRow; + _widthCol = widthCol; + _dataList = dataList; + _columnsSettings = columnsSettings; + } + } +} diff --git a/Library/CustomComponents/ZhelovanovNonVisualComponents/WordHistogramm.Designer.cs b/Library/CustomComponents/ZhelovanovNonVisualComponents/WordHistogramm.Designer.cs index 44cf84d..dbcae98 100644 --- a/Library/CustomComponents/ZhelovanovNonVisualComponents/WordHistogramm.Designer.cs +++ b/Library/CustomComponents/ZhelovanovNonVisualComponents/WordHistogramm.Designer.cs @@ -1,4 +1,4 @@ -namespace KOP_Labs.NonVisualComponents +namespace CustomComponents.ZhelovanovNonVisualComponents { partial class WordHistogramm { diff --git a/Library/CustomComponents/ZhelovanovNonVisualComponents/WordHistogramm.cs b/Library/CustomComponents/ZhelovanovNonVisualComponents/WordHistogramm.cs index 59dafbd..b0812c9 100644 --- a/Library/CustomComponents/ZhelovanovNonVisualComponents/WordHistogramm.cs +++ b/Library/CustomComponents/ZhelovanovNonVisualComponents/WordHistogramm.cs @@ -10,7 +10,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace KOP_Labs.NonVisualComponents +namespace CustomComponents.ZhelovanovNonVisualComponents { public partial class WordHistogramm : Component { diff --git a/Library/CustomComponents/ZhelovanovVisualComponents/TextBoxComponent.Designer.cs b/Library/CustomComponents/ZhelovanovVisualComponents/TextBoxComponent.Designer.cs index b9b5f16..758c53c 100644 --- a/Library/CustomComponents/ZhelovanovVisualComponents/TextBoxComponent.Designer.cs +++ b/Library/CustomComponents/ZhelovanovVisualComponents/TextBoxComponent.Designer.cs @@ -1,4 +1,4 @@ -namespace KOP_Labs +namespace CustomComponents.ZhelovanovVisualComponents { partial class TextBoxComponent { diff --git a/Library/CustomComponents/ZhelovanovVisualComponents/TextBoxComponent.cs b/Library/CustomComponents/ZhelovanovVisualComponents/TextBoxComponent.cs index 4fa13fa..8e6bc93 100644 --- a/Library/CustomComponents/ZhelovanovVisualComponents/TextBoxComponent.cs +++ b/Library/CustomComponents/ZhelovanovVisualComponents/TextBoxComponent.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button; -namespace KOP_Labs +namespace CustomComponents.ZhelovanovVisualComponents { public partial class TextBoxComponent : UserControl { diff --git a/Library/LibraryView/FormBook.Designer.cs b/Library/LibraryView/FormBook.Designer.cs index 8c576c7..7b0d54b 100644 --- a/Library/LibraryView/FormBook.Designer.cs +++ b/Library/LibraryView/FormBook.Designer.cs @@ -1,4 +1,6 @@ -namespace LibraryView +using KOP_Labs; + +namespace LibraryView { partial class FormBook { @@ -29,13 +31,13 @@ private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); - this.romanovaComboBoxGenre = new ComponentsLibrary.MyVisualComponents.RomanovaComboBox(); + this.MeComboBoxGenre = new CustomComponents.DropDownList(); this.textBoxTitle = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.textBoxDescription = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); - this.textBoxCost = new ComponentsLibrary.IstyukovVisualComponents.TextBoxModified(); + this.textBoxCost = new CustomComponents.ZhelovanovVisualComponents.TextBoxComponent(); this.buttonSave = new System.Windows.Forms.Button(); this.buttonClose = new System.Windows.Forms.Button(); this.SuspendLayout(); @@ -51,11 +53,11 @@ // // romanovaComboBoxGenre // - this.romanovaComboBoxGenre.Location = new System.Drawing.Point(-3, 240); - this.romanovaComboBoxGenre.Name = "romanovaComboBoxGenre"; - this.romanovaComboBoxGenre.SelectElement = ""; - this.romanovaComboBoxGenre.Size = new System.Drawing.Size(259, 116); - this.romanovaComboBoxGenre.TabIndex = 1; + this.MeComboBoxGenre.Location = new System.Drawing.Point(-3, 240); + this.MeComboBoxGenre.Name = "romanovaComboBoxGenre"; + this.MeComboBoxGenre.Selected = ""; + this.MeComboBoxGenre.Size = new System.Drawing.Size(259, 116); + this.MeComboBoxGenre.TabIndex = 1; // // textBoxTitle // @@ -141,7 +143,7 @@ this.Controls.Add(this.textBoxDescription); this.Controls.Add(this.label2); this.Controls.Add(this.textBoxTitle); - this.Controls.Add(this.romanovaComboBoxGenre); + this.Controls.Add(this.MeComboBoxGenre); this.Controls.Add(this.label1); this.Name = "FormBook"; this.Text = "Книги"; @@ -160,8 +162,8 @@ private TextBox textBoxDescription; private Label label3; private Label label4; - private CustomComponents. - private Button buttonSave; + private CustomComponents.ZhelovanovVisualComponents.TextBoxComponent textBoxCost; + private Button buttonSave; private Button buttonClose; } } \ No newline at end of file diff --git a/Library/LibraryView/FormBook.cs b/Library/LibraryView/FormBook.cs index 6aad1cc..1bdba59 100644 --- a/Library/LibraryView/FormBook.cs +++ b/Library/LibraryView/FormBook.cs @@ -31,7 +31,7 @@ namespace LibraryView var genries = _genreLogic.Read(null); foreach (var genre in genries) { - romanovaComboBoxGenre.FillList(genre.Name); + MeComboBoxGenre.AddingToList(genre.Name); } } @@ -48,14 +48,14 @@ namespace LibraryView { textBoxTitle.Text = view.Title; textBoxDescription.Text = view.Description; - romanovaComboBoxGenre.SelectElement = view.Genre; + MeComboBoxGenre.Selected = view.Genre; textBoxCost.Value = null; } else { textBoxTitle.Text = view.Title; textBoxDescription.Text = view.Description; - romanovaComboBoxGenre.SelectElement = view.Genre; + MeComboBoxGenre.Selected = view.Genre; textBoxCost.Value = view.Cost; } } @@ -81,7 +81,7 @@ namespace LibraryView return; } - if (string.IsNullOrEmpty(romanovaComboBoxGenre.SelectElement.ToString())) + if (string.IsNullOrEmpty(MeComboBoxGenre.Selected.ToString())) { MessageBox.Show("Выберите жанр книги", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -106,7 +106,7 @@ namespace LibraryView Id = id, Title = textBoxTitle.Text, Description = textBoxDescription.Text, - Genre = romanovaComboBoxGenre.SelectElement.ToString(), + Genre = MeComboBoxGenre.Selected.ToString(), Cost = cost }); MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); diff --git a/Library/LibraryView/FormMain.Designer.cs b/Library/LibraryView/FormMain.Designer.cs index 0300c41..a7bdf0b 100644 --- a/Library/LibraryView/FormMain.Designer.cs +++ b/Library/LibraryView/FormMain.Designer.cs @@ -87,7 +87,7 @@ private MenuStrip menuStrip; private ToolStripMenuItem справочникиToolStripMenuItem; - private ComponentsLibrary.BasharinVisualComponents.SevaTreeView sevaTreeView; + private CustomComponents.BasharinVisualComponents.SevaTreeView sevaTreeView; private ComponentsLibrary.MyNotVisualComponents.RomanovaExcelDocument romanovaExcelDocument; private ComponentsLibrary.BasharinNotVisualComponents.DiagramToPDF diagramTopdf1; private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderWord componentDocumentWithTableMultiHeaderWord; diff --git a/Library/LibraryView/FormMain.cs b/Library/LibraryView/FormMain.cs index 794800d..ea59edb 100644 --- a/Library/LibraryView/FormMain.cs +++ b/Library/LibraryView/FormMain.cs @@ -1,16 +1,16 @@ -using ComponentsLibrary.IstyukovNotVisualComponents; -using ComponentsLibrary.MyUnvisualComponents; -using ComponentsLibrary.MyUnvisualComponents.HelperModels; -using ComponentsLibraryNet60.DocumentWithTable; -using ComponentsLibraryNet60.Models; +//using KOP_Labs.Classes; +using KOP_Labs.NonVisualComponents; using LibraryContracts.BindingModels; using LibraryContracts.BusinessLogicsContracts; using LibraryDatabaseImplement.Models; using Microsoft.Office.Interop.Excel; using System; using System.Collections.Generic; +using System.Diagnostics.Metrics; using System.Windows.Forms; using Unity; +using CustomComponents.ZhelovanovNonVisualComponents; +using CustomComponents; namespace LibraryView { @@ -138,7 +138,7 @@ namespace LibraryView private void diagramDocMenuItem_Click(object sender, EventArgs e) { - CreatePdfDiagram(); + CreateWordDiagram(); } protected override bool ProcessCmdKey(ref Message msg, Keys keyData) @@ -175,7 +175,7 @@ namespace LibraryView if (keyData == (Keys.Control | Keys.C)) { - CreatePdfDiagram(); + CreateWordDiagram(); return true; } @@ -204,13 +204,13 @@ namespace LibraryView string[] data = dataSet.Split(';'); var sfd = new SaveFileDialog(); - sfd.FileName = "D:\\Study\\3 course\\KOP\\file\\simpleDocProducts.xls"; + sfd.FileName = "D:\\Papka\\KOP\\simpleDocProducts.xls"; sfd.Filter = "Excel files (*.xlsx)|*.xlsx"; if (sfd.ShowDialog() == DialogResult.OK) { if (data != null) { - romanovaExcelDocument.CreateExcel(sfd.FileName, "Книги", data); + bigTextComponent.CreateExcel(sfd.FileName, "Книги", data); MessageBox.Show("Файл был создан успешно", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } else @@ -221,9 +221,11 @@ namespace LibraryView } } - private void CreatePdfDiagram() + private void CreateWordDiagram() { - Dictionary data = new Dictionary(); + + MyHistogramm histogram; + List data = new List(); var books = _bookLogic.Read(null); var genries = _genreLogic.Read(null); if (books != null && genries != null) @@ -238,23 +240,25 @@ namespace LibraryView count++; } } - data.Add(genre.Name, count); + new DataHistogramm(genre.Name, count); } var sfd = new SaveFileDialog(); sfd.FileName = "DiagramBook.pdf"; sfd.Filter = "Pdf files (*.pdf)|*.pdf"; if (sfd.ShowDialog() == DialogResult.OK) { - diagramTopdf1.CreateDocument(sfd.FileName, "Бесплатные книги", - "Сколько бесплатных книг какого жанра", ComponentsLibrary.BasharinNotVisualComponents.Area.TOP, data); - MessageBox.Show("Файл был создан успешно", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); - } + + histogram = new(sfd.FileName, "Бесплатные книги", "Сколько бесплатных книг какого жанра", EnumLegends.Right, data); + + wordHistogramm1.CreateHistogramm(histogram); + MessageBox.Show("Файл был создан успешно", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } } } private void CreateWordTable() { - var sfd = new SaveFileDialog(); + var sfd = new SaveFileDialog(); sfd.FileName = "WordBooks.docx"; sfd.Filter = "Word files (*.docx)|*.docx"; var booksDB = _bookLogic.Read(null); @@ -271,7 +275,7 @@ namespace LibraryView }; books.Add(prod); } - if (sfd.ShowDialog() == DialogResult.OK) + /*if (sfd.ShowDialog() == DialogResult.OK) { componentDocumentWithTableMultiHeaderWord.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig { @@ -289,8 +293,41 @@ namespace LibraryView Data = books }); MessageBox.Show("Файл был создан успешно", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } + }*/ + + if (sfd.ShowDialog() == DialogResult.OK) + { + try + { + string title = "Информация по всем книгам"; + string[,] row1 = { + { "Id", "Id" } + }; + + string[,] row2 = { + { "Название", "Title" } + }; + + string[,] row3 = { + { "Описание", "Description" } + }; + string[,] row4 = { + { "Категория", "Genre" } + }; + string[,] row5 = { + { "Стоимость книг", "CostStr" } + }; + MyTable table = new MyTable(sfd.FileName, title, new List { row1, row2, row3, row4, row5 }); + wordTableComponent1.CreateDoc(table); + + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } public List getColumnsWidth(int count, int width) { diff --git a/Library/LibraryView/LibraryView.csproj b/Library/LibraryView/LibraryView.csproj index 43410ec..3f09ca8 100644 --- a/Library/LibraryView/LibraryView.csproj +++ b/Library/LibraryView/LibraryView.csproj @@ -10,10 +10,12 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Library/LibraryView/Program.cs b/Library/LibraryView/Program.cs index f18829b..562622d 100644 --- a/Library/LibraryView/Program.cs +++ b/Library/LibraryView/Program.cs @@ -1,7 +1,26 @@ +using LibraryBusinessLogic.BusinessLogics; +using LibraryContracts.BusinessLogicsContracts; +using LibraryContracts.StorageContracts; +using LibraryDatabaseImplement.Implements; +using Unity; +using Unity.Lifetime; + namespace LibraryView { - internal static class Program + public static class Program { + private static IUnityContainer container = null; + public static IUnityContainer Container + { + get + { + if (container == null) + { + container = BuildUnityContainer(); + } + return container; + } + } /// /// The main entry point for the application. /// @@ -10,8 +29,19 @@ namespace LibraryView { // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new FormSecond()); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(Container.Resolve()); + } + + private static IUnityContainer BuildUnityContainer() + { + var currentContainer = new UnityContainer(); + currentContainer.RegisterType(new HierarchicalLifetimeManager()); + currentContainer.RegisterType(new HierarchicalLifetimeManager()); + currentContainer.RegisterType(new HierarchicalLifetimeManager()); + currentContainer.RegisterType(new HierarchicalLifetimeManager()); + return currentContainer; } } } \ No newline at end of file