Сделал лабораторную 4
This commit is contained in:
parent
40cd0e854b
commit
fbad9188bf
201
Bulldozer/Bulldozer/FormBulldozerCollection.Designer.cs
generated
201
Bulldozer/Bulldozer/FormBulldozerCollection.Designer.cs
generated
@ -28,97 +28,172 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
pictureBoxCollection = new PictureBox();
|
||||
panelTools = new Panel();
|
||||
textBox = new TextBox();
|
||||
buttonUpdateColletion = new Button();
|
||||
buttonDeleteBulldozer = new Button();
|
||||
buttonAddBulldozer = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||
panelTools.SuspendLayout();
|
||||
SuspendLayout();
|
||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
this.panelTools = new System.Windows.Forms.Panel();
|
||||
this.groupListBulldozersBox = new System.Windows.Forms.GroupBox();
|
||||
this.buttonDeleteBulldozersList = new System.Windows.Forms.Button();
|
||||
this.buttonAddBulldozersList = new System.Windows.Forms.Button();
|
||||
this.listBoxBulldozerStorages = new System.Windows.Forms.ListBox();
|
||||
this.textBoxStorageName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxDeletingBulldozer = new System.Windows.Forms.TextBox();
|
||||
this.buttonUpdateColletion = new System.Windows.Forms.Button();
|
||||
this.buttonDeleteBulldozer = new System.Windows.Forms.Button();
|
||||
this.buttonAddBulldozer = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||
this.panelTools.SuspendLayout();
|
||||
this.groupListBulldozersBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
pictureBoxCollection.Anchor = AnchorStyles.Left;
|
||||
pictureBoxCollection.BackColor = SystemColors.Control;
|
||||
pictureBoxCollection.Location = new Point(12, 12);
|
||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
pictureBoxCollection.Size = new Size(711, 571);
|
||||
pictureBoxCollection.TabIndex = 0;
|
||||
pictureBoxCollection.TabStop = false;
|
||||
this.pictureBoxCollection.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.pictureBoxCollection.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(14, 16);
|
||||
this.pictureBoxCollection.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(813, 761);
|
||||
this.pictureBoxCollection.TabIndex = 0;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// panelTools
|
||||
//
|
||||
panelTools.Controls.Add(textBox);
|
||||
panelTools.Controls.Add(buttonUpdateColletion);
|
||||
panelTools.Controls.Add(buttonDeleteBulldozer);
|
||||
panelTools.Controls.Add(buttonAddBulldozer);
|
||||
panelTools.Location = new Point(729, 12);
|
||||
panelTools.Name = "panelTools";
|
||||
panelTools.Size = new Size(234, 571);
|
||||
panelTools.TabIndex = 1;
|
||||
panelTools.Tag = "";
|
||||
this.panelTools.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.panelTools.Controls.Add(this.groupListBulldozersBox);
|
||||
this.panelTools.Controls.Add(this.textBoxDeletingBulldozer);
|
||||
this.panelTools.Controls.Add(this.buttonUpdateColletion);
|
||||
this.panelTools.Controls.Add(this.buttonDeleteBulldozer);
|
||||
this.panelTools.Controls.Add(this.buttonAddBulldozer);
|
||||
this.panelTools.Location = new System.Drawing.Point(833, 16);
|
||||
this.panelTools.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.panelTools.Name = "panelTools";
|
||||
this.panelTools.Size = new System.Drawing.Size(267, 761);
|
||||
this.panelTools.TabIndex = 1;
|
||||
this.panelTools.Tag = "";
|
||||
//
|
||||
// textBox
|
||||
// groupListBulldozersBox
|
||||
//
|
||||
textBox.Location = new Point(23, 164);
|
||||
textBox.Name = "textBox";
|
||||
textBox.Size = new Size(193, 23);
|
||||
textBox.TabIndex = 3;
|
||||
this.groupListBulldozersBox.Controls.Add(this.buttonDeleteBulldozersList);
|
||||
this.groupListBulldozersBox.Controls.Add(this.buttonAddBulldozersList);
|
||||
this.groupListBulldozersBox.Controls.Add(this.listBoxBulldozerStorages);
|
||||
this.groupListBulldozersBox.Controls.Add(this.textBoxStorageName);
|
||||
this.groupListBulldozersBox.Location = new System.Drawing.Point(16, 33);
|
||||
this.groupListBulldozersBox.Name = "groupListBulldozersBox";
|
||||
this.groupListBulldozersBox.Size = new System.Drawing.Size(230, 282);
|
||||
this.groupListBulldozersBox.TabIndex = 8;
|
||||
this.groupListBulldozersBox.TabStop = false;
|
||||
this.groupListBulldozersBox.Text = "Наборы";
|
||||
//
|
||||
// buttonDeleteBulldozersList
|
||||
//
|
||||
this.buttonDeleteBulldozersList.Location = new System.Drawing.Point(6, 226);
|
||||
this.buttonDeleteBulldozersList.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonDeleteBulldozersList.Name = "buttonDeleteBulldozersList";
|
||||
this.buttonDeleteBulldozersList.Size = new System.Drawing.Size(221, 53);
|
||||
this.buttonDeleteBulldozersList.TabIndex = 7;
|
||||
this.buttonDeleteBulldozersList.Text = "Удалить набор";
|
||||
this.buttonDeleteBulldozersList.UseVisualStyleBackColor = true;
|
||||
this.buttonDeleteBulldozersList.Click += new System.EventHandler(this.buttonDeleteBulldozersList_Click);
|
||||
//
|
||||
// buttonAddBulldozersList
|
||||
//
|
||||
this.buttonAddBulldozersList.Location = new System.Drawing.Point(6, 55);
|
||||
this.buttonAddBulldozersList.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonAddBulldozersList.Name = "buttonAddBulldozersList";
|
||||
this.buttonAddBulldozersList.Size = new System.Drawing.Size(221, 53);
|
||||
this.buttonAddBulldozersList.TabIndex = 6;
|
||||
this.buttonAddBulldozersList.Text = "Добавить набор";
|
||||
this.buttonAddBulldozersList.UseVisualStyleBackColor = true;
|
||||
this.buttonAddBulldozersList.Click += new System.EventHandler(this.buttonAddBulldozersList_Click);
|
||||
//
|
||||
// listBoxBulldozerStorages
|
||||
//
|
||||
this.listBoxBulldozerStorages.FormattingEnabled = true;
|
||||
this.listBoxBulldozerStorages.ItemHeight = 20;
|
||||
this.listBoxBulldozerStorages.Location = new System.Drawing.Point(6, 115);
|
||||
this.listBoxBulldozerStorages.Name = "listBoxBulldozerStorages";
|
||||
this.listBoxBulldozerStorages.Size = new System.Drawing.Size(220, 104);
|
||||
this.listBoxBulldozerStorages.TabIndex = 5;
|
||||
this.listBoxBulldozerStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxBulldozerStorages_SelectedIndexChanged);
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
this.textBoxStorageName.Location = new System.Drawing.Point(7, 20);
|
||||
this.textBoxStorageName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||
this.textBoxStorageName.Size = new System.Drawing.Size(220, 27);
|
||||
this.textBoxStorageName.TabIndex = 4;
|
||||
//
|
||||
// textBoxDeletingBulldozer
|
||||
//
|
||||
this.textBoxDeletingBulldozer.Location = new System.Drawing.Point(25, 525);
|
||||
this.textBoxDeletingBulldozer.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.textBoxDeletingBulldozer.Name = "textBoxDeletingBulldozer";
|
||||
this.textBoxDeletingBulldozer.Size = new System.Drawing.Size(220, 27);
|
||||
this.textBoxDeletingBulldozer.TabIndex = 3;
|
||||
//
|
||||
// buttonUpdateColletion
|
||||
//
|
||||
buttonUpdateColletion.Location = new Point(23, 263);
|
||||
buttonUpdateColletion.Name = "buttonUpdateColletion";
|
||||
buttonUpdateColletion.Size = new Size(193, 40);
|
||||
buttonUpdateColletion.TabIndex = 2;
|
||||
buttonUpdateColletion.Text = "Обновить коллекцию";
|
||||
buttonUpdateColletion.UseVisualStyleBackColor = true;
|
||||
buttonUpdateColletion.Click += ButtonUpdateCollection_Click;
|
||||
this.buttonUpdateColletion.Location = new System.Drawing.Point(25, 692);
|
||||
this.buttonUpdateColletion.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonUpdateColletion.Name = "buttonUpdateColletion";
|
||||
this.buttonUpdateColletion.Size = new System.Drawing.Size(221, 53);
|
||||
this.buttonUpdateColletion.TabIndex = 2;
|
||||
this.buttonUpdateColletion.Text = "Обновить коллекцию";
|
||||
this.buttonUpdateColletion.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonDeleteBulldozer
|
||||
//
|
||||
buttonDeleteBulldozer.Location = new Point(23, 193);
|
||||
buttonDeleteBulldozer.Name = "buttonDeleteBulldozer";
|
||||
buttonDeleteBulldozer.Size = new Size(193, 40);
|
||||
buttonDeleteBulldozer.TabIndex = 1;
|
||||
buttonDeleteBulldozer.Text = "Удалить объект";
|
||||
buttonDeleteBulldozer.UseVisualStyleBackColor = true;
|
||||
buttonDeleteBulldozer.Click += ButtonDeleteBulldozer_Click;
|
||||
this.buttonDeleteBulldozer.Location = new System.Drawing.Point(25, 563);
|
||||
this.buttonDeleteBulldozer.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonDeleteBulldozer.Name = "buttonDeleteBulldozer";
|
||||
this.buttonDeleteBulldozer.Size = new System.Drawing.Size(221, 53);
|
||||
this.buttonDeleteBulldozer.TabIndex = 1;
|
||||
this.buttonDeleteBulldozer.Text = "Удалить объект";
|
||||
this.buttonDeleteBulldozer.UseVisualStyleBackColor = true;
|
||||
this.buttonDeleteBulldozer.Click += new System.EventHandler(this.buttonDeleteBulldozer_Click);
|
||||
//
|
||||
// buttonAddBulldozer
|
||||
//
|
||||
buttonAddBulldozer.Location = new Point(23, 32);
|
||||
buttonAddBulldozer.Name = "buttonAddBulldozer";
|
||||
buttonAddBulldozer.Size = new Size(193, 40);
|
||||
buttonAddBulldozer.TabIndex = 0;
|
||||
buttonAddBulldozer.Text = "Добавить объект";
|
||||
buttonAddBulldozer.UseVisualStyleBackColor = true;
|
||||
buttonAddBulldozer.Click += ButtonAddBulldozer_Click;
|
||||
this.buttonAddBulldozer.Location = new System.Drawing.Point(24, 464);
|
||||
this.buttonAddBulldozer.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.buttonAddBulldozer.Name = "buttonAddBulldozer";
|
||||
this.buttonAddBulldozer.Size = new System.Drawing.Size(221, 53);
|
||||
this.buttonAddBulldozer.TabIndex = 0;
|
||||
this.buttonAddBulldozer.Text = "Добавить объект";
|
||||
this.buttonAddBulldozer.UseVisualStyleBackColor = true;
|
||||
this.buttonAddBulldozer.Click += new System.EventHandler(this.buttonAddBulldozer_Click);
|
||||
//
|
||||
// FormBulldozerCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(971, 595);
|
||||
Controls.Add(panelTools);
|
||||
Controls.Add(pictureBoxCollection);
|
||||
Name = "FormBulldozerCollection";
|
||||
Text = "Bulldozer Collection";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||
panelTools.ResumeLayout(false);
|
||||
panelTools.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1110, 793);
|
||||
this.Controls.Add(this.panelTools);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "FormBulldozerCollection";
|
||||
this.Text = "Bulldozer Collection";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||
this.panelTools.ResumeLayout(false);
|
||||
this.panelTools.PerformLayout();
|
||||
this.groupListBulldozersBox.ResumeLayout(false);
|
||||
this.groupListBulldozersBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCollection;
|
||||
private Panel panelTools;
|
||||
private TextBox textBox;
|
||||
private TextBox textBoxDeletingBulldozer;
|
||||
private Button buttonUpdateColletion;
|
||||
private Button buttonDeleteBulldozer;
|
||||
private Button buttonAddBulldozer;
|
||||
private ListBox listBoxBulldozerStorages;
|
||||
private TextBox textBoxStorageName;
|
||||
private GroupBox groupListBulldozersBox;
|
||||
private Button buttonDeleteBulldozersList;
|
||||
private Button buttonAddBulldozersList;
|
||||
}
|
||||
}
|
@ -7,44 +7,142 @@ namespace Bulldozer
|
||||
{
|
||||
public partial class FormBulldozerCollection : Form
|
||||
{
|
||||
private readonly BulldozersGenericCollection<DrawingBulldozer, DrawingObjectBulldozer> _bulldozers;
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly BulldozersGenericStorage _storage;
|
||||
|
||||
|
||||
public FormBulldozerCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_bulldozers = new BulldozersGenericCollection<DrawingBulldozer,
|
||||
DrawingObjectBulldozer>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
_storage = new BulldozersGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
|
||||
}
|
||||
private void ButtonAddBulldozer_Click(object sender, EventArgs e)
|
||||
|
||||
/// <summary>
|
||||
/// Заполнение listBoxBulldozerStorages
|
||||
/// </summary>
|
||||
private void ReloadObjects()
|
||||
{
|
||||
int index = listBoxBulldozerStorages.SelectedIndex;
|
||||
listBoxBulldozerStorages.Items.Clear();
|
||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||
{
|
||||
listBoxBulldozerStorages.Items.Add(_storage.Keys[i]);
|
||||
}
|
||||
if (listBoxBulldozerStorages.Items.Count > 0 && (index == -1 || index >= listBoxBulldozerStorages.Items.Count))
|
||||
{
|
||||
listBoxBulldozerStorages.SelectedIndex = 0;
|
||||
}
|
||||
else if (listBoxBulldozerStorages.Items.Count > 0 && index > -1 && index < listBoxBulldozerStorages.Items.Count)
|
||||
{
|
||||
listBoxBulldozerStorages.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление набора в коллекцию
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAddBulldozersList_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Выбор набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void listBoxBulldozerStorages_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _storage[listBoxBulldozerStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBulldozers();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonDeleteBulldozersList_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxBulldozerStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show($"Удалить объект {listBoxBulldozerStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storage.DelSet(listBoxBulldozerStorages.SelectedItem.ToString() ?? string.Empty);
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAddBulldozer_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxBulldozerStorages.SelectedIndex == -1)
|
||||
{
|
||||
MessageBox.Show("Выберите набор в списке.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxBulldozerStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
MessageBox.Show("Выбранный набор не найден.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
FormBulldozer form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_bulldozers + form.SelectedBulldozer != null)
|
||||
if (obj + form.SelectedBulldozer > -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = _bulldozers.ShowBulldozers();
|
||||
pictureBoxCollection.Image = obj.ShowBulldozers();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDeleteBulldozer_Click(object sender, EventArgs e)
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonDeleteBulldozer_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
|
||||
if (listBoxBulldozerStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(textBox.Text);
|
||||
if (_bulldozers - pos != null)
|
||||
var obj = _storage[listBoxBulldozerStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(textBoxDeletingBulldozer.Text);
|
||||
if (obj - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = _bulldozers.ShowBulldozers();
|
||||
pictureBoxCollection.Image = obj.ShowBulldozers();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -52,9 +150,23 @@ namespace Bulldozer
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обновление рисунка по набору
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonUpdateCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _bulldozers.ShowBulldozers();
|
||||
if (listBoxBulldozerStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxBulldozerStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxCollection.Image = obj.ShowBulldozers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,64 +1,4 @@
|
||||
<?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.
|
||||
-->
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
@ -18,7 +18,7 @@ namespace Bulldozer.Generics
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (ширина)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeWidth = 300;
|
||||
private readonly int _placeSizeWidth = 270;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (высота)
|
||||
/// </summary>
|
||||
@ -53,13 +53,20 @@ namespace Bulldozer.Generics
|
||||
return collect?._collection.Insert(obj) ?? -1;
|
||||
}
|
||||
|
||||
public static bool operator -(BulldozersGenericCollection<T, U> collect, int
|
||||
pos)
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
/// </summary>
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static T? operator -(BulldozersGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection.Get(pos);
|
||||
T? obj = collect._collection[pos];
|
||||
if (obj != null)
|
||||
return collect._collection.Remove(pos);
|
||||
return false;
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта IMoveableObject
|
||||
@ -68,7 +75,7 @@ pos)
|
||||
/// <returns></returns>
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection.Get(pos)?.GetMoveableObject;
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод всего набора объектов
|
||||
@ -95,7 +102,7 @@ pos)
|
||||
1; ++j)
|
||||
{
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2 + 20, j *
|
||||
_placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
||||
@ -111,19 +118,24 @@ pos)
|
||||
int heightObjCount = _pictureHeight / _placeSizeHeight;
|
||||
int widthObjCount = _pictureWidth / _placeSizeWidth;
|
||||
int totalObjects = _collection.Count;
|
||||
|
||||
for (int i = 0; i < totalObjects; i++)
|
||||
int i = 0;
|
||||
foreach (var bulldozer in _collection.GetBulldozers())
|
||||
{
|
||||
T? type = _collection.Get(i);
|
||||
if (type != null)
|
||||
|
||||
if (bulldozer != null)
|
||||
{
|
||||
int col = widthObjCount - 1 - (i % widthObjCount);
|
||||
int row = heightObjCount - 1 - (i / widthObjCount);
|
||||
|
||||
type.SetPosition(col * _placeSizeWidth, row * _placeSizeHeight);
|
||||
type?.DrawBulldozer(g);
|
||||
bulldozer.SetPosition(col * _placeSizeWidth + 3, row * _placeSizeHeight + 3);
|
||||
bulldozer?.DrawBulldozer(g);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (i > totalObjects)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
87
Bulldozer/Bulldozer/Generics/BulldozersGenericStorage.cs
Normal file
87
Bulldozer/Bulldozer/Generics/BulldozersGenericStorage.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using Bulldozer.DrawingObjects;
|
||||
using Bulldozer.MovementStrategy;
|
||||
|
||||
namespace Bulldozer.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс для хранения коллекции
|
||||
/// </summary>
|
||||
internal class BulldozersGenericStorage
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь (хранилище)
|
||||
/// </summary>
|
||||
readonly Dictionary<string, BulldozersGenericCollection<DrawingBulldozer, DrawingObjectBulldozer>> _bulldozerStorages;
|
||||
/// <summary>
|
||||
/// Возвращение списка названий наборов
|
||||
/// </summary>
|
||||
public List<string> Keys => _bulldozerStorages.Keys.ToList();
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="pictureWidth"></param>
|
||||
/// <param name="pictureHeight"></param>
|
||||
public BulldozersGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_bulldozerStorages = new Dictionary<string, BulldozersGenericCollection<DrawingBulldozer, DrawingObjectBulldozer>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление набора
|
||||
/// </summary>
|
||||
/// <param name="name">Название набора</param>
|
||||
public void AddSet(string name)
|
||||
{
|
||||
if (!_bulldozerStorages.ContainsKey(name))
|
||||
{
|
||||
_bulldozerStorages.Add(name, new BulldozersGenericCollection<DrawingBulldozer, DrawingObjectBulldozer>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление набора
|
||||
/// </summary>
|
||||
/// <param name="name">Название набора</param>
|
||||
public void DelSet(string name)
|
||||
{
|
||||
// TODO: Прописать логику для удаления набора
|
||||
if (_bulldozerStorages.ContainsKey(name))
|
||||
{
|
||||
_bulldozerStorages.Remove(name);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Доступ к набору
|
||||
/// </summary>
|
||||
/// <param name="ind"></param>
|
||||
/// <returns></returns>
|
||||
public BulldozersGenericCollection<DrawingBulldozer, DrawingObjectBulldozer>?
|
||||
this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO: Продумать логику получения набора
|
||||
if (_bulldozerStorages.ContainsKey(ind))
|
||||
{
|
||||
return _bulldozerStorages[ind];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
namespace Bulldozer.Generics
|
||||
using System.Numerics;
|
||||
|
||||
namespace Bulldozer.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
@ -8,57 +10,49 @@
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Массив объектов, которые храним
|
||||
/// Список объектов, которые храним
|
||||
/// </summary>
|
||||
private readonly T?[] _places;
|
||||
private readonly List<T?> _places;
|
||||
/// <summary>
|
||||
/// Количество объектов в массиве
|
||||
/// Количество объектов в списке
|
||||
/// </summary>
|
||||
public int Count => _places.Length;
|
||||
public int Count => _places.Count;
|
||||
/// <summary>
|
||||
/// Максимальное количество объектов в списке
|
||||
/// </summary>
|
||||
private readonly int _maxCount;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_places = new T?[count];
|
||||
_maxCount = count;
|
||||
_places = new List<T?>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="bulldozer">Добавляемый автомобиль</param>
|
||||
/// <param name="bulldozer">Добавляемый бульдозер</param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T bulldozer)
|
||||
{
|
||||
if (_places[Count - 1] != null)
|
||||
if (_places.Count == _maxCount)
|
||||
return -1;
|
||||
return Insert(bulldozer, 0);
|
||||
|
||||
Insert(bulldozer, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="bulldozer">Добавляемый автомобиль</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <param name="bulldozer">Добавляемый бульдозер</param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T bulldozer, int position)
|
||||
public int Insert(T bulldozer , int position)
|
||||
{
|
||||
if (!(position >= 0 && position < Count))
|
||||
return -1;
|
||||
if (_places[position] != null)
|
||||
{
|
||||
int ind = position;
|
||||
while (ind < Count && _places[ind] != null)
|
||||
ind++;
|
||||
if (ind == Count)
|
||||
return -1;
|
||||
for (int i = ind - 1; i >= position; i--)
|
||||
_places[i + 1] = _places[i];
|
||||
}
|
||||
_places[position] = bulldozer;
|
||||
if (position < 0 || position >= _maxCount) return -1;
|
||||
_places.Insert(position, bulldozer);
|
||||
return position;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
@ -67,9 +61,9 @@
|
||||
/// <returns></returns>
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (!(position >= 0 && position < Count) || _places[position] == null)
|
||||
if (position < 0 || position >= Count)
|
||||
return false;
|
||||
_places[position] = null;
|
||||
_places.RemoveAt(position);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
@ -79,9 +73,45 @@
|
||||
/// <returns></returns>
|
||||
public T? Get(int position)
|
||||
{
|
||||
if (!(position >= 0 && position < Count))
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
// Позиция находится за пределами допустимого диапазона, вернем null
|
||||
return null;
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T? this[int position]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (position < 0 || position >= Count) return null;
|
||||
return _places[position];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (position < 0 || position >= Count || Count == _maxCount) return;
|
||||
_places.Insert(position, value);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Проход по списку
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<T?> GetBulldozers(int? maxBulldozers = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxBulldozers.HasValue && i == maxBulldozers.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user