Измение логики многих форм.
This commit is contained in:
parent
c53647752a
commit
16b6400b36
@ -4,45 +4,51 @@ namespace ProjectBulldozer.Drawning
|
||||
public class DrawingBulldozer : DrawingTractor
|
||||
{
|
||||
public DrawingBulldozer(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||
bool horns, bool seifBatteries, int width, int height) : base(speed, weight, bodyColor, width, height, 120, 110)
|
||||
bool otval, bool thirdWheel, int width, int height) : base(speed, weight, bodyColor, width, height, 120, 110)
|
||||
{
|
||||
if (EntityTractor != null)
|
||||
{
|
||||
EntityTractor = new EntityBulldozer(speed, width, bodyColor, additionalColor, horns, seifBatteries);
|
||||
EntityTractor = new EntityBulldozer(speed, width, bodyColor, additionalColor, otval, thirdWheel);
|
||||
}
|
||||
}
|
||||
public object Otval { get; private set; }
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityTractor is not EntityBulldozer Bulldozer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush blackBrush = new SolidBrush(Color.Black);
|
||||
Brush windows = new SolidBrush(Color.LightBlue);
|
||||
Brush bodyColor = new SolidBrush(Bulldozer.BodyColor);
|
||||
Brush additionalColor = new SolidBrush(Bulldozer.AdditionalColor);
|
||||
Brush grayBrush = new SolidBrush(Color.Gray);
|
||||
//otval
|
||||
Point[] Otval =
|
||||
{
|
||||
|
||||
if (Bulldozer.Otval)
|
||||
{
|
||||
//otval
|
||||
Point[] Otval =
|
||||
{
|
||||
new Point(_startPosX + 118, _startPosY + 50),
|
||||
new Point(_startPosX + 148, _startPosY + 111),
|
||||
new Point(_startPosX+ 118, _startPosY + 111),
|
||||
|
||||
|
||||
};
|
||||
g.FillPolygon(additionalColor, Otval);
|
||||
g.DrawPolygon(pen, Otval);
|
||||
g.FillPolygon(additionalColor, Otval);
|
||||
g.DrawPolygon(pen, Otval);
|
||||
}
|
||||
//гусеницы
|
||||
Brush gg = new SolidBrush(Color.LightGray);
|
||||
g.FillEllipse(gg, _startPosX + 16, _startPosY + 65, 101, 63);
|
||||
g.DrawEllipse(pen, _startPosX + 16, _startPosY + 65, 101, 63);
|
||||
g.FillEllipse(grayBrush, _startPosX + 65, _startPosY + 100, 13, 13);
|
||||
g.DrawEllipse(pen, _startPosX + 65, _startPosY + 100, 13, 13);
|
||||
|
||||
if (Bulldozer.ThirdWheel)
|
||||
{
|
||||
|
||||
g.FillEllipse(grayBrush, _startPosX + 65, _startPosY + 100, 13, 13);
|
||||
g.DrawEllipse(pen, _startPosX + 65, _startPosY + 100, 13, 13);
|
||||
}
|
||||
Point[] Ttt =
|
||||
{
|
||||
{
|
||||
|
||||
new Point(_startPosX + 16, _startPosY + 79),
|
||||
new Point(_startPosX + 16, _startPosY + 120),
|
||||
new Point(_startPosX, _startPosY + 48),
|
||||
@ -50,10 +56,8 @@ namespace ProjectBulldozer.Drawning
|
||||
};
|
||||
g.FillPolygon(blackBrush, Ttt);
|
||||
g.DrawPolygon(pen, Ttt);
|
||||
if (Bulldozer.SeifBatteries)
|
||||
{
|
||||
g.FillRectangle(blackBrush, _startPosX + 110, _startPosY + 60, 5, 10);
|
||||
}
|
||||
g.FillRectangle(blackBrush, _startPosX + 110, _startPosY + 60, 5, 10);
|
||||
|
||||
base.DrawTransport(g);
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ namespace ProjectBulldozer.Drawning
|
||||
public class DrawingTractor
|
||||
{
|
||||
public EntityTractor? EntityTractor { get; protected set; }
|
||||
protected int _pictureWidth;
|
||||
protected int _pictureHeight;
|
||||
public int _pictureWidth;
|
||||
public int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
protected readonly int _tractWidth = 120;
|
||||
|
@ -182,7 +182,5 @@
|
||||
private ListBox listBoxStorage;
|
||||
private Button ButtonAddObject;
|
||||
private Button ButtonRemoveObject;
|
||||
private GroupBox Instruments;
|
||||
private EventHandler textBoxStorageName_TextChanged;
|
||||
}
|
||||
private GroupBox Instruments; }
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
using Bulldozer;
|
||||
using ProjectBulldozer.Generics;
|
||||
using ProjectBulldozer.Drawning;
|
||||
|
||||
namespace ProjectBulldozer
|
||||
{
|
||||
public partial class FormTractorCollections : Form
|
||||
{
|
||||
private readonly TractorGenericStorage _storage;
|
||||
//private readonly TractorGenericCollection<DrawingTractor, DrawingObjectTractor> _Tractors;
|
||||
readonly int countPlace = 10;
|
||||
public FormTractorCollections()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -29,6 +31,7 @@ namespace ProjectBulldozer
|
||||
listBoxStorage.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
@ -39,10 +42,12 @@ namespace ProjectBulldozer
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
}
|
||||
|
||||
private void listBoxStorage_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollections.Image = _storage[listBoxStorage.SelectedItem?.ToString() ?? string.Empty]?.ShowTractors();
|
||||
}
|
||||
|
||||
private void ButtonRemoveObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorage.SelectedIndex == -1)
|
||||
@ -58,27 +63,35 @@ namespace ProjectBulldozer
|
||||
}
|
||||
private void ButtonAddTractor_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formBulldozerConfig = new FormBulldozerConfig();
|
||||
formBulldozerConfig.AddEvent(AddTractor);
|
||||
formBulldozerConfig.Show();
|
||||
}
|
||||
|
||||
private void AddTractor(DrawingTractor tractor)
|
||||
{
|
||||
tractor._pictureWidth = pictureBoxCollections.Width;
|
||||
tractor._pictureHeight = pictureBoxCollections.Height;
|
||||
|
||||
if (listBoxStorage.SelectedIndex == -1) return;
|
||||
|
||||
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormBulldozer form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
int addedIndex = obj + tractor;
|
||||
if (addedIndex != -1 && addedIndex < countPlace)
|
||||
{
|
||||
//проверяем, удалось ли нам загрузить объект
|
||||
if (obj + form.SelectedTractor > -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollections.Image = obj.ShowTractors();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollections.Image = obj.ShowTractors();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
private void ButtonRemoveTractor_Click(object sender, EventArgs e)
|
||||
@ -105,15 +118,9 @@ namespace ProjectBulldozer
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||
private void textBoxStorageName_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorage.SelectedIndex == -1) return;
|
||||
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxCollections.Image = obj.ShowTractors();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
46
ProjectBulldozer/FormBulldozerConfig.Designer.cs
generated
46
ProjectBulldozer/FormBulldozerConfig.Designer.cs
generated
@ -1,4 +1,5 @@
|
||||
namespace Bulldozer
|
||||
|
||||
namespace Bulldozer
|
||||
{
|
||||
partial class FormBulldozerConfig
|
||||
{
|
||||
@ -216,7 +217,7 @@
|
||||
checkBoxThirdWheel.TabIndex = 4;
|
||||
checkBoxThirdWheel.Text = "Отвал";
|
||||
checkBoxThirdWheel.UseVisualStyleBackColor = true;
|
||||
checkBoxThirdWheel.CheckedChanged += checkBoxKovsh_CheckedChanged;
|
||||
checkBoxThirdWheel.CheckedChanged += checkBoxOtval_CheckedChanged;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
@ -374,39 +375,6 @@
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
private void pictureBoxObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
private void checkBoxKovsh_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void panelBlue_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void panelPurple_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void GroupColor_Enter(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void groupBox1_Enter(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
private GroupBox groupBox1;
|
||||
private Label label2;
|
||||
private Label label1;
|
||||
@ -432,6 +400,14 @@
|
||||
private Panel PanelObject;
|
||||
private Label label_body_color;
|
||||
private Label label_additional_color;
|
||||
private EventHandler groupBox1_Enter;
|
||||
private PaintEventHandler panelPurple_Paint;
|
||||
private PaintEventHandler panelYellow_Paint;
|
||||
private PaintEventHandler panelBlue_Paint;
|
||||
private EventHandler checkBoxOtval_CheckedChanged;
|
||||
private EventHandler pictureBoxObject_Click;
|
||||
|
||||
public EventHandler GroupColor_Enter { get; private set; }
|
||||
public EventHandler ButtonCancel_Click { get; private set; }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user