Browse Source

2022.11.12

master
vsa 3 years ago
parent
commit
e998513d7b
  1. 217
      Shop/Shop/Form1.Designer.cs
  2. 40
      Shop/Shop/Form1.cs
  3. 134
      Shop/Shop/ShelfControl.Designer.cs
  4. 51
      Shop/Shop/ShelfControl.cs
  5. 120
      Shop/Shop/ShelfControl.resx
  6. 9
      Shop/Shop/ShopWin.csproj
  7. 59
      WorkField/WorkField/FieldControl.Designer.cs
  8. 27
      WorkField/WorkField/FieldControl.cs
  9. 120
      WorkField/WorkField/FieldControl.resx
  10. 99
      WorkField/WorkField/FieldControlUnit.cs
  11. 83
      WorkField/WorkField/Form1.Designer.cs
  12. 51
      WorkField/WorkField/Form1.cs
  13. 11
      WorkField/WorkField/Model/Block.cs
  14. 100
      WorkField/WorkField/Model/BlockList.cs
  15. 76
      WorkField/WorkField/Model/CStadium.cs
  16. 18
      WorkField/WorkField/Model/Description.txt
  17. 10
      WorkField/WorkField/Model/FieldBlock.cs
  18. 13
      WorkField/WorkField/Model/PlayerBlock.cs
  19. 86
      WorkField/WorkField/Model/Stadium.cs
  20. 10
      WorkField/WorkField/Model/WallBlock.cs
  21. 3
      WorkField/WorkField/Program.cs
  22. 1
      WorkField/WorkField/Properties/AssemblyInfo.cs
  23. 18
      WorkField/WorkField/WorkField.csproj

217
Shop/Shop/Form1.Designer.cs

@ -30,29 +30,29 @@
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.groupBox6 = new System.Windows.Forms.GroupBox();
this.panel8 = new System.Windows.Forms.Panel();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.panel7 = new System.Windows.Forms.Panel();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.panel2 = 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.panel5 = new System.Windows.Forms.Panel();
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.panel4 = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.panel3 = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.panel1.SuspendLayout();
this.panel9.SuspendLayout();
this.panel8.SuspendLayout();
this.panel7.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
this.panel4.SuspendLayout();
this.panel5.SuspendLayout();
this.panel7.SuspendLayout();
this.panel8.SuspendLayout();
this.panel9.SuspendLayout();
this.panel4.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// textBox1
@ -73,44 +73,43 @@
this.panel1.Size = new System.Drawing.Size(800, 100);
this.panel1.TabIndex = 1;
//
// panel2
// panel9
//
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;
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;
//
// panel3
// groupBox6
//
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;
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";
//
// panel4
// panel8
//
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;
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;
//
// panel5
// groupBox5
//
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;
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";
//
// panel7
//
@ -121,23 +120,28 @@
this.panel7.Size = new System.Drawing.Size(111, 100);
this.panel7.TabIndex = 5;
//
// panel8
// groupBox4
//
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;
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";
//
// panel9
// panel2
//
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;
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;
this.panel2.Visible = false;
//
// textBox2
//
@ -146,25 +150,14 @@
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
// panel5
//
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";
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;
//
// groupBox3
//
@ -176,35 +169,43 @@
this.groupBox3.TabStop = false;
this.groupBox3.Text = "groupBox3";
//
// groupBox4
// panel4
//
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";
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;
//
// groupBox5
// groupBox2
//
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";
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";
//
// groupBox6
// panel3
//
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";
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;
//
// 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";
//
// timer1
//
@ -223,14 +224,14 @@
this.Name = "Form1";
this.Text = "Shop";
this.panel1.ResumeLayout(false);
this.panel9.ResumeLayout(false);
this.panel8.ResumeLayout(false);
this.panel7.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.panel4.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();

40
Shop/Shop/Form1.cs

