diff --git a/Shop/Shop.sln b/Shop/Shop.sln new file mode 100644 index 0000000..20ec905 --- /dev/null +++ b/Shop/Shop.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32126.317 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShopWin", "Shop\ShopWin.csproj", "{F7EC9EF3-27BF-45DC-BED7-9FDB433EA174}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F7EC9EF3-27BF-45DC-BED7-9FDB433EA174}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7EC9EF3-27BF-45DC-BED7-9FDB433EA174}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7EC9EF3-27BF-45DC-BED7-9FDB433EA174}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7EC9EF3-27BF-45DC-BED7-9FDB433EA174}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EB5A0A33-47CA-43C4-9B9D-354293491058} + EndGlobalSection +EndGlobal diff --git a/Shop/Shop/App.config b/Shop/Shop/App.config new file mode 100644 index 0000000..5754728 --- /dev/null +++ b/Shop/Shop/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Shop/Shop/Form1.Designer.cs b/Shop/Shop/Form1.Designer.cs new file mode 100644 index 0000000..786c05b --- /dev/null +++ b/Shop/Shop/Form1.Designer.cs @@ -0,0 +1,260 @@ +namespace ShopWin +{ + partial class Form1 + { + /// + /// 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.components = new System.ComponentModel.Container(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.panel2 = new System.Windows.Forms.Panel(); + this.panel3 = new System.Windows.Forms.Panel(); + this.panel4 = new System.Windows.Forms.Panel(); + this.panel5 = new System.Windows.Forms.Panel(); + this.panel7 = new System.Windows.Forms.Panel(); + this.panel8 = new System.Windows.Forms.Panel(); + this.panel9 = new System.Windows.Forms.Panel(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.panel1.SuspendLayout(); + this.panel2.SuspendLayout(); + this.panel3.SuspendLayout(); + this.panel4.SuspendLayout(); + this.panel5.SuspendLayout(); + this.panel7.SuspendLayout(); + this.panel8.SuspendLayout(); + this.panel9.SuspendLayout(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(282, 13); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(100, 20); + this.textBox1.TabIndex = 0; + // + // panel1 + // + this.panel1.Controls.Add(this.panel9); + this.panel1.Controls.Add(this.panel8); + this.panel1.Controls.Add(this.panel7); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 350); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(800, 100); + this.panel1.TabIndex = 1; + // + // panel2 + // + this.panel2.Controls.Add(this.textBox2); + this.panel2.Controls.Add(this.panel5); + this.panel2.Controls.Add(this.panel4); + this.panel2.Controls.Add(this.panel3); + this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel2.Location = new System.Drawing.Point(0, 250); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(800, 100); + this.panel2.TabIndex = 3; + // + // panel3 + // + this.panel3.Controls.Add(this.groupBox1); + this.panel3.Dock = System.Windows.Forms.DockStyle.Left; + this.panel3.Location = new System.Drawing.Point(0, 0); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(111, 100); + this.panel3.TabIndex = 4; + // + // panel4 + // + this.panel4.Controls.Add(this.groupBox2); + this.panel4.Dock = System.Windows.Forms.DockStyle.Left; + this.panel4.Location = new System.Drawing.Point(111, 0); + this.panel4.Name = "panel4"; + this.panel4.Size = new System.Drawing.Size(111, 100); + this.panel4.TabIndex = 5; + // + // panel5 + // + this.panel5.Controls.Add(this.groupBox3); + this.panel5.Dock = System.Windows.Forms.DockStyle.Left; + this.panel5.Location = new System.Drawing.Point(222, 0); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(111, 100); + this.panel5.TabIndex = 6; + // + // panel7 + // + this.panel7.Controls.Add(this.groupBox4); + this.panel7.Dock = System.Windows.Forms.DockStyle.Left; + this.panel7.Location = new System.Drawing.Point(0, 0); + this.panel7.Name = "panel7"; + this.panel7.Size = new System.Drawing.Size(111, 100); + this.panel7.TabIndex = 5; + // + // panel8 + // + this.panel8.Controls.Add(this.groupBox5); + this.panel8.Dock = System.Windows.Forms.DockStyle.Left; + this.panel8.Location = new System.Drawing.Point(111, 0); + this.panel8.Name = "panel8"; + this.panel8.Size = new System.Drawing.Size(111, 100); + this.panel8.TabIndex = 6; + // + // panel9 + // + this.panel9.Controls.Add(this.groupBox6); + this.panel9.Dock = System.Windows.Forms.DockStyle.Left; + this.panel9.Location = new System.Drawing.Point(222, 0); + this.panel9.Name = "panel9"; + this.panel9.Size = new System.Drawing.Size(111, 100); + this.panel9.TabIndex = 7; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(362, 39); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(100, 20); + this.textBox2.TabIndex = 7; + // + // groupBox1 + // + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox1.Location = new System.Drawing.Point(0, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(111, 100); + this.groupBox1.TabIndex = 1; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "groupBox1"; + // + // groupBox2 + // + this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox2.Location = new System.Drawing.Point(0, 0); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(111, 100); + this.groupBox2.TabIndex = 2; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "groupBox2"; + // + // groupBox3 + // + this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox3.Location = new System.Drawing.Point(0, 0); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(111, 100); + this.groupBox3.TabIndex = 2; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "groupBox3"; + // + // groupBox4 + // + this.groupBox4.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox4.Location = new System.Drawing.Point(0, 0); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(111, 100); + this.groupBox4.TabIndex = 2; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "groupBox4"; + // + // groupBox5 + // + this.groupBox5.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox5.Location = new System.Drawing.Point(0, 0); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Size = new System.Drawing.Size(111, 100); + this.groupBox5.TabIndex = 2; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "groupBox5"; + // + // groupBox6 + // + this.groupBox6.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox6.Location = new System.Drawing.Point(0, 0); + this.groupBox6.Name = "groupBox6"; + this.groupBox6.Size = new System.Drawing.Size(111, 100); + this.groupBox6.TabIndex = 2; + this.groupBox6.TabStop = false; + this.groupBox6.Text = "groupBox6"; + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Interval = 200; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.panel2); + this.Controls.Add(this.panel1); + this.Controls.Add(this.textBox1); + this.Name = "Form1"; + this.Text = "Shop"; + this.panel1.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.panel2.PerformLayout(); + this.panel3.ResumeLayout(false); + this.panel4.ResumeLayout(false); + this.panel5.ResumeLayout(false); + this.panel7.ResumeLayout(false); + this.panel8.ResumeLayout(false); + this.panel9.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Panel panel9; + private System.Windows.Forms.Panel panel8; + private System.Windows.Forms.Panel panel7; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Panel panel5; + private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.GroupBox groupBox6; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Timer timer1; + } +} + diff --git a/Shop/Shop/Form1.cs b/Shop/Shop/Form1.cs new file mode 100644 index 0000000..dfbe3fb --- /dev/null +++ b/Shop/Shop/Form1.cs @@ -0,0 +1,57 @@ +using System; +using System.Drawing; +using System.Windows.Forms; +using ShopWin.Model; + +namespace ShopWin +{ + public partial class Form1 : Form + { + private CShop _shop; + + public Form1() + { + InitializeComponent(); + h_initShop(); + h_RefreshShop(); + } + + private void h_RefreshShop() + { + panel1.BackColor = _shop.ShelfList[1].CheckBrokenState() + ? Color.DarkRed + : Color.Green; + panel2.BackColor = _shop.ShelfList[0].CheckBrokenState() + ? Color.DarkRed + : Color.Green; + + + groupBox1.Text = h_GetGroupboxTitle(_shop.ShelfList[0], 0); + groupBox2.Text = h_GetGroupboxTitle(_shop.ShelfList[0], 1); + groupBox3.Text = h_GetGroupboxTitle(_shop.ShelfList[0], 2); + groupBox4.Text = h_GetGroupboxTitle(_shop.ShelfList[1], 0); + groupBox5.Text = h_GetGroupboxTitle(_shop.ShelfList[1], 1); + groupBox6.Text = h_GetGroupboxTitle(_shop.ShelfList[1], 2); + } + + private string h_GetGroupboxTitle(CShelf cShelf, int v) + { + if (cShelf.ProductList.Count <= v) return "-"; + return cShelf.ProductList[v].Article; + } + + private void h_initShop() + { + _shop = new CShop("Shop1"); + _shop.ShelfList.Add(new CShelf("1")); + _shop.ShelfList.Add(new CShelf("2")); + _shop.FillTest(3); + } + + private void timer1_Tick(object sender, EventArgs e) + { + _shop.Tick(); + h_RefreshShop(); + } + } +} diff --git a/Shop/Shop/Form1.resx b/Shop/Shop/Form1.resx new file mode 100644 index 0000000..aac33d5 --- /dev/null +++ b/Shop/Shop/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/Shop/Shop/Model/CProduct.cs b/Shop/Shop/Model/CProduct.cs new file mode 100644 index 0000000..15b9554 --- /dev/null +++ b/Shop/Shop/Model/CProduct.cs @@ -0,0 +1,43 @@ +using System; + +namespace ShopWin.Model +{ + /// + /// Товар + /// + public class CProduct + { + /// + /// Артикул + /// + public string Article; + /// + /// Наименование + /// + public string Title; + /// + /// Цена + /// + public double Price; + /// + /// Вес + /// + public double Weight; + + public CProduct() + { + Article = DateTime.Now.Millisecond.ToString(); + Title = $"ПРОДУКТ {DateTime.Now.Millisecond}"; + Price = 100 * DateTime.Now.Millisecond; + Weight = DateTime.Now.Millisecond; + } + + public CProduct(string article, string title, double price, double weight) + { + Article = article; + Title = title; + Price = price; + Weight = weight; + } + } +} diff --git a/Shop/Shop/Model/CShelf.cs b/Shop/Shop/Model/CShelf.cs new file mode 100644 index 0000000..98ccc28 --- /dev/null +++ b/Shop/Shop/Model/CShelf.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; +using System.Threading; + +namespace ShopWin.Model +{ + /// + /// Полка + /// + public class CShelf + { + /// + /// Номер полки + /// + public string Number; + /// + /// Максимальный вес товаров + /// + public double MaxWeight; + /// + /// Список продуктов на полке + /// + public List ProductList; + + public CShelf(string number) + { + Number = number; + MaxWeight = 1000; + ProductList = new List(); + } + + public void FillTest(int iCount) + { + for (int ii = 0; ii < iCount; ii++) { + ProductList.Add(new CProduct()); + Thread.Sleep(20); + } + } + + public bool CheckBrokenState() + { + double iSumWeight = 0; + for (int ii = 0; ii < ProductList.Count; ii++) { + iSumWeight += ProductList[ii].Weight; + } + + return iSumWeight > MaxWeight; + } + + + } +} diff --git a/Shop/Shop/Model/CShop.cs b/Shop/Shop/Model/CShop.cs new file mode 100644 index 0000000..2243aaa --- /dev/null +++ b/Shop/Shop/Model/CShop.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; + +namespace ShopWin.Model +{ + /// + /// Магазин + /// + public class CShop + { + private Random _random = new Random(); + public string Title = ""; + public List ShelfList = new List(); + + public CShop(string title) + { + Title = title; + } + + public void Tick() + { + if (_random.Next(0, 10) == 1) { + if (ShelfList[0].ProductList.Count > 0) { + ShelfList[0].ProductList.RemoveAt(0); + } + } + } + + public void FillTest(int iCount) + { + for (int ii = 0; ii < ShelfList.Count; ii++) { + ShelfList[ii].FillTest(iCount); + } + + } + + } +} diff --git a/Shop/Shop/Model/Description.txt b/Shop/Shop/Model/Description.txt new file mode 100644 index 0000000..e3232a8 --- /dev/null +++ b/Shop/Shop/Model/Description.txt @@ -0,0 +1,16 @@ +Магазин и остатки товаров на полках + + +Товар + Артикул + Наименование + Цена + +Полка + номер + товар[] + +Магазин + название + полка[] + diff --git a/Shop/Shop/Program.cs b/Shop/Shop/Program.cs new file mode 100644 index 0000000..b1059a7 --- /dev/null +++ b/Shop/Shop/Program.cs @@ -0,0 +1,19 @@ +using System; +using System.Windows.Forms; + +namespace ShopWin +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Shop/Shop/Properties/AssemblyInfo.cs b/Shop/Shop/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0cf08f9 --- /dev/null +++ b/Shop/Shop/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WindowsFormsApp2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WindowsFormsApp2")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f7ec9ef3-27bf-45dc-bed7-9fdb433ea174")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Shop/Shop/Properties/Resources.Designer.cs b/Shop/Shop/Properties/Resources.Designer.cs new file mode 100644 index 0000000..083a0e0 --- /dev/null +++ b/Shop/Shop/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 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 ShopWin.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ShopWin.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [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/Shop/Shop/Properties/Resources.resx b/Shop/Shop/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/Shop/Shop/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/Shop/Shop/Properties/Settings.Designer.cs b/Shop/Shop/Properties/Settings.Designer.cs new file mode 100644 index 0000000..db2369c --- /dev/null +++ b/Shop/Shop/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 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 ShopWin.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.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/Shop/Shop/Properties/Settings.settings b/Shop/Shop/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/Shop/Shop/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Shop/Shop/ShopWin.csproj b/Shop/Shop/ShopWin.csproj new file mode 100644 index 0000000..42c2cb5 --- /dev/null +++ b/Shop/Shop/ShopWin.csproj @@ -0,0 +1,91 @@ + + + + + Debug + AnyCPU + {F7EC9EF3-27BF-45DC-BED7-9FDB433EA174} + WinExe + ShopWin + ShopWin + 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 + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + \ No newline at end of file diff --git a/WorkField/WorkField.sln b/WorkField/WorkField.sln new file mode 100644 index 0000000..b1e0326 --- /dev/null +++ b/WorkField/WorkField.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32126.317 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkField", "WorkField\WorkField.csproj", "{9BE5A9AD-525E-4094-92DC-D13D6FF659DE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9BE5A9AD-525E-4094-92DC-D13D6FF659DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BE5A9AD-525E-4094-92DC-D13D6FF659DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BE5A9AD-525E-4094-92DC-D13D6FF659DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BE5A9AD-525E-4094-92DC-D13D6FF659DE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F6FACE66-3478-4218-BF76-289314CF5F7E} + EndGlobalSection +EndGlobal diff --git a/WorkField/WorkField/1.bmp b/WorkField/WorkField/1.bmp new file mode 100644 index 0000000..55c21bc Binary files /dev/null and b/WorkField/WorkField/1.bmp differ diff --git a/WorkField/WorkField/App.config b/WorkField/WorkField/App.config new file mode 100644 index 0000000..5754728 --- /dev/null +++ b/WorkField/WorkField/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/WorkField/WorkField/Form1.Designer.cs b/WorkField/WorkField/Form1.Designer.cs new file mode 100644 index 0000000..4a3acb4 --- /dev/null +++ b/WorkField/WorkField/Form1.Designer.cs @@ -0,0 +1,168 @@ +namespace WorkField +{ + partial class Form1 + { + /// + /// 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.components = new System.ComponentModel.Container(); + this.button1 = new System.Windows.Forms.Button(); + this.panel1 = new System.Windows.Forms.Panel(); + this.panel2 = new System.Windows.Forms.Panel(); + this.lab2Y = new System.Windows.Forms.Label(); + this.lab2X = new System.Windows.Forms.Label(); + this.panel3 = new System.Windows.Forms.Panel(); + this.lab1Y = new System.Windows.Forms.Label(); + this.lab1X = new System.Windows.Forms.Label(); + this.btnMove = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.panel2.SuspendLayout(); + this.panel3.SuspendLayout(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(308, 10); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 0; + this.button1.Text = "Добавить игрока"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // panel1 + // + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 52); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(800, 398); + this.panel1.TabIndex = 1; + // + // panel2 + // + this.panel2.Controls.Add(this.lab2Y); + this.panel2.Controls.Add(this.lab2X); + this.panel2.Dock = System.Windows.Forms.DockStyle.Right; + this.panel2.Location = new System.Drawing.Point(690, 0); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(110, 52); + this.panel2.TabIndex = 4; + // + // lab2Y + // + this.lab2Y.AutoSize = true; + this.lab2Y.Location = new System.Drawing.Point(38, 29); + this.lab2Y.Name = "lab2Y"; + this.lab2Y.Size = new System.Drawing.Size(35, 13); + this.lab2Y.TabIndex = 5; + this.lab2Y.Text = "label3"; + // + // lab2X + // + this.lab2X.AutoSize = true; + this.lab2X.Location = new System.Drawing.Point(38, 10); + this.lab2X.Name = "lab2X"; + this.lab2X.Size = new System.Drawing.Size(35, 13); + this.lab2X.TabIndex = 4; + this.lab2X.Text = "label4"; + // + // panel3 + // + this.panel3.Controls.Add(this.lab1Y); + this.panel3.Controls.Add(this.lab1X); + this.panel3.Dock = System.Windows.Forms.DockStyle.Right; + this.panel3.Location = new System.Drawing.Point(580, 0); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(110, 52); + this.panel3.TabIndex = 7; + // + // lab1Y + // + this.lab1Y.AutoSize = true; + this.lab1Y.Location = new System.Drawing.Point(38, 29); + this.lab1Y.Name = "lab1Y"; + this.lab1Y.Size = new System.Drawing.Size(35, 13); + this.lab1Y.TabIndex = 5; + this.lab1Y.Text = "label5"; + // + // lab1X + // + this.lab1X.AutoSize = true; + this.lab1X.Location = new System.Drawing.Point(38, 10); + this.lab1X.Name = "lab1X"; + this.lab1X.Size = new System.Drawing.Size(35, 13); + this.lab1X.TabIndex = 4; + this.lab1X.Text = "label6"; + // + // btnMove + // + this.btnMove.Location = new System.Drawing.Point(389, 10); + this.btnMove.Name = "btnMove"; + this.btnMove.Size = new System.Drawing.Size(75, 23); + this.btnMove.TabIndex = 8; + this.btnMove.Text = "Время!"; + this.btnMove.UseVisualStyleBackColor = true; + this.btnMove.Click += new System.EventHandler(this.btnMove_Click); + // + // timer1 + // + this.timer1.Interval = 1000; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.btnMove); + this.Controls.Add(this.panel3); + this.Controls.Add(this.panel2); + this.Controls.Add(this.panel1); + this.Controls.Add(this.button1); + this.Name = "Form1"; + this.Text = "Стадион"; + this.panel2.ResumeLayout(false); + this.panel2.PerformLayout(); + this.panel3.ResumeLayout(false); + this.panel3.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.Label lab2Y; + private System.Windows.Forms.Label lab2X; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.Label lab1Y; + private System.Windows.Forms.Label lab1X; + private System.Windows.Forms.Button btnMove; + private System.Windows.Forms.Timer timer1; + } +} + diff --git a/WorkField/WorkField/Form1.cs b/WorkField/WorkField/Form1.cs new file mode 100644 index 0000000..3a3c8b0 --- /dev/null +++ b/WorkField/WorkField/Form1.cs @@ -0,0 +1,74 @@ +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; +using WorkField.Model; + +namespace WorkField +{ + public partial class Form1 : Form + { + public CStadium _stadium; + + public Form1() + { + InitializeComponent(); + h_PrepareStadium(); + // h_RefreshPanel(); + } + + private void h_PrepareStadium() + { + _stadium = new CStadium(30, 30); + _stadium.PlayerList.Add( + new CPlayer("player1", 10, 10, _stadium.IsPosition)); + _stadium.PlayerList.Add( + new CPlayer("player2", 25, 10, h_CanMove)); + } + + private bool h_CanMove(int arg1, int arg2) + { + if (DateTime.Now.Second < 30) { + return false; + } + + return true; + } + + private void button1_Click(object sender, EventArgs e) + { + int iNum = _stadium.PlayerList.Count + 1; + _stadium.PlayerList.Add( + new CPlayer($"player{iNum}", + 10, 10 + iNum * 2, h_CanMove)); + } + + private void btnMove_Click(object sender, EventArgs e) + { + timer1.Enabled = !timer1.Enabled; + } + + private void h_RefreshInfo() + { + lab1X.Text = _stadium.PlayerList[0].X.ToString(); + lab1Y.Text = _stadium.PlayerList[0].Y.ToString(); + lab1X.BackColor = _stadium.PlayerList[0].IsFreezed + ? Color.Brown + : Color.Gray; + lab2X.Text = _stadium.PlayerList[1].X.ToString(); + lab2Y.Text = _stadium.PlayerList[1].Y.ToString(); + + } + + private void timer1_Tick(object sender, EventArgs e) + { + //_stadium.Move(); + h_RefreshInfo(); + } + } +} diff --git a/WorkField/WorkField/Form1.resx b/WorkField/WorkField/Form1.resx new file mode 100644 index 0000000..aac33d5 --- /dev/null +++ b/WorkField/WorkField/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/WorkField/WorkField/Model/CPlayer.cs b/WorkField/WorkField/Model/CPlayer.cs new file mode 100644 index 0000000..d095094 --- /dev/null +++ b/WorkField/WorkField/Model/CPlayer.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WorkField.Model +{ + public class CPlayer + { + private Random _rnd = new Random(); + + public string Surname; + public int X; + public int Y; + private readonly Func _fnCanMove; + + public bool IsFreezed + { + get { return DateTime.Now <= UnfreezeTime; } + set + { + if (value) { + UnfreezeTime = DateTime.Now.AddSeconds(3); + } + else { + UnfreezeTime = DateTime.Now; + } + } + } + + private DateTime UnfreezeTime; + + public CPlayer(string surname, int x, int y, + Func fnCanMove) + { + Surname = surname; + X = x; + Y = y; + _fnCanMove = fnCanMove; + UnfreezeTime = DateTime.MinValue; + } + + public void Move() + { + int newX = X + _rnd.Next(-1, 2); + int newY = Y + _rnd.Next(-1, 2); + if (_fnCanMove != null && _fnCanMove(newX, newY)) { + X = newX; + Y = newY; + } + else { + IsFreezed = true; + } + } + } +} diff --git a/WorkField/WorkField/Model/CStadium.cs b/WorkField/WorkField/Model/CStadium.cs new file mode 100644 index 0000000..1050377 --- /dev/null +++ b/WorkField/WorkField/Model/CStadium.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Runtime.Remoting; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace WorkField.Model +{ + /// + /// Стадион + /// + public class CStadium + { + private System.Threading.Timer _timer; + + /// + /// Ширина + /// + public int Width; + /// + /// Длина + /// + public int Height; + /// + /// Список работников + /// + public List PlayerList; + + public CStadium (int width, int height) + { + Width = width; + Height = height; + PlayerList = new List(); + + _timer = new Timer(h_tick, null, + new TimeSpan(0, 0, 0, 0, 300), + new TimeSpan(0, 0, 0, 0, 1000) + ); + } + + private void h_tick(object x) + { + this.Move(); + } + + internal void Move() + { + foreach (CPlayer pPlayer in PlayerList) { + pPlayer.Move(); + } + } + + public bool IsPosition(int newX, int newY) + { + string sFilename = "1.bmp"; + Bitmap pB = new Bitmap(sFilename); + if (newX < 0) return false; + if (newY < 0) return false; + if (newX > pB.Width) return false; + if (newY > pB.Height) return false; + //for (int xx = 0; xx < pB.Width; xx++) { + // for (int yy = 0; yy < pB.Height; yy++) { + Color pColor = pB.GetPixel(newX, newY); + return !(pColor.R == Color.Black.R + && pColor.G == Color.Black.G + && pColor.B == Color.Black.B + ); + // } + //} + return true; + } + } +} diff --git a/WorkField/WorkField/Model/Description.txt b/WorkField/WorkField/Model/Description.txt new file mode 100644 index 0000000..25dfb9c --- /dev/null +++ b/WorkField/WorkField/Model/Description.txt @@ -0,0 +1,14 @@ +Поле с работниками + +Поле + Ширина + Длина + Работник[] + +Работник + Фамилия + X + Y + + + diff --git a/WorkField/WorkField/Program.cs b/WorkField/WorkField/Program.cs new file mode 100644 index 0000000..e2d40df --- /dev/null +++ b/WorkField/WorkField/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WorkField +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/WorkField/WorkField/Properties/AssemblyInfo.cs b/WorkField/WorkField/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..42b6ac3 --- /dev/null +++ b/WorkField/WorkField/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WorkField")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WorkField")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9be5a9ad-525e-4094-92dc-d13d6ff659de")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WorkField/WorkField/Properties/Resources.Designer.cs b/WorkField/WorkField/Properties/Resources.Designer.cs new file mode 100644 index 0000000..fa0745f --- /dev/null +++ b/WorkField/WorkField/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// 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 WorkField.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [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() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [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("WorkField.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [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/WorkField/WorkField/Properties/Resources.resx b/WorkField/WorkField/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/WorkField/WorkField/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/WorkField/WorkField/Properties/Settings.Designer.cs b/WorkField/WorkField/Properties/Settings.Designer.cs new file mode 100644 index 0000000..cc7d6b1 --- /dev/null +++ b/WorkField/WorkField/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 WorkField.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/WorkField/WorkField/Properties/Settings.settings b/WorkField/WorkField/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/WorkField/WorkField/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/WorkField/WorkField/WorkField.csproj b/WorkField/WorkField/WorkField.csproj new file mode 100644 index 0000000..1a11bfc --- /dev/null +++ b/WorkField/WorkField/WorkField.csproj @@ -0,0 +1,92 @@ + + + + + Debug + AnyCPU + {9BE5A9AD-525E-4094-92DC-D13D6FF659DE} + WinExe + WorkField + WorkField + 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 + + + + + + + + + Always + + + + + \ No newline at end of file