commit 9794a690ec16819dd79c5b47eaedc28255612e8e Author: Lev Rusanov <30170278+JDM170@users.noreply.github.com> Date: Sun Mar 12 16:11:19 2023 +0700 Первый коммит и промежуточный результат Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com> diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..be82272 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +# Visual Studio 2015/2017 cache/options directory +.vs/ + +# User-specific files +*.csproj.user + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ diff --git a/App.config b/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Form1.Designer.cs b/Form1.Designer.cs new file mode 100644 index 0000000..d7f695d --- /dev/null +++ b/Form1.Designer.cs @@ -0,0 +1,176 @@ +namespace WindowsFormsApp1 +{ + partial class Form1 + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором форм Windows + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.btn_start = new System.Windows.Forms.Button(); + this.btn_stop = new System.Windows.Forms.Button(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.lbl_pass_count = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.lbl_err_count = new System.Windows.Forms.Label(); + this.trackBar1 = new System.Windows.Forms.TrackBar(); + this.label2 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit(); + this.SuspendLayout(); + // + // btn_start + // + this.btn_start.Location = new System.Drawing.Point(30, 26); + this.btn_start.Name = "btn_start"; + this.btn_start.Size = new System.Drawing.Size(75, 23); + this.btn_start.TabIndex = 0; + this.btn_start.Text = "Старт"; + this.btn_start.UseVisualStyleBackColor = true; + this.btn_start.Click += new System.EventHandler(this.btn_start_Click); + // + // btn_stop + // + this.btn_stop.Location = new System.Drawing.Point(136, 26); + this.btn_stop.Name = "btn_stop"; + this.btn_stop.Size = new System.Drawing.Size(75, 23); + this.btn_stop.TabIndex = 1; + this.btn_stop.Text = "Стоп"; + this.btn_stop.UseVisualStyleBackColor = true; + this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click); + // + // textBox1 + // + this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.textBox1.Location = new System.Drawing.Point(30, 67); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(306, 31); + this.textBox1.TabIndex = 2; + this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(30, 120); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(60, 13); + this.label1.TabIndex = 3; + this.label1.Text = "Пройдено:"; + // + // lbl_pass_count + // + this.lbl_pass_count.AutoSize = true; + this.lbl_pass_count.BackColor = System.Drawing.SystemColors.Control; + this.lbl_pass_count.Location = new System.Drawing.Point(92, 120); + this.lbl_pass_count.Name = "lbl_pass_count"; + this.lbl_pass_count.Size = new System.Drawing.Size(13, 13); + this.lbl_pass_count.TabIndex = 4; + this.lbl_pass_count.Text = "0"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(30, 158); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(50, 13); + this.label3.TabIndex = 5; + this.label3.Text = "Ошибок:"; + // + // lbl_err_count + // + this.lbl_err_count.AutoSize = true; + this.lbl_err_count.Location = new System.Drawing.Point(92, 158); + this.lbl_err_count.Name = "lbl_err_count"; + this.lbl_err_count.Size = new System.Drawing.Size(13, 13); + this.lbl_err_count.TabIndex = 6; + this.lbl_err_count.Text = "0"; + // + // trackBar1 + // + this.trackBar1.Location = new System.Drawing.Point(179, 126); + this.trackBar1.Name = "trackBar1"; + this.trackBar1.Size = new System.Drawing.Size(157, 45); + this.trackBar1.TabIndex = 7; + this.trackBar1.Visible = false; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(161, 158); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(63, 13); + this.label2.TabIndex = 8; + this.label2.Text = "медленнее"; + this.label2.Visible = false; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(298, 158); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(50, 13); + this.label4.TabIndex = 9; + this.label4.Text = "быстрее"; + this.label4.Visible = false; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(370, 204); + this.Controls.Add(this.label4); + this.Controls.Add(this.label2); + this.Controls.Add(this.trackBar1); + this.Controls.Add(this.lbl_err_count); + this.Controls.Add(this.label3); + this.Controls.Add(this.lbl_pass_count); + this.Controls.Add(this.label1); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.btn_stop); + this.Controls.Add(this.btn_start); + this.Name = "Form1"; + this.Text = "Учимся печатать быстро"; + ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btn_start; + private System.Windows.Forms.Button btn_stop; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label lbl_pass_count; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label lbl_err_count; + private System.Windows.Forms.TrackBar trackBar1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label4; + } +} + diff --git a/Form1.cs b/Form1.cs new file mode 100644 index 0000000..f31981c --- /dev/null +++ b/Form1.cs @@ -0,0 +1,88 @@ +using System; +/*using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks;*/ +using System.Windows.Forms; + + +namespace WindowsFormsApp1 +{ + public partial class Form1 : Form + { + static int timerStart = 2000; + string str = ""; + int lastSymbol = 0; + int pass_count = 0; + int err_count = 0; + Random rnd = new Random(); + Timer timer = new Timer(); + + public Form1() + { + InitializeComponent(); + } + + private void timerCallback(object sender, EventArgs ea) + { + lastSymbol = rnd.Next(1072, 1103); + if (str.Length < 10) + { + str += (char)lastSymbol; + textBox1.Text = str; + } + else + { + timer.Stop(); + MessageBox.Show("Игра окончена"); + } + } + + private void btn_start_Click(object sender, EventArgs e) + { + pass_count = 0; + err_count = 0; + lbl_pass_count.Text = pass_count.ToString(); + lbl_err_count.Text = err_count.ToString(); + timer.Interval = timerStart; + timer.Tick += new EventHandler(timerCallback); + timer.Start(); + textBox1.Focus(); + } + + private void btn_stop_Click(object sender, EventArgs e) + { + if(timer.Enabled) timer.Stop(); + } + + private void textBox1_KeyPress(object sender, KeyPressEventArgs e) + { + e.Handled = true; + if (timer.Enabled) + { + if (e.KeyChar == lastSymbol) + { + str = str.Substring(0, str.Length - 1); + pass_count++; + textBox1.Text = str; + lbl_pass_count.Text = pass_count.ToString(); + } + else + { + err_count++; + lbl_err_count.Text = err_count.ToString(); + } + } + } + + /*private void trackBar1_ValueChanged(object sender, EventArgs e) + { + textBox2.Clear(); + textBox2.Text += trackBar1.Value.ToString(); + }*/ + } +} diff --git a/Form1.resx b/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..38ed89c --- /dev/null +++ b/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WindowsFormsApp1 +{ + internal static class Program + { + /// + /// Главная точка входа для приложения. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2debda7 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанных со сборкой. +[assembly: AssemblyTitle("WindowsFormsApp1")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WindowsFormsApp1")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, следует установить атрибут ComVisible в TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("5f9de337-1610-4fc7-aa64-a27f19de5819")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..3ab32fe --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программным средством. +// Версия среды выполнения: 4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если +// код создан повторно. +// +//------------------------------------------------------------------------------ + +namespace WindowsFormsApp1.Properties +{ + + + /// + /// Класс ресурсов со строгим типом для поиска локализованных строк и пр. + /// + // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder + // класс с помощью таких средств, как ResGen или Visual Studio. + // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen + // с параметром /str или заново постройте свой VS-проект. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp1.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Переопределяет свойство CurrentUICulture текущего потока для всех + /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..438df21 --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WindowsFormsApp1.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/WindowsFormsApp1.csproj b/WindowsFormsApp1.csproj new file mode 100644 index 0000000..144c6f5 --- /dev/null +++ b/WindowsFormsApp1.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {5F9DE337-1610-4FC7-AA64-A27F19DE5819} + WinExe + WindowsFormsApp1 + WindowsFormsApp1 + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/WindowsFormsApp1.sln b/WindowsFormsApp1.sln new file mode 100644 index 0000000..20757f2 --- /dev/null +++ b/WindowsFormsApp1.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33103.184 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1", "WindowsFormsApp1.csproj", "{5F9DE337-1610-4FC7-AA64-A27F19DE5819}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5F9DE337-1610-4FC7-AA64-A27F19DE5819}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F9DE337-1610-4FC7-AA64-A27F19DE5819}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F9DE337-1610-4FC7-AA64-A27F19DE5819}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F9DE337-1610-4FC7-AA64-A27F19DE5819}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1360BD4A-C379-4F5F-AA15-A5F35B10A702} + EndGlobalSection +EndGlobal