20221203
This commit is contained in:
parent
f0acfce2f3
commit
f844787c26
71
anbs_cp/Classes/FileExtensions.cs
Normal file
71
anbs_cp/Classes/FileExtensions.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
using MimeKit;
|
||||||
|
|
||||||
|
namespace anbs_cp.Classes;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс -- расширение для класса File
|
||||||
|
/// </summary>
|
||||||
|
public static class FileExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получение md5-хэша файла.
|
||||||
|
/// Взято с https://stackoverflow.com/a/24031467/16469671
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">Имя файла</param>
|
||||||
|
/// <returns>Массив хэша</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение md5-хэша загружаемого файла.
|
||||||
|
/// Взято с https://stackoverflow.com/a/67081012/16469671
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">Загружаемый файл</param>
|
||||||
|
/// <returns>Массив хэша</returns>
|
||||||
|
public static byte[] Hash (IFormFile file)
|
||||||
|
{
|
||||||
|
using MD5 md5 = MD5.Create();
|
||||||
|
using StreamReader streamReader = new(file.OpenReadStream());
|
||||||
|
return md5.ComputeHash(streamReader.BaseStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение md5-хэша файла и вывод в строке.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">Имя файла</param>
|
||||||
|
/// <returns>Срока с хэшем файла</returns>
|
||||||
|
public static string HashString (string fileName) => Convert.ToHexString(Hash(fileName));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение md5-хэша файла и вывод в строке.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">Загружаемый файл</param>
|
||||||
|
/// <returns>Срока с хэшем файла</returns>
|
||||||
|
public static string HashString (IFormFile file) => Convert.ToHexString(Hash(file));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получает MIME-тип файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Имя файла</param>
|
||||||
|
/// <returns>MIME-тип файла</returns>
|
||||||
|
public static string MIMEType (string filename) =>
|
||||||
|
MimeTypes.GetMimeType(filename);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получает MIME-тип файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">Загружаемый файл</param>
|
||||||
|
/// <returns>MIME-тип файла</returns>
|
||||||
|
public static string MIMEType (IFormFile file) =>
|
||||||
|
file.ContentType;
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<Version>1.2022.1130</Version>
|
<Version>2022.1203.1</Version>
|
||||||
<Authors>Alexander Babaev</Authors>
|
<Authors>Alexander Babaev</Authors>
|
||||||
<Product>ANB Software Components Pack</Product>
|
<Product>ANB Software Components Pack</Product>
|
||||||
<Description>Library of some useful functions in C# language.</Description>
|
<Description>Library of some useful functions in C# language.</Description>
|
||||||
@ -15,8 +15,8 @@
|
|||||||
<SignAssembly>True</SignAssembly>
|
<SignAssembly>True</SignAssembly>
|
||||||
<PackageProjectUrl>https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack</PackageProjectUrl>
|
<PackageProjectUrl>https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack</RepositoryUrl>
|
<RepositoryUrl>https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack</RepositoryUrl>
|
||||||
<AssemblyVersion>1.2022.1130</AssemblyVersion>
|
<AssemblyVersion>2022.1203.1</AssemblyVersion>
|
||||||
<FileVersion>1.2022.1130</FileVersion>
|
<FileVersion>2022.1203.1</FileVersion>
|
||||||
<PackageId>ANBSoftware.ComponentsPack</PackageId>
|
<PackageId>ANBSoftware.ComponentsPack</PackageId>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<AnalysisLevel>6.0</AnalysisLevel>
|
<AnalysisLevel>6.0</AnalysisLevel>
|
||||||
@ -27,16 +27,20 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<WarningLevel>7</WarningLevel>
|
<WarningLevel>7</WarningLevel>
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||||
|
<DebugType>none</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
<WarningLevel>7</WarningLevel>
|
<WarningLevel>7</WarningLevel>
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||||
|
<DebugType>none</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.2.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop" Version="17.4.33103.184" />
|
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop" Version="17.4.33103.184" />
|
||||||
|
<PackageReference Include="MimeKitLite" Version="3.4.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -2,4 +2,7 @@
|
|||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=anbs/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=anbs/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0412_0435_0440_043D_0451_043C/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0412_0435_0440_043D_0451_043C/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_041F_0430_0440_0441_0435_0440/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=_041F_0430_0440_0441_0435_0440/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0421_043E_0437_0434_0430_0451_043C/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0421_043E_0437_0434_0430_0451_043C/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0432_0432_0435_0434_0451_043D/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0445_044D_0448_0430/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0445_044D_0448_0435_043C/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
183
demo/CountValueTest.Designer.cs
generated
183
demo/CountValueTest.Designer.cs
generated
@ -28,97 +28,98 @@ sealed partial class CountValueTest
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent ()
|
private void InitializeComponent ()
|
||||||
{
|
{
|
||||||
this.InsertDataLabel = new System.Windows.Forms.Label();
|
this.InsertDataLabel = new System.Windows.Forms.Label();
|
||||||
this.InsertDataBox = new System.Windows.Forms.TextBox();
|
this.InsertDataBox = new System.Windows.Forms.TextBox();
|
||||||
this.ResultLabel = new System.Windows.Forms.Label();
|
this.ResultLabel = new System.Windows.Forms.Label();
|
||||||
this.CalculateButton = new System.Windows.Forms.Button();
|
this.CalculateButton = new System.Windows.Forms.Button();
|
||||||
this.SelectFormatterLabel = new System.Windows.Forms.Label();
|
this.SelectFormatterLabel = new System.Windows.Forms.Label();
|
||||||
this.SelectFormatterBox = new System.Windows.Forms.ComboBox();
|
this.SelectFormatterBox = new System.Windows.Forms.ComboBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// InsertDataLabel
|
// InsertDataLabel
|
||||||
//
|
//
|
||||||
this.InsertDataLabel.AutoSize = true;
|
this.InsertDataLabel.AutoSize = true;
|
||||||
this.InsertDataLabel.Location = new System.Drawing.Point(12, 66);
|
this.InsertDataLabel.Location = new System.Drawing.Point(12, 66);
|
||||||
this.InsertDataLabel.Name = "InsertDataLabel";
|
this.InsertDataLabel.Name = "InsertDataLabel";
|
||||||
this.InsertDataLabel.Size = new System.Drawing.Size(197, 17);
|
this.InsertDataLabel.Size = new System.Drawing.Size(341, 17);
|
||||||
this.InsertDataLabel.TabIndex = 0;
|
this.InsertDataLabel.TabIndex = 0;
|
||||||
this.InsertDataLabel.Text = "&Insert any int value:";
|
this.InsertDataLabel.Text = "&Введите любое целочисленное значение:";
|
||||||
//
|
//
|
||||||
// InsertDataBox
|
// InsertDataBox
|
||||||
//
|
//
|
||||||
this.InsertDataBox.Location = new System.Drawing.Point(12, 86);
|
this.InsertDataBox.Location = new System.Drawing.Point(12, 86);
|
||||||
this.InsertDataBox.Name = "InsertDataBox";
|
this.InsertDataBox.Name = "InsertDataBox";
|
||||||
this.InsertDataBox.Size = new System.Drawing.Size(246, 24);
|
this.InsertDataBox.Size = new System.Drawing.Size(341, 24);
|
||||||
this.InsertDataBox.TabIndex = 1;
|
this.InsertDataBox.TabIndex = 1;
|
||||||
//
|
this.InsertDataBox.TextChanged += new System.EventHandler(this.InsertDataBox_TextChanged);
|
||||||
// ResultLabel
|
//
|
||||||
//
|
// ResultLabel
|
||||||
this.ResultLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
//
|
||||||
this.ResultLabel.Location = new System.Drawing.Point(0, 143);
|
this.ResultLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
this.ResultLabel.Margin = new System.Windows.Forms.Padding(5);
|
this.ResultLabel.Location = new System.Drawing.Point(0, 143);
|
||||||
this.ResultLabel.Name = "ResultLabel";
|
this.ResultLabel.Margin = new System.Windows.Forms.Padding(5);
|
||||||
this.ResultLabel.Padding = new System.Windows.Forms.Padding(5);
|
this.ResultLabel.Name = "ResultLabel";
|
||||||
this.ResultLabel.Size = new System.Drawing.Size(270, 79);
|
this.ResultLabel.Padding = new System.Windows.Forms.Padding(5);
|
||||||
this.ResultLabel.TabIndex = 2;
|
this.ResultLabel.Size = new System.Drawing.Size(365, 79);
|
||||||
this.ResultLabel.Text = "&Insert any int value to insert box above and press \"Calculate\" button to see res" +
|
this.ResultLabel.TabIndex = 2;
|
||||||
"ult...";
|
this.ResultLabel.Text = "&Вставьте любое целочисленное значение в поле выше и нажмите кнопку \"Вычислить\", " +
|
||||||
this.ResultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
"чтобы увидеть результат...";
|
||||||
//
|
this.ResultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
// CalculateButton
|
//
|
||||||
//
|
// CalculateButton
|
||||||
this.CalculateButton.Location = new System.Drawing.Point(81, 116);
|
//
|
||||||
this.CalculateButton.Name = "CalculateButton";
|
this.CalculateButton.Location = new System.Drawing.Point(140, 116);
|
||||||
this.CalculateButton.Size = new System.Drawing.Size(103, 23);
|
this.CalculateButton.Name = "CalculateButton";
|
||||||
this.CalculateButton.TabIndex = 3;
|
this.CalculateButton.Size = new System.Drawing.Size(103, 23);
|
||||||
this.CalculateButton.Text = "Calc&ulate";
|
this.CalculateButton.TabIndex = 3;
|
||||||
this.CalculateButton.UseVisualStyleBackColor = true;
|
this.CalculateButton.Text = "В&ычислить";
|
||||||
this.CalculateButton.Click += new System.EventHandler(this.CalculateButton_Click);
|
this.CalculateButton.UseVisualStyleBackColor = true;
|
||||||
//
|
this.CalculateButton.Click += new System.EventHandler(this.CalculateButton_Click);
|
||||||
// SelectFormatterLabel
|
//
|
||||||
//
|
// SelectFormatterLabel
|
||||||
this.SelectFormatterLabel.AutoSize = true;
|
//
|
||||||
this.SelectFormatterLabel.Location = new System.Drawing.Point(12, 9);
|
this.SelectFormatterLabel.AutoSize = true;
|
||||||
this.SelectFormatterLabel.Name = "SelectFormatterLabel";
|
this.SelectFormatterLabel.Location = new System.Drawing.Point(12, 9);
|
||||||
this.SelectFormatterLabel.Size = new System.Drawing.Size(161, 17);
|
this.SelectFormatterLabel.Name = "SelectFormatterLabel";
|
||||||
this.SelectFormatterLabel.TabIndex = 4;
|
this.SelectFormatterLabel.Size = new System.Drawing.Size(188, 17);
|
||||||
this.SelectFormatterLabel.Text = "&Select formatter:";
|
this.SelectFormatterLabel.TabIndex = 4;
|
||||||
//
|
this.SelectFormatterLabel.Text = "В&ыберете обработчик:";
|
||||||
// SelectFormatterBox
|
//
|
||||||
//
|
// SelectFormatterBox
|
||||||
this.SelectFormatterBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
//
|
||||||
this.SelectFormatterBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
this.SelectFormatterBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.SelectFormatterBox.FormattingEnabled = true;
|
this.SelectFormatterBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||||
this.SelectFormatterBox.Items.AddRange(new object[] {
|
this.SelectFormatterBox.FormattingEnabled = true;
|
||||||
"CountFormatter",
|
this.SelectFormatterBox.Items.AddRange(new object[] {
|
||||||
"FileSizeFormatter"});
|
"Обработчик счёта",
|
||||||
this.SelectFormatterBox.Location = new System.Drawing.Point(12, 29);
|
"Обработчик размера файла"});
|
||||||
this.SelectFormatterBox.Name = "SelectFormatterBox";
|
this.SelectFormatterBox.Location = new System.Drawing.Point(12, 29);
|
||||||
this.SelectFormatterBox.Size = new System.Drawing.Size(246, 25);
|
this.SelectFormatterBox.Name = "SelectFormatterBox";
|
||||||
this.SelectFormatterBox.TabIndex = 5;
|
this.SelectFormatterBox.Size = new System.Drawing.Size(341, 25);
|
||||||
//
|
this.SelectFormatterBox.TabIndex = 5;
|
||||||
// CountValueTest
|
//
|
||||||
//
|
// CountValueTest
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F);
|
//
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 17F);
|
||||||
this.ClientSize = new System.Drawing.Size(270, 222);
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.Controls.Add(this.SelectFormatterBox);
|
this.ClientSize = new System.Drawing.Size(365, 222);
|
||||||
this.Controls.Add(this.SelectFormatterLabel);
|
this.Controls.Add(this.SelectFormatterBox);
|
||||||
this.Controls.Add(this.CalculateButton);
|
this.Controls.Add(this.SelectFormatterLabel);
|
||||||
this.Controls.Add(this.ResultLabel);
|
this.Controls.Add(this.CalculateButton);
|
||||||
this.Controls.Add(this.InsertDataBox);
|
this.Controls.Add(this.ResultLabel);
|
||||||
this.Controls.Add(this.InsertDataLabel);
|
this.Controls.Add(this.InsertDataBox);
|
||||||
this.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
this.Controls.Add(this.InsertDataLabel);
|
||||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.Font = new System.Drawing.Font("Courier New", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
this.MaximizeBox = false;
|
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.MinimizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "CountValueTest";
|
this.MinimizeBox = false;
|
||||||
this.ShowIcon = false;
|
this.Name = "CountValueTest";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.ShowIcon = false;
|
||||||
this.Text = "Formatter Test Unit";
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Load += new System.EventHandler(this.CountValueTest_Load);
|
this.Text = "Тест модуля форматирования строки";
|
||||||
this.ResumeLayout(false);
|
this.Load += new System.EventHandler(this.CountValueTest_Load);
|
||||||
this.PerformLayout();
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,4 +29,12 @@ public sealed partial class CountValueTest: Form
|
|||||||
{
|
{
|
||||||
SelectFormatterBox.SelectedIndex = 0;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
125
demo/FileHashAndMimeTypeTest.Designer.cs
generated
Normal file
125
demo/FileHashAndMimeTypeTest.Designer.cs
generated
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
namespace demo;
|
||||||
|
|
||||||
|
sealed partial class FileHashAndMimeType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose (bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
42
demo/FileHashAndMimeTypeTest.cs
Normal file
42
demo/FileHashAndMimeTypeTest.cs
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
63
demo/FileHashAndMimeTypeTest.resx
Normal file
63
demo/FileHashAndMimeTypeTest.resx
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
20
demo/MainMenu.Designer.cs
generated
20
demo/MainMenu.Designer.cs
generated
@ -30,6 +30,7 @@ sealed partial class MainMenu
|
|||||||
{
|
{
|
||||||
this.CountValueTest = new System.Windows.Forms.Button();
|
this.CountValueTest = new System.Windows.Forms.Button();
|
||||||
this.SimpleMapperTest = new System.Windows.Forms.Button();
|
this.SimpleMapperTest = new System.Windows.Forms.Button();
|
||||||
|
this.FileExtensionTest = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// CountValueTest
|
// CountValueTest
|
||||||
@ -38,7 +39,7 @@ sealed partial class MainMenu
|
|||||||
this.CountValueTest.Name = "CountValueTest";
|
this.CountValueTest.Name = "CountValueTest";
|
||||||
this.CountValueTest.Size = new System.Drawing.Size(337, 53);
|
this.CountValueTest.Size = new System.Drawing.Size(337, 53);
|
||||||
this.CountValueTest.TabIndex = 0;
|
this.CountValueTest.TabIndex = 0;
|
||||||
this.CountValueTest.Text = "New CountValue Test";
|
this.CountValueTest.Text = "Новый тест модуля форматирования строки";
|
||||||
this.CountValueTest.UseVisualStyleBackColor = true;
|
this.CountValueTest.UseVisualStyleBackColor = true;
|
||||||
this.CountValueTest.Click += new System.EventHandler(this.button1_Click);
|
this.CountValueTest.Click += new System.EventHandler(this.button1_Click);
|
||||||
//
|
//
|
||||||
@ -48,22 +49,34 @@ sealed partial class MainMenu
|
|||||||
this.SimpleMapperTest.Name = "SimpleMapperTest";
|
this.SimpleMapperTest.Name = "SimpleMapperTest";
|
||||||
this.SimpleMapperTest.Size = new System.Drawing.Size(335, 51);
|
this.SimpleMapperTest.Size = new System.Drawing.Size(335, 51);
|
||||||
this.SimpleMapperTest.TabIndex = 1;
|
this.SimpleMapperTest.TabIndex = 1;
|
||||||
this.SimpleMapperTest.Text = "New SimpleMapper test";
|
this.SimpleMapperTest.Text = "Новый тест модуля SimpleMapper";
|
||||||
this.SimpleMapperTest.UseVisualStyleBackColor = true;
|
this.SimpleMapperTest.UseVisualStyleBackColor = true;
|
||||||
this.SimpleMapperTest.Click += new System.EventHandler(this.SimpleMapperTest_Click);
|
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
|
// MainMenu
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(361, 252);
|
this.ClientSize = new System.Drawing.Size(361, 252);
|
||||||
|
this.Controls.Add(this.FileExtensionTest);
|
||||||
this.Controls.Add(this.SimpleMapperTest);
|
this.Controls.Add(this.SimpleMapperTest);
|
||||||
this.Controls.Add(this.CountValueTest);
|
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.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.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.Name = "MainMenu";
|
this.Name = "MainMenu";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "Main menu";
|
this.Text = "Главное меню";
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -72,4 +85,5 @@ sealed partial class MainMenu
|
|||||||
|
|
||||||
private Button CountValueTest;
|
private Button CountValueTest;
|
||||||
private Button SimpleMapperTest;
|
private Button SimpleMapperTest;
|
||||||
|
private Button FileExtensionTest;
|
||||||
}
|
}
|
||||||
|
@ -17,4 +17,10 @@ public sealed partial class MainMenu: Form
|
|||||||
SampleMapperTest formSampleMapperTest = new();
|
SampleMapperTest formSampleMapperTest = new();
|
||||||
formSampleMapperTest.ShowDialog();
|
formSampleMapperTest.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FileExtensionTest_Click (object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
FileHashAndMimeType formTest = new();
|
||||||
|
formTest.ShowDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
8
demo/SampleMapperTest.Designer.cs
generated
8
demo/SampleMapperTest.Designer.cs
generated
@ -81,7 +81,7 @@ sealed partial class SampleMapperTest
|
|||||||
this.MapBtn.Name = "MapBtn";
|
this.MapBtn.Name = "MapBtn";
|
||||||
this.MapBtn.Size = new System.Drawing.Size(737, 57);
|
this.MapBtn.Size = new System.Drawing.Size(737, 57);
|
||||||
this.MapBtn.TabIndex = 5;
|
this.MapBtn.TabIndex = 5;
|
||||||
this.MapBtn.Text = "MAP";
|
this.MapBtn.Text = "СВЯЗАТЬ";
|
||||||
this.MapBtn.UseVisualStyleBackColor = true;
|
this.MapBtn.UseVisualStyleBackColor = true;
|
||||||
this.MapBtn.Click += new System.EventHandler(this.MapBtn_Click);
|
this.MapBtn.Click += new System.EventHandler(this.MapBtn_Click);
|
||||||
//
|
//
|
||||||
@ -142,9 +142,9 @@ sealed partial class SampleMapperTest
|
|||||||
this.MapModeLabel.AutoSize = true;
|
this.MapModeLabel.AutoSize = true;
|
||||||
this.MapModeLabel.Location = new System.Drawing.Point(32, 230);
|
this.MapModeLabel.Location = new System.Drawing.Point(32, 230);
|
||||||
this.MapModeLabel.Name = "MapModeLabel";
|
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.TabIndex = 11;
|
||||||
this.MapModeLabel.Text = "Map mode";
|
this.MapModeLabel.Text = "Режим связывания:";
|
||||||
//
|
//
|
||||||
// SampleMapperTest
|
// SampleMapperTest
|
||||||
//
|
//
|
||||||
@ -166,7 +166,7 @@ sealed partial class SampleMapperTest
|
|||||||
this.Margin = new System.Windows.Forms.Padding(4);
|
this.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.Name = "SampleMapperTest";
|
this.Name = "SampleMapperTest";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "SampleMapper test";
|
this.Text = "Тест класса SampleMapper";
|
||||||
((System.ComponentModel.ISupportInitialize)(this.DemoIntEdt)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.DemoIntEdt)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
@ -41,9 +41,8 @@ public sealed partial class SampleMapperTest: Form
|
|||||||
|
|
||||||
string serialize2 = JsonConvert.SerializeObject(demo2);
|
string serialize2 = JsonConvert.SerializeObject(demo2);
|
||||||
|
|
||||||
ResultArea.Text = $@"Demo2 Class before map:
|
// ReSharper disable once LocalizableElement
|
||||||
{serialize1}
|
ResultArea.Text = $"Класс Demo2 до связывания:\r\n{serialize1}\r\nи после:\r\n{serialize2}";
|
||||||
and after:{serialize2}";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,4 +26,10 @@
|
|||||||
<ProjectReference Include="..\anbs_cp\anbs_cp.csproj" />
|
<ProjectReference Include="..\anbs_cp\anbs_cp.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="FileHashAndMimeTypeTest.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user