@ -13,11 +13,47 @@ namespace ShopWin
{
InitializeComponent();
h_initShop();
h_initControls();
h_RefreshShop();
}
private void h_initControls()
{
foreach (CShelf pShelf in _shop.ShelfList) {
var panel = new System.Windows.Forms.Panel();
panel.Dock = System.Windows.Forms.DockStyle.Bottom;
panel.Location = new System.Drawing.Point(0, 150);
panel.Name = "panel6";
panel.Size = new System.Drawing.Size(800, 100);
panel.TabIndex = 8;
var shelfControl = new ShelfControl();
shelfControl.Dock = System.Windows.Forms.DockStyle.Fill;
panel.Controls.Add(shelfControl);
shelfControl.Init(pShelf);
Controls.Add(panel);
}
}
private void h_refreshShelfControls(Control parentControl)
{
foreach (Control control in parentControl.Controls) {
if (control is ShelfControl) {
(control as ShelfControl).Refresh();
} else {
h_refreshShelfControls(control);
}
}
}
private void h_RefreshShop()
{
h_refreshShelfControls(this);
panel1.BackColor = _shop.ShelfList[1].CheckBrokenState()
? Color.DarkRed
: Color.Green;
@ -45,6 +81,8 @@ namespace ShopWin
_shop = new CShop("Shop1");
_shop.ShelfList.Add(new CShelf("1", h_OnBreak));
_shop.ShelfList.Add(new CShelf("2", h_OnBreak));
_shop.ShelfList.Add(new CShelf("3", h_OnBreak));
_shop.ShelfList.Add(new CShelf("4", h_OnBreak));
_shop.FillTest(3);
}
@ -58,5 +96,5 @@ namespace ShopWin
// _shop.Tick();
h_RefreshShop();
}
}
}
}

134
Shop/Shop/ShelfControl.Designer.cs

@ -0,0 +1,134 @@
namespace ShopWin
{
partial class ShelfControl
{
/// <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 Component 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.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.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.panel2.SuspendLayout();
this.panel4.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.RosyBrown;
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel1.Location = new System.Drawing.Point(0, 157);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(710, 10);
this.panel1.TabIndex = 0;
//
// panel2
//
this.panel2.Controls.Add(this.panel3);
this.panel2.Controls.Add(this.panel4);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(710, 157);
this.panel2.TabIndex = 1;
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.RosyBrown;
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel3.Location = new System.Drawing.Point(213, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(497, 157);
this.panel3.TabIndex = 2;
//
// panel4
//
this.panel4.Controls.Add(this.listView1);
this.panel4.Dock = System.Windows.Forms.DockStyle.Left;
this.panel4.Location = new System.Drawing.Point(0, 0);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(213, 157);
this.panel4.TabIndex = 2;
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3});
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(0, 0);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(213, 157);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Text = "#";
//
// columnHeader2
//
this.columnHeader2.Text = "Title";
//
// columnHeader3
//
this.columnHeader3.Text = "Weight";
//
// ShelfControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Name = "ShelfControl";
this.Size = new System.Drawing.Size(710, 167);
this.panel2.ResumeLayout(false);
this.panel4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
}
}

51
Shop/Shop/ShelfControl.cs

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShopWin.Model;
namespace ShopWin
{
public partial class ShelfControl : UserControl
{
private CShelf _shelf;
public ShelfControl()
{
InitializeComponent();
}
public void Init(CShelf shelf)
{
_shelf = shelf;
listView1.Tag = _shelf;
}
public void Refresh()
{
if (_shelf == null) return;
listView1.Items.Clear();
for (int index = 0; index < _shelf.ProductList.Count; index++) {
CProduct pGood = _shelf.ProductList[index];
ListViewItem lvi = listView1.Items.Add((index + 1).ToString(), (index + 1).ToString());
lvi.SubItems.Add(pGood.Title);
lvi.SubItems.Add(pGood.Weight.ToString());
lvi.Tag = pGood;
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems == null) return;
if (listView1.SelectedItems.Count == 0) return;
CProduct p = (listView1.SelectedItems[0].Tag as CProduct);
if (p == null) return;
Debug.WriteLine(p.Title);
}
}
}

