From ea41b1d126675fe90341d40c06f55aa57204b65a Mon Sep 17 00:00:00 2001 From: Evgeny Egov Date: Sat, 6 Jan 2024 21:41:57 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Drawnings/DrawningCarCompareByType.cs | 4 ++ .../FormCarCollection.Designer.cs | 56 +++++++++---------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/ProjectSportCar/ProjectSportCar/Drawnings/DrawningCarCompareByType.cs b/ProjectSportCar/ProjectSportCar/Drawnings/DrawningCarCompareByType.cs index 95be441..ad08707 100644 --- a/ProjectSportCar/ProjectSportCar/Drawnings/DrawningCarCompareByType.cs +++ b/ProjectSportCar/ProjectSportCar/Drawnings/DrawningCarCompareByType.cs @@ -11,19 +11,23 @@ public class DrawningCarCompareByType : IComparer { return -1; } + if (y == null || y.EntityCar == null) { return 1; } + if (x.GetType().Name != y.GetType().Name) { return x.GetType().Name.CompareTo(y.GetType().Name); } + var speedCompare = x.EntityCar.Speed.CompareTo(y.EntityCar.Speed); if (speedCompare != 0) { return speedCompare; } + return x.EntityCar.Weight.CompareTo(y.EntityCar.Weight); } } \ No newline at end of file diff --git a/ProjectSportCar/ProjectSportCar/FormCarCollection.Designer.cs b/ProjectSportCar/ProjectSportCar/FormCarCollection.Designer.cs index e44e245..57457b1 100644 --- a/ProjectSportCar/ProjectSportCar/FormCarCollection.Designer.cs +++ b/ProjectSportCar/ProjectSportCar/FormCarCollection.Designer.cs @@ -30,6 +30,8 @@ { groupBoxTools = new GroupBox(); panelCompanyTools = new Panel(); + buttonSortByColor = new Button(); + buttonSortByType = new Button(); buttonAddCar = new Button(); maskedTextBoxPosition = new MaskedTextBox(); buttonRefresh = new Button(); @@ -52,8 +54,6 @@ loadToolStripMenuItem = new ToolStripMenuItem(); saveFileDialog = new SaveFileDialog(); openFileDialog = new OpenFileDialog(); - buttonSortByColor = new Button(); - buttonSortByType = new Button(); groupBoxTools.SuspendLayout(); panelCompanyTools.SuspendLayout(); panelStorage.SuspendLayout(); @@ -70,7 +70,7 @@ groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Location = new Point(783, 24); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(179, 651); + groupBoxTools.Size = new Size(179, 657); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; @@ -86,11 +86,33 @@ panelCompanyTools.Controls.Add(buttonGoToCheck); panelCompanyTools.Dock = DockStyle.Bottom; panelCompanyTools.Enabled = false; - panelCompanyTools.Location = new Point(3, 336); + panelCompanyTools.Location = new Point(3, 355); panelCompanyTools.Name = "panelCompanyTools"; panelCompanyTools.Size = new Size(173, 299); panelCompanyTools.TabIndex = 9; // + // buttonSortByColor + // + buttonSortByColor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonSortByColor.Location = new Point(3, 250); + buttonSortByColor.Name = "buttonSortByColor"; + buttonSortByColor.Size = new Size(167, 40); + buttonSortByColor.TabIndex = 8; + buttonSortByColor.Text = "Сортировка по цвету"; + buttonSortByColor.UseVisualStyleBackColor = true; + buttonSortByColor.Click += ButtonSortByColor_Click; + // + // buttonSortByType + // + buttonSortByType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonSortByType.Location = new Point(3, 210); + buttonSortByType.Name = "buttonSortByType"; + buttonSortByType.Size = new Size(167, 40); + buttonSortByType.TabIndex = 7; + buttonSortByType.Text = "Сортировка по типу"; + buttonSortByType.UseVisualStyleBackColor = true; + buttonSortByType.Click += ButtonSortByType_Click; + // // buttonAddCar // buttonAddCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; @@ -253,7 +275,7 @@ pictureBox.Dock = DockStyle.Fill; pictureBox.Location = new Point(0, 24); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(783, 592); + pictureBox.Size = new Size(783, 657); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // @@ -297,33 +319,11 @@ // openFileDialog.Filter = "txt file | *.txt"; // - // buttonSortByColor - // - buttonSortByColor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonSortByColor.Location = new Point(3, 250); - buttonSortByColor.Name = "buttonSortByColor"; - buttonSortByColor.Size = new Size(167, 40); - buttonSortByColor.TabIndex = 8; - buttonSortByColor.Text = "Сортировка по цвету"; - buttonSortByColor.UseVisualStyleBackColor = true; - buttonSortByColor.Click += ButtonSortByColor_Click; - // - // buttonSortByType - // - buttonSortByType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonSortByType.Location = new Point(3, 210); - buttonSortByType.Name = "buttonSortByType"; - buttonSortByType.Size = new Size(167, 40); - buttonSortByType.TabIndex = 7; - buttonSortByType.Text = "Сортировка по типу"; - buttonSortByType.UseVisualStyleBackColor = true; - buttonSortByType.Click += ButtonSortByType_Click; - // // FormCarCollection // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(962, 616); + ClientSize = new Size(962, 681); Controls.Add(pictureBox); Controls.Add(groupBoxTools); Controls.Add(menuStrip);