зафиксировать всё

This commit is contained in:
Учебный 2023-10-29 22:47:34 +04:00
parent bd494d4f70
commit bad8d47c56
16 changed files with 473 additions and 354 deletions

View File

@ -8,10 +8,15 @@ using System.Text;
using ProjectBoat_bae;
using ProjectBoat_bae.Entities;
using ProjectBoat_bae.MovementStrategy;
namespace ProjectBoat_bae.DrawningObjects
{
public class Drawningboat
{
// Получение объекта IMoveableObject из объекта DrawningCar
public IMoveableObject GetMoveableObject => new
DrawningObjectBoat(this);
// Класс-сущность
public EntityBoat? EntityBoat { get; protected set; }

View File

@ -38,6 +38,7 @@
buttonClickMotorBoat = new Button();
buttonStep = new Button();
comboBoxStrategy = new ComboBox();
buttonSelectBoat_Click = new Button();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
@ -144,11 +145,22 @@
comboBoxStrategy.Size = new Size(182, 33);
comboBoxStrategy.TabIndex = 9;
//
// buttonSelectBoat_Click
//
buttonSelectBoat_Click.Location = new Point(517, 598);
buttonSelectBoat_Click.Name = "buttonSelectBoat_Click";
buttonSelectBoat_Click.Size = new Size(233, 34);
buttonSelectBoat_Click.TabIndex = 10;
buttonSelectBoat_Click.Text = "Выбранная лодка";
buttonSelectBoat_Click.UseVisualStyleBackColor = true;
buttonSelectBoat_Click.Click += this.buttonSelectBoat_Click_Click;
//
// FormBoat
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1178, 644);
Controls.Add(buttonSelectBoat_Click);
Controls.Add(comboBoxStrategy);
Controls.Add(buttonStep);
Controls.Add(buttonClickMotorBoat);
@ -176,5 +188,7 @@
private Button buttonClickMotorBoat;
private Button buttonStep;
private ComboBox comboBoxStrategy;
private Button button1;
private Button buttonSelectBoat_Click;
}
}

View File

@ -8,8 +8,6 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProjectBoat_bae;
using ProjectBoat_bae.Properties;
using ProjectBoat_bae.Entities;
using ProjectBoat_bae.MovementStrategy;
using ProjectBoat_bae.DrawningObjects;
@ -22,10 +20,14 @@ namespace ProjectBoat_bae
private Drawningboat? _drawingBoat;
private AbstractStrategy? _abstractStrategy;
/// Âűáđŕííűé ŕâňîěîáčëü
public Drawningboat? SelectedBoat { get; private set; }
public FormBoat()
{
InitializeComponent();
_abstractStrategy = null;
SelectedBoat = null;
}
// Ìåòîä ïðîðèñîâêè
@ -69,19 +71,39 @@ namespace ProjectBoat_bae
}
private void buttonClickMotorBoat_Click(object sender, EventArgs e)
{
Random random = new Random();
_drawingBoat = new DrawningMotorBoat(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)),
Random random = new();
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;
}
Color dopColor = Color.FromArgb(random.Next(0, 256),
random.Next(0, 256), random.Next(0, 256));
ColorDialog dialogAddColor = new();
if (dialogAddColor.ShowDialog() == DialogResult.OK)
{
dopColor = dialogAddColor.Color;
}
_drawingBoat = new DrawningMotorBoat(random.Next(100, 300),
random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)), pictureBox1.Width, pictureBox1.Height);
pictureBox1.Width, pictureBox1.Height);
_drawingBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
private void buttonClick_Click(object sender, EventArgs e)
{
Random random = new();
_drawingBoat = new Drawningboat(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
pictureBox1.Width, pictureBox1.Height);
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;
}
_drawingBoat = new Drawningboat(random.Next(100, 300), random.Next(1000, 3000), color, pictureBox1.Width, pictureBox1.Height);
_drawingBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw();
}
@ -120,5 +142,11 @@ namespace ProjectBoat_bae
_abstractStrategy = null;
}
}
private void buttonSelectBoat_Click_Click(object sender, EventArgs e)
{
SelectedBoat = _drawingBoat;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -0,0 +1,124 @@
namespace ProjectBoat_bae
{
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()
{
pictureBoxCollection = new PictureBox();
buttonAddBoat_Click = new Button();
buttonRemoveBoat_Click = new Button();
buttonRefreshCollection_Click = new Button();
textBox1 = new TextBox();
maskedTextBoxNumber = new MaskedTextBox();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
SuspendLayout();
//
// pictureBoxCollection
//
pictureBoxCollection.Location = new Point(0, 0);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(1176, 647);
pictureBoxCollection.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBoxCollection.TabIndex = 0;
pictureBoxCollection.TabStop = false;
//
// buttonAddBoat_Click
//
buttonAddBoat_Click.Location = new Point(955, 73);
buttonAddBoat_Click.Name = "buttonAddBoat_Click";
buttonAddBoat_Click.Size = new Size(201, 47);
buttonAddBoat_Click.TabIndex = 1;
buttonAddBoat_Click.Text = "Добавить лодку";
buttonAddBoat_Click.UseVisualStyleBackColor = true;
buttonAddBoat_Click.Click += buttonAddBoat_Click_Click;
//
// buttonRemoveBoat_Click
//
buttonRemoveBoat_Click.Location = new Point(955, 345);
buttonRemoveBoat_Click.Name = "buttonRemoveBoat_Click";
buttonRemoveBoat_Click.Size = new Size(201, 46);
buttonRemoveBoat_Click.TabIndex = 2;
buttonRemoveBoat_Click.Text = "Удалить лодку";
buttonRemoveBoat_Click.UseVisualStyleBackColor = true;
buttonRemoveBoat_Click.Click += buttonRemoveBoat_Click_Click;
//
// buttonRefreshCollection_Click
//
buttonRefreshCollection_Click.Location = new Point(955, 421);
buttonRefreshCollection_Click.Name = "buttonRefreshCollection_Click";
buttonRefreshCollection_Click.Size = new Size(201, 50);
buttonRefreshCollection_Click.TabIndex = 3;
buttonRefreshCollection_Click.Text = "Обновить коллекцию";
buttonRefreshCollection_Click.UseVisualStyleBackColor = true;
buttonRefreshCollection_Click.Click += buttonRefreshCollection_Click_Click;
//
// textBox1
//
textBox1.BackColor = SystemColors.MenuBar;
textBox1.Location = new Point(955, 12);
textBox1.Name = "textBox1";
textBox1.Size = new Size(150, 31);
textBox1.TabIndex = 4;
textBox1.Text = "Инструменты";
textBox1.TextAlign = HorizontalAlignment.Center;
//
// maskedTextBoxNumber
//
maskedTextBoxNumber.Location = new Point(979, 293);
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(150, 31);
maskedTextBoxNumber.TabIndex = 5;
maskedTextBoxNumber.Text = "_";
//
// FormBoatCollection
//
AutoScaleDimensions = new SizeF(10F, 25F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1178, 644);
Controls.Add(maskedTextBoxNumber);
Controls.Add(textBox1);
Controls.Add(buttonRefreshCollection_Click);
Controls.Add(buttonRemoveBoat_Click);
Controls.Add(buttonAddBoat_Click);
Controls.Add(pictureBoxCollection);
Name = "FormBoatCollection";
Text = "FormBoatCollection";
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private PictureBox pictureBoxCollection;
private Button buttonAddBoat_Click;
private Button buttonRemoveBoat_Click;
private Button buttonRefreshCollection_Click;
private TextBox textBox1;
private MaskedTextBox maskedTextBoxNumber;
}
}

View File

@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProjectBoat_bae.DrawningObjects;
using ProjectBoat_bae.Generics;
using ProjectBoat_bae.MovementStrategy;
namespace ProjectBoat_bae
{
public partial class FormBoatCollection : Form
{
private readonly BoatsGenericCollection<Drawningboat, DrawningObjectBoat> _boats;
public FormBoatCollection()
{
InitializeComponent();
_boats = new BoatsGenericCollection<Drawningboat, DrawningObjectBoat>(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
// Добавление объекта в набор
private void buttonAddBoat_Click_Click(object sender, EventArgs e)
{
FormBoat form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (_boats + form.SelectedBoat != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = _boats.ShowBoats();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
// Удаление объекта из набора
private void buttonRemoveBoat_Click_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
//int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
//if (_boats - pos != null)
//{
// MessageBox.Show("Объект удален");
// pictureBoxCollection.Image = _boats.ShowBoats();
//}
//else
//{
// MessageBox.Show("Не удалось удалить объект");
//}
int pos = -1;
try
{
pos = Convert.ToInt32(maskedTextBoxNumber.Text);
}
catch (Exception ex) { }
if (_boats - pos)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _boats.ShowBoats();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void buttonRefreshCollection_Click_Click(object sender, EventArgs e)
{
pictureBoxCollection.Image = _boats.ShowBoats();
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectBoat_bae.MovementStrategy;
using ProjectBoat_bae.DrawningObjects;
namespace ProjectBoat_bae.Generics
{
internal class BoatsGenericCollection <T, U>
where T : Drawningboat
where U : IMoveableObject
{
// Ширина окна прорисовки
private readonly int _pictureWidth;
// Высота окна прорисовки
private readonly int _pictureHeight;
/// <summary>
/// Размер занимаемого объектом места (ширина)
/// </summary>
private readonly int _placeSizeWidth = 160;
// Размер занимаемого объектом места (высота)
private readonly int _placeSizeHeight = 160;
// Набор объектов
private readonly SetGeneric<T> _collection;
// Конструктор
public BoatsGenericCollection(int picWidth, int picHeight)
{
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height);
}
// Перегрузка оператора сложения
public static int operator +(BoatsGenericCollection<T, U> collect, T?
obj)
{
if (obj == null)
{
return -1;
}
return collect._collection.Insert(obj);
}
// Перегрузка оператора вычитания
public static bool operator -(BoatsGenericCollection<T, U> collect, int
pos)
{
T? obj = collect._collection.Get(pos);
if (obj != null)
{
collect._collection.Remove(pos);
}
return false;
}
// Получение объекта IMoveableObject
public U? GetU(int pos)
{
return (U?)_collection.Get(pos)?.GetMoveableObject;
}
// Вывод всего набора объектов
public Bitmap ShowBoats()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
Graphics gr = Graphics.FromImage(bmp);
DrawBackground(gr);
DrawObjects(gr);
return bmp;
}
// Метод отрисовки фона
private void DrawBackground(Graphics g)
{
Pen pen = new(Color.Black, 3);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
1; ++j)
{//линия рамзетки места
g.DrawLine(pen, i * _placeSizeWidth, j *
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
_placeSizeHeight);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
}
// Метод прорисовки объектов
private void DrawObjects(Graphics g)
{
for (int i = 0; i < _collection.Count; i++)
{
Drawningboat boat = _collection.Get(i);
if (boat != null)
{
int width = _pictureWidth / _placeSizeWidth;
boat.SetPosition(i % width * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
boat.DrawTransport(g);
}
}
}
}
}

View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectBoat_bae.Generics
{
internal class SetGeneric<T> where T : class
{
private readonly T?[] _places;
public int Count => _places.Length;
public SetGeneric(int count)
{
_places = new T?[count];
}
public int Insert(T boat)
{
if (_places[Count - 1] != null)
return -1;
return Insert(boat, 0);
}
public int Insert(T boat, int position)
{
if (position < 0 || position >= Count)
return -1;
if (_places[position] != null)
{
int indexEnd = position + 1;
while (_places[indexEnd] != null)
{
indexEnd++;
}
for (int i = indexEnd + 1; i > position; i--)
{
_places[i] = _places[i - 1];
}
}
_places[position] = boat;
return position;
}
public bool Remove(int position)
{
if (position < 0 || position >= _places.Count())
return false;
_places[position] = null;
return true;
}
public T? Get(int position)
{
if (position < 0 || position >= _places.Count())
return null;
return _places[position];
}
}
}

View File

@ -11,7 +11,7 @@ namespace ProjectBoat_bae
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormBoat());
Application.Run(new FormBoatCollection());
}
}
}

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "laba3(base)", "laba3(base)\laba3(base).csproj", "{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C4A3D74-03A3-4FF3-82C4-D0570E36B3CE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DBC78A3D-9D37-411B-8DAD-A904CC5BF8E0}
EndGlobalSection
EndGlobal

View File

@ -1,39 +0,0 @@
namespace laba3_base_
{
partial class Form1
{
/// <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()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace laba3_base_
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -1,132 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace laba3_base_.Generics
{
internal class CarsGenericCollection<T, U>
where T : DrawningPlane
where U : IMoveableObject
{
/// <summary>
/// Ширина окна прорисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна прорисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Размер занимаемого объектом места (ширина)
/// </summary>
private readonly int _placeSizeWidth = 175;
/// <summary>
/// Размер занимаемого объектом места (высота)
/// </summary>
private readonly int _placeSizeHeight = 80;
/// <summary>
/// Набор объектов
/// </summary>
private readonly SetGeneric<T> _collection;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
public PlanesGenericCollection(int picWidth, int picHeight)
{
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height);
}
/// <summary>
/// Перегрузка оператора сложения
/// </summary>
/// <param name="collect"></param>
/// <param name="obj"></param>
/// <returns></returns>
public static bool operator +(PlanesGenericCollection<T, U> collect, T?
obj)
{
if (obj == null)
{
return false;
}
return collect?._collection.Insert(obj) ?? false;
}
/// <summary>
/// Перегрузка оператора вычитания
/// </summary>
/// <param name="collect"></param>
/// <param name="pos"></param>
/// <returns></returns>
public static T? operator -(PlanesGenericCollection<T, U> collect, int
pos)
{
T? obj = collect._collection.Get(pos);
if (obj != null)
{
collect._collection.Remove(pos);
}
return obj;
}
/// <summary>
/// Получение объекта IMoveableObject
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public U? GetU(int pos)
{
return (U?)_collection.Get(pos)?.GetMoveableObject;
}
/// <summary>
/// Вывод всего набора объектов
/// </summary>
/// <returns></returns>
public Bitmap ShowCars()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
Graphics gr = Graphics.FromImage(bmp);
DrawBackground(gr);
DrawObjects(gr);
return bmp;
}
/// <summary>
/// Метод отрисовки фона
/// </summary>
/// <param name="g"></param>
private void DrawBackground(Graphics g)
{
Pen pen = new(Color.Black, 3);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
1; ++j)
{//линия рамзетки места
g.DrawLine(pen, i * _placeSizeWidth, j *
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
_placeSizeHeight);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
}
/// <summary>
/// Метод прорисовки объектов
/// </summary>
/// <param name="g"></param>
private void DrawObjects(Graphics g)
{
for (int i = 0; i < _collection.Count; i++)
{
// TODO получение объекта
// TODO установка позиции
// TODO прорисовка объекта
}
}
}
}

View File

@ -1,85 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace laba3_base_.Generics
{
internal class SetGeneric<T>
where T : class
{
// Массив объектов, которые храним
private readonly T?[] _places;
// Количество объектов в массиве
public int Count => _places.Length;
// Конструктор
public SetGeneric(int count)
{
_places = new T?[count];
}
// Добавление объекта в набор
public bool Insert(T car)
{
try
{
for (int i = _places.Length - 1; i > 0; i--)
{
_places[i] = _places[i - 1];
}
_places[0] = car;
return true;
}
catch
{
return false;
}
}
// Добавление объекта в набор на конкретную позицию
public bool Insert(T car, int position)
{
if (position < 0 || position >= _places.Count() || car == null)
{
return false;
}
if (_places[position] == null)
{
return false;
}
int positionNull = Array.FindIndex(_places, position, x => x == null);
if (positionNull == -1)
return false;
for (int i = positionNull; i > position; i--)
{
_places[i] = _places[i - 1];
}
_places[position] = car;
return true;
}
// Удаление объекта из набора с конкретной позиции
public bool Remove(int position)
{
if (position < 0 || position >= _places.Count())
return false;
_places[position] = null;
return true;
}
// Получение объекта из набора по позиции
public T? Get(int position)
{
if (position < 0 || position >= _places.Count())
return null;
return _places[position];
}
}
}

View File

@ -1,17 +0,0 @@
namespace laba3_base_
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}

View File

@ -1,12 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<RootNamespace>laba3_base_</RootNamespace>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>