120
Shop/Shop/ShelfControl.resx

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>

9
Shop/Shop/ShopWin.csproj

@ -57,6 +57,12 @@
<Compile Include="Model\CShop.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShelfControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ShelfControl.Designer.cs">
<DependentUpon>ShelfControl.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
@ -70,6 +76,9 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="ShelfControl.resx">
<DependentUpon>ShelfControl.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

59
WorkField/WorkField/FieldControl.Designer.cs

@ -0,0 +1,59 @@
namespace WorkFieldWin
{
partial class FieldControl
{
/// <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 Component 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.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(523, 243);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//
// FieldControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.pictureBox1);
this.Name = "FieldControl";
this.Size = new System.Drawing.Size(523, 243);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
}
}

27
WorkField/WorkField/FieldControl.cs

@ -0,0 +1,27 @@
using System.Windows.Forms;
using WorkField.Model;
namespace WorkFieldWin
{
public partial class FieldControl : UserControl
{
private FieldControlUnit _control;
public FieldControl()
{
InitializeComponent();
}
public void Init(CStadium st)
{
_control = new FieldControlUnit(
pictureBox1.CreateGraphics(),
st);
}
public void RefreshContent()
{
_control.Refresh();
}
}
}

120
WorkField/WorkField/FieldControl.resx

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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>

99
WorkField/WorkField/FieldControlUnit.cs

@ -0,0 +1,99 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using WorkField.Model;
namespace WorkFieldWin
{
internal class FieldControlUnit
{
private Graphics _gr;
private CStadium _st;
private int PlayerWidth = 4;
private double Scale = 1;
private int PlayerHeight = 4;
public FieldControlUnit(Graphics gr, CStadium st)
{
_gr = gr;
_st = st;
}
private int h_GetX(int X)
{
return (int)(X * Scale);
}
private int h_GetY(int Y)
{
return (int)(Y * Scale);
}
public void Refresh()
{
// h_LoadImage();
h_DrawImage();
h_refreshPicture();
}
private void h_LoadImage()
{
Bitmap im = new Bitmap("1.bmp");
Bitmap resizedImage = h_ResizeImage(im, h_GetX(im.Width), h_GetY(im.Height));
_gr.DrawImage(resizedImage, new Point(h_GetX(0), h_GetY(0)));
}
private void h_DrawImage()
{
Bitmap im = new Bitmap(
h_GetX(_st.BlockList.GetWidth()),
h_GetY(_st.BlockList.GetHeight()));
Graphics gr = Graphics.FromImage(im);
foreach (var pl in _st.BlockList.List) {
if (pl is CFieldBlock) {
gr.DrawEllipse(Pens.GreenYellow, h_GetX(pl.X), h_GetY(pl.Y), h_GetX(PlayerWidth), h_GetY(PlayerHeight));
}
if (pl is CWallBlock) {
gr.DrawEllipse(Pens.BlueViolet, h_GetX(pl.X), h_GetY(pl.Y), h_GetX(PlayerWidth), h_GetY(PlayerHeight));
}
}
_gr.DrawImage(im, 0, 0);
}
private static Bitmap h_ResizeImage(Image image, int width, int height)
{
var destRect = new Rectangle(0, 0, width, height);
var destImage = new Bitmap(width, height);
destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
using (var graphics = Graphics.FromImage(destImage)) {
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
using (var wrapMode = new ImageAttributes()) {
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
}
}
return destImage;
}
private void h_refreshPicture()
{
foreach (CPlayerBlock pl in _st.PlayerList) {
_gr.DrawEllipse(Pens.Brown, h_GetX(pl.X), h_GetY(pl.Y), h_GetX(PlayerWidth), h_GetY(PlayerHeight));
}
}
}
}

83
WorkField/WorkField/Form1.Designer.cs

