protected override void MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (Drawing != null) { Point ptPhy = Coordinates(e); Microsoft.Win32.OpenFileDialog ofDialog = new Microsoft.Win32.OpenFileDialog() { Title = "Insert Background", Filter = Webb.Playbook.Data.Extensions.ImageFileFilter, }; if (ofDialog.ShowDialog().Value) { ImageBrush imgBrush = new ImageBrush() { Stretch = Stretch.None, AlignmentX = AlignmentX.Center, AlignmentY = AlignmentY.Center, ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(ofDialog.FileName, UriKind.RelativeOrAbsolute)), }; System.Drawing.Image image = System.Drawing.Image.FromFile(ofDialog.FileName); PBImage pbImg = new PBImage() { Coordinates = ptPhy, File = ofDialog.FileName, Width = ToLogical(image.Width), Height = ToLogical(image.Height), }; Drawing.Add(pbImg); pbImg.MoveTo(pbImg.Coordinates); } Drawing.SetDefaultBehavior(); } }
private void DGVList_Select(int index) { if (index >= 0 && index < DGVList.RowCount) { string id = DGVList.Rows[index].Cells["COLId"].Value.ToString(); ClipboardData data = ClipboardDataMan.Get(id); if (data != null) { TBText.Clear(); PBImage.Image = null; DGVData.Rows.Clear(); DGVData.Columns.Clear(); //显示信息大小 TSSLDataSize.Text = ByteConvertTool.Fmt(data.Size); //设置富文本 //if (data.RichText != null) //{ // try // { // using (Stream s = new MemoryStream()) // { // s.Position = 0; // s.Write(data.RichText, 0, data.RichText.Length); // s.Position = 0; // RTBRich.LoadFile(s, RichTextBoxStreamType.RichText); // } // } // catch (Exception e) { } //} //设置纯文本 if (data.Text != null) { //TCData.SelectTab("TPText"); TBText.AppendText(data.Text); } //设置表格 if (data.Text != null) { string[] rows = data.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (var _r in rows) { string[] _d = _r.Split('\t'); if (ListTool.HasElements(_d)) { if (DGVData.Columns.Count < _d.Length) { for (int i = DGVData.Columns.Count; i < _d.Length; i++) { DGVData.Columns.Add($"DGVData_COL{i}", $"{i + 1}"); } } DGVData.Rows.Add(_d); } } } //设置图片 if (data.Image != null) { //TCData.SelectTab("TPImage"); PBImage.Image = data.Image; PBImage.Update(); } } } }