From b055d523bf196775f808a30ccdf62252b2392aa4 Mon Sep 17 00:00:00 2001 From: the Date: Mon, 24 Jun 2024 17:09:03 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BA=D1=80=D0=B0=D1=81=D0=BE=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WinFormsApp/FormMediaFiles.Designer.cs | 26 ++++++++++++++++++++------ WinFormsApp/FormMediaFiles.cs | 24 ++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/WinFormsApp/FormMediaFiles.Designer.cs b/WinFormsApp/FormMediaFiles.Designer.cs index 93d7f0d..e072670 100644 --- a/WinFormsApp/FormMediaFiles.Designer.cs +++ b/WinFormsApp/FormMediaFiles.Designer.cs @@ -35,8 +35,10 @@ buttonSelectFile = new Button(); labelFile = new Label(); groupBox1 = new GroupBox(); + dataGridView = new DataGridView(); groupBoxFiles.SuspendLayout(); groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // // groupBoxFiles @@ -45,10 +47,10 @@ groupBoxFiles.Dock = DockStyle.Left; groupBoxFiles.Location = new Point(0, 0); groupBoxFiles.Name = "groupBoxFiles"; - groupBoxFiles.Size = new Size(282, 439); + groupBoxFiles.Size = new Size(282, 586); groupBoxFiles.TabIndex = 0; groupBoxFiles.TabStop = false; - groupBoxFiles.Text = "Файлы"; + groupBoxFiles.Text = "Фотографии"; // // panelFiles // @@ -56,7 +58,7 @@ panelFiles.Dock = DockStyle.Fill; panelFiles.Location = new Point(3, 19); panelFiles.Name = "panelFiles"; - panelFiles.Size = new Size(276, 417); + panelFiles.Size = new Size(276, 564); panelFiles.TabIndex = 0; // // comboBoxProduct @@ -104,18 +106,28 @@ groupBox1.Controls.Add(buttonAdd); groupBox1.Controls.Add(buttonSelectFile); groupBox1.Dock = DockStyle.Right; - groupBox1.Location = new Point(466, 0); + groupBox1.Location = new Point(678, 0); groupBox1.Name = "groupBox1"; - groupBox1.Size = new Size(200, 439); + groupBox1.Size = new Size(200, 586); groupBox1.TabIndex = 5; groupBox1.TabStop = false; groupBox1.Text = "groupBox1"; // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Fill; + dataGridView.Location = new Point(282, 0); + dataGridView.Name = "dataGridView"; + dataGridView.Size = new Size(396, 586); + dataGridView.TabIndex = 6; + // // FormMediaFiles // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(666, 439); + ClientSize = new Size(878, 586); + Controls.Add(dataGridView); Controls.Add(groupBox1); Controls.Add(groupBoxFiles); Name = "FormMediaFiles"; @@ -125,6 +137,7 @@ groupBoxFiles.ResumeLayout(false); groupBox1.ResumeLayout(false); groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } @@ -137,5 +150,6 @@ private Label labelFile; private GroupBox groupBox1; private Panel panelFiles; + private DataGridView dataGridView; } } \ No newline at end of file diff --git a/WinFormsApp/FormMediaFiles.cs b/WinFormsApp/FormMediaFiles.cs index 669f7c4..b26ad2f 100644 --- a/WinFormsApp/FormMediaFiles.cs +++ b/WinFormsApp/FormMediaFiles.cs @@ -33,6 +33,19 @@ namespace WinFormsApp private void LoadData() { if (comboBoxProduct.SelectedIndex < 0) return; + _logger.LogInformation("Загрузка файлов"); + try + { + var filelist = _mediafileLogic.ReadList(null); + if (filelist != null) + { + dataGridView.DataSource = filelist; + } + } + catch (Exception ex) + { + + } var list = _mediafileLogic.ReadList(new MediaFileSearchModel() { ProductId = (Guid?)comboBoxProduct.SelectedValue ?? Guid.Empty, @@ -47,6 +60,13 @@ namespace WinFormsApp panelFiles.Controls.Add(imageBox); imageBox.SizeMode = PictureBoxSizeMode.Zoom; imageBox.Height = 400; + imageBox.BorderStyle = BorderStyle.FixedSingle; + + var imageLabel = new Label(); + imageLabel.Text = item.Name; + imageLabel.Dock = DockStyle.Top; + imageLabel.TextAlign = ContentAlignment.MiddleCenter; + panelFiles.Controls.Add(imageLabel); panelFiles.Refresh(); } @@ -99,13 +119,13 @@ namespace WinFormsApp if (dialog.ShowDialog() == DialogResult.OK) { _filename = dialog.FileName; - labelFile.Text = System.IO.Path.GetDirectoryName(_filename); + labelFile.Text = System.IO.Path.GetFileName(_filename); } } private void FormMediaFiles_Resize(object sender, EventArgs e) { - panelFiles.Width = Convert.ToInt32(this.Width * 0.5); + groupBoxFiles.Width = Convert.ToInt32(this.Width * 0.4); panelFiles.Height = this.Height; foreach (var control in this.Controls.OfType()) {