part 1
This commit is contained in:
parent
19fd6bc82d
commit
c8d9b3ece7
@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectCatamaran.Drawnings;
|
||||||
|
|
||||||
|
namespace ProjectCatamaran.CollectionGenericObjects;
|
||||||
|
public abstract class AbstractCompany
|
||||||
|
{
|
||||||
|
protected readonly int _placeSizeWidth = 210;
|
||||||
|
|
||||||
|
protected readonly int _placeSizeHeight = 80;
|
||||||
|
protected readonly int _pictureWidth;
|
||||||
|
protected readonly int _pictureHeight;
|
||||||
|
protected ICollectionGenericObjects<DrawningBoat?> _collection = null;
|
||||||
|
private int GetMaxCount => _pictureWidth + _pictureHeight / (_placeSizeWidth + _placeSizeHeight);
|
||||||
|
|
||||||
|
public AbstractCompany(int picWidth,int picHeight,ICollectionGenericObjects<DrawningBoat?> collection)
|
||||||
|
{
|
||||||
|
_pictureWidth = picWidth;
|
||||||
|
_pictureHeight = picHeight;
|
||||||
|
_collection = collection;
|
||||||
|
_collection.SetMaxCount = GetMaxCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator +(AbstractCompany company, DrawningBoat boat)
|
||||||
|
{
|
||||||
|
return company._collection?.Insert(boat) ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator -(AbstractCompany company, int position)
|
||||||
|
{
|
||||||
|
return company._collection?.Remove(position) ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DrawningBoat? GetRandomObject()
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
return _collection?.Get(rnd.Next(GetMaxCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap Show()
|
||||||
|
{
|
||||||
|
Bitmap bitmap = new(_pictureWidth, _pictureHeight);
|
||||||
|
Graphics graphics = Graphics.FromImage(bitmap);
|
||||||
|
DrawBackground(graphics);
|
||||||
|
SetObjectPosition();
|
||||||
|
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
|
||||||
|
{
|
||||||
|
DrawningBoat? obj = _collection?.Get(i);
|
||||||
|
obj?.DrawTransport(graphics);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
protected abstract void DrawBackground(Graphics g);
|
||||||
|
protected abstract void SetObjectPosition();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectCatamaran.Drawnings;
|
||||||
|
|
||||||
|
namespace ProjectCatamaran.CollectionGenericObjects;
|
||||||
|
public class BoatSharingService : AbstractCompany
|
||||||
|
{
|
||||||
|
public BoatSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningBoat?> collection) : base(picWidth, picHeight, collection)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DrawBackground(Graphics g)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SetObjectPosition()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCatamaran.CollectionGenericObjects;
|
||||||
|
|
||||||
|
public interface ICollectionGenericObjects<T> where T : class
|
||||||
|
{
|
||||||
|
int Count { get; }
|
||||||
|
int SetMaxCount { set; }
|
||||||
|
bool Insert(T obj);
|
||||||
|
bool Insert(T obj, int position);
|
||||||
|
bool Remove(int position);
|
||||||
|
|
||||||
|
T? Get(int position);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCatamaran.CollectionGenericObjects;
|
||||||
|
|
||||||
|
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T> where T : class
|
||||||
|
{
|
||||||
|
private T?[] _collection;
|
||||||
|
public int Count => _collection.Length;
|
||||||
|
|
||||||
|
public int SetMaxCount
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > 0)
|
||||||
|
{
|
||||||
|
_collection = new T?[value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MassiveGenericObjects()
|
||||||
|
{
|
||||||
|
_collection = Array.Empty<T?>();
|
||||||
|
}
|
||||||
|
public T? Get(int position)
|
||||||
|
{
|
||||||
|
//todo
|
||||||
|
return _collection[position];
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Insert(T obj)
|
||||||
|
{
|
||||||
|
//todo
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Insert(T obj, int position)
|
||||||
|
{
|
||||||
|
//todo
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(int position)
|
||||||
|
{
|
||||||
|
//todo
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
173
ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs
generated
Normal file
173
ProjectCatamaran/ProjectCatamaran/FormBoatCollection.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
namespace ProjectCatamaran
|
||||||
|
{
|
||||||
|
partial class FormBoatCollection
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
groupBoxTools = new GroupBox();
|
||||||
|
buttonRefresh = new Button();
|
||||||
|
buttonGoToCheck = new Button();
|
||||||
|
buttonRemoveBoat = new Button();
|
||||||
|
maskedTextBoxPosition = new MaskedTextBox();
|
||||||
|
buttonAddCatamaran = new Button();
|
||||||
|
buttonAddBoat = new Button();
|
||||||
|
comboBoxSelectorCompany = new ComboBox();
|
||||||
|
pictureBox = new PictureBox();
|
||||||
|
groupBoxTools.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBoxTools
|
||||||
|
//
|
||||||
|
groupBoxTools.Controls.Add(buttonRefresh);
|
||||||
|
groupBoxTools.Controls.Add(buttonGoToCheck);
|
||||||
|
groupBoxTools.Controls.Add(buttonRemoveBoat);
|
||||||
|
groupBoxTools.Controls.Add(maskedTextBoxPosition);
|
||||||
|
groupBoxTools.Controls.Add(buttonAddCatamaran);
|
||||||
|
groupBoxTools.Controls.Add(buttonAddBoat);
|
||||||
|
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
|
groupBoxTools.Location = new Point(631, 0);
|
||||||
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
|
groupBoxTools.Size = new Size(169, 450);
|
||||||
|
groupBoxTools.TabIndex = 0;
|
||||||
|
groupBoxTools.TabStop = false;
|
||||||
|
groupBoxTools.Text = "Инструменты";
|
||||||
|
//
|
||||||
|
// buttonRefresh
|
||||||
|
//
|
||||||
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonRefresh.Location = new Point(6, 381);
|
||||||
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
|
buttonRefresh.Size = new Size(157, 39);
|
||||||
|
buttonRefresh.TabIndex = 6;
|
||||||
|
buttonRefresh.Text = "Обновить";
|
||||||
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
|
buttonRefresh.Click += ButtonRefresh_Click;
|
||||||
|
//
|
||||||
|
// buttonGoToCheck
|
||||||
|
//
|
||||||
|
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonGoToCheck.Location = new Point(6, 324);
|
||||||
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
|
buttonGoToCheck.Size = new Size(157, 39);
|
||||||
|
buttonGoToCheck.TabIndex = 5;
|
||||||
|
buttonGoToCheck.Text = "Передать на тесты";
|
||||||
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
|
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
||||||
|
//
|
||||||
|
// buttonRemoveBoat
|
||||||
|
//
|
||||||
|
buttonRemoveBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonRemoveBoat.Location = new Point(6, 279);
|
||||||
|
buttonRemoveBoat.Name = "buttonRemoveBoat";
|
||||||
|
buttonRemoveBoat.Size = new Size(157, 39);
|
||||||
|
buttonRemoveBoat.TabIndex = 4;
|
||||||
|
buttonRemoveBoat.Text = "Удалить лодку";
|
||||||
|
buttonRemoveBoat.UseVisualStyleBackColor = true;
|
||||||
|
buttonRemoveBoat.Click += ButtonRemoveBoat_Click;
|
||||||
|
//
|
||||||
|
// maskedTextBoxPosition
|
||||||
|
//
|
||||||
|
maskedTextBoxPosition.Location = new Point(1, 233);
|
||||||
|
maskedTextBoxPosition.Mask = "00";
|
||||||
|
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
|
maskedTextBoxPosition.Size = new Size(162, 23);
|
||||||
|
maskedTextBoxPosition.TabIndex = 3;
|
||||||
|
maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
|
// buttonAddCatamaran
|
||||||
|
//
|
||||||
|
buttonAddCatamaran.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonAddCatamaran.Location = new Point(6, 125);
|
||||||
|
buttonAddCatamaran.Name = "buttonAddCatamaran";
|
||||||
|
buttonAddCatamaran.Size = new Size(157, 39);
|
||||||
|
buttonAddCatamaran.TabIndex = 2;
|
||||||
|
buttonAddCatamaran.Text = "Добавление катамарана";
|
||||||
|
buttonAddCatamaran.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddCatamaran.Click += ButtonAddCatamaran_Click;
|
||||||
|
//
|
||||||
|
// buttonAddBoat
|
||||||
|
//
|
||||||
|
buttonAddBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonAddBoat.Location = new Point(6, 80);
|
||||||
|
buttonAddBoat.Name = "buttonAddBoat";
|
||||||
|
buttonAddBoat.Size = new Size(157, 39);
|
||||||
|
buttonAddBoat.TabIndex = 1;
|
||||||
|
buttonAddBoat.Text = "Добавление лодки";
|
||||||
|
buttonAddBoat.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddBoat.Click += ButtonAddBoat_Click;
|
||||||
|
//
|
||||||
|
// comboBoxSelectorCompany
|
||||||
|
//
|
||||||
|
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxSelectorCompany.FormattingEnabled = true;
|
||||||
|
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
||||||
|
comboBoxSelectorCompany.Location = new Point(6, 22);
|
||||||
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
|
comboBoxSelectorCompany.Size = new Size(157, 23);
|
||||||
|
comboBoxSelectorCompany.TabIndex = 0;
|
||||||
|
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// pictureBox
|
||||||
|
//
|
||||||
|
pictureBox.Dock = DockStyle.Fill;
|
||||||
|
pictureBox.Location = new Point(0, 0);
|
||||||
|
pictureBox.Name = "pictureBox";
|
||||||
|
pictureBox.Size = new Size(631, 450);
|
||||||
|
pictureBox.TabIndex = 1;
|
||||||
|
pictureBox.TabStop = false;
|
||||||
|
//
|
||||||
|
// FormBoatCollection
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(pictureBox);
|
||||||
|
Controls.Add(groupBoxTools);
|
||||||
|
Name = "FormBoatCollection";
|
||||||
|
Text = "Коллекция лодок";
|
||||||
|
groupBoxTools.ResumeLayout(false);
|
||||||
|
groupBoxTools.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBoxTools;
|
||||||
|
private Button buttonAddCatamaran;
|
||||||
|
private Button buttonAddBoat;
|
||||||
|
private ComboBox comboBoxSelectorCompany;
|
||||||
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
|
private PictureBox pictureBox;
|
||||||
|
private Button buttonRemoveBoat;
|
||||||
|
private Button buttonRefresh;
|
||||||
|
private Button buttonGoToCheck;
|
||||||
|
}
|
||||||
|
}
|
150
ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs
Normal file
150
ProjectCatamaran/ProjectCatamaran/FormBoatCollection.cs
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
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 ProjectCatamaran.CollectionGenericObjects;
|
||||||
|
using ProjectCatamaran.Drawnings;
|
||||||
|
|
||||||
|
namespace ProjectCatamaran;
|
||||||
|
public partial class FormBoatCollection : Form
|
||||||
|
{
|
||||||
|
private AbstractCompany? _company;
|
||||||
|
public FormBoatCollection()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
switch (comboBoxSelectorCompany.Text)
|
||||||
|
{
|
||||||
|
case "Хранилище":
|
||||||
|
_company = new BoatSharingService(pictureBox.Width, pictureBox.Height,
|
||||||
|
new MassiveGenericObjects<DrawningBoat?>());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateObject(string type)
|
||||||
|
{
|
||||||
|
if (_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Random random = new();
|
||||||
|
DrawningBoat drawningBoat;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case nameof(DrawningBoat):
|
||||||
|
drawningBoat = new DrawningBoat(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
|
GetColor(random));
|
||||||
|
break;
|
||||||
|
case nameof(DrawningCatamaran):
|
||||||
|
drawningBoat = new DrawningCatamaran(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_company + drawningBoat)
|
||||||
|
{
|
||||||
|
MessageBox.Show(("Объект добавлен"));
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Color GetColor(Random random)
|
||||||
|
{
|
||||||
|
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAddBoat_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CreateObject(nameof(DrawningBoat));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAddCatamaran_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CreateObject(nameof(DrawningCatamaran));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonRemoveBoat_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MessageBox.Show("Удалить объект", "Удаление", MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question) == DialogResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
|
if (_company - pos)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект удален");
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonGoToCheck_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawningBoat? boat = null;
|
||||||
|
int counter = 100;
|
||||||
|
while (boat == null)
|
||||||
|
{
|
||||||
|
boat = _company.GetRandomObject();
|
||||||
|
counter--;
|
||||||
|
if (counter <= 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (boat == null)
|
||||||
|
return;
|
||||||
|
FormCatamaran form = new()
|
||||||
|
{
|
||||||
|
SetBoat = boat
|
||||||
|
};
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonRefresh_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
|
}
|
120
ProjectCatamaran/ProjectCatamaran/FormBoatCollection.resx
Normal file
120
ProjectCatamaran/ProjectCatamaran/FormBoatCollection.resx
Normal file
@ -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>
|
@ -29,14 +29,13 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
pictureBoxCatamaran = new PictureBox();
|
pictureBoxCatamaran = new PictureBox();
|
||||||
buttonCreateCatamaran = new Button();
|
|
||||||
buttonUp = new Button();
|
buttonUp = new Button();
|
||||||
buttonRight = new Button();
|
buttonRight = new Button();
|
||||||
buttonLeft = new Button();
|
buttonLeft = new Button();
|
||||||
buttonDown = new Button();
|
buttonDown = new Button();
|
||||||
buttonCreateBoat = new Button();
|
|
||||||
comboBoxStrategy = new ComboBox();
|
comboBoxStrategy = new ComboBox();
|
||||||
buttonStrategyStep = new Button();
|
buttonStrategyStep = new Button();
|
||||||
|
colorDialog1 = new ColorDialog();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -45,21 +44,10 @@
|
|||||||
pictureBoxCatamaran.Dock = DockStyle.Fill;
|
pictureBoxCatamaran.Dock = DockStyle.Fill;
|
||||||
pictureBoxCatamaran.Location = new Point(0, 0);
|
pictureBoxCatamaran.Location = new Point(0, 0);
|
||||||
pictureBoxCatamaran.Name = "pictureBoxCatamaran";
|
pictureBoxCatamaran.Name = "pictureBoxCatamaran";
|
||||||
pictureBoxCatamaran.Size = new Size(801, 450);
|
pictureBoxCatamaran.Size = new Size(800, 450);
|
||||||
pictureBoxCatamaran.TabIndex = 0;
|
pictureBoxCatamaran.TabIndex = 0;
|
||||||
pictureBoxCatamaran.TabStop = false;
|
pictureBoxCatamaran.TabStop = false;
|
||||||
//
|
//
|
||||||
// buttonCreateCatamaran
|
|
||||||
//
|
|
||||||
buttonCreateCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonCreateCatamaran.Location = new Point(12, 402);
|
|
||||||
buttonCreateCatamaran.Name = "buttonCreateCatamaran";
|
|
||||||
buttonCreateCatamaran.Size = new Size(166, 40);
|
|
||||||
buttonCreateCatamaran.TabIndex = 1;
|
|
||||||
buttonCreateCatamaran.Text = "Создать катамаран";
|
|
||||||
buttonCreateCatamaran.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateCatamaran.Click += ButtonCreateCatamaran_Click;
|
|
||||||
//
|
|
||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
@ -108,17 +96,6 @@
|
|||||||
buttonDown.UseVisualStyleBackColor = true;
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
buttonDown.Click += ButtonMove_Click;
|
buttonDown.Click += ButtonMove_Click;
|
||||||
//
|
//
|
||||||
// buttonCreateBoat
|
|
||||||
//
|
|
||||||
buttonCreateBoat.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonCreateBoat.Location = new Point(184, 402);
|
|
||||||
buttonCreateBoat.Name = "buttonCreateBoat";
|
|
||||||
buttonCreateBoat.Size = new Size(166, 40);
|
|
||||||
buttonCreateBoat.TabIndex = 6;
|
|
||||||
buttonCreateBoat.Text = "Создать лодку";
|
|
||||||
buttonCreateBoat.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateBoat.Click += ButtonCreateBoat_Click;
|
|
||||||
//
|
|
||||||
// comboBoxStrategy
|
// comboBoxStrategy
|
||||||
//
|
//
|
||||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
@ -147,12 +124,10 @@
|
|||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
Controls.Add(buttonStrategyStep);
|
Controls.Add(buttonStrategyStep);
|
||||||
Controls.Add(comboBoxStrategy);
|
Controls.Add(comboBoxStrategy);
|
||||||
Controls.Add(buttonCreateBoat);
|
|
||||||
Controls.Add(buttonDown);
|
Controls.Add(buttonDown);
|
||||||
Controls.Add(buttonLeft);
|
Controls.Add(buttonLeft);
|
||||||
Controls.Add(buttonRight);
|
Controls.Add(buttonRight);
|
||||||
Controls.Add(buttonUp);
|
Controls.Add(buttonUp);
|
||||||
Controls.Add(buttonCreateCatamaran);
|
|
||||||
Controls.Add(pictureBoxCatamaran);
|
Controls.Add(pictureBoxCatamaran);
|
||||||
Name = "FormCatamaran";
|
Name = "FormCatamaran";
|
||||||
Text = "Катамаран";
|
Text = "Катамаран";
|
||||||
@ -163,13 +138,12 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private PictureBox pictureBoxCatamaran;
|
private PictureBox pictureBoxCatamaran;
|
||||||
private Button buttonCreateCatamaran;
|
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonCreateBoat;
|
|
||||||
private ComboBox comboBoxStrategy;
|
private ComboBox comboBoxStrategy;
|
||||||
private Button buttonStrategyStep;
|
private Button buttonStrategyStep;
|
||||||
|
private ColorDialog colorDialog1;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,6 +17,18 @@ namespace ProjectCatamaran
|
|||||||
{
|
{
|
||||||
private DrawningBoat? _drawningBoat;
|
private DrawningBoat? _drawningBoat;
|
||||||
private AbstractStrategy? _strategy;
|
private AbstractStrategy? _strategy;
|
||||||
|
|
||||||
|
public DrawningBoat SetBoat
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_drawningBoat = value;
|
||||||
|
_drawningBoat.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||||
|
comboBoxStrategy.Enabled = true;
|
||||||
|
_strategy = null;
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
public FormCatamaran()
|
public FormCatamaran()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -64,39 +76,6 @@ namespace ProjectCatamaran
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateObject(string type)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case nameof(DrawningBoat):
|
|
||||||
_drawningBoat = new DrawningBoat(random.Next(100, 300), random.Next(1000, 3000),
|
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
|
||||||
break;
|
|
||||||
case nameof(DrawningCatamaran):
|
|
||||||
_drawningBoat = new DrawningCatamaran(random.Next(100, 300), random.Next(1000, 3000),
|
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_drawningBoat.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
|
||||||
_drawningBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
_strategy = null;
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
private void ButtonCreateCatamaran_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateObject(nameof(DrawningCatamaran));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCreateBoat_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
CreateObject(nameof(DrawningBoat));
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обработка нажатия кнопки "Шаг"
|
/// Обработка нажатия кнопки "Шаг"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -117,4 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
Loading…
x
Reference in New Issue
Block a user