1using System; 2using System.Drawing; 3using System.Windows.Forms; 4using System.Collections.Generic; 5using WindowCapture.Integration; 6 7namespace WindowCapture.UI 8{ 9 /// <summary> 10 /// Preview dialog for reviewing rephrased descriptions and captions 11 /// </summary> 12 public class OriginalizePreviewDialog : Form 13 { 14 private List<DocumentTextItem> items; 15 16 public OriginalizePreviewDialog(List<DocumentTextItem> items) 17 { 18 this.items = items; 19 InitializeDialog(); 20 } 21 22 private void InitializeDialog() 23 { 24 Text = "Оригинализация описаний"; 25 Size = new Size(720, 550); 26 StartPosition = FormStartPosition.CenterParent; 27 FormBorderStyle = FormBorderStyle.FixedDialog; 28 MaximizeBox = false; 29 MinimizeBox = false; 30 BackColor = Color.FromArgb(30, 30, 34); 31 ForeColor = Color.FromArgb(230, 230, 230); 32 33 // Header 34 var lblHeader = new Label(); 35 lblHeader.Text = "Проверьте и отредактируйте перефразированные тексты:"; 36 lblHeader.Location = new Point(12, 10); 37 lblHeader.AutoSize = true; 38 lblHeader.Font = new Font("Segoe UI", 10f); 39 lblHeader.ForeColor = Color.FromArgb(230, 230, 230); 40 Controls.Add(lblHeader); 41 42 // Scrollable panel for items 43 var scrollPanel = new Panel(); 44 scrollPanel.Location = new Point(12, 38); 45 scrollPanel.Size = new Size(690, 420); 46 scrollPanel.AutoScroll = true; 47 scrollPanel.BackColor = Color.FromArgb(35, 35, 40); 48 Controls.Add(scrollPanel); 49 50 int y = 8; 51 int itemWidth = 660; 52 53 for (int i = 0; i < items.Count; i++) 54 { 55 var item = items[i]; 56 int idx = i; // Capture for closure 57 58 // Checkbox + type label 59 var chk = new CheckBox(); 60 chk.Checked = true; 61 chk.Location = new Point(8, y); 62 chk.Size = new Size(16, 16); 63 chk.FlatStyle = FlatStyle.Flat; 64 chk.BackColor = Color.Transparent; 65 chk.CheckedChanged += (s, e) => { items[idx].Accepted = chk.Checked; }; 66 scrollPanel.Controls.Add(chk); 67 68 var lblType = new Label(); 69 lblType.Text = item.IsCaption ? "Название:" : "Описание:"; 70 lblType.Location = new Point(28, y); 71 lblType.AutoSize = true; 72 lblType.Font = new Font("Segoe UI Semibold", 8.5f); 73 lblType.ForeColor = item.IsCaption ? Color.FromArgb(86, 156, 214) : Color.FromArgb(230, 230, 230); 74 scrollPanel.Controls.Add(lblType); 75 y += 20; 76 77 // "Было:" label + original text 78 var lblOld = new Label(); 79 lblOld.Text = "Было:"; 80 lblOld.Location = new Point(28, y); 81 lblOld.AutoSize = true; 82 lblOld.Font = new Font("Segoe UI", 8f); 83 lblOld.ForeColor = Color.FromArgb(140, 140, 140); 84 scrollPanel.Controls.Add(lblOld); 85 y += 16; 86 87 string oldDisplayText = item.IsCaption ? (item.CaptionPrefix + item.TextToRephrase) : item.OriginalText; 88 var txtOld = new TextBox(); 89 txtOld.Text = oldDisplayText; 90 txtOld.Location = new Point(28, y); 91 txtOld.Size = new Size(itemWidth - 36, Math.Max(36, Math.Min(60, oldDisplayText.Length / 2))); 92 txtOld.Multiline = true; 93 txtOld.ReadOnly = true; 94 txtOld.BackColor = Color.FromArgb(45, 45, 50); 95 txtOld.ForeColor = Color.FromArgb(140, 140, 140); 96 txtOld.BorderStyle = BorderStyle.FixedSingle; 97 txtOld.Font = new Font("Segoe UI", 8.5f); 98 txtOld.ScrollBars = ScrollBars.Vertical; 99 scrollPanel.Controls.Add(txtOld); 100 y += txtOld.Height + 4; 101 102 // "Стало:" label + editable new text 103 var lblNew = new Label(); 104 lblNew.Text = "Стало:"; 105 lblNew.Location = new Point(28, y); 106 lblNew.AutoSize = true; 107 lblNew.Font = new Font("Segoe UI", 8f); 108 lblNew.ForeColor = Color.FromArgb(78, 154, 78); 109 scrollPanel.Controls.Add(lblNew); 110 y += 16; 111 112 string newDisplayText = item.NewText ?? ""; 113 if (item.IsCaption && !string.IsNullOrEmpty(item.CaptionPrefix)) 114 { 115 // Show prefix as non-editable hint 116 var lblPrefix = new Label(); 117 lblPrefix.Text = item.CaptionPrefix; 118 lblPrefix.Location = new Point(28, y); 119 lblPrefix.AutoSize = true; 120 lblPrefix.Font = new Font("Segoe UI", 8.5f); 121 lblPrefix.ForeColor = Color.FromArgb(86, 156, 214); 122 scrollPanel.Controls.Add(lblPrefix); 123 } 124 125 var txtNew = new TextBox(); 126 txtNew.Text = newDisplayText; 127 int newX = item.IsCaption ? 28 + (int)(item.CaptionPrefix ?? "").Length * 6 + 10 : 28; 128 if (item.IsCaption) 129 { 130 // Caption: single line next to prefix 131 txtNew.Location = new Point(Math.Min(newX, 200), y); 132 txtNew.Size = new Size(itemWidth - 36 - Math.Min(newX - 28, 172), 22); 133 txtNew.Multiline = false; 134 } 135 else 136 { 137 // Description: multiline below label 138 txtNew.Location = new Point(28, y); 139 txtNew.Size = new Size(itemWidth - 36, Math.Max(36, Math.Min(60, newDisplayText.Length / 2))); 140 txtNew.Multiline = true; 141 txtNew.ScrollBars = ScrollBars.Vertical; 142 } 143 txtNew.BackColor = Color.FromArgb(50, 50, 55); 144 txtNew.ForeColor = Color.FromArgb(230, 230, 230); 145 txtNew.BorderStyle = BorderStyle.FixedSingle; 146 txtNew.Font = new Font("Segoe UI", 8.5f); 147 txtNew.TextChanged += (s, e) => { items[idx].NewText = txtNew.Text; }; 148 scrollPanel.Controls.Add(txtNew); 149 y += txtNew.Height + 12; 150 151 // Separator line 152 var sep = new Panel(); 153 sep.Location = new Point(8, y); 154 sep.Size = new Size(itemWidth - 16, 1); 155 sep.BackColor = Color.FromArgb(60, 60, 65); 156 scrollPanel.Controls.Add(sep); 157 y += 8; 158 } 159 160 // Bottom buttons 161 var btnApply = new Button(); 162 btnApply.Text = "Применить"; 163 btnApply.Location = new Point(490, 468); 164 btnApply.Size = new Size(100, 32); 165 btnApply.FlatStyle = FlatStyle.Flat; 166 btnApply.FlatAppearance.BorderColor = Color.FromArgb(86, 156, 214); 167 btnApply.BackColor = Color.FromArgb(86, 156, 214); 168 btnApply.ForeColor = Color.FromArgb(230, 230, 230); 169 btnApply.Font = new Font("Segoe UI", 9.5f); 170 btnApply.Cursor = Cursors.Hand; 171 btnApply.Click += (s, e) => { DialogResult = DialogResult.OK; Close(); }; 172 Controls.Add(btnApply); 173 174 var btnCancel = new Button(); 175 btnCancel.Text = "Отмена"; 176 btnCancel.Location = new Point(600, 468); 177 btnCancel.Size = new Size(100, 32); 178 btnCancel.FlatStyle = FlatStyle.Flat; 179 btnCancel.FlatAppearance.BorderColor = Color.FromArgb(60, 60, 65); 180 btnCancel.BackColor = Color.FromArgb(50, 50, 55); 181 btnCancel.ForeColor = Color.FromArgb(230, 230, 230); 182 btnCancel.Font = new Font("Segoe UI", 9.5f); 183 btnCancel.Cursor = Cursors.Hand; 184 btnCancel.Click += (s, e) => { DialogResult = DialogResult.Cancel; Close(); }; 185 Controls.Add(btnCancel); 186 } 187 } 188}