public void AddTranslation(GTResp gtr) { txt_Source.Text = gtr.source; if (TRANSCRIPTION) { if (!string.IsNullOrEmpty(gtr.src_transcr)) { var txt = new MahouUI.TextBoxCA(); txt.Name = txtstrc; txt.Multiline = true; if (this.Controls.ContainsKey(txtstrc)) { txt = (MahouUI.TextBoxCA) this.Controls[txtstrc]; } else { this.Controls.Add(txt); } txt.Text = "[" + MahouUI.UnescapeUnicode(gtr.src_transcr) + "]"; } else { if (this.Controls.ContainsKey(txtstrc)) { this.Controls.Remove(this.Controls[txtstrc]); } } } pan_Translations.Width = Width - 2; bool exist = false; if (GTRs.Count == 0) { pan_Translations.Height = 0; } if (!String.IsNullOrEmpty(MahouUI.AutoCopyTranslation)) { if (MahouUI.AutoCopyTranslation.ToLower() == gtr.targ_lang.ToLower()) { Debug.WriteLine("AutoCopyTranslation: " + gtr.targ_lang); KMHook.RestoreClipBoard(gtr.translation); MahouUI.ACT_Match++; } } foreach (Control ct in pan_Translations.Controls) { if (ct.Name == "PN_LINE_" + gtr.src_lang + ".to." + gtr.targ_lang) { exist = true; break; } } if (exist) { UpdateTranslation(gtr); } else { GTRs.Add(gtr); var ind = GTRs.IndexOf(gtr); var pan = new Panel(); pan.Width = pan_Translations.Width - 2; pan.Height = MahouUI.TrText.Height * 2; Debug.WriteLine("Pan height: " + pan.Height); pan.Name = "PN_LINE_" + gtr.src_lang + ".to." + gtr.targ_lang; pan.Location = new Point(1, pan_Translations.Height + 1); var slt = new MahouUI.TextBoxCA(); var txt = new MahouUI.TextBoxCA(); slt.ReadOnly = txt.ReadOnly = true; slt.TabStop = txt.TabStop = false; slt.Name = "SL_TXT" + gtr.targ_lang; slt.BorderStyle = txt.BorderStyle = 0; slt.Location = new Point(1, 0); slt.Text = (gtr.auto_detect ? "" : gtr.src_lang + "/") + gtr.targ_lang + ":"; var g = CreateGraphics(); var size = g.MeasureString(slt.Text, slt.Font); slt.Width = (int)size.Width; txt.Name = "TR_TXT" + gtr.targ_lang; txt.Text = MahouUI.UnescapeUnicode(gtr.translation); var btn = new ButtonLabel(); btn.Text = "♫"; btn.gtr = gtr; btn.Name = "LBBT_SP" + gtr.targ_lang; btn.Width = 14; btn.Height = 14; pan.Controls.Add(slt); pan.Controls.Add(txt); var trcw = 0; if (TRANSCRIPTION) { if (!String.IsNullOrEmpty(gtr.targ_transcr)) { MahouUI.TextBoxCA txttrc = new MahouUI.TextBoxCA(); txttrc.ReadOnly = true; txttrc.TabStop = false; txttrc.BorderStyle = 0; txttrc.Multiline = true; txttrc.Font = MahouUI.TrText; txttrc.Name = "TRC_TXT" + gtr.targ_lang; txttrc.Text = "[" + MahouUI.UnescapeUnicode(gtr.targ_transcr) + "]"; var si = g.MeasureString(txttrc.Text, txttrc.Font); trcw = txttrc.Width = (int)si.Width; txttrc.Location = new Point(txt.Location.X + pan.Width - slt.Width - 2 - btn.Width - 2 - trcw, txt.Location.Y); pan.Controls.Add(txttrc); } } g.Dispose(); btn.Location = new Point(pan.Width - 14 - 1, 1); pan.Controls.Add(btn); txt.Width = pan.Width - slt.Width - 2 - btn.Width - 2 - trcw; txt.Multiline = true; txt.Location = new Point(slt.Width + 2, 1); btn.BackColor = slt.BackColor = txt.BackColor = pan_Translations.BackColor; btn.ForeColor = slt.ForeColor = txt.ForeColor = pan_Translations.ForeColor; pan_Translations.Controls.Add(pan); txt_Source.Font = slt.Font = txt.Font = MahouUI.TrText; UpdateHeight(); } SetOptimalWidth(); SetOptimalWidth(); }