Доработки

This commit is contained in:
ivans 2024-03-04 10:34:56 +04:00
parent 4e49b73845
commit 9d823f93b0
5 changed files with 133 additions and 47 deletions

View File

@ -33,7 +33,7 @@ public class DrawningSelfPropelledArtilleryUnit
/// <summary>
/// Ширина прорисовки cамоходной арт. установки
/// </summary>
private readonly int _drawningSelfPropelledArtilleryUnitWidth = 143;
private readonly int _drawningSelfPropelledArtilleryUnitWidth = 135;
/// <summary>
/// Высота прорисовки cамоходной арт. установки
@ -68,10 +68,26 @@ public class DrawningSelfPropelledArtilleryUnit
/// <returns>true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
public bool SetPictureSize(int width, int height)
{
// TODO проверка, что объект "влезает" в размеры поля
// если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
if (_drawningSelfPropelledArtilleryUnitWidth > width || _drawningSelfPropelledArtilleryUnitHeight > height)
{
return false;
}
_pictureWidth = width;
_pictureHeight = height;
if (_startPosX.HasValue || _startPosY.HasValue)
{
if (_startPosX + _drawningSelfPropelledArtilleryUnitWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawningSelfPropelledArtilleryUnitWidth;
}
else if (_startPosX < 0) _startPosX = 0;
if (_startPosY + _drawningSelfPropelledArtilleryUnitHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawningSelfPropelledArtilleryUnitHeight;
}
else if (_startPosY < 0) _startPosY = 0;
}
return true;
}
@ -89,8 +105,19 @@ public class DrawningSelfPropelledArtilleryUnit
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
// то надо изменить координаты, чтобы он оставался в этих границах
_startPosX = x;
_startPosY = y;
if (x + _drawningSelfPropelledArtilleryUnitWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawningSelfPropelledArtilleryUnitWidth;
}
else if (x < 0) _startPosX = 0;
else _startPosX = x;
if (y + _drawningSelfPropelledArtilleryUnitHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawningSelfPropelledArtilleryUnitHeight;
}
else if (y < 0) _startPosY = 0;
else _startPosY = y;
}
@ -157,76 +184,76 @@ public class DrawningSelfPropelledArtilleryUnit
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(EntitySelfPropelledArtilleryUnit.AdditionalColor);
g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 75, 30, 30);
g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 75, 30, 30);
g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value + 75, 90, 30);
g.DrawEllipse(pen, _startPosX.Value + 0, _startPosY.Value + 75, 30, 30);
g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value + 75, 30, 30);
g.DrawRectangle(pen, _startPosX.Value + 15, _startPosY.Value + 75, 90, 30);
//границы ЦВЕТ
Brush brOlive = new SolidBrush(Color.Olive);
g.FillRectangle(brOlive, _startPosX.Value + 35, _startPosY.Value + 40, 35, 30);
g.FillEllipse(brOlive, _startPosX.Value + 10, _startPosY.Value + 75, 30, 30);
g.FillEllipse(brOlive, _startPosX.Value + 100, _startPosY.Value + 75, 30, 30);
g.FillRectangle(brOlive, _startPosX.Value + 25, _startPosY.Value + 75, 90, 30);
g.FillRectangle(brOlive, _startPosX.Value + 25, _startPosY.Value + 40, 35, 30);//башня
g.FillEllipse(brOlive, _startPosX.Value +0, _startPosY.Value + 75, 30, 30);
g.FillEllipse(brOlive, _startPosX.Value + 90, _startPosY.Value + 75, 30, 30);
g.FillRectangle(brOlive, _startPosX.Value + 15, _startPosY.Value + 75, 90, 30);
// границы арт. установки
g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 40, 35, 30);
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 65, 120, 13);
g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value + 40, 35, 30);
g.DrawRectangle(pen, _startPosX.Value + 0, _startPosY.Value + 65, 120, 13);//крыша
// верхние катки ЦВЕТ
Brush brCadetBlue = new SolidBrush(Color.CadetBlue);
g.FillEllipse(brCadetBlue, _startPosX.Value + 40, _startPosY.Value + 70, 20, 20);
g.FillEllipse(brCadetBlue, _startPosX.Value + 60, _startPosY.Value + 70, 20, 20);
g.FillEllipse(brCadetBlue, _startPosX.Value + 80, _startPosY.Value + 70, 20, 20);
g.FillEllipse(brCadetBlue, _startPosX.Value + 30, _startPosY.Value + 70, 20, 20);
g.FillEllipse(brCadetBlue, _startPosX.Value + 50, _startPosY.Value + 70, 20, 20);
g.FillEllipse(brCadetBlue, _startPosX.Value + 70, _startPosY.Value + 70, 20, 20);
// верхние катки ОТРИСОВКА
g.DrawEllipse(pen, _startPosX.Value + 40, _startPosY.Value + 70, 20, 20);
g.DrawEllipse(pen, _startPosX.Value + 60, _startPosY.Value + 70, 20, 20);
g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 70, 20, 20);
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 70, 20, 20);
g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 70, 20, 20);
g.DrawEllipse(pen, _startPosX.Value + 70, _startPosY.Value + 70, 20, 20);
//нижние катки ЦВЕТ
Brush brDimGray = new SolidBrush(Color.DimGray);
g.FillEllipse(brDimGray, _startPosX.Value + 40, _startPosY.Value + 90, 15, 15);
g.FillEllipse(brDimGray, _startPosX.Value + 55, _startPosY.Value + 90, 15, 15);
g.FillEllipse(brDimGray, _startPosX.Value + 70, _startPosY.Value + 90, 15, 15);
g.FillEllipse(brDimGray, _startPosX.Value + 85, _startPosY.Value + 90, 15, 15);
g.FillEllipse(brDimGray, _startPosX.Value + 30, _startPosY.Value + 90, 15, 15);
g.FillEllipse(brDimGray, _startPosX.Value + 45, _startPosY.Value + 90, 15, 15);
g.FillEllipse(brDimGray, _startPosX.Value + 60, _startPosY.Value + 90, 15, 15);
g.FillEllipse(brDimGray, _startPosX.Value + 75, _startPosY.Value + 90, 15, 15);
//нижние катки ОТРИСОВКА
g.DrawEllipse(pen, _startPosX.Value + 40, _startPosY.Value + 90, 15, 15);
g.DrawEllipse(pen, _startPosX.Value + 55, _startPosY.Value + 90, 15, 15);
g.DrawEllipse(pen, _startPosX.Value + 70, _startPosY.Value + 90, 15, 15);
g.DrawEllipse(pen, _startPosX.Value + 85, _startPosY.Value + 90, 15, 15);
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 90, 15, 15);
g.DrawEllipse(pen, _startPosX.Value + 45, _startPosY.Value + 90, 15, 15);
g.DrawEllipse(pen, _startPosX.Value + 60, _startPosY.Value + 90, 15, 15);
g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 90, 15, 15);
//Большие катки ЦВЕТ
Brush brSlateGray = new SolidBrush(Color.SlateGray);
g.FillEllipse(brSlateGray, _startPosX.Value + 13, _startPosY.Value + 78, 24, 24);
g.FillEllipse(brSlateGray, _startPosX.Value + 103, _startPosY.Value + 78, 24, 24);
g.FillEllipse(brSlateGray, _startPosX.Value + 3, _startPosY.Value + 78, 24, 24);
g.FillEllipse(brSlateGray, _startPosX.Value + 93, _startPosY.Value + 78, 24, 24);
//Большие катки ОТРИСОВКА
g.DrawEllipse(pen, _startPosX.Value + 13, _startPosY.Value + 78, 24, 24);
g.DrawEllipse(pen, _startPosX.Value + 103, _startPosY.Value + 78, 24, 24);
g.DrawEllipse(pen, _startPosX.Value + 3, _startPosY.Value + 78, 24, 24);
g.DrawEllipse(pen, _startPosX.Value + 93, _startPosY.Value + 78, 24, 24);
g.FillRectangle(brOlive, _startPosX.Value + 10, _startPosY.Value + 65, 120, 13);
g.FillRectangle(brOlive, _startPosX.Value + 0, _startPosY.Value + 65, 120, 13);//
if (EntitySelfPropelledArtilleryUnit.TurretCannon)
{
g.FillEllipse(additionalBrush, _startPosX.Value + 36, _startPosY.Value + 35, 50, 30);
g.FillRectangle(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 36, 20, 29);
g.FillRectangle(additionalBrush, _startPosX.Value + 70, _startPosY.Value + 45, 60, 5);
g.FillEllipse(additionalBrush, _startPosX.Value + 123, _startPosY.Value + 42, 20, 10);
g.FillEllipse(additionalBrush, _startPosX.Value + 26, _startPosY.Value + 35, 50, 30);
g.FillRectangle(additionalBrush, _startPosX.Value + 25, _startPosY.Value + 36, 20, 29);
g.FillRectangle(additionalBrush, _startPosX.Value + 60, _startPosY.Value + 45, 60, 5);
g.FillEllipse(additionalBrush, _startPosX.Value + 113, _startPosY.Value + 42, 20, 10);
}
if (EntitySelfPropelledArtilleryUnit.LaunchBattery)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 45, 20, 20);
g.FillRectangle(additionalBrush, _startPosX.Value + 0, _startPosY.Value + 45, 20, 20);
g.FillPolygon(additionalBrush, new Point[]
{
new Point(_startPosX.Value + 10, _startPosY.Value + 15), new Point(_startPosX.Value + 10, _startPosY.Value + 65),
new Point(_startPosX.Value + 30, _startPosY.Value + 65), new Point(_startPosX.Value + 30, _startPosY.Value + 45),
new Point(_startPosX.Value + 10, _startPosY.Value + 15)
new Point(_startPosX.Value + 0, _startPosY.Value + 15), new Point(_startPosX.Value + 0, _startPosY.Value + 65),
new Point(_startPosX.Value + 20, _startPosY.Value + 65), new Point(_startPosX.Value + 20, _startPosY.Value + 45),
new Point(_startPosX.Value + 0, _startPosY.Value + 15)
});
g.FillEllipse(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 5, 10, 30);
g.FillRectangle(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 15, 20, 5);
g.FillRectangle(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 25, 15, 5);
g.FillEllipse(additionalBrush, _startPosX.Value + 0, _startPosY.Value + 5, 10, 30);
g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 15, 20, 5);
g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 25, 15, 5);
}
}

View File

@ -0,0 +1,39 @@
namespace SelfPropelledArtilleryUnit
{
partial class FormSelfPropelledArtilleryUnit
{
/// <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 = "FormSelfPropelledArtilleryUnit";
}
#endregion
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SelfPropelledArtilleryUnit
{
public partial class FormSelfPropelledArtilleryUnit : Form
{
public FormSelfPropelledArtilleryUnit()
{
InitializeComponent();
}
}
}

View File

@ -49,9 +49,9 @@
// buttonCreate
//
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreate.Location = new Point(12, 446);
buttonCreate.Location = new Point(12, 438);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(94, 35);
buttonCreate.Size = new Size(94, 43);
buttonCreate.TabIndex = 1;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>