todo
This commit is contained in:
parent
8790849a68
commit
188adc4d5b
@ -44,12 +44,24 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
|
||||
public T? Get(int position)
|
||||
{
|
||||
if(position <0 || position >= _collection.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// TODO проверка позиции
|
||||
return _collection[position];
|
||||
}
|
||||
|
||||
public bool Insert(T obj)
|
||||
{
|
||||
for(int i = 0; i < _collection.Length; i++)
|
||||
{
|
||||
if (_collection[i] == null)
|
||||
{
|
||||
_collection[i] = obj;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// TODO вставка в свободное место набора
|
||||
return false;
|
||||
}
|
||||
@ -57,20 +69,41 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
public bool Insert(T obj, int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
if(position < 0|| position > _collection.Length)
|
||||
if(position < 0|| position >= _collection.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
||||
// ищется свободное место после этой позиции и идет вставка туда
|
||||
// если нет после, ищем до
|
||||
|
||||
if (_collection[position] == null)
|
||||
{
|
||||
_collection[position] = obj;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = position; i < _collection.Length; ++i) //ищем свободное место справа
|
||||
{
|
||||
if (_collection[i] == null)
|
||||
{
|
||||
_collection[i] = obj;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < position; ++i) // иначе слева
|
||||
{
|
||||
if (_collection[i] == null)
|
||||
{
|
||||
_collection[i] = obj;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO вставка
|
||||
return false;
|
||||
}
|
||||
@ -79,6 +112,13 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
{
|
||||
// TODO проверка позиции
|
||||
// TODO удаление объекта из массива, присвоив элементу массива значение null
|
||||
return true;
|
||||
if (position < 0 || position >= _collection.Length || _collection[position] == null)
|
||||
return false;
|
||||
if (_collection[position] != null )
|
||||
{
|
||||
_collection[position] = null;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,45 @@ public class WarmlyShip2SharingService : AbstractCompany
|
||||
|
||||
protected override void DrawBackgound(Graphics g)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Pen pen = new(Color.Black, 3);
|
||||
int posX = 0;
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
int posY = 0;
|
||||
g.DrawLine(pen, posX, posY, posX, posY + _placeSizeHeight * (_pictureHeight / _placeSizeHeight));
|
||||
for (int j = 0; j <= _pictureHeight / _placeSizeHeight; j++)
|
||||
{
|
||||
g.DrawLine(pen, posX, posY, posX + _placeSizeWidth - 30, posY);
|
||||
posY += _placeSizeHeight;
|
||||
}
|
||||
posX += _placeSizeWidth;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetObjectsPosition()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
int posX = 0;
|
||||
int posY = _pictureHeight / _placeSizeHeight - 1;
|
||||
for (int i = 0; i < _collection?.Count; i++)
|
||||
{
|
||||
if (_collection.Get(i) != null)
|
||||
{
|
||||
_collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
|
||||
_collection?.Get(i)?.SetPosition(posX * _placeSizeWidth + 5, posY * _placeSizeHeight + 5);
|
||||
}
|
||||
if (posY > 0)
|
||||
{
|
||||
posY--;
|
||||
}
|
||||
else
|
||||
{
|
||||
posX++;
|
||||
posY = _pictureHeight / _placeSizeHeight - 1;
|
||||
}
|
||||
if (posY < 0) { return; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -37,12 +37,12 @@ namespace WarmlyShipProject.Drawnings
|
||||
/// <summary>
|
||||
/// Ширина прорисовки автомобиля
|
||||
/// </summary>
|
||||
private readonly int _drawningWarmlyShip2Width = 110;
|
||||
private readonly int _drawningWarmlyShip2Width = 150;
|
||||
|
||||
/// <summary>
|
||||
/// Высота прорисовки автомобиля
|
||||
/// </summary>
|
||||
private readonly int _drawningWarmlyShip2Height = 60;
|
||||
private readonly int _drawningWarmlyShip2Height = 40;
|
||||
|
||||
/// <summary>
|
||||
/// Координата X объекта
|
||||
|
@ -30,12 +30,10 @@
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormWarmlyShip));
|
||||
pictureBoxWarmlyShip2 = new PictureBox();
|
||||
buttonCreateWarmlyShip2 = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonCreateWarmlyShip = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonStrategyStep = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxWarmlyShip2).BeginInit();
|
||||
@ -52,17 +50,6 @@
|
||||
pictureBoxWarmlyShip2.TabStop = false;
|
||||
pictureBoxWarmlyShip2.Click += PictureBoxWarmlyShip2_Click;
|
||||
//
|
||||
// buttonCreateWarmlyShip2
|
||||
//
|
||||
buttonCreateWarmlyShip2.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateWarmlyShip2.Location = new Point(12, 381);
|
||||
buttonCreateWarmlyShip2.Name = "buttonCreateWarmlyShip2";
|
||||
buttonCreateWarmlyShip2.Size = new Size(290, 23);
|
||||
buttonCreateWarmlyShip2.TabIndex = 1;
|
||||
buttonCreateWarmlyShip2.Text = "СОЗДАТЬ ТЕПЛОХОД С ПРИБЛУДАМИ";
|
||||
buttonCreateWarmlyShip2.UseVisualStyleBackColor = true;
|
||||
buttonCreateWarmlyShip2.Click += ButtonCreateWarmlyShip2_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
@ -117,17 +104,6 @@
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonCreateWarmlyShip
|
||||
//
|
||||
buttonCreateWarmlyShip.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateWarmlyShip.Location = new Point(308, 381);
|
||||
buttonCreateWarmlyShip.Name = "buttonCreateWarmlyShip";
|
||||
buttonCreateWarmlyShip.Size = new Size(290, 23);
|
||||
buttonCreateWarmlyShip.TabIndex = 7;
|
||||
buttonCreateWarmlyShip.Text = "СОЗДАТЬ ТЕПЛОХОД БЕЗ ПРИБЛУД";
|
||||
buttonCreateWarmlyShip.UseVisualStyleBackColor = true;
|
||||
buttonCreateWarmlyShip.Click += ButtonCreateWarmlyShip_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
@ -148,21 +124,19 @@
|
||||
buttonStrategyStep.UseVisualStyleBackColor = true;
|
||||
buttonStrategyStep.Click += ButtonStrategyStep_Click;
|
||||
//
|
||||
// FormWarmlyShip2
|
||||
// FormWarmlyShip
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(729, 416);
|
||||
Controls.Add(buttonStrategyStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonCreateWarmlyShip);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonCreateWarmlyShip2);
|
||||
Controls.Add(pictureBoxWarmlyShip2);
|
||||
Name = "FormWarmlyShip2";
|
||||
Name = "FormWarmlyShip";
|
||||
Text = "Теплоход";
|
||||
Load += FormWarmlyShip2_Load;
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxWarmlyShip2).EndInit();
|
||||
@ -173,12 +147,10 @@
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxWarmlyShip2;
|
||||
private Button buttonCreateWarmlyShip2;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
private Button buttonRight;
|
||||
private Button buttonDown;
|
||||
private Button buttonCreateWarmlyShip;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStrategyStep;
|
||||
}
|
||||
|
@ -52,49 +52,7 @@ namespace WarmlyShipProject
|
||||
_drawningWarmlyShip.DrawTransport(gr);
|
||||
pictureBoxWarmlyShip2.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Ñîçäàíèå îáúåêòà êëàññà-ïåðåìåùåíèÿ
|
||||
/// </summary>
|
||||
/// <param name="type">Òèï ñîçäàâàåìîãî îáúåêòà</param>
|
||||
private void CreateObject(string type)
|
||||
{
|
||||
Random random = new();
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawningWarmlyShip):
|
||||
_drawningWarmlyShip = new DrawningWarmlyShip(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(DrawningWarmlyShip2):
|
||||
_drawningWarmlyShip = new DrawningWarmlyShip2(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)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
_drawningWarmlyShip.SetPictureSize(pictureBoxWarmlyShip2.Width, pictureBoxWarmlyShip2.Height);
|
||||
_drawningWarmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
_strategy = null;
|
||||
comboBoxStrategy.Enabled = true;
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü ïîëíîöåííûé òåïëîõîä "
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreateWarmlyShip2_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningWarmlyShip2));
|
||||
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü óùåðáíûé òåïëîõîä "
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
private void ButtonCreateWarmlyShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningWarmlyShip));
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение объекта по форме (нажатие кнопок навигации)
|
||||
/// </summary>
|
||||
|
@ -332,7 +332,7 @@
|
||||
<data name="buttonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAArQAAAPUCAYAAABcvao0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vgAADr4B6kKxwAAASklJREFUeF7t3XnY3WV953Ge7AtIgpBQVgcIihCoVbbayqZ2NIB2RkBwmWsEQYsg
|
||||
vQAADr0BR/uQrQAASklJREFUeF7t3XnY3WV953Ge7AtIgpBQVgcIihCoVbbayqZ2NIB2RkBwmWsEQYsg
|
||||
oqKjjrigiAtg1VasgDDqtEDUel0GAcclLI4SlhESaEcSHAhQSIAEkpCQ5J7fCRcVnt8XyPIs53zv1x+v
|
||||
uepnAiTnOee+34Qn52xWSgGG0BNPPFH+5V/+pfzsZz8rF198cfnUpz5Vjj/++PL617++vPKVryz77LNP
|
||||
2WWXXcoOO+xQJk+eXMaPH18222wzoIv19fWte712Xre77777utfyIYccUo4++ujy8Y9/vFxyySXlf//v
|
||||
|
Loading…
Reference in New Issue
Block a user