@ -38,13 +38,20 @@
this.lab1X = new System.Windows.Forms.Label();
this.btnMove = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.panel4 = new System.Windows.Forms.Panel();
this.panel5 = new System.Windows.Forms.Panel();
this.fieldControl2 = new WorkFieldWin.FieldControl();
this.fieldControl1 = new WorkFieldWin.FieldControl();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
this.panel4.SuspendLayout();
this.panel5.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(308, 10);
this.button1.Location = new System.Drawing.Point(210, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
@ -54,10 +61,12 @@
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel1.Location = new System.Drawing.Point(0, 52);
this.panel1.BackColor = System.Drawing.Color.WhiteSmoke;
this.panel1.Controls.Add(this.fieldControl1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 53);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(800, 398);
this.panel1.Size = new System.Drawing.Size(784, 190);
this.panel1.TabIndex = 1;
//
// panel2
@ -65,9 +74,9 @@
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.Location = new System.Drawing.Point(674, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(110, 52);
this.panel2.Size = new System.Drawing.Size(110, 53);
this.panel2.TabIndex = 4;
//
// lab2Y
@ -93,9 +102,9 @@
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.Location = new System.Drawing.Point(564, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(110, 52);
this.panel3.Size = new System.Drawing.Size(110, 53);
this.panel3.TabIndex = 7;
//
// lab1Y
@ -118,7 +127,7 @@
//
// btnMove
//
this.btnMove.Location = new System.Drawing.Point(389, 10);
this.btnMove.Location = new System.Drawing.Point(291, 12);
this.btnMove.Name = "btnMove";
this.btnMove.Size = new System.Drawing.Size(75, 23);
this.btnMove.TabIndex = 8;
@ -131,22 +140,64 @@
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// panel4
//
this.panel4.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.panel4.Controls.Add(this.btnMove);
this.panel4.Controls.Add(this.button1);
this.panel4.Controls.Add(this.panel3);
this.panel4.Controls.Add(this.panel2);
this.panel4.Dock = System.Windows.Forms.DockStyle.Top;
this.panel4.Location = new System.Drawing.Point(0, 0);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(784, 53);
this.panel4.TabIndex = 2;
//
// panel5
//
this.panel5.BackColor = System.Drawing.Color.DarkGray;
this.panel5.Controls.Add(this.fieldControl2);
this.panel5.Dock = System.Windows.Forms.DockStyle.Top;
this.panel5.Location = new System.Drawing.Point(0, 243);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(784, 362);
this.panel5.TabIndex = 2;
//
// fieldControl2
//
this.fieldControl2.Dock = System.Windows.Forms.DockStyle.Fill;
this.fieldControl2.Location = new System.Drawing.Point(0, 0);
this.fieldControl2.Name = "fieldControl2";
this.fieldControl2.Size = new System.Drawing.Size(784, 362);
this.fieldControl2.TabIndex = 1;
//
// fieldControl1
//
this.fieldControl1.BackColor = System.Drawing.Color.WhiteSmoke;
this.fieldControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.fieldControl1.Location = new System.Drawing.Point(0, 0);
this.fieldControl1.Name = "fieldControl1";
this.fieldControl1.Size = new System.Drawing.Size(784, 190);
this.fieldControl1.TabIndex = 0;
//
// 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.ClientSize = new System.Drawing.Size(784, 419);
this.Controls.Add(this.panel5);
this.Controls.Add(this.panel1);
this.Controls.Add(this.button1);
this.Controls.Add(this.panel4);
this.DoubleBuffered = true;
this.Name = "Form1";
this.Text = "Стадион";
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.panel4.ResumeLayout(false);
this.panel5.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -163,6 +214,10 @@
private System.Windows.Forms.Label lab1X;
private System.Windows.Forms.Button btnMove;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Panel panel4;
private WorkFieldWin.FieldControl fieldControl1;
private WorkFieldWin.FieldControl fieldControl2;
private System.Windows.Forms.Panel panel5;
}
}

51
WorkField/WorkField/Form1.cs

@ -1,11 +1,5 @@
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;
@ -24,30 +18,34 @@ namespace WorkField
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));
_stadium = new CStadium("1.bmp");
_stadium.AddNewStandardPlayer();
_stadium.AddNewStandardPlayer();
//_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;
}
//private bool h_CanMove(int arg1, int arg2)
//{
// if (DateTime.Now.Second < 30) {
// return false;
// }
return true;
}
// 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));
_stadium.AddNewStandardPlayer();
//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;
@ -63,6 +61,15 @@ namespace WorkField
lab2X.Text = _stadium.PlayerList[1].X.ToString();
lab2Y.Text = _stadium.PlayerList[1].Y.ToString();
h_RefreshPicture();
}
private void h_RefreshPicture()
{
fieldControl1.RefreshContent();
fieldControl2.RefreshContent();
}
private void timer1_Tick(object sender, EventArgs e)

11
WorkField/WorkField/Model/Block.cs

@ -0,0 +1,11 @@
namespace WorkField.Model
{
/// <summary>
/// Блок
/// </summary>
public class CBlock
{
public int X;
public int Y;
}
}

100
WorkField/WorkField/Model/BlockList.cs

@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace WorkField.Model
{
/// <summary>
/// Тип блока
/// </summary>
public enum EBlockType
{
Unknown = 0,
Wall = 1,
Field = 2,
}
/// <summary>
/// БлокСписок
/// </summary>
public class CBlockList
{
public List<CBlock> List;
/// <summary>Initializes a new instance of the <see cref="T:System.Object" /> class.</summary>
public CBlockList()
{
List = new List<CBlock>();
}
public int GetWidth()
{
int iMaxX = 0;
foreach (var pB in List) {
if (pB.X > iMaxX) {
iMaxX = pB.X;
}
}
return iMaxX;
}
public int GetHeight()
{
int iMaxY = 0;
foreach (var pB in List) {
if (pB.Y > iMaxY) {
iMaxY = pB.Y;
}
}
return iMaxY;
}
/// <summary>
/// Ищет элемент в позиции
/// </summary>
/// <param name="iX"></param>
/// <param name="iY"></param>
/// <returns></returns>
public CBlock Find(int iX, int iY)
{
CBlock el = List
.FirstOrDefault(block =>
block.X == iX && block.Y == iY);
//CBlock el = null;
//foreach (CBlock block in List) {
// if (block.X == iX && block.Y == iY) {
// el = block;
// break;
// }
//}
return el;
}
public bool Add(int iX, int iY, EBlockType enType)
{
CBlock pp = Find(iX, iY);
if (pp != null) {
return false;
}
switch (enType) {
case EBlockType.Field:
List.Add(new CFieldBlock() { X = iX, Y = iY });
break;
case EBlockType.Wall:
List.Add(new CWallBlock() { X = iX, Y = iY });
break;
case EBlockType.Unknown:
throw new ArgumentOutOfRangeException(nameof(enType), enType, null);
}
return true;
}
}
}

76
WorkField/WorkField/Model/CStadium.cs

@ -1,76 +0,0 @@
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
{
/// <summary>
/// Стадион
/// </summary>
public class CStadium
{
private System.Threading.Timer _timer;
/// <summary>
/// Ширина
/// </summary>
public int Width;
/// <summary>
/// Длина
/// </summary>
public int Height;
/// <summary>
/// Список работников
/// </summary>
public List<CPlayer> PlayerList;
public CStadium (int width, int height)
{
Width = width;
Height = height;
PlayerList = new List<CPlayer>();
_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;
}
}
}

18
WorkField/WorkField/Model/Description.txt

@ -1,14 +1,22 @@
Поле с работниками
Поле
Ширина
Длина
Работник[]
БлокСписок
РаботникБлок[]
Работник
Фамилия
БлокСписок (контроль уникальности, поиск блока по координатам)
Блок[]
Блок
X
Y
СтенаБлок: Блок
ПолеБлок: Блок
РаботникБлок: Блок
Фамилия

10
WorkField/WorkField/Model/FieldBlock.cs

@ -0,0 +1,10 @@
namespace WorkField.Model
{
/// <summary>
/// ПолеБлок
/// </summary>
public class CFieldBlock : CBlock
{
}
}

13
WorkField/WorkField/Model/CPlayer.cs → WorkField/WorkField/Model/PlayerBlock.cs

@ -1,18 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WorkField.Model
{
public class CPlayer
/// <summary>
/// РаботникБлок
/// </summary>
public class CPlayerBlock: CBlock
{
private Random _rnd = new Random();
public string Surname;
public int X;
public int Y;
private readonly Func<int, int, bool> _fnCanMove;
public bool IsFreezed
@ -31,7 +28,7 @@ namespace WorkField.Model
private DateTime UnfreezeTime;
public CPlayer(string surname, int x, int y,
public CPlayerBlock(string surname, int x, int y,
Func<int, int, bool> fnCanMove)
{
Surname = surname;

86
WorkField/WorkField/Model/Stadium.cs

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
namespace WorkField.Model
{
/// <summary>
/// Стадион
/// </summary>
public class CStadium
{
private System.Threading.Timer _timer;
private string _mapFilename;
public CBlockList BlockList;
/// <summary>
/// Список работников
/// </summary>
public List<CPlayerBlock> PlayerList;
public CStadium(string sFn)
{
_mapFilename = sFn;
PlayerList = new List<CPlayerBlock>();
BlockList = new CBlockList();
h_FillField();
_timer = new Timer(h_tick, null,
new TimeSpan(0, 0, 0, 0, 300),
new TimeSpan(0, 0, 0, 0, 1000)
);
}
private void h_FillField()
{
Bitmap pB = new Bitmap(_mapFilename);
for (int xx = 0; xx < pB.Width; xx++) {
for (int yy = 0; yy < pB.Height; yy++) {
Color pColor = pB.GetPixel(xx, yy);
bool isWall = h_IsColor(pColor, Color.Black);
bool isField = !isWall; // h_IsColor(pColor, Color.White);
if (isWall) BlockList.Add(xx, yy, EBlockType.Wall);
if (isField) BlockList.Add(xx, yy, EBlockType.Field);
}
}
}
private static bool h_IsColor(Color pC1, Color pC2)
{
return pC2.R == pC1.R
&& pC2.G == pC1.G
&& pC2.B == pC1.B;
}
private void h_tick(object x)
{
this.Move();
}
internal void Move()
{
foreach (CPlayerBlock pPlayer in PlayerList) {
pPlayer.Move();
}
}
public bool IsPosition(int newX, int newY)
{
CBlock pBlock = BlockList.Find(newX, newY);
if (pBlock == null) return false;
if (pBlock is CWallBlock) return false;
return true;
}
public void AddNewStandardPlayer()
{
int iNum = PlayerList.Count + 1;
PlayerList.Add(
new CPlayerBlock($"player{iNum}",
10, 10 + iNum * 2, IsPosition));
}
}
}

10
WorkField/WorkField/Model/WallBlock.cs

@ -0,0 +1,10 @@
namespace WorkField.Model
{
/// <summary>
/// СтенаБлок
/// </summary>
public class CWallBlock : CBlock
{
}
}

3
WorkField/WorkField/Program.cs

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WorkField

1
WorkField/WorkField/Properties/AssemblyInfo.cs

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

18
WorkField/WorkField/WorkField.csproj

@ -46,16 +46,30 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FieldControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="FieldControl.Designer.cs">
<DependentUpon>FieldControl.cs</DependentUpon>
</Compile>
<Compile Include="FieldControlUnit.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Model\CStadium.cs" />
<Compile Include="Model\CPlayer.cs" />
<Compile Include="Model\Block.cs" />
<Compile Include="Model\BlockList.cs" />
<Compile Include="Model\FieldBlock.cs" />
<Compile Include="Model\PlayerBlock.cs" />
<Compile Include="Model\Stadium.cs" />
<Compile Include="Model\WallBlock.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FieldControl.resx">
<DependentUpon>FieldControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>

Loading…
Cancel
Save