public void Deal(string guid, TimeSettingParameter parameter) { 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 = DateTime.Now.ToString(parameter.Format); label.AutoSize = true; label.Name = guid; label.Font = new Font(FontFamily.GenericMonospace, parameter.Size); label.DoubleClick += SetPmjDataClick; panelTest.Controls.Add(label); pmjData.DataSource = parameter; //设置可以移动 SetItemEvent(label); _pmjDataList.Add(pmjData); } else { var label = pmjData.Control as Label; label.Text = DateTime.Now.ToString(parameter.Format); label.Font = new Font(FontFamily.GenericMonospace, parameter.Size); pmjData.DataSource = parameter; ResetLocation(label); } }
/// <summary> /// 裁剪到的图片 /// </summary> /// <param name="bitmap"></param> public void GetCutPicture(string guid, PictureSettingParameter 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 pictureBox = new PictureBox(); var bitmap = para.Bitmap; Console.WriteLine($"图片格式:{para.Bitmap.PixelFormat}"); pmjData.Control = pictureBox; pmjData.DataSource = para; SetPictureBoxImage(pictureBox, bitmap); pictureBox.Name = pmjData.Id; pictureBox.DoubleClick += SetPmjDataClick; panelTest.Controls.Add(pictureBox); //设置可以移动 SetItemEvent(pictureBox); _pmjDataList.Add(pmjData); } else { var pictureBox = pmjData.Control as PictureBox; pictureBox?.Image.Dispose(); SetPictureBoxImage(pictureBox, para.Bitmap); pmjData.DataSource = para; ResetLocation(pictureBox); } }
public void DealBarcodeSetting(string guid, BarcodeSettingParameter para) { try { this._id = guid; //查找是否存在这个组件 var pmjData = _pmjDataList.FirstOrDefault(item => item.Id == guid); //生成bitmap图片 var bitmap = GetBarcodeBitmap(para); Console.WriteLine($"二维码, width:{bitmap.Width} height:{bitmap.Height} format:{bitmap.PixelFormat}"); if (null == pmjData) { pmjData = new PmjData(); pmjData.Id = guid; pmjData.DataType = EnumPmjData.条码; var picture = new PictureBox(); picture.Name = guid; pmjData.Control = picture; SetPictureBoxImage(picture, bitmap); picture.DoubleClick += SetPmjDataClick; panelTest.Controls.Add(picture); pmjData.DataSource = para; //设置可以移动 SetItemEvent(picture); _pmjDataList.Add(pmjData); } else { var pic = pmjData.Control as PictureBox; //销毁原来的bitmap数据 (pic.Image as Bitmap)?.Dispose(); SetPictureBoxImage(pic, bitmap); //有可能会越界,如果越界的话,就直接重置top的数值 ResetLocation(pic); pmjData.DataSource = para; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void SerialNumberDeal(string guid, SerialNumberParameter para) { try { 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.NumberInit.ToString(para.Format); label.Name = guid; label.AutoSize = true; label.Font = new Font(FontFamily.GenericMonospace, para.Size); 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.NumberInit.ToString(para.Format); label.Font = new Font(FontFamily.GenericMonospace, para.Size); pmjData.DataSource = para; ResetLocation(label); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <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); } }