// 创建 字幕控件时调用, 初始化默认属性 // 属性界面改变属性之后要调用这个更新 字幕控件 private void ChangeTxtAttr(Ctrl.SubtitleCtrl txt) { txt.Name = "subtitle_" + _txtIndex; txt.BackColor = ColorTranslator.FromHtml(txtAttr.Bgcolor); txt.ForeColor = ColorTranslator.FromHtml(txtAttr.Color); txt.Text = txtAttr.Txt; txt.Direction = txtAttr.Direction; txt.Speed = txtAttr.Speed; int x = ToFormX(txtAttr.X); int y = ToFormY(txtAttr.Y); txt.Location = new Point(x, y); txt.Width = ToFormX(txtAttr.W); txt.Height = ToFormY(txtAttr.H); txt.X = txtAttr.X; txt.Y = txtAttr.Y; txt.W = txtAttr.W; txt.H = txtAttr.H; txt.fontname = txtAttr.Fontname; txt.fontsize = txtAttr.Fontsize; txt.transparent = txtAttr.Transparent; txt.Font = new Font("宋体", float.Parse(txtAttr.Fontsize), FontStyle.Regular); //txt.Name1 = ""; }
private void pScreen_MouseUp(object sender, MouseEventArgs e) { ReverseFrame(); _start = null; if (txtAttr.W <= 0 || txtAttr.W <= 0) { MessageBox.Show("宽度或高度为负数!"); return; } Ctrl.SubtitleCtrl txt = AddSubtitleText(); _ht.Add(_scrLeft + " " + _scrTop, txt); //lbTxt.Items.Add(_scrLeft + " " + _scrTop); }
// 点击之后, 在属性界面加载本字幕控件的 属性 private void Txt_Click(object sender, EventArgs e) { //MessageBox.Show (((Control)sender).Name); Ctrl.SubtitleCtrl txt = (Ctrl.SubtitleCtrl)sender; _currentFocus = txt; txtAttr.LoadBasicAttr((Control)txt); txtAttr.X = txt.X; txtAttr.Y = txt.Y; txtAttr.W = txt.W; txtAttr.H = txt.H; txtAttr.Fontname = txt.fontname; txtAttr.Fontsize = txt.fontsize; txtAttr.Transparent = txt.transparent; txtAttr.Speed = txt.Speed; txtAttr.Direction = txt.Direction; }
private Ctrl.SubtitleCtrl AddSubtitleText() { // Settings to generate a New TextBox Ctrl.SubtitleCtrl txt = new Ctrl.SubtitleCtrl(); // Create the Variable for TextBox _currentFocus = txt; ChangeTxtAttr(txt); //txt.TextChanged += new System.EventHandler(txt_TextChanged); txt.Click += Txt_Click; txt.Tag = _txtIndex; _txtIndex++; // Create Variables to Define "X" and "Y" Locations //var txtLocX = txt.Location.X; //var txtLocY = txt.Location.Y; //Set your TextBox Location Here //txt.Location.X = x; //txt.Location.Y = y; //txt.Location = new Point(x, y); //txt.TextWrapping = TextWrapping.Wrap; //txt.WordWrap = true; //txt.Multiline = true; //txt.Height = h; //txt.Width = w; txt.AutoSize = false; //txt.AcceptsReturn = true; //txt.Margin = new Thickness(10, 15, 950, 0); // This adds a new TextBox //txt.MouseDown += new MouseEventHandler(textbox_MouseDown); //txt.MouseMove += new MouseEventHandler(textbox_MouseMove); //txt.MouseUp += new MouseEventHandler(textbox_MouseUp); //txt.MouseLeave += delegate (object sender, EventArgs e) //{ // Cursor = Cursors.Default; //}; ControlMoverOrResizer.Init(txt); this.pScreen.Controls.Add(txt); return(txt); }