Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
 /// <summary>
 /// This method is required for Windows Forms designer support.
 /// Do not change the method contents inside the source code editor. The Forms designer might
 /// not be able to load this method if it was changed manually.
 /// </summary>
 private void InitializeComponent()
 {
     this.X                = new JustUI.JUIButton();
     this.TITLE            = new JustUI.JUITitle();
     this.pan_Translations = new Mahou.TranslatePanel.ColorPanel();
     this.txt_Source       = new Mahou.MahouUI.TextBoxCA();
     this.bull             = new System.Windows.Forms.Button();
     this.SuspendLayout();
     //
     // X
     //
     this.X.BackColor = System.Drawing.SystemColors.Window;
     this.X.FlatAppearance.BorderSize         = 0;
     this.X.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(47)))), ((int)(((byte)(79)))), ((int)(((byte)(79)))));
     this.X.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(211)))), ((int)(((byte)(211)))), ((int)(((byte)(211)))));
     this.X.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
     this.X.ForeColor = System.Drawing.SystemColors.WindowText;
     this.X.Location  = new System.Drawing.Point(140, 0);
     this.X.Name      = "X";
     this.X.Size      = new System.Drawing.Size(22, 23);
     this.X.TabIndex  = 0;
     this.X.TabStop   = false;
     this.X.Text      = "X";
     this.X.UseVisualStyleBackColor = true;
     this.X.MouseUp += new System.Windows.Forms.MouseEventHandler(this.XClick);
     //
     // TITLE
     //
     this.TITLE.BackColor = System.Drawing.SystemColors.Window;
     this.TITLE.ForeColor = System.Drawing.SystemColors.WindowText;
     this.TITLE.Location  = new System.Drawing.Point(0, 0);
     this.TITLE.Name      = "TITLE";
     this.TITLE.Size      = new System.Drawing.Size(100, 23);
     this.TITLE.TabIndex  = 1;
     this.TITLE.Text      = "Translation";
     this.TITLE.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
     //
     // pan_Translations
     //
     this.pan_Translations.Location = new System.Drawing.Point(13, 67);
     this.pan_Translations.Name     = "pan_Translations";
     this.pan_Translations.Size     = new System.Drawing.Size(149, 71);
     this.pan_Translations.TabIndex = 3;
     //
     // txt_Source
     //
     this.txt_Source.BorderStyle = System.Windows.Forms.BorderStyle.None;
     this.txt_Source.Font        = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
     this.txt_Source.Location    = new System.Drawing.Point(13, 28);
     this.txt_Source.Name        = "txt_Source";
     this.txt_Source.ReadOnly    = true;
     this.txt_Source.Size        = new System.Drawing.Size(100, 13);
     this.txt_Source.TabIndex    = 4;
     this.txt_Source.TabStop     = false;
     this.txt_Source.Text        = "source text";
     //
     // bull
     //
     this.bull.Location = new System.Drawing.Point(0, 0);
     this.bull.Name     = "bull";
     this.bull.Size     = new System.Drawing.Size(0, 0);
     this.bull.TabIndex = 5;
     this.bull.Text     = "bull";
     this.bull.UseVisualStyleBackColor = true;
     //
     // TranslatePanel
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.BackColor           = System.Drawing.SystemColors.Window;
     this.ClientSize          = new System.Drawing.Size(172, 179);
     this.ControlBox          = false;
     this.Controls.Add(this.bull);
     this.Controls.Add(this.txt_Source);
     this.Controls.Add(this.pan_Translations);
     this.Controls.Add(this.TITLE);
     this.Controls.Add(this.X);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
     this.MaximizeBox     = false;
     this.MaximumSize     = new System.Drawing.Size(800, 400);
     this.MinimizeBox     = false;
     this.MinimumSize     = new System.Drawing.Size(40, 24);
     this.Name            = "TranslatePanel";
     this.Opacity         = 0.9D;
     this.ShowIcon        = false;
     this.ShowInTaskbar   = false;
     this.StartPosition   = System.Windows.Forms.FormStartPosition.Manual;
     this.Text            = "TranslatePanel";
     this.TopMost         = true;
     this.TransparencyKey = System.Drawing.Color.Peru;
     this.Deactivate     += new System.EventHandler(this.TranslatePanelDeactivate);
     this.ResumeLayout(false);
     this.PerformLayout();
 }