using System.Drawing; using System.Windows.Forms; namespace TradeApp.WinForms.V08; partial class ProductDetailsForm { private System.ComponentModel.IContainer components = null; private Panel AsyncTaskPhoto; private PictureBox productPictureBox; private Label photoPlaceholderLabel; private TableLayoutPanel AsyncTaskDetails; private Label titleLabel; private Label descriptionLabel; private Label descriptionValueLabel; private Label manufacturerLabel; private Label manufacturerValueLabel; private Label supplierLabel; private Label supplierValueLabel; private Label priceLabel; private Label priceValueLabel; private FlowLayoutPanel pricePanel; private Label AsyncTaskOriginalPrice; private Label unitLabel; private Label unitValueLabel; private Label stockLabel; private Label stockValueLabel; private Label articleLabel; private Label articleValueLabel; private Panel AsyncTaskDiscountContainer; private Label discountTitleLabel; private Label AsyncTaskDiscountValue; private Label finalPriceTitleLabel; private Label finalPriceValueLabel; private Button closeButton; protected override void Dispose(bool disposing) { if (disposing) { productPictureBox?.Image?.Dispose(); components?.Dispose(); } base.Dispose(disposing); } private void InitializeComponent() { AsyncTaskPhoto = new Panel(); productPictureBox = new PictureBox(); photoPlaceholderLabel = new Label(); AsyncTaskDetails = new TableLayoutPanel(); titleLabel = new Label(); descriptionLabel = new Label(); descriptionValueLabel = new Label(); manufacturerLabel = new Label(); manufacturerValueLabel = new Label(); supplierLabel = new Label(); supplierValueLabel = new Label(); priceLabel = new Label(); priceValueLabel = new Label(); AsyncTaskOriginalPrice = new Label(); unitLabel = new Label(); unitValueLabel = new Label(); stockLabel = new Label(); stockValueLabel = new Label(); articleLabel = new Label(); articleValueLabel = new Label(); AsyncTaskDiscountContainer = new Panel(); discountTitleLabel = new Label(); AsyncTaskDiscountValue = new Label(); finalPriceTitleLabel = new Label(); finalPriceValueLabel = new Label(); closeButton = new Button(); AsyncTaskPhoto.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)productPictureBox).BeginInit(); AsyncTaskDetails.SuspendLayout(); AsyncTaskDiscountContainer.SuspendLayout(); SuspendLayout(); AsyncTaskPhoto.BorderStyle = BorderStyle.FixedSingle; AsyncTaskPhoto.Location = new Point(10, 10); AsyncTaskPhoto.Margin = new Padding(3); AsyncTaskPhoto.Size = new Size(270, 410); AsyncTaskPhoto.Controls.Add(productPictureBox); AsyncTaskPhoto.Controls.Add(photoPlaceholderLabel); productPictureBox.Dock = DockStyle.Fill; productPictureBox.SizeMode = PictureBoxSizeMode.Zoom; photoPlaceholderLabel.AutoSize = false; photoPlaceholderLabel.Dock = DockStyle.Fill; photoPlaceholderLabel.Font = new Font("Segoe UI", 11F, FontStyle.Bold); photoPlaceholderLabel.Text = "Фото"; photoPlaceholderLabel.TextAlign = ContentAlignment.MiddleCenter; AsyncTaskDetails.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; AsyncTaskDetails.ColumnCount = 2; AsyncTaskDetails.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 160F)); AsyncTaskDetails.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); AsyncTaskDetails.Location = new Point(293, 10); AsyncTaskDetails.Margin = new Padding(3); AsyncTaskDetails.Size = new Size(450, 410); pricePanel = new FlowLayoutPanel(); pricePanel.FlowDirection = FlowDirection.LeftToRight; pricePanel.Dock = DockStyle.Fill; pricePanel.AutoSize = true; pricePanel.WrapContents = false; pricePanel.Padding = new Padding(0); pricePanel.Margin = new Padding(0); AsyncTaskDetails.Controls.Add(titleLabel, 0, 0); AsyncTaskDetails.Controls.Add(descriptionLabel, 0, 1); AsyncTaskDetails.Controls.Add(descriptionValueLabel, 1, 1); AsyncTaskDetails.Controls.Add(manufacturerLabel, 0, 2); AsyncTaskDetails.Controls.Add(manufacturerValueLabel, 1, 2); AsyncTaskDetails.Controls.Add(supplierLabel, 0, 3); AsyncTaskDetails.Controls.Add(supplierValueLabel, 1, 3); AsyncTaskDetails.Controls.Add(priceLabel, 0, 4); // Place both price labels into a FlowLayoutPanel so they share the same row AsyncTaskDetails.Controls.Add(pricePanel, 1, 4); pricePanel.Controls.Add(priceValueLabel); pricePanel.Controls.Add(AsyncTaskOriginalPrice); AsyncTaskDetails.Controls.Add(unitLabel, 0, 5); AsyncTaskDetails.Controls.Add(unitValueLabel, 1, 5); AsyncTaskDetails.Controls.Add(stockLabel, 0, 6); AsyncTaskDetails.Controls.Add(stockValueLabel, 1, 6); AsyncTaskDetails.Controls.Add(articleLabel, 0, 7); AsyncTaskDetails.Controls.Add(articleValueLabel, 1, 7); AsyncTaskDetails.Margin = new Padding(3); AsyncTaskDetails.RowCount = 8; AsyncTaskDetails.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F)); AsyncTaskDetails.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); AsyncTaskDetails.RowStyles.Add(new RowStyle(SizeType.Absolute, 42F)); AsyncTaskDetails.RowStyles.Add(new RowStyle(SizeType.Absolute, 42F)); AsyncTaskDetails.RowStyles.Add(new RowStyle(SizeType.Absolute, 42F)); AsyncTaskDetails.RowStyles.Add(new RowStyle(SizeType.Absolute, 42F)); AsyncTaskDetails.RowStyles.Add(new RowStyle(SizeType.Absolute, 42F)); AsyncTaskDetails.RowStyles.Add(new RowStyle(SizeType.Absolute, 42F)); titleLabel.AutoSize = true; AsyncTaskDetails.SetColumnSpan(titleLabel, 2); titleLabel.Dock = DockStyle.Fill; titleLabel.Font = new Font("Segoe UI", 12F, FontStyle.Bold); titleLabel.Padding = new Padding(8); titleLabel.TextAlign = ContentAlignment.MiddleLeft; ConfigureCaption(descriptionLabel, "Описание товара:"); ConfigureValue(descriptionValueLabel); descriptionValueLabel.AutoEllipsis = true; ConfigureCaption(manufacturerLabel, "Производитель:"); ConfigureValue(manufacturerValueLabel); ConfigureCaption(supplierLabel, "Поставщик:"); ConfigureValue(supplierValueLabel); ConfigureCaption(priceLabel, "Цена:"); ConfigureValue(priceValueLabel); // priceValueLabel is placed inside a FlowLayoutPanel; make it autosize and left-docked so it appears // correctly when generated into the FlowLayoutPanel cell. priceValueLabel.AutoSize = true; priceValueLabel.Dock = DockStyle.Left; priceValueLabel.Padding = new Padding(6); priceValueLabel.TextAlign = ContentAlignment.MiddleLeft; AsyncTaskOriginalPrice.AutoSize = true; AsyncTaskOriginalPrice.Dock = DockStyle.Fill; AsyncTaskOriginalPrice.Font = new Font("Segoe UI", 9F, FontStyle.Strikeout); AsyncTaskOriginalPrice.ForeColor = Color.Red; AsyncTaskOriginalPrice.Padding = new Padding(6); AsyncTaskOriginalPrice.TextAlign = ContentAlignment.MiddleLeft; AsyncTaskOriginalPrice.Visible = false; ConfigureCaption(unitLabel, "Единица измерения:"); ConfigureValue(unitValueLabel); ConfigureCaption(stockLabel, "Количество на складе:"); ConfigureValue(stockValueLabel); ConfigureCaption(articleLabel, "Артикул:"); ConfigureValue(articleValueLabel); AsyncTaskDiscountContainer.BorderStyle = BorderStyle.FixedSingle; AsyncTaskDiscountContainer.Dock = DockStyle.Right; AsyncTaskDiscountContainer.Width = 220; AsyncTaskDiscountContainer.Margin = new Padding(3); // Add controls in reverse so Dock=Top produces top-to-bottom visual order AsyncTaskDiscountContainer.Controls.Add(closeButton); AsyncTaskDiscountContainer.Controls.Add(finalPriceValueLabel); AsyncTaskDiscountContainer.Controls.Add(finalPriceTitleLabel); AsyncTaskDiscountContainer.Controls.Add(AsyncTaskDiscountValue); AsyncTaskDiscountContainer.Controls.Add(discountTitleLabel); discountTitleLabel.AutoSize = false; discountTitleLabel.Dock = DockStyle.Top; discountTitleLabel.Font = new Font("Segoe UI", 11F, FontStyle.Bold); discountTitleLabel.Height = 54; discountTitleLabel.Text = "Действующая скидка"; discountTitleLabel.TextAlign = ContentAlignment.MiddleCenter; AsyncTaskDiscountValue.AutoSize = false; AsyncTaskDiscountValue.Dock = DockStyle.Top; AsyncTaskDiscountValue.Font = new Font("Segoe UI", 24F, FontStyle.Bold); AsyncTaskDiscountValue.ForeColor = Color.Black; AsyncTaskDiscountValue.Height = 70; AsyncTaskDiscountValue.TextAlign = ContentAlignment.MiddleCenter; finalPriceTitleLabel.AutoSize = false; finalPriceTitleLabel.Dock = DockStyle.Top; finalPriceTitleLabel.Font = new Font("Segoe UI", 9F, FontStyle.Bold); finalPriceTitleLabel.Height = 35; finalPriceTitleLabel.Text = "Цена со скидкой"; finalPriceTitleLabel.TextAlign = ContentAlignment.MiddleCenter; finalPriceValueLabel.AutoSize = false; finalPriceValueLabel.Dock = DockStyle.Top; finalPriceValueLabel.Font = new Font("Segoe UI", 13F, FontStyle.Bold); finalPriceValueLabel.Height = 50; finalPriceValueLabel.TextAlign = ContentAlignment.MiddleCenter; closeButton.Dock = DockStyle.Bottom; closeButton.Height = 36; closeButton.Margin = new Padding(8); closeButton.Text = "Закрыть"; closeButton.UseVisualStyleBackColor = true; closeButton.Click += CloseButton_Click; AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; BackColor = SystemColors.Window; ClientSize = new Size(1040, 450); Controls.Add(AsyncTaskDiscountContainer); Controls.Add(AsyncTaskDetails); Controls.Add(AsyncTaskPhoto); MinimumSize = new Size(900, 420); StartPosition = FormStartPosition.CenterParent; Text = AppearanceSettings.ProductDetailsTitle; BackColor = ColorTranslator.FromHtml(AppearanceSettings.MainBackgroundColor); AsyncTaskPhoto.BackColor = ColorTranslator.FromHtml(AppearanceSettings.MainBackgroundColor); AsyncTaskDetails.BackColor = ColorTranslator.FromHtml(AppearanceSettings.MainBackgroundColor); AsyncTaskDiscountContainer.BackColor = ColorTranslator.FromHtml(AppearanceSettings.SecondaryBackgroundColor); Load += ProductDetailsForm_Load; AsyncTaskPhoto.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)productPictureBox).EndInit(); AsyncTaskDetails.ResumeLayout(false); AsyncTaskDetails.PerformLayout(); AsyncTaskDiscountContainer.ResumeLayout(false); ResumeLayout(false); } private static void ConfigureCaption(Label label, string text) { label.Dock = DockStyle.Fill; label.Font = new Font("Segoe UI", 9F, FontStyle.Bold); label.Padding = new Padding(6); label.Text = text; label.TextAlign = ContentAlignment.MiddleLeft; } private static void ConfigureValue(Label label) { label.Dock = DockStyle.Fill; label.Padding = new Padding(6); label.TextAlign = ContentAlignment.MiddleLeft; } }