Преглед изворни кода

Добавлена 5 лабораторная

Вадим Королёв пре 2 година
родитељ
комит
adcd7f5d67

+ 25 - 0
5 Strings/WinLists.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32802.440
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinLists", "WinLists\WinLists.csproj", "{F022FB97-C0E7-44CB-901A-131627DB66B7}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{F022FB97-C0E7-44CB-901A-131627DB66B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F022FB97-C0E7-44CB-901A-131627DB66B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F022FB97-C0E7-44CB-901A-131627DB66B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F022FB97-C0E7-44CB-901A-131627DB66B7}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {71E2B8BF-30F3-4D67-ACB3-2AC87CBA6F86}
+	EndGlobalSection
+EndGlobal

+ 95 - 0
5 Strings/WinLists/MainForm.Designer.cs

@@ -0,0 +1,95 @@
+
+namespace WinLists
+{
+    partial class MainForm
+    {
+        /// <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.lbItems = new System.Windows.Forms.ListBox();
+            this.btnLaunch = new System.Windows.Forms.Button();
+            this.lblOutput = new System.Windows.Forms.Label();
+            this.SuspendLayout();
+            // 
+            // lbItems
+            // 
+            this.lbItems.FormattingEnabled = true;
+            this.lbItems.ItemHeight = 15;
+            this.lbItems.Items.AddRange(new object[] {
+            "Hello World",
+            "Vadim is the best",
+            "Pascal sucks",
+            "Texbot. By students, for EVERYONE!",
+            "Sample text"});
+            this.lbItems.Location = new System.Drawing.Point(12, 12);
+            this.lbItems.Name = "lbItems";
+            this.lbItems.Size = new System.Drawing.Size(776, 199);
+            this.lbItems.TabIndex = 0;
+            // 
+            // btnLaunch
+            // 
+            this.btnLaunch.Location = new System.Drawing.Point(12, 217);
+            this.btnLaunch.Name = "btnLaunch";
+            this.btnLaunch.Size = new System.Drawing.Size(100, 31);
+            this.btnLaunch.TabIndex = 1;
+            this.btnLaunch.Text = "Пуск";
+            this.btnLaunch.UseVisualStyleBackColor = true;
+            this.btnLaunch.Click += new System.EventHandler(this.btnLaunchClick);
+            // 
+            // lblOutput
+            // 
+            this.lblOutput.AutoSize = true;
+            this.lblOutput.Font = new System.Drawing.Font("Segoe UI Semibold", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
+            this.lblOutput.Location = new System.Drawing.Point(12, 251);
+            this.lblOutput.Name = "lblOutput";
+            this.lblOutput.Size = new System.Drawing.Size(191, 32);
+            this.lblOutput.TabIndex = 2;
+            this.lblOutput.Text = "Надпись ответа";
+            // 
+            // MainForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(800, 450);
+            this.Controls.Add(this.lblOutput);
+            this.Controls.Add(this.btnLaunch);
+            this.Controls.Add(this.lbItems);
+            this.Name = "MainForm";
+            this.Text = "Обработка срок";
+            this.Load += new System.EventHandler(this.MainFormLoad);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.ListBox lbItems;
+        private System.Windows.Forms.Button btnLaunch;
+        private System.Windows.Forms.Label lblOutput;
+    }
+}
+

+ 50 - 0
5 Strings/WinLists/MainForm.cs

@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace WinLists
+{
+    public partial class MainForm : Form
+    {
+        public MainForm()
+        {
+            InitializeComponent();
+        }
+
+        private void MainFormLoad(object sender, EventArgs e)
+        {
+            lblOutput.Visible = false;
+        }
+
+		/// <summary>
+		/// Вычисление решения по нажатию на кнопку
+		/// </summary>
+        private void btnLaunchClick(object sender, EventArgs e)
+        {
+            // Разбить строку на слова
+            if (lbItems.SelectedIndex == -1) {
+                MessageBox.Show("Выберите элемент из списка!");
+                return;
+            }
+            var words = Convert.ToString(lbItems.Items[lbItems.SelectedIndex]).Split(' ');
+
+            // Пройтись по каждому слову, сформировать строку ответа
+            string output = "";
+            foreach (var word in words)
+            {
+                output += word.Substring(1, word.Length - 1); // Убираем первую букву слова
+                output += " ";
+            }
+
+            // Обновляем надпись
+            lblOutput.Visible = true;
+            lblOutput.Text = output;
+        }
+    }
+}

+ 60 - 0
5 Strings/WinLists/MainForm.resx

@@ -0,0 +1,60 @@
+<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>
+</root>

+ 23 - 0
5 Strings/WinLists/Program.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace WinLists
+{
+    static class Program
+    {
+        /// <summary>
+        ///  The main entry point for the application.
+        /// </summary>
+        [STAThread]
+        static void Main()
+        {
+            Application.SetHighDpiMode(HighDpiMode.SystemAware);
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            Application.Run(new MainForm());
+        }
+    }
+}

+ 9 - 0
5 Strings/WinLists/WinLists.csproj

@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>WinExe</OutputType>
+    <TargetFramework>net5.0-windows</TargetFramework>
+    <UseWindowsForms>true</UseWindowsForms>
+  </PropertyGroup>
+
+</Project>