файлы лабораторной
This commit is contained in:
parent
295bdabdb7
commit
20f939bb77
15
lainer/Lainer1/LainerForm.Designer.cs
generated
15
lainer/Lainer1/LainerForm.Designer.cs
generated
@ -37,6 +37,7 @@
|
|||||||
ButtonCreateSuperLainer = new Button();
|
ButtonCreateSuperLainer = new Button();
|
||||||
comboBoxStrategy = new ComboBox();
|
comboBoxStrategy = new ComboBox();
|
||||||
ButtonStep = new Button();
|
ButtonStep = new Button();
|
||||||
|
ButtonSelectLainer = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLainer).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxLainer).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -122,7 +123,7 @@
|
|||||||
// comboBoxStrategy
|
// comboBoxStrategy
|
||||||
//
|
//
|
||||||
comboBoxStrategy.FormattingEnabled = true;
|
comboBoxStrategy.FormattingEnabled = true;
|
||||||
comboBoxStrategy.Items.AddRange(new object[] { "центр", "край"});
|
comboBoxStrategy.Items.AddRange(new object[] { "центр", "край" });
|
||||||
comboBoxStrategy.Location = new Point(566, 12);
|
comboBoxStrategy.Location = new Point(566, 12);
|
||||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||||
comboBoxStrategy.Size = new Size(151, 28);
|
comboBoxStrategy.Size = new Size(151, 28);
|
||||||
@ -138,11 +139,22 @@
|
|||||||
ButtonStep.UseVisualStyleBackColor = true;
|
ButtonStep.UseVisualStyleBackColor = true;
|
||||||
ButtonStep.Click += ButtonStep_Click;
|
ButtonStep.Click += ButtonStep_Click;
|
||||||
//
|
//
|
||||||
|
// ButtonSelectLainer
|
||||||
|
//
|
||||||
|
ButtonSelectLainer.Location = new Point(369, 356);
|
||||||
|
ButtonSelectLainer.Name = "ButtonSelectLainer";
|
||||||
|
ButtonSelectLainer.Size = new Size(94, 29);
|
||||||
|
ButtonSelectLainer.TabIndex = 9;
|
||||||
|
ButtonSelectLainer.Text = "выбрать";
|
||||||
|
ButtonSelectLainer.UseVisualStyleBackColor = true;
|
||||||
|
ButtonSelectLainer.Click += ButtonSelectLainer_Click;
|
||||||
|
//
|
||||||
// LainerForm
|
// LainerForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(729, 397);
|
ClientSize = new Size(729, 397);
|
||||||
|
Controls.Add(ButtonSelectLainer);
|
||||||
Controls.Add(ButtonStep);
|
Controls.Add(ButtonStep);
|
||||||
Controls.Add(comboBoxStrategy);
|
Controls.Add(comboBoxStrategy);
|
||||||
Controls.Add(ButtonCreateSuperLainer);
|
Controls.Add(ButtonCreateSuperLainer);
|
||||||
@ -171,5 +183,6 @@
|
|||||||
private Button ButtonCreateSuperLainer;
|
private Button ButtonCreateSuperLainer;
|
||||||
private ComboBox comboBoxStrategy;
|
private ComboBox comboBoxStrategy;
|
||||||
private Button ButtonStep;
|
private Button ButtonStep;
|
||||||
|
private Button ButtonSelectLainer;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,9 +6,13 @@ namespace ProjectLainer
|
|||||||
{
|
{
|
||||||
private DrawingLainer? _drawningLainer;
|
private DrawingLainer? _drawningLainer;
|
||||||
private AbstractStrategy? _abstractStrategy;
|
private AbstractStrategy? _abstractStrategy;
|
||||||
|
private AbstractStrategy? _strategy;
|
||||||
|
public DrawingLainer? SelectedLainer { get; private set; }
|
||||||
public LainerForm()
|
public LainerForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_strategy = null;
|
||||||
|
SelectedLainer = null;
|
||||||
}
|
}
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
@ -25,29 +29,39 @@ namespace ProjectLainer
|
|||||||
private void ButtonCreateSuperLainer_Click(object sender, EventArgs e)
|
private void ButtonCreateSuperLainer_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new();
|
Random random = new();
|
||||||
|
Color mainColor = Color.FromArgb(random.Next(0, 256),
|
||||||
|
random.Next(0, 256), random.Next(0, 256));
|
||||||
|
Color additColor = Color.FromArgb(random.Next(0, 256),
|
||||||
|
random.Next(0, 256), random.Next(0, 256));
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
mainColor = dialog.Color;
|
||||||
|
}
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
additColor = dialog.Color;
|
||||||
|
}
|
||||||
_drawningLainer = new DrawningSuperLainer(random.Next(100, 300),
|
_drawningLainer = new DrawningSuperLainer(random.Next(100, 300),
|
||||||
random.Next(1000, 3000),
|
random.Next(1000, 3000), mainColor, additColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
||||||
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)),
|
|
||||||
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
||||||
_drawningLainer.SetPosition(random.Next(10, 100), random.Next(10,
|
_drawningLainer.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
100));
|
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new();
|
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;
|
||||||
|
}
|
||||||
_drawningLainer = new DrawingLainer(random.Next(100, 300),
|
_drawningLainer = new DrawingLainer(random.Next(100, 300),
|
||||||
random.Next(1000, 3000),
|
random.Next(1000, 3000), color,
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
|
||||||
random.Next(0, 256)),
|
|
||||||
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
||||||
_drawningLainer.SetPosition(random.Next(10, 100), random.Next(10,
|
_drawningLainer.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
100));
|
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
@ -82,33 +96,36 @@ namespace ProjectLainer
|
|||||||
}
|
}
|
||||||
if (comboBoxStrategy.Enabled)
|
if (comboBoxStrategy.Enabled)
|
||||||
{
|
{
|
||||||
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
_strategy = comboBoxStrategy.SelectedIndex switch
|
||||||
switch
|
|
||||||
{
|
{
|
||||||
0 => new MoveToCenter(),
|
0 => new MoveToCenter(),
|
||||||
1 => new MoveToBorder(),
|
1 => new MoveToBorder(),
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
if (_abstractStrategy == null)
|
if (_strategy == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_abstractStrategy.SetData(new
|
_strategy.SetData(_drawningLainer.GetMoveableObject,
|
||||||
DrawningObjectLainer(_drawningLainer), pictureBoxLainer.Width,
|
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
||||||
pictureBoxLainer.Height);
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
}
|
}
|
||||||
if (_abstractStrategy == null)
|
if (_strategy == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_abstractStrategy.MakeStep();
|
comboBoxStrategy.Enabled = false;
|
||||||
|
_strategy.MakeStep();
|
||||||
Draw();
|
Draw();
|
||||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
if (_strategy.GetStatus() == Status.Finish)
|
||||||
{
|
{
|
||||||
comboBoxStrategy.Enabled = true;
|
comboBoxStrategy.Enabled = true;
|
||||||
_abstractStrategy = null;
|
_strategy = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void ButtonSelectLainer_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedLainer = _drawningLainer;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user