From 2ee8f9d7439610cfd681e750cdbdb0fe3d270f25 Mon Sep 17 00:00:00 2001 From: danilafilippov7299 Date: Thu, 7 Nov 2024 15:15:17 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BA=D0=BE=D0=BD=D1=87=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=B2=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D0=B0=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WinFormsApp1/WinFormsApp1/Create.cs | 2 +- WinFormsApp1/WinFormsApp1/Form1.Designer.cs | 2 + WinFormsApp1/WinFormsApp1/Form1.cs | 46 ++++++++++++++++++++- WinFormsApp1/WinFormsApp1/Order.cs | 2 - 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/WinFormsApp1/WinFormsApp1/Create.cs b/WinFormsApp1/WinFormsApp1/Create.cs index ba06285..5ed8e3c 100644 --- a/WinFormsApp1/WinFormsApp1/Create.cs +++ b/WinFormsApp1/WinFormsApp1/Create.cs @@ -88,7 +88,7 @@ namespace WinFormsApp1 } catch (Exception er) { - MessageBox.Show(er.Message, "Some title", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(er.Message, "Some title", MessageBoxButtons.OK, MessageBoxIcon.Information); } } diff --git a/WinFormsApp1/WinFormsApp1/Form1.Designer.cs b/WinFormsApp1/WinFormsApp1/Form1.Designer.cs index 6527215..fa34dea 100644 --- a/WinFormsApp1/WinFormsApp1/Form1.Designer.cs +++ b/WinFormsApp1/WinFormsApp1/Form1.Designer.cs @@ -69,6 +69,7 @@ this.shabListOutputComponent1.Size = new System.Drawing.Size(1042, 376); this.shabListOutputComponent1.TabIndex = 2; this.shabListOutputComponent1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.shabListOutputComponent1_KeyDown); + this.shabListOutputComponent1.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.shabListOutputComponent1_PreviewKeyDown); // // contextMenuStrip1 // @@ -164,6 +165,7 @@ this.Name = "Form1"; this.Text = "Form1"; this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown); + this.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.Form1_PreviewKeyDown); this.contextMenuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); diff --git a/WinFormsApp1/WinFormsApp1/Form1.cs b/WinFormsApp1/WinFormsApp1/Form1.cs index 481a7ad..0d62c39 100644 --- a/WinFormsApp1/WinFormsApp1/Form1.cs +++ b/WinFormsApp1/WinFormsApp1/Form1.cs @@ -8,6 +8,30 @@ namespace WinFormsApp1 { public partial class Form1 : Form { + public bool cont = false; + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) + { + if (keyData == (System.Windows.Forms.Keys.ControlKey | System.Windows.Forms.Keys.Control)) cont = true; + + if (cont && keyData == Keys.A) создатьЗаписьToolStripMenuItem_Click_1(null, null); + else if (cont && keyData == Keys.U) открытьЗаписьToolStripMenuItem_Click_1(null, null); + else if (cont && keyData == Keys.D) удалитьЗаписьToolStripMenuItem_Click_1(null, null); + else if (cont && keyData == Keys.S) создатьПростойДокументToolStripMenuItem_Click_1(null, null); + else if (cont && keyData == Keys.T) создатьДокументСНастраиваемойТаблицейToolStripMenuItem_Click_1(null, null); + else if (cont && keyData == Keys.C) создатьДокументСДиаграммойToolStripMenuItem_Click_1(null, null); + // Handle key at form level. + // Do not send event to focused control by returning true. + + if (keyData == Keys.A || + keyData == Keys.U || + keyData == Keys.D || + keyData == Keys.S || + keyData == Keys.T || + keyData == Keys.C) cont = false; + //if (keyData != Keys.None && keyData != (System.Windows.Forms.Keys.ControlKey | System.Windows.Forms.Keys.Control)) cont = false; + return true; + return base.ProcessCmdKey(ref msg, keyData); + } public Form1() { InitializeComponent(); @@ -87,8 +111,9 @@ namespace WinFormsApp1 catch { } ExcelPackage.LicenseContext = LicenseContext.NonCommercial; - excelImages1.CreateDocument(saveFileDialog.FileName, "My Document", objects.Select(x => Order.ConvertBytesToImage(x.Photo)).ToList()); + excelImages1.CreateDocument(saveFileDialog.FileName, "Фото заказов", objects.Select(x => Order.ConvertBytesToImage(x.Photo)).ToList()); + MessageBox.Show("Простой документ был создан! \n по адресу: " + saveFileDialog.FileName, "Some title", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } @@ -115,7 +140,7 @@ namespace WinFormsApp1 wordTable1.CreateWordTable(new Labs.HelperClasses.WordTable.WordTableConfig( saveFileDialog.FileName, - "ExcelMine", + "Таблица заказов", new List { new ColumnProperties("Id", 100, "Идентификатор", "Идентификатор"), new ColumnProperties("CustomerFIO", 100, "Личные данные", "ФИО заказчика"), @@ -128,6 +153,7 @@ namespace WinFormsApp1 }, objects )); + MessageBox.Show("Документ с настраиваемой таблицей был создан! \n по адресу: " + saveFileDialog.FileName, "Some title", MessageBoxButtons.OK, MessageBoxIcon.Information); } } @@ -171,6 +197,7 @@ namespace WinFormsApp1 ShabComponentsLibrary.Enums.LegendPosition.Top, l ); + MessageBox.Show("Документ с круговой таблицей был создан! \n по адресу: " + saveFileDialog.FileName, "Some title", MessageBoxButtons.OK, MessageBoxIcon.Information); } } @@ -214,6 +241,21 @@ namespace WinFormsApp1 { shabListOutputComponent1.InsertValues(_storage.GetFullList()); } + + private void Form1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + + } + + private void shabListOutputComponent1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) + { + if (e.Control && e.KeyCode == Keys.A) создатьЗаписьToolStripMenuItem_Click_1(sender, e); + else if (e.Control && e.KeyCode == Keys.U) открытьЗаписьToolStripMenuItem_Click_1(sender, e); + else if (e.Control && e.KeyCode == Keys.D) удалитьЗаписьToolStripMenuItem_Click_1(sender, e); + else if (e.Control && e.KeyCode == Keys.S) создатьПростойДокументToolStripMenuItem_Click_1(sender, e); + else if (e.Control && e.KeyCode == Keys.T) создатьДокументСНастраиваемойТаблицейToolStripMenuItem_Click_1(sender, e); + else if (e.Control && e.KeyCode == Keys.C) создатьДокументСДиаграммойToolStripMenuItem_Click_1(sender, e); + } } } diff --git a/WinFormsApp1/WinFormsApp1/Order.cs b/WinFormsApp1/WinFormsApp1/Order.cs index c08e3ef..cdf52c8 100644 --- a/WinFormsApp1/WinFormsApp1/Order.cs +++ b/WinFormsApp1/WinFormsApp1/Order.cs @@ -9,8 +9,6 @@ namespace WinFormsApp1 { public class Order { - - public static byte[] converterToBytes(Image x) { ImageConverter _imageConverter = new ImageConverter();