From f844787c265f44a789d45cbb01a7d5779afe519f Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 3 Dec 2022 14:04:02 +0300 Subject: [PATCH] 20221203 --- anbs_cp/Classes/FileExtensions.cs | 71 ++++++++ anbs_cp/anbs_cp.csproj | 10 +- anbsoftware.componentspack.sln.DotSettings | 5 +- demo/CountValueTest.Designer.cs | 183 +++++++++++---------- demo/CountValueTest.cs | 8 + demo/FileHashAndMimeTypeTest.Designer.cs | 125 ++++++++++++++ demo/FileHashAndMimeTypeTest.cs | 42 +++++ demo/FileHashAndMimeTypeTest.resx | 63 +++++++ demo/MainMenu.Designer.cs | 20 ++- demo/MainMenu.cs | 6 + demo/SampleMapperTest.Designer.cs | 8 +- demo/SampleMapperTest.cs | 5 +- demo/demo.csproj | 6 + 13 files changed, 447 insertions(+), 105 deletions(-) create mode 100644 anbs_cp/Classes/FileExtensions.cs create mode 100644 demo/FileHashAndMimeTypeTest.Designer.cs create mode 100644 demo/FileHashAndMimeTypeTest.cs create mode 100644 demo/FileHashAndMimeTypeTest.resx diff --git a/anbs_cp/Classes/FileExtensions.cs b/anbs_cp/Classes/FileExtensions.cs new file mode 100644 index 0000000..7dee49b --- /dev/null +++ b/anbs_cp/Classes/FileExtensions.cs @@ -0,0 +1,71 @@ +using System.Security.Cryptography; + +using Microsoft.AspNetCore.Http; + +using MimeKit; + +namespace anbs_cp.Classes; + +/// +/// Класс -- расширение для класса File +/// +public static class FileExtension +{ + /// + /// Получение md5-хэша файла. + /// Взято с https://stackoverflow.com/a/24031467/16469671 + /// + /// Имя файла + /// Массив хэша + public static byte[] Hash (string fileName) + { + using MD5 md5 = MD5.Create(); + byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(fileName); + byte[] result = md5.ComputeHash(inputBytes); + + return result; + } + + /// + /// Получение md5-хэша загружаемого файла. + /// Взято с https://stackoverflow.com/a/67081012/16469671 + /// + /// Загружаемый файл + /// Массив хэша + public static byte[] Hash (IFormFile file) + { + using MD5 md5 = MD5.Create(); + using StreamReader streamReader = new(file.OpenReadStream()); + return md5.ComputeHash(streamReader.BaseStream); + } + + /// + /// Получение md5-хэша файла и вывод в строке. + /// + /// Имя файла + /// Срока с хэшем файла + public static string HashString (string fileName) => Convert.ToHexString(Hash(fileName)); + + /// + /// Получение md5-хэша файла и вывод в строке. + /// + /// Загружаемый файл + /// Срока с хэшем файла + public static string HashString (IFormFile file) => Convert.ToHexString(Hash(file)); + + /// + /// Получает MIME-тип файла + /// + /// Имя файла + /// MIME-тип файла + public static string MIMEType (string filename) => + MimeTypes.GetMimeType(filename); + + /// + /// Получает MIME-тип файла + /// + /// Загружаемый файл + /// MIME-тип файла + public static string MIMEType (IFormFile file) => + file.ContentType; +} \ No newline at end of file diff --git a/anbs_cp/anbs_cp.csproj b/anbs_cp/anbs_cp.csproj index 3400fff..b3ae293 100644 --- a/anbs_cp/anbs_cp.csproj +++ b/anbs_cp/anbs_cp.csproj @@ -2,7 +2,7 @@ net7.0 - 1.2022.1130 + 2022.1203.1 Alexander Babaev ANB Software Components Pack Library of some useful functions in C# language. @@ -15,8 +15,8 @@ True https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack - 1.2022.1130 - 1.2022.1130 + 2022.1203.1 + 2022.1203.1 ANBSoftware.ComponentsPack MIT 6.0 @@ -27,16 +27,20 @@ 7 True + none 7 True + none + + diff --git a/anbsoftware.componentspack.sln.DotSettings b/anbsoftware.componentspack.sln.DotSettings index 5d94243..68f48c1 100644 --- a/anbsoftware.componentspack.sln.DotSettings +++ b/anbsoftware.componentspack.sln.DotSettings @@ -2,4 +2,7 @@ True True True - True \ No newline at end of file + True + True + True + True \ No newline at end of file diff --git a/demo/CountValueTest.Designer.cs b/demo/CountValueTest.Designer.cs index 19fd306..aef3ab5 100644 --- a/demo/CountValueTest.Designer.cs +++ b/demo/CountValueTest.Designer.cs @@ -28,97 +28,98 @@ sealed partial class CountValueTest /// private void InitializeComponent () { - this.InsertDataLabel = new System.Windows.Forms.Label(); - this.InsertDataBox = new System.Windows.Forms.TextBox(); - this.ResultLabel = new System.Windows.Forms.Label(); - this.CalculateButton = new System.Windows.Forms.Button(); - this.SelectFormatterLabel = new System.Windows.Forms.Label(); - this.SelectFormatterBox = new System.Windows.Forms.ComboBox(); - this.SuspendLayout(); - // - // InsertDataLabel - // - this.InsertDataLabel.AutoSize = true; - this.InsertDataLabel.Location = new System.Drawing.Point(12, 66); - this.InsertDataLabel.Name = "InsertDataLabel"; - this.InsertDataLabel.Size = new System.Drawing.Size(197, 17); - this.InsertDataLabel.TabIndex = 0; - this.InsertDataLabel.Text = "&Insert any int value:"; - // - // InsertDataBox - // - this.InsertDataBox.Location = new System.Drawing.Point(12, 86); - this.InsertDataBox.Name = "InsertDataBox"; - this.InsertDataBox.Size = new System.Drawing.Size(246, 24); - this.InsertDataBox.TabIndex = 1; - // - // ResultLabel - // - this.ResultLabel.Dock = System.Windows.Forms.DockStyle.Bottom; - this.ResultLabel.Location = new System.Drawing.Point(0, 143); - this.ResultLabel.Margin = new System.Windows.Forms.Padding(5); - this.ResultLabel.Name = "ResultLabel"; - this.ResultLabel.Padding = new System.Windows.Forms.Padding(5); - this.ResultLabel.Size = new System.Drawing.Size(270, 79); - this.ResultLabel.TabIndex = 2; - this.ResultLabel.Text = "&Insert any int value to insert box above and press \"Calculate\" button to see res" + -"ult..."; - this.ResultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // CalculateButton - // - this.CalculateButton.Location = new System.Drawing.Point(81, 116); - this.CalculateButton.Name = "CalculateButton"; - this.CalculateButton.Size = new System.Drawing.Size(103, 23); - this.CalculateButton.TabIndex = 3; - this.CalculateButton.Text = "Calc&ulate"; - this.CalculateButton.UseVisualStyleBackColor = true; - this.CalculateButton.Click += new System.EventHandler(this.CalculateButton_Click); - // - // SelectFormatterLabel - // - this.SelectFormatterLabel.AutoSize = true; - this.SelectFormatterLabel.Location = new System.Drawing.Point(12, 9); - this.SelectFormatterLabel.Name = "SelectFormatterLabel"; - this.SelectFormatterLabel.Size = new System.Drawing.Size(161, 17); - this.SelectFormatterLabel.TabIndex = 4; - this.SelectFormatterLabel.Text = "&Select formatter:"; - // - // SelectFormatterBox - // - this.SelectFormatterBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.SelectFormatterBox.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.SelectFormatterBox.FormattingEnabled = true; - this.SelectFormatterBox.Items.AddRange(new object[] { - "CountFormatter", - "FileSizeFormatter"}); - this.SelectFormatterBox.Location = new System.Drawing.Point(12, 29); - this.SelectFormatterBox.Name = "SelectFormatterBox"; - this.SelectFormatterBox.Size = new System.Drawing.Size(246, 25); - this.SelectFormatterBox.TabIndex = 5; - // - // CountValueTest - // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(270, 222); - this.Controls.Add(this.SelectFormatterBox); - this.Controls.Add(this.SelectFormatterLabel); - this.Controls.Add(this.CalculateButton); - this.Controls.Add(this.ResultLabel); - this.Controls.Add(this.InsertDataBox); - this.Controls.Add(this.InsertDataLabel); - this.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "CountValueTest"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Formatter Test Unit"; - this.Load += new System.EventHandler(this.CountValueTest_Load); - this.ResumeLayout(false); - this.PerformLayout(); + this.InsertDataLabel = new System.Windows.Forms.Label(); + this.InsertDataBox = new System.Windows.Forms.TextBox(); + this.ResultLabel = new System.Windows.Forms.Label(); + this.CalculateButton = new System.Windows.Forms.Button(); + this.SelectFormatterLabel = new System.Windows.Forms.Label(); + this.SelectFormatterBox = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // InsertDataLabel + // + this.InsertDataLabel.AutoSize = true; + this.InsertDataLabel.Location = new System.Drawing.Point(12, 66); + this.InsertDataLabel.Name = "InsertDataLabel"; + this.InsertDataLabel.Size = new System.Drawing.Size(341, 17); + this.InsertDataLabel.TabIndex = 0; + this.InsertDataLabel.Text = "&Введите любое целочисленное значение:"; + // + // InsertDataBox + // + this.InsertDataBox.Location = new System.Drawing.Point(12, 86); + this.InsertDataBox.Name = "InsertDataBox"; + this.InsertDataBox.Size = new System.Drawing.Size(341, 24); + this.InsertDataBox.TabIndex = 1; + this.InsertDataBox.TextChanged += new System.EventHandler(this.InsertDataBox_TextChanged); + // + // ResultLabel + // + this.ResultLabel.Dock = System.Windows.Forms.DockStyle.Bottom; + this.ResultLabel.Location = new System.Drawing.Point(0, 143); + this.ResultLabel.Margin = new System.Windows.Forms.Padding(5); + this.ResultLabel.Name = "ResultLabel"; + this.ResultLabel.Padding = new System.Windows.Forms.Padding(5); + this.ResultLabel.Size = new System.Drawing.Size(365, 79); + this.ResultLabel.TabIndex = 2; + this.ResultLabel.Text = "&Вставьте любое целочисленное значение в поле выше и нажмите кнопку \"Вычислить\", " + + "чтобы увидеть результат..."; + this.ResultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // CalculateButton + // + this.CalculateButton.Location = new System.Drawing.Point(140, 116); + this.CalculateButton.Name = "CalculateButton"; + this.CalculateButton.Size = new System.Drawing.Size(103, 23); + this.CalculateButton.TabIndex = 3; + this.CalculateButton.Text = "В&ычислить"; + this.CalculateButton.UseVisualStyleBackColor = true; + this.CalculateButton.Click += new System.EventHandler(this.CalculateButton_Click); + // + // SelectFormatterLabel + // + this.SelectFormatterLabel.AutoSize = true; + this.SelectFormatterLabel.Location = new System.Drawing.Point(12, 9); + this.SelectFormatterLabel.Name = "SelectFormatterLabel"; + this.SelectFormatterLabel.Size = new System.Drawing.Size(188, 17); + this.SelectFormatterLabel.TabIndex = 4; + this.SelectFormatterLabel.Text = "В&ыберете обработчик:"; + // + // SelectFormatterBox + // + this.SelectFormatterBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.SelectFormatterBox.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.SelectFormatterBox.FormattingEnabled = true; + this.SelectFormatterBox.Items.AddRange(new object[] { + "Обработчик счёта", + "Обработчик размера файла"}); + this.SelectFormatterBox.Location = new System.Drawing.Point(12, 29); + this.SelectFormatterBox.Name = "SelectFormatterBox"; + this.SelectFormatterBox.Size = new System.Drawing.Size(341, 25); + this.SelectFormatterBox.TabIndex = 5; + // + // CountValueTest + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(365, 222); + this.Controls.Add(this.SelectFormatterBox); + this.Controls.Add(this.SelectFormatterLabel); + this.Controls.Add(this.CalculateButton); + this.Controls.Add(this.ResultLabel); + this.Controls.Add(this.InsertDataBox); + this.Controls.Add(this.InsertDataLabel); + this.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "CountValueTest"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Тест модуля форматирования строки"; + this.Load += new System.EventHandler(this.CountValueTest_Load); + this.ResumeLayout(false); + this.PerformLayout(); } diff --git a/demo/CountValueTest.cs b/demo/CountValueTest.cs index 413373c..e8c7202 100644 --- a/demo/CountValueTest.cs +++ b/demo/CountValueTest.cs @@ -29,4 +29,12 @@ public sealed partial class CountValueTest: Form { SelectFormatterBox.SelectedIndex = 0; } + + private void InsertDataBox_TextChanged (object sender, EventArgs e) + { + ulong value = TypeConverter.StrToUInt64(InsertDataBox.Text); + + if (value > long.MaxValue) + InsertDataBox.Text = long.MaxValue.ToString(); + } } \ No newline at end of file diff --git a/demo/FileHashAndMimeTypeTest.Designer.cs b/demo/FileHashAndMimeTypeTest.Designer.cs new file mode 100644 index 0000000..bb6e4f9 --- /dev/null +++ b/demo/FileHashAndMimeTypeTest.Designer.cs @@ -0,0 +1,125 @@ +namespace demo; + +sealed partial class FileHashAndMimeType +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose (bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent () + { + this.ResultLabel = new System.Windows.Forms.Label(); + this.SelectFileLabel = new System.Windows.Forms.Label(); + this.fileNameEdt = new System.Windows.Forms.TextBox(); + this.ViewButton = new System.Windows.Forms.Button(); + this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.topPanel = new System.Windows.Forms.Panel(); + this.topPanel.SuspendLayout(); + this.SuspendLayout(); + // + // ResultLabel + // + this.ResultLabel.Dock = System.Windows.Forms.DockStyle.Fill; + this.ResultLabel.Location = new System.Drawing.Point(0, 0); + this.ResultLabel.Margin = new System.Windows.Forms.Padding(5); + this.ResultLabel.Name = "ResultLabel"; + this.ResultLabel.Padding = new System.Windows.Forms.Padding(5); + this.ResultLabel.Size = new System.Drawing.Size(412, 428); + this.ResultLabel.TabIndex = 2; + this.ResultLabel.Text = "В&ыберете файл (введите ипя файла с полным путём вверху или с помощью диалога, на" + + "жав \"Обзор\")..."; + this.ResultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // SelectFileLabel + // + this.SelectFileLabel.AutoSize = true; + this.SelectFileLabel.Location = new System.Drawing.Point(3, 11); + this.SelectFileLabel.Name = "SelectFileLabel"; + this.SelectFileLabel.Size = new System.Drawing.Size(134, 17); + this.SelectFileLabel.TabIndex = 4; + this.SelectFileLabel.Text = "В&ыберете файл:"; + // + // fileNameEdt + // + this.fileNameEdt.Location = new System.Drawing.Point(3, 38); + this.fileNameEdt.Name = "fileNameEdt"; + this.fileNameEdt.Size = new System.Drawing.Size(288, 24); + this.fileNameEdt.TabIndex = 5; + this.fileNameEdt.TextChanged += new System.EventHandler(this.fileNameEdt_TextChanged); + // + // ViewButton + // + this.ViewButton.Location = new System.Drawing.Point(297, 39); + this.ViewButton.Name = "ViewButton"; + this.ViewButton.Size = new System.Drawing.Size(103, 23); + this.ViewButton.TabIndex = 3; + this.ViewButton.Text = "&Обзор"; + this.ViewButton.UseVisualStyleBackColor = true; + this.ViewButton.Click += new System.EventHandler(this.ViewButton_Click); + // + // openFileDialog + // + this.openFileDialog.AddToRecent = false; + this.openFileDialog.Filter = "Все файлы|*.*"; + this.openFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog_FileOk); + // + // topPanel + // + this.topPanel.Controls.Add(this.SelectFileLabel); + this.topPanel.Controls.Add(this.ViewButton); + this.topPanel.Controls.Add(this.fileNameEdt); + this.topPanel.Dock = System.Windows.Forms.DockStyle.Top; + this.topPanel.Location = new System.Drawing.Point(0, 0); + this.topPanel.Name = "topPanel"; + this.topPanel.Size = new System.Drawing.Size(412, 74); + this.topPanel.TabIndex = 6; + // + // FileHashAndMimeType + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(412, 428); + this.Controls.Add(this.topPanel); + this.Controls.Add(this.ResultLabel); + this.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FileHashAndMimeType"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Получение хэша и MIME-типа файла"; + this.topPanel.ResumeLayout(false); + this.topPanel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + private Label ResultLabel; + private Label SelectFileLabel; + private TextBox fileNameEdt; + private Button ViewButton; + private OpenFileDialog openFileDialog; + private Panel topPanel; +} \ No newline at end of file diff --git a/demo/FileHashAndMimeTypeTest.cs b/demo/FileHashAndMimeTypeTest.cs new file mode 100644 index 0000000..0cc25ad --- /dev/null +++ b/demo/FileHashAndMimeTypeTest.cs @@ -0,0 +1,42 @@ +using anbs_cp.Classes; +// ReSharper disable LocalizableElement + +namespace demo; + +public sealed partial class FileHashAndMimeType: Form +{ + public FileHashAndMimeType () + { + InitializeComponent(); + } + + private void ViewButton_Click (object sender, EventArgs e) + { + openFileDialog.ShowDialog(); + } + +private void GetFileHashAndMimeType() + { + if (string.IsNullOrEmpty(fileNameEdt.Text)) + { + ResultLabel.Text = " !"; + return; + } + + string fileHash = FileExtension.HashString(fileNameEdt.Text); + string fileType = FileExtension.MIMEType(fileNameEdt.Text); + + ResultLabel.Text = + $" \r\n{fileNameEdt.Text}\r\n :\r\n{fileHash}\r\n :\r\n{fileType}"; + } + + private void openFileDialog_FileOk (object sender, System.ComponentModel.CancelEventArgs e) + { + fileNameEdt.Text = openFileDialog.FileName; + } + + private void fileNameEdt_TextChanged (object sender, EventArgs e) + { + GetFileHashAndMimeType(); + } +} \ No newline at end of file diff --git a/demo/FileHashAndMimeTypeTest.resx b/demo/FileHashAndMimeTypeTest.resx new file mode 100644 index 0000000..e6275bd --- /dev/null +++ b/demo/FileHashAndMimeTypeTest.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/demo/MainMenu.Designer.cs b/demo/MainMenu.Designer.cs index 9f45d05..133bf74 100644 --- a/demo/MainMenu.Designer.cs +++ b/demo/MainMenu.Designer.cs @@ -30,6 +30,7 @@ sealed partial class MainMenu { this.CountValueTest = new System.Windows.Forms.Button(); this.SimpleMapperTest = new System.Windows.Forms.Button(); + this.FileExtensionTest = new System.Windows.Forms.Button(); this.SuspendLayout(); // // CountValueTest @@ -38,7 +39,7 @@ sealed partial class MainMenu this.CountValueTest.Name = "CountValueTest"; this.CountValueTest.Size = new System.Drawing.Size(337, 53); this.CountValueTest.TabIndex = 0; - this.CountValueTest.Text = "New CountValue Test"; + this.CountValueTest.Text = "Новый тест модуля форматирования строки"; this.CountValueTest.UseVisualStyleBackColor = true; this.CountValueTest.Click += new System.EventHandler(this.button1_Click); // @@ -48,22 +49,34 @@ sealed partial class MainMenu this.SimpleMapperTest.Name = "SimpleMapperTest"; this.SimpleMapperTest.Size = new System.Drawing.Size(335, 51); this.SimpleMapperTest.TabIndex = 1; - this.SimpleMapperTest.Text = "New SimpleMapper test"; + this.SimpleMapperTest.Text = "Новый тест модуля SimpleMapper"; this.SimpleMapperTest.UseVisualStyleBackColor = true; this.SimpleMapperTest.Click += new System.EventHandler(this.SimpleMapperTest_Click); // + // FileExtensionTest + // + this.FileExtensionTest.Location = new System.Drawing.Point(12, 128); + this.FileExtensionTest.Name = "FileExtensionTest"; + this.FileExtensionTest.Size = new System.Drawing.Size(335, 51); + this.FileExtensionTest.TabIndex = 2; + this.FileExtensionTest.Text = "Новый тест модуля FileExtension"; + this.FileExtensionTest.UseVisualStyleBackColor = true; + this.FileExtensionTest.Click += new System.EventHandler(this.FileExtensionTest_Click); + // // MainMenu // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(361, 252); + this.Controls.Add(this.FileExtensionTest); this.Controls.Add(this.SimpleMapperTest); this.Controls.Add(this.CountValueTest); this.Font = new System.Drawing.Font("Times New Roman", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Margin = new System.Windows.Forms.Padding(4); this.Name = "MainMenu"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Main menu"; + this.Text = "Главное меню"; this.ResumeLayout(false); } @@ -72,4 +85,5 @@ sealed partial class MainMenu private Button CountValueTest; private Button SimpleMapperTest; + private Button FileExtensionTest; } diff --git a/demo/MainMenu.cs b/demo/MainMenu.cs index cf9b2af..c85a8f8 100644 --- a/demo/MainMenu.cs +++ b/demo/MainMenu.cs @@ -17,4 +17,10 @@ public sealed partial class MainMenu: Form SampleMapperTest formSampleMapperTest = new(); formSampleMapperTest.ShowDialog(); } + + private void FileExtensionTest_Click (object sender, EventArgs e) + { + FileHashAndMimeType formTest = new(); + formTest.ShowDialog(); + } } diff --git a/demo/SampleMapperTest.Designer.cs b/demo/SampleMapperTest.Designer.cs index 8e5fc9f..6b6ca92 100644 --- a/demo/SampleMapperTest.Designer.cs +++ b/demo/SampleMapperTest.Designer.cs @@ -81,7 +81,7 @@ sealed partial class SampleMapperTest this.MapBtn.Name = "MapBtn"; this.MapBtn.Size = new System.Drawing.Size(737, 57); this.MapBtn.TabIndex = 5; - this.MapBtn.Text = "MAP"; + this.MapBtn.Text = "СВЯЗАТЬ"; this.MapBtn.UseVisualStyleBackColor = true; this.MapBtn.Click += new System.EventHandler(this.MapBtn_Click); // @@ -142,9 +142,9 @@ sealed partial class SampleMapperTest this.MapModeLabel.AutoSize = true; this.MapModeLabel.Location = new System.Drawing.Point(32, 230); this.MapModeLabel.Name = "MapModeLabel"; - this.MapModeLabel.Size = new System.Drawing.Size(91, 21); + this.MapModeLabel.Size = new System.Drawing.Size(167, 21); this.MapModeLabel.TabIndex = 11; - this.MapModeLabel.Text = "Map mode"; + this.MapModeLabel.Text = "Режим связывания:"; // // SampleMapperTest // @@ -166,7 +166,7 @@ sealed partial class SampleMapperTest this.Margin = new System.Windows.Forms.Padding(4); this.Name = "SampleMapperTest"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "SampleMapper test"; + this.Text = "Тест класса SampleMapper"; ((System.ComponentModel.ISupportInitialize)(this.DemoIntEdt)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/demo/SampleMapperTest.cs b/demo/SampleMapperTest.cs index cab7845..0890aa8 100644 --- a/demo/SampleMapperTest.cs +++ b/demo/SampleMapperTest.cs @@ -41,9 +41,8 @@ public sealed partial class SampleMapperTest: Form string serialize2 = JsonConvert.SerializeObject(demo2); - ResultArea.Text = $@"Demo2 Class before map: - {serialize1} - and after:{serialize2}"; + // ReSharper disable once LocalizableElement + ResultArea.Text = $"Класс Demo2 до связывания:\r\n{serialize1}\r\nи после:\r\n{serialize2}"; } } diff --git a/demo/demo.csproj b/demo/demo.csproj index ac4ebca..d1ba3bc 100644 --- a/demo/demo.csproj +++ b/demo/demo.csproj @@ -26,4 +26,10 @@ + + + Form + + + \ No newline at end of file