private TextSettingParameter GetParameter() { var para = new TextSettingParameter(); para.Content = tbContent.Text; if (string.IsNullOrEmpty(para.Content)) { para.Content = "文本内容不能为空"; } para.Size = int.Parse((cmbFontSize.SelectedItem as CmbDataItem)?.Name ?? "0"); para.UserControl = this; return(para); }
/// <summary> /// 处理文件编辑的动作 /// </summary> /// <param name="guid"></param> /// <param name="para"></param> public void DealTextSetting(string guid, TextSettingParameter para) { Log.Info(para); this._id = guid; //查找是否存在这个组件 var pmjData = _pmjDataList.FirstOrDefault(item => item.Id == guid); if (null == pmjData) { pmjData = new PmjData(); pmjData.Id = guid; pmjData.DataType = EnumPmjData.文本; var label = new Label(); pmjData.Control = label; label.Text = para.Content; label.TextAlign = ContentAlignment.MiddleCenter; label.Margin = new Padding(0); label.Padding = new Padding(0); label.Name = guid; label.AutoSize = true; label.Font = new Font(FontFamily.GenericMonospace, para.Size, FontStyle.Regular, GraphicsUnit.Pixel); label.DoubleClick += SetPmjDataClick; panelTest.Controls.Add(label); pmjData.DataSource = para; //设置可以移动 SetItemEvent(label); _pmjDataList.Add(pmjData); } else { var label = pmjData.Control as Label; label.Text = para.Content; label.Font = new Font(FontFamily.GenericMonospace, para.Size); pmjData.DataSource = para; ResetLocation(label); } }