Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b75e1f20b | ||
|
|
feeb709fd2 | ||
|
|
3983ae497f | ||
|
|
d732ad2663 | ||
|
|
964619d691 | ||
|
|
7dbd8ad01f | ||
|
|
c05b306cb1 | ||
|
|
cd5b790f24 |
@@ -19,12 +19,12 @@ namespace Liner.Drawing
|
|||||||
/// <param name="deck">Признак наличия доп палубы</param>
|
/// <param name="deck">Признак наличия доп палубы</param>
|
||||||
/// <param name="width">Ширина картинки</param>
|
/// <param name="width">Ширина картинки</param>
|
||||||
/// <param name="height">Высота картинки</param>
|
/// <param name="height">Высота картинки</param>
|
||||||
public DrawingBigLiner(int speed, double weight, Color bodyColor, Color bottomColor, bool swimmingPool, bool deck, int width, int height)
|
public DrawingBigLiner(int speed, double weight, Color bottomColor, Color bodyColor, bool swimmingPool, bool deck, int width, int height)
|
||||||
: base(speed,weight,bodyColor,bottomColor,width,height,100,80)
|
: base(speed,weight,bodyColor,width,height,100,80)
|
||||||
{
|
{
|
||||||
if(EntityLiner!= null)
|
if(EntityLiner!= null)
|
||||||
{
|
{
|
||||||
EntityLiner = new EntityBigLiner(speed, weight, bodyColor, bottomColor, deck, swimmingPool);
|
EntityLiner = new EntityBigLiner(speed, weight,bottomColor, bodyColor, deck, swimmingPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -41,8 +41,8 @@ namespace Liner.Drawing
|
|||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush poolBrush = new SolidBrush(Color.Blue);
|
Brush poolBrush = new SolidBrush(Color.Blue);
|
||||||
Brush bottomBrush = new SolidBrush(EntityLiner.BottomColor);
|
Brush bottomBrush = new SolidBrush(liner.BottomColor);
|
||||||
Brush deckBrush = new SolidBrush(EntityLiner.BodyColor);
|
Brush deckBrush = new SolidBrush(liner.BodyColor);
|
||||||
// палуба
|
// палуба
|
||||||
Point[] firstDeck = {new Point(_startPosX + 30, _startPosY), new Point(_startPosX + 30 + 60, _startPosY),
|
Point[] firstDeck = {new Point(_startPosX + 30, _startPosY), new Point(_startPosX + 30 + 60, _startPosY),
|
||||||
new Point(_startPosX + 30 + 60, _startPosY + 20), new Point(_startPosX + 30, _startPosY + 20)};
|
new Point(_startPosX + 30 + 60, _startPosY + 20), new Point(_startPosX + 30, _startPosY + 20)};
|
||||||
@@ -76,5 +76,12 @@ namespace Liner.Drawing
|
|||||||
g.DrawPolygon(pen, bottom);//рисуем нижний корпус
|
g.DrawPolygon(pen, bottom);//рисуем нижний корпус
|
||||||
if (liner.SwimmingPool) { g.FillPolygon(poolBrush, pool); }//рисуем бассейн
|
if (liner.SwimmingPool) { g.FillPolygon(poolBrush, pool); }//рисуем бассейн
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// установка цвета большого лайнера
|
||||||
|
/// </summary>
|
||||||
|
public void SetAddColor(Color color)
|
||||||
|
{
|
||||||
|
(EntityLiner as EntityBigLiner).BodyColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,32 +63,32 @@ namespace Liner.Drawing
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес лайнера</param>
|
/// <param name="weight">Вес лайнера</param>
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bottomColor">Основной цвет</param>
|
||||||
/// <param name="width">Ширина картинки</param>
|
/// <param name="width">Ширина картинки</param>
|
||||||
/// <param name="height">Высота картинки</param>
|
/// <param name="height">Высота картинки</param>
|
||||||
public DrawingLiner(int speed, double weight, Color bodyColor, Color bottomColor, int width, int height)
|
public DrawingLiner(int speed, double weight, Color bottomColor, int width, int height)
|
||||||
{
|
{
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
EntityLiner = new EntityLiner(speed, weight, bodyColor, bottomColor);
|
EntityLiner = new EntityLiner(speed, weight, bottomColor);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес лайнера</param>
|
/// <param name="weight">Вес лайнера</param>
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bottomColor">Основной цвет</param>
|
||||||
/// <param name="width">Ширина картинки</param>
|
/// <param name="width">Ширина картинки</param>
|
||||||
/// <param name="height">Высота картинки</param>
|
/// <param name="height">Высота картинки</param>
|
||||||
/// <param name="linerWidth">Ширина прорисовки лайнера</param>
|
/// <param name="linerWidth">Ширина прорисовки лайнера</param>
|
||||||
/// <param name="linerHeight">Высота прорисовки лайнера</param>
|
/// <param name="linerHeight">Высота прорисовки лайнера</param>
|
||||||
protected DrawingLiner(int speed, double weight, Color bodyColor, Color bottomColor, int width, int height,int linerWidth,int linerHeight)
|
protected DrawingLiner(int speed, double weight, Color bottomColor, int width, int height,int linerWidth,int linerHeight)
|
||||||
{
|
{
|
||||||
_linerHeight = linerHeight;
|
_linerHeight = linerHeight;
|
||||||
_linerWidth = linerWidth;
|
_linerWidth = linerWidth;
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
EntityLiner = new EntityLiner(speed, weight, bodyColor, bottomColor);
|
EntityLiner = new EntityLiner(speed, weight, bottomColor);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка позиции
|
/// Установка позиции
|
||||||
@@ -113,8 +113,8 @@ namespace Liner.Drawing
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush bottomBrush = new SolidBrush(EntityLiner.BottomColor);
|
Brush bottomBrush = new SolidBrush(EntityLiner.BottomColor);
|
||||||
Brush deckBrush = new SolidBrush(EntityLiner.BodyColor);
|
Brush deckBrush = new SolidBrush(Color.Black);//черная палуба по умолчанию
|
||||||
// палуба
|
// палуба
|
||||||
Point[] firstDeck = {new Point(_startPosX + 30, _startPosY), new Point(_startPosX + 30 + 60, _startPosY),
|
Point[] firstDeck = {new Point(_startPosX + 30, _startPosY), new Point(_startPosX + 30 + 60, _startPosY),
|
||||||
new Point(_startPosX + 30 + 60, _startPosY + 20), new Point(_startPosX + 30, _startPosY + 20)};
|
new Point(_startPosX + 30 + 60, _startPosY + 20), new Point(_startPosX + 30, _startPosY + 20)};
|
||||||
|
|||||||
69
Liner/Drawing/ExtentionDrawingLiner.cs
Normal file
69
Liner/Drawing/ExtentionDrawingLiner.cs
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
using Liner.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Liner.Drawing
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Расширение для класса EntityLiner
|
||||||
|
/// </summary>
|
||||||
|
public static class ExtentionDrawningLiner
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Создание объекта из строки
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">Строка с данными для создания объекта</param>
|
||||||
|
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||||
|
/// <param name="width">Ширина</param>
|
||||||
|
/// <param name="height">Высота</param>
|
||||||
|
/// <returns>Объект</returns>
|
||||||
|
public static DrawingLiner? CreateDrawingLiner(this string info, char
|
||||||
|
separatorForObject, int width, int height)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(separatorForObject);
|
||||||
|
if (strs.Length == 3)
|
||||||
|
{
|
||||||
|
return new DrawingLiner(Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
|
||||||
|
}
|
||||||
|
if (strs.Length == 6)
|
||||||
|
{
|
||||||
|
return new DrawingBigLiner(Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]),
|
||||||
|
Color.FromName(strs[2]),
|
||||||
|
Color.FromName(strs[3]),
|
||||||
|
Convert.ToBoolean(strs[4]),
|
||||||
|
Convert.ToBoolean(strs[5]),
|
||||||
|
width, height);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение данных для сохранения в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drawingLiner">Сохраняемый объект</param>
|
||||||
|
/// <param name="separatorForObject">Разделитель даннных</param>
|
||||||
|
/// <returns>Строка с данными по объекту</returns>
|
||||||
|
public static string GetDataForSave(this DrawingLiner drawingLiner,
|
||||||
|
char separatorForObject)
|
||||||
|
{
|
||||||
|
var liner = drawingLiner.EntityLiner;
|
||||||
|
if (liner == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
var str =
|
||||||
|
$"{liner.Speed}{separatorForObject}{liner.Weight}{separatorForObject}{liner.BottomColor.Name}";
|
||||||
|
if (liner is not EntityBigLiner bigLiner)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return
|
||||||
|
$"{str}{separatorForObject}{bigLiner.BodyColor.Name}{separatorForObject}{bigLiner.SwimmingPool}{separatorForObject}" +
|
||||||
|
$"{bigLiner.Deck}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,10 @@ namespace Liner.Entities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Deck { get; private set; }
|
public bool Deck { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Доп цвет
|
||||||
|
/// </summary>
|
||||||
|
public Color BodyColor { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// Конструктор с параметрами
|
/// Конструктор с параметрами
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
@@ -25,10 +29,11 @@ namespace Liner.Entities
|
|||||||
/// <param name="bottomColor">Дополнительный цвет</param>
|
/// <param name="bottomColor">Дополнительный цвет</param>
|
||||||
/// <param name="deck">Признак наличия доп палубы</param>
|
/// <param name="deck">Признак наличия доп палубы</param>
|
||||||
/// <param name="swimmingPool">Признак наличия бассейна</param>
|
/// <param name="swimmingPool">Признак наличия бассейна</param>
|
||||||
public EntityBigLiner(int speed, double weight, Color bodyColor, Color bottomColor,bool deck, bool swimmingPool) : base(speed, weight, bodyColor,bottomColor)
|
public EntityBigLiner(int speed, double weight, Color bottomColor,Color bodyColor,bool deck, bool swimmingPool) : base(speed, weight, bottomColor)
|
||||||
{
|
{
|
||||||
Deck = deck;
|
Deck = deck;
|
||||||
SwimmingPool = swimmingPool;
|
SwimmingPool = swimmingPool;
|
||||||
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,7 @@ namespace Liner.Entities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Основной цвет
|
/// Основной цвет
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color BodyColor { get; private set; }
|
public Color BottomColor { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// Доп цвет
|
|
||||||
/// </summary>
|
|
||||||
public Color BottomColor { get; private set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Шаг
|
/// Шаг
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -34,13 +30,11 @@ namespace Liner.Entities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес лайнера</param>
|
/// <param name="weight">Вес лайнера</param>
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bottomColor">Основной цвет</param>
|
||||||
/// <param name="bottomColor">Доп цвет</param>
|
public EntityLiner(int speed, double weight, Color bottomColor)
|
||||||
public EntityLiner(int speed, double weight, Color bodyColor, Color bottomColor)
|
|
||||||
{
|
{
|
||||||
Speed = speed;
|
Speed = speed;
|
||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
|
||||||
BottomColor = bottomColor;
|
BottomColor = bottomColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
65
Liner/FormLinerCollection.Designer.cs
generated
65
Liner/FormLinerCollection.Designer.cs
generated
@@ -39,9 +39,16 @@
|
|||||||
textBoxNumber = new TextBox();
|
textBoxNumber = new TextBox();
|
||||||
buttonAddLiner = new Button();
|
buttonAddLiner = new Button();
|
||||||
pictureBoxCollection = new PictureBox();
|
pictureBoxCollection = new PictureBox();
|
||||||
|
FileMenuStrip = new MenuStrip();
|
||||||
|
FileToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
openFileDialog = new OpenFileDialog();
|
||||||
|
saveFileDialog = new SaveFileDialog();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
Storages.SuspendLayout();
|
Storages.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||||
|
FileMenuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
@@ -64,9 +71,9 @@
|
|||||||
Storages.Controls.Add(buttonDeleteSet);
|
Storages.Controls.Add(buttonDeleteSet);
|
||||||
Storages.Controls.Add(textBoxStorageName);
|
Storages.Controls.Add(textBoxStorageName);
|
||||||
Storages.Controls.Add(buttonAddStorage);
|
Storages.Controls.Add(buttonAddStorage);
|
||||||
Storages.Location = new Point(7, 19);
|
Storages.Location = new Point(7, 22);
|
||||||
Storages.Name = "Storages";
|
Storages.Name = "Storages";
|
||||||
Storages.Size = new Size(200, 276);
|
Storages.Size = new Size(200, 273);
|
||||||
Storages.TabIndex = 4;
|
Storages.TabIndex = 4;
|
||||||
Storages.TabStop = false;
|
Storages.TabStop = false;
|
||||||
Storages.Text = "Sets";
|
Storages.Text = "Sets";
|
||||||
@@ -147,19 +154,60 @@
|
|||||||
//
|
//
|
||||||
// pictureBoxCollection
|
// pictureBoxCollection
|
||||||
//
|
//
|
||||||
pictureBoxCollection.Location = new Point(2, 0);
|
pictureBoxCollection.Location = new Point(2, 27);
|
||||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
pictureBoxCollection.Size = new Size(731, 565);
|
pictureBoxCollection.Size = new Size(731, 538);
|
||||||
pictureBoxCollection.TabIndex = 1;
|
pictureBoxCollection.TabIndex = 1;
|
||||||
pictureBoxCollection.TabStop = false;
|
pictureBoxCollection.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// FileMenuStrip
|
||||||
|
//
|
||||||
|
FileMenuStrip.Items.AddRange(new ToolStripItem[] { FileToolStripMenuItem });
|
||||||
|
FileMenuStrip.Location = new Point(0, 0);
|
||||||
|
FileMenuStrip.Name = "FileMenuStrip";
|
||||||
|
FileMenuStrip.Size = new Size(951, 24);
|
||||||
|
FileMenuStrip.TabIndex = 2;
|
||||||
|
FileMenuStrip.Text = "FileMenuStrip";
|
||||||
|
//
|
||||||
|
// FileToolStripMenuItem
|
||||||
|
//
|
||||||
|
FileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
|
||||||
|
FileToolStripMenuItem.Name = "FileToolStripMenuItem";
|
||||||
|
FileToolStripMenuItem.Size = new Size(40, 20);
|
||||||
|
FileToolStripMenuItem.Text = "FILE";
|
||||||
|
//
|
||||||
|
// SaveToolStripMenuItem
|
||||||
|
//
|
||||||
|
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||||
|
SaveToolStripMenuItem.Size = new Size(105, 22);
|
||||||
|
SaveToolStripMenuItem.Text = "SAVE";
|
||||||
|
SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// LoadToolStripMenuItem
|
||||||
|
//
|
||||||
|
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||||
|
LoadToolStripMenuItem.Size = new Size(105, 22);
|
||||||
|
LoadToolStripMenuItem.Text = "LOAD";
|
||||||
|
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
openFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
saveFileDialog.FileName = "saveFile";
|
||||||
|
saveFileDialog.Filter = "txt file | *.txt";
|
||||||
|
//
|
||||||
// FormLinerCollection
|
// FormLinerCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(951, 568);
|
ClientSize = new Size(951, 568);
|
||||||
|
Controls.Add(FileMenuStrip);
|
||||||
Controls.Add(pictureBoxCollection);
|
Controls.Add(pictureBoxCollection);
|
||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
|
MainMenuStrip = FileMenuStrip;
|
||||||
Name = "FormLinerCollection";
|
Name = "FormLinerCollection";
|
||||||
Text = "Liner Collection";
|
Text = "Liner Collection";
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
@@ -167,7 +215,10 @@
|
|||||||
Storages.ResumeLayout(false);
|
Storages.ResumeLayout(false);
|
||||||
Storages.PerformLayout();
|
Storages.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||||
|
FileMenuStrip.ResumeLayout(false);
|
||||||
|
FileMenuStrip.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -183,5 +234,11 @@
|
|||||||
private Button buttonDeleteSet;
|
private Button buttonDeleteSet;
|
||||||
private TextBox textBoxStorageName;
|
private TextBox textBoxStorageName;
|
||||||
private Button buttonAddStorage;
|
private Button buttonAddStorage;
|
||||||
|
private MenuStrip FileMenuStrip;
|
||||||
|
private ToolStripMenuItem FileToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,24 +41,30 @@ namespace Liner
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
var formLinerConfig = new FormLinerConfig();
|
||||||
string.Empty];
|
formLinerConfig.AddEvent(AddLiner);
|
||||||
|
formLinerConfig.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddLiner(DrawingLiner liner)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MainScreen form = new();
|
if ((obj + liner) != -1)
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
{
|
||||||
if (obj + form.SelectedLiner != -1)
|
MessageBox.Show("Объект добавлен");
|
||||||
{
|
pictureBoxCollection.Image = obj.ShowLiners();
|
||||||
MessageBox.Show("Объект добавлен");
|
}
|
||||||
pictureBoxCollection.Image = obj.ShowLiners();
|
else
|
||||||
}
|
{
|
||||||
else
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -185,5 +191,38 @@ namespace Liner
|
|||||||
listBoxStorages.SelectedIndex = index;
|
listBoxStorages.SelectedIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_storage.SaveData(saveFileDialog.FileName))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Сохранение прошло успешно",
|
||||||
|
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не сохранилось", "Результат",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_storage.LoadData(openFileDialog.FileName))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
ReloadObjects();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не загрузилось", "Результат",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,4 +117,13 @@
|
|||||||
<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="FileMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>144, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>284, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
356
Liner/FormLinerConfig.Designer.cs
generated
Normal file
356
Liner/FormLinerConfig.Designer.cs
generated
Normal file
@@ -0,0 +1,356 @@
|
|||||||
|
namespace Liner
|
||||||
|
{
|
||||||
|
partial class FormLinerConfig
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
groupBoxParametrs = new GroupBox();
|
||||||
|
labelModifiedObject = new Label();
|
||||||
|
labelSimpleObject = new Label();
|
||||||
|
groupBoxColors = new GroupBox();
|
||||||
|
panelPurple = new Panel();
|
||||||
|
panelBlack = new Panel();
|
||||||
|
panelGray = new Panel();
|
||||||
|
panelWhite = new Panel();
|
||||||
|
panelYellow = new Panel();
|
||||||
|
panelBlue = new Panel();
|
||||||
|
panelGreen = new Panel();
|
||||||
|
panelRed = new Panel();
|
||||||
|
checkBoxDeck = new CheckBox();
|
||||||
|
checkBoxPool = new CheckBox();
|
||||||
|
numericUpDownWeight = new NumericUpDown();
|
||||||
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
|
TextWeight = new Label();
|
||||||
|
TextSpeed = new Label();
|
||||||
|
panelObject = new Panel();
|
||||||
|
pictureBoxObject = new PictureBox();
|
||||||
|
labelAddColor = new Label();
|
||||||
|
labelMainColor = new Label();
|
||||||
|
buttonOk = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
groupBoxParametrs.SuspendLayout();
|
||||||
|
groupBoxColors.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||||
|
panelObject.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBoxParametrs
|
||||||
|
//
|
||||||
|
groupBoxParametrs.Controls.Add(labelModifiedObject);
|
||||||
|
groupBoxParametrs.Controls.Add(labelSimpleObject);
|
||||||
|
groupBoxParametrs.Controls.Add(groupBoxColors);
|
||||||
|
groupBoxParametrs.Controls.Add(checkBoxDeck);
|
||||||
|
groupBoxParametrs.Controls.Add(checkBoxPool);
|
||||||
|
groupBoxParametrs.Controls.Add(numericUpDownWeight);
|
||||||
|
groupBoxParametrs.Controls.Add(numericUpDownSpeed);
|
||||||
|
groupBoxParametrs.Controls.Add(TextWeight);
|
||||||
|
groupBoxParametrs.Controls.Add(TextSpeed);
|
||||||
|
groupBoxParametrs.Location = new Point(12, 12);
|
||||||
|
groupBoxParametrs.Name = "groupBoxParametrs";
|
||||||
|
groupBoxParametrs.Size = new Size(588, 307);
|
||||||
|
groupBoxParametrs.TabIndex = 0;
|
||||||
|
groupBoxParametrs.TabStop = false;
|
||||||
|
groupBoxParametrs.Text = "Parametrs";
|
||||||
|
//
|
||||||
|
// labelModifiedObject
|
||||||
|
//
|
||||||
|
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelModifiedObject.Location = new Point(419, 241);
|
||||||
|
labelModifiedObject.Name = "labelModifiedObject";
|
||||||
|
labelModifiedObject.Size = new Size(120, 50);
|
||||||
|
labelModifiedObject.TabIndex = 8;
|
||||||
|
labelModifiedObject.Text = "Big";
|
||||||
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelSimpleObject.Location = new Point(278, 241);
|
||||||
|
labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
labelSimpleObject.Size = new Size(120, 50);
|
||||||
|
labelSimpleObject.TabIndex = 7;
|
||||||
|
labelSimpleObject.Text = "Small";
|
||||||
|
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// groupBoxColors
|
||||||
|
//
|
||||||
|
groupBoxColors.Controls.Add(panelPurple);
|
||||||
|
groupBoxColors.Controls.Add(panelBlack);
|
||||||
|
groupBoxColors.Controls.Add(panelGray);
|
||||||
|
groupBoxColors.Controls.Add(panelWhite);
|
||||||
|
groupBoxColors.Controls.Add(panelYellow);
|
||||||
|
groupBoxColors.Controls.Add(panelBlue);
|
||||||
|
groupBoxColors.Controls.Add(panelGreen);
|
||||||
|
groupBoxColors.Controls.Add(panelRed);
|
||||||
|
groupBoxColors.Location = new Point(244, 22);
|
||||||
|
groupBoxColors.Name = "groupBoxColors";
|
||||||
|
groupBoxColors.Size = new Size(338, 200);
|
||||||
|
groupBoxColors.TabIndex = 6;
|
||||||
|
groupBoxColors.TabStop = false;
|
||||||
|
groupBoxColors.Text = "Colors";
|
||||||
|
//
|
||||||
|
// panelPurple
|
||||||
|
//
|
||||||
|
panelPurple.BackColor = Color.Purple;
|
||||||
|
panelPurple.Location = new Point(248, 110);
|
||||||
|
panelPurple.Name = "panelPurple";
|
||||||
|
panelPurple.Size = new Size(57, 49);
|
||||||
|
panelPurple.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
panelBlack.BackColor = Color.Black;
|
||||||
|
panelBlack.Location = new Point(175, 110);
|
||||||
|
panelBlack.Name = "panelBlack";
|
||||||
|
panelBlack.Size = new Size(57, 49);
|
||||||
|
panelBlack.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
panelGray.BackColor = Color.Gray;
|
||||||
|
panelGray.Location = new Point(97, 110);
|
||||||
|
panelGray.Name = "panelGray";
|
||||||
|
panelGray.Size = new Size(57, 49);
|
||||||
|
panelGray.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
panelWhite.BackColor = Color.White;
|
||||||
|
panelWhite.Location = new Point(18, 110);
|
||||||
|
panelWhite.Name = "panelWhite";
|
||||||
|
panelWhite.Size = new Size(57, 49);
|
||||||
|
panelWhite.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
panelYellow.BackColor = Color.Yellow;
|
||||||
|
panelYellow.Location = new Point(248, 22);
|
||||||
|
panelYellow.Name = "panelYellow";
|
||||||
|
panelYellow.Size = new Size(57, 49);
|
||||||
|
panelYellow.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
panelBlue.BackColor = Color.Blue;
|
||||||
|
panelBlue.Location = new Point(175, 22);
|
||||||
|
panelBlue.Name = "panelBlue";
|
||||||
|
panelBlue.Size = new Size(57, 49);
|
||||||
|
panelBlue.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
panelGreen.BackColor = Color.Green;
|
||||||
|
panelGreen.Location = new Point(97, 22);
|
||||||
|
panelGreen.Name = "panelGreen";
|
||||||
|
panelGreen.Size = new Size(57, 49);
|
||||||
|
panelGreen.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
panelRed.BackColor = Color.Red;
|
||||||
|
panelRed.Location = new Point(18, 22);
|
||||||
|
panelRed.Name = "panelRed";
|
||||||
|
panelRed.Size = new Size(57, 49);
|
||||||
|
panelRed.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// checkBoxDeck
|
||||||
|
//
|
||||||
|
checkBoxDeck.AutoSize = true;
|
||||||
|
checkBoxDeck.Location = new Point(17, 162);
|
||||||
|
checkBoxDeck.Name = "checkBoxDeck";
|
||||||
|
checkBoxDeck.Size = new Size(110, 19);
|
||||||
|
checkBoxDeck.TabIndex = 5;
|
||||||
|
checkBoxDeck.Text = "Additional Deck";
|
||||||
|
checkBoxDeck.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxPool
|
||||||
|
//
|
||||||
|
checkBoxPool.AutoSize = true;
|
||||||
|
checkBoxPool.Location = new Point(17, 137);
|
||||||
|
checkBoxPool.Name = "checkBoxPool";
|
||||||
|
checkBoxPool.Size = new Size(110, 19);
|
||||||
|
checkBoxPool.TabIndex = 4;
|
||||||
|
checkBoxPool.Text = "Swimming pool";
|
||||||
|
checkBoxPool.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
numericUpDownWeight.Location = new Point(81, 70);
|
||||||
|
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||||
|
numericUpDownWeight.Size = new Size(70, 23);
|
||||||
|
numericUpDownWeight.TabIndex = 3;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
numericUpDownSpeed.Location = new Point(81, 41);
|
||||||
|
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||||
|
numericUpDownSpeed.Size = new Size(70, 23);
|
||||||
|
numericUpDownSpeed.TabIndex = 2;
|
||||||
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// TextWeight
|
||||||
|
//
|
||||||
|
TextWeight.AutoSize = true;
|
||||||
|
TextWeight.Location = new Point(17, 73);
|
||||||
|
TextWeight.Name = "TextWeight";
|
||||||
|
TextWeight.Size = new Size(48, 15);
|
||||||
|
TextWeight.TabIndex = 1;
|
||||||
|
TextWeight.Text = "Weight:";
|
||||||
|
//
|
||||||
|
// TextSpeed
|
||||||
|
//
|
||||||
|
TextSpeed.AutoSize = true;
|
||||||
|
TextSpeed.Location = new Point(17, 43);
|
||||||
|
TextSpeed.Name = "TextSpeed";
|
||||||
|
TextSpeed.Size = new Size(42, 15);
|
||||||
|
TextSpeed.TabIndex = 0;
|
||||||
|
TextSpeed.Text = "Speed:";
|
||||||
|
//
|
||||||
|
// panelObject
|
||||||
|
//
|
||||||
|
panelObject.AllowDrop = true;
|
||||||
|
panelObject.Controls.Add(pictureBoxObject);
|
||||||
|
panelObject.Location = new Point(626, 56);
|
||||||
|
panelObject.Name = "panelObject";
|
||||||
|
panelObject.Size = new Size(325, 224);
|
||||||
|
panelObject.TabIndex = 1;
|
||||||
|
panelObject.DragDrop += PanelObject_DragDrop;
|
||||||
|
panelObject.DragEnter += PanelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
pictureBoxObject.Location = new Point(20, 6);
|
||||||
|
pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
pictureBoxObject.Size = new Size(292, 218);
|
||||||
|
pictureBoxObject.TabIndex = 11;
|
||||||
|
pictureBoxObject.TabStop = false;
|
||||||
|
//
|
||||||
|
// labelAddColor
|
||||||
|
//
|
||||||
|
labelAddColor.AllowDrop = true;
|
||||||
|
labelAddColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelAddColor.Location = new Point(801, 7);
|
||||||
|
labelAddColor.Name = "labelAddColor";
|
||||||
|
labelAddColor.Size = new Size(150, 46);
|
||||||
|
labelAddColor.TabIndex = 10;
|
||||||
|
labelAddColor.Text = "Additional Color";
|
||||||
|
labelAddColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelAddColor.DragDrop += LabelColor_DragDrop;
|
||||||
|
labelAddColor.DragEnter += LabelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// labelMainColor
|
||||||
|
//
|
||||||
|
labelMainColor.AllowDrop = true;
|
||||||
|
labelMainColor.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelMainColor.Location = new Point(626, 7);
|
||||||
|
labelMainColor.Name = "labelMainColor";
|
||||||
|
labelMainColor.Size = new Size(150, 46);
|
||||||
|
labelMainColor.TabIndex = 9;
|
||||||
|
labelMainColor.Text = "Main Color";
|
||||||
|
labelMainColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelMainColor.DragDrop += LabelColor_DragDrop;
|
||||||
|
labelMainColor.DragEnter += LabelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// buttonOk
|
||||||
|
//
|
||||||
|
buttonOk.Location = new Point(626, 290);
|
||||||
|
buttonOk.Name = "buttonOk";
|
||||||
|
buttonOk.Size = new Size(135, 29);
|
||||||
|
buttonOk.TabIndex = 2;
|
||||||
|
buttonOk.Text = "Add";
|
||||||
|
buttonOk.UseVisualStyleBackColor = true;
|
||||||
|
buttonOk.Click += ButtonOk_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(816, 290);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(135, 29);
|
||||||
|
buttonCancel.TabIndex = 3;
|
||||||
|
buttonCancel.Text = "Cancel";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FormLinerConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(985, 331);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(labelAddColor);
|
||||||
|
Controls.Add(buttonOk);
|
||||||
|
Controls.Add(panelObject);
|
||||||
|
Controls.Add(labelMainColor);
|
||||||
|
Controls.Add(groupBoxParametrs);
|
||||||
|
Name = "FormLinerConfig";
|
||||||
|
Text = "FormLinerConfig";
|
||||||
|
groupBoxParametrs.ResumeLayout(false);
|
||||||
|
groupBoxParametrs.PerformLayout();
|
||||||
|
groupBoxColors.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
|
panelObject.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBoxParametrs;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private Label TextWeight;
|
||||||
|
private Label TextSpeed;
|
||||||
|
private GroupBox groupBoxColors;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelRed;
|
||||||
|
private CheckBox checkBoxDeck;
|
||||||
|
private CheckBox checkBoxPool;
|
||||||
|
private Panel panelPurple;
|
||||||
|
private Panel panelBlack;
|
||||||
|
private Panel panelGray;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private Panel panelYellow;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private Label labelModifiedObject;
|
||||||
|
private Panel panelObject;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
private Label labelAddColor;
|
||||||
|
private Label labelMainColor;
|
||||||
|
private Button buttonOk;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
170
Liner/FormLinerConfig.cs
Normal file
170
Liner/FormLinerConfig.cs
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Liner.Drawing;
|
||||||
|
using Liner.Entities;
|
||||||
|
|
||||||
|
namespace Liner
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Форма создания объекта
|
||||||
|
/// </summary>
|
||||||
|
public partial class FormLinerConfig : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Переменная-выбранная машина
|
||||||
|
/// </summary>
|
||||||
|
DrawingLiner? _liner = null;
|
||||||
|
/// <summary>
|
||||||
|
/// Событие
|
||||||
|
/// </summary>
|
||||||
|
private event Action<DrawingLiner>? EventAddLiner;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public FormLinerConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGray.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelRed.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
buttonCancel.Click += (s, a) => Close();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Отрисовать лайнер
|
||||||
|
/// </summary>
|
||||||
|
private void DrawLiner()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_liner?.SetPosition(15, 15);
|
||||||
|
_liner?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление события
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ev">Привязанный метод</param>
|
||||||
|
public void AddEvent(Action<DrawingLiner> ev)
|
||||||
|
{
|
||||||
|
if (EventAddLiner == null)
|
||||||
|
{
|
||||||
|
EventAddLiner = ev;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddLiner += ev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Передаем информацию при нажатии на Label
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Передаем информацию при нажатии на Panel с цветом
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Действия при приеме перетаскиваемой информации
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
|
{
|
||||||
|
case "labelSimpleObject":
|
||||||
|
_liner = new DrawingLiner((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_liner = new DrawingBigLiner((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxPool.Checked,
|
||||||
|
checkBoxDeck.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawLiner();
|
||||||
|
}
|
||||||
|
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_liner == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (((Label)sender).Name)
|
||||||
|
{
|
||||||
|
case "labelMainColor":
|
||||||
|
_liner.EntityLiner.BottomColor = (Color)e.Data.GetData(typeof(Color));
|
||||||
|
break;
|
||||||
|
case "labelAddColor":
|
||||||
|
if (!(_liner is DrawingBigLiner))
|
||||||
|
return;
|
||||||
|
(_liner as DrawingBigLiner).SetAddColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawLiner();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление лайнера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddLiner?.Invoke(_liner);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Liner/FormLinerConfig.resx
Normal file
120
Liner/FormLinerConfig.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>
|
||||||
@@ -50,7 +50,11 @@ namespace Liner.Generics
|
|||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_collection = new SetGeneric<T>(width * height);
|
_collection = new SetGeneric<T>(width * height);
|
||||||
}
|
}
|
||||||
|
/// </summary>
|
||||||
|
/// Получение объектов коллекции
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
public IEnumerable<T?> GetLiners => _collection.GetLiners();
|
||||||
|
|
||||||
/// Перегрузка оператора сложения
|
/// Перегрузка оператора сложения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="collect"></param>
|
/// <param name="collect"></param>
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ namespace Liner.Generics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Разделитель для записи ключа и значения элемента словаря
|
||||||
|
/// </summary>
|
||||||
|
private static readonly char _separatorForKeyValue = '|';
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записей коллекции данных в файл
|
||||||
|
/// </summary>
|
||||||
|
private readonly char _separatorRecords = ';';
|
||||||
|
/// <summary>
|
||||||
|
/// Разделитель для записи информации по объекту в файл
|
||||||
|
/// </summary>
|
||||||
|
private static readonly char _separatorForObject = ':';
|
||||||
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pictureWidth"></param>
|
/// <param name="pictureWidth"></param>
|
||||||
@@ -76,5 +88,93 @@ namespace Liner.Generics
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение информации по лайнерам в хранилище в файл
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
||||||
|
public bool SaveData(string filename)
|
||||||
|
{
|
||||||
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
File.Delete(filename);
|
||||||
|
}
|
||||||
|
StringBuilder data = new();
|
||||||
|
foreach (KeyValuePair<string,
|
||||||
|
LinerGenericCollection<DrawingLiner, DrawingObjectLiner>> record in _linerStorages)
|
||||||
|
{
|
||||||
|
StringBuilder records = new();
|
||||||
|
foreach (DrawingLiner? elem in record.Value.GetLiners)
|
||||||
|
{
|
||||||
|
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||||
|
}
|
||||||
|
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||||
|
}
|
||||||
|
if (data.Length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
string dataStr = data.ToString();
|
||||||
|
using (StreamWriter writer = new StreamWriter(filename))
|
||||||
|
{
|
||||||
|
writer.WriteLine("LinerStorage");
|
||||||
|
writer.WriteLine(dataStr);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Загрузка информации по автомобилям в хранилище из файла
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Путь и имя файла</param>
|
||||||
|
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
||||||
|
public bool LoadData(string filename)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader reader = new StreamReader(filename))
|
||||||
|
{
|
||||||
|
string checker = reader.ReadLine();
|
||||||
|
if (checker == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!checker.StartsWith("LinerStorage"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_linerStorages.Clear();
|
||||||
|
string strs;
|
||||||
|
bool firstinit = true;
|
||||||
|
while ((strs = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
if (strs == null && firstinit)
|
||||||
|
return false;
|
||||||
|
if (strs == null)
|
||||||
|
break;
|
||||||
|
if (strs == string.Empty)
|
||||||
|
break;
|
||||||
|
firstinit = false;
|
||||||
|
string name = strs.Split('|')[0];
|
||||||
|
LinerGenericCollection<DrawingLiner, DrawingObjectLiner> collection = new(_pictureWidth, _pictureHeight);
|
||||||
|
foreach (string data in strs.Split('|')[1].Split(';').Reverse())
|
||||||
|
{
|
||||||
|
DrawingLiner? liner =
|
||||||
|
data?.CreateDrawingLiner(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||||
|
if (liner != null)
|
||||||
|
{
|
||||||
|
if (collection + liner == -1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
_linerStorages.Add(name, collection);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Liner
|
|||||||
addColor = dialog.Color;
|
addColor = dialog.Color;
|
||||||
}
|
}
|
||||||
_drawingLiner = new DrawingLiner(random.Next(100, 300),
|
_drawingLiner = new DrawingLiner(random.Next(100, 300),
|
||||||
random.Next(1000, 3000), mainColor, addColor,
|
random.Next(1000, 3000), mainColor,
|
||||||
pictureBoxLiner.Width, pictureBoxLiner.Height);
|
pictureBoxLiner.Width, pictureBoxLiner.Height);
|
||||||
_drawingLiner.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawingLiner.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
Draw();
|
Draw();
|
||||||
|
|||||||
Reference in New Issue
Block a user