From 0d20d952a896ab4771da650b24ceb9ef20faaee7 Mon Sep 17 00:00:00 2001 From: F1rsTTeaM Date: Sat, 16 Mar 2024 15:13:57 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=87=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 2 +- .../PlaneSharingService.cs | 39 ++++++++++++++++++- .../FormAirplaneCollection.Designer.cs | 5 +++ .../FormAirplaneCollection.cs | 9 +++-- .../ProjectAirplaneWithRadar/Program.cs | 2 +- 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/AirplaneWithRadar/ProjectAirplaneWithRadar/CollectionGenericObjects/AbstractCompany.cs b/AirplaneWithRadar/ProjectAirplaneWithRadar/CollectionGenericObjects/AbstractCompany.cs index b70b242..c675298 100644 --- a/AirplaneWithRadar/ProjectAirplaneWithRadar/CollectionGenericObjects/AbstractCompany.cs +++ b/AirplaneWithRadar/ProjectAirplaneWithRadar/CollectionGenericObjects/AbstractCompany.cs @@ -15,7 +15,7 @@ namespace ProjectAirplaneWithRadar.CollectionGenericObjects /// /// Размер места (высота) /// - protected readonly int _placeSizeHeight = 80; + protected readonly int _placeSizeHeight = 100; /// /// Ширина окна diff --git a/AirplaneWithRadar/ProjectAirplaneWithRadar/CollectionGenericObjects/PlaneSharingService.cs b/AirplaneWithRadar/ProjectAirplaneWithRadar/CollectionGenericObjects/PlaneSharingService.cs index 0c2da8d..4a210f3 100644 --- a/AirplaneWithRadar/ProjectAirplaneWithRadar/CollectionGenericObjects/PlaneSharingService.cs +++ b/AirplaneWithRadar/ProjectAirplaneWithRadar/CollectionGenericObjects/PlaneSharingService.cs @@ -12,12 +12,47 @@ namespace ProjectAirplaneWithRadar.CollectionGenericObjects protected override void DrawBackgound(Graphics g) { - throw new NotImplementedException(); + Pen pen = new(Color.Black, 4); + 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 - 40, j * _placeSizeHeight); + } + g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight); + } } protected override void SetObjectsPosition() { - throw new NotImplementedException(); + int width = _pictureWidth / _placeSizeWidth; + int height = _pictureHeight / _placeSizeHeight; + + int curWidth = 0; + int curHeight = 0; + + for (int i = 0; i < (_collection?.Count ?? 0); i++) + { + if (_collection.Get(i) != null) + { + _collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight); + _collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 10, curHeight * _placeSizeHeight); + } + + if (curWidth < width - 1) + curWidth++; + else + { + curWidth = 0; + curHeight++; + } + if (curHeight > height) + { + return; + } + } } } + } diff --git a/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneCollection.Designer.cs b/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneCollection.Designer.cs index 0ec2d91..4cbd16b 100644 --- a/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneCollection.Designer.cs +++ b/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneCollection.Designer.cs @@ -67,6 +67,7 @@ buttonRefresh.TabIndex = 6; buttonRefresh.Text = "Обновить"; buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonRefresh_Click; // // buttonGoToCheck // @@ -88,6 +89,7 @@ buttonRemoveAirplane.TabIndex = 4; buttonRemoveAirplane.Text = "Удалить самолет"; buttonRemoveAirplane.UseVisualStyleBackColor = true; + buttonRemoveAirplane.Click += ButtonRemoveAirplane_Click; // // maskedTextBoxPosition // @@ -107,6 +109,7 @@ buttonAddAirplaneWithRadar.TabIndex = 2; buttonAddAirplaneWithRadar.Text = "Добавить самолет с радаром"; buttonAddAirplaneWithRadar.UseVisualStyleBackColor = true; + buttonAddAirplaneWithRadar.Click += ButtonAddAirplaneWithRadar_Click; // // buttonAddAirplane // @@ -117,6 +120,7 @@ buttonAddAirplane.TabIndex = 1; buttonAddAirplane.Text = "Добавить самолет"; buttonAddAirplane.UseVisualStyleBackColor = true; + buttonAddAirplane.Click += ButtonAddAirplane_Click; // // comboBoxSelectorCompany // @@ -128,6 +132,7 @@ comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Size = new Size(188, 23); comboBoxSelectorCompany.TabIndex = 0; + comboBoxSelectorCompany.Click += ComboBoxSelectorCompany_SelectedIndexChanged; // // pictureBox // diff --git a/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneCollection.cs b/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneCollection.cs index 9c4f53b..2afd965 100644 --- a/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneCollection.cs +++ b/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneCollection.cs @@ -53,11 +53,12 @@ namespace ProjectAirplaneWithRadar case nameof(DrawningAirplane): drawingAirplane = new DrawningAirplane(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); break; - case nameof(DrawingAirplaneWithRadar): + case nameof(DrawingAirplaneWithRadar): drawingAirplane = new DrawingAirplaneWithRadar(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)), - Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); + GetColor(random), + GetColor(random), + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); + break; default: return; diff --git a/AirplaneWithRadar/ProjectAirplaneWithRadar/Program.cs b/AirplaneWithRadar/ProjectAirplaneWithRadar/Program.cs index 3ed1af4..42c6dca 100644 --- a/AirplaneWithRadar/ProjectAirplaneWithRadar/Program.cs +++ b/AirplaneWithRadar/ProjectAirplaneWithRadar/Program.cs @@ -11,7 +11,7 @@ namespace ProjectAirplaneWithRadar // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormAirplaneWithRadar()); + Application.Run(new FormAirplaneCollection()); } } } \ No newline at end of file