/// <summary> /// 提示位置错误 /// </summary> /// <param name="loation"></param> /// <param name="name"></param> private bool ShowErrorMsg(List <double> loation, string name) { var result = false; var pdfSize = PdfConverter.GetPdfSize(_pdfPaths[_index]); if (Math.Abs(loation[0]) < 0.000001) { MessageBox.Show($"{Resources.SignError},{name}{Resources.LoseHView}"); result = true; } if (loation[0] > pdfSize.Width) { MessageBox.Show($"{Resources.SignError},{name}{Resources.BeyondHView}"); result = true; } if (Math.Abs(loation[1]) < 0.000001) { MessageBox.Show($"{Resources.SignError},{name}{Resources.LoseVView}"); result = true; } if (loation[1] > pdfSize.Height) { MessageBox.Show($"{Resources.SignError},{name}{Resources.BeyondVView}"); result = true; } return(result); }
/// <summary> /// 初始化数据 /// </summary> private void UpdateData() { _img?.Dispose(); string filePath; var pdfPath = _pdfPaths[_index]; // 拼凑同目录下的图片路径 if (_file != null) { filePath = _file.OldPath.Remove(_file.OldPath.LastIndexOf('.')) + ".jpg"; } else { filePath = pdfPath.Remove(pdfPath.LastIndexOf('.')) + ".jpg"; } List <string> imgFiles; // 存在就加载,不存在则转换 if (File.Exists(filePath)) { _img = Image.FromFile(filePath); } else if (_file != null) { imgFiles = _file.OldPath.ToImages(); if (imgFiles.Count > 0) { _img = Image.FromFile(_file.OldPath.ToImages()[0]); } else { pbImg.Image = null; Text = Path.GetFileName(_file == null ? _files[_index].OldPath : _file.OldPath); return; } } else { imgFiles = pdfPath.ToImages(); if (imgFiles.Count > 0) { _img = Image.FromFile(imgFiles[0]); } else { pbImg.Image = null; Text = Path.GetFileName(_file == null ? _files[_index].OldPath : _file.OldPath); return; } } _pdfScale = GetScale(PdfConverter.GetPdfSize(pdfPath), _img.Size); _imgScale = GetScale(_img.Size, pnlImg.Size); pbImg.Image = _img; // 设置标记前必须先设置图纸所在控件大小,防止参照上一个图纸大小设置位置 ZoomCtrl(); SetLocation(); Text = Path.GetFileName(_file == null ? _files[_index].OldPath : _file.OldPath); }