|
@@ -1,6 +1,7 @@
|
|
|
using ComPDFKitViewer;
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
using Microsoft.Win32;
|
|
|
+using PDF_Office.CustomControl.CompositeControl;
|
|
|
using PDF_Office.Model;
|
|
|
using PDF_Office.Model.PropertyPanel.AnnotPanel;
|
|
|
using Prism.Commands;
|
|
@@ -20,7 +21,117 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
|
|
|
{
|
|
|
public class TextEditPropertyViewModel : PDFEditVM, INavigationAware
|
|
|
{
|
|
|
-
|
|
|
+ private ComboDataItem _fontFamilyData;
|
|
|
+ public ComboDataItem FontFamilyData
|
|
|
+ {
|
|
|
+ get { return _fontFamilyData; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _fontFamilyData, value);
|
|
|
+ if(_fontFamilyData != null && TextEditEvent != null)
|
|
|
+ {
|
|
|
+ TextEditEvent.FontFamily = new FontFamily(_fontFamilyData.ValueStr);
|
|
|
+ TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private ComboDataItem _presetTextData;
|
|
|
+ public ComboDataItem PresetTextData
|
|
|
+ {
|
|
|
+ get { return _presetTextData; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _presetTextData, value);
|
|
|
+ if(_presetTextData != null && FontStyleList != null)
|
|
|
+ {
|
|
|
+ var item = FontStyleList.FirstOrDefault(temp => temp.mTag == _presetTextData.ValueStr);
|
|
|
+ if(item != null && TextEditEvent != null)
|
|
|
+ {
|
|
|
+ TextEditEvent.FontFamily = item.mFontFamily;
|
|
|
+ TextEditEvent.FontSize = item.mFontSize;
|
|
|
+ TextEditEvent.FontWeight = item.mFontWeight;
|
|
|
+ TextEditEvent.FontStyle = item.mFontStyle;
|
|
|
+ TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private FontStyle _fontStyle;
|
|
|
+ public FontStyle FontStyleItem
|
|
|
+ {
|
|
|
+ get { return _fontStyle; }
|
|
|
+ set {SetProperty(ref _fontStyle, value);}
|
|
|
+ }
|
|
|
+
|
|
|
+ private FontWeight _fontWeight;
|
|
|
+ public FontWeight FontWeightItem
|
|
|
+ {
|
|
|
+ get { return _fontWeight; }
|
|
|
+ set { SetProperty(ref _fontWeight, value); }
|
|
|
+ }
|
|
|
+
|
|
|
+ private ComboDataItem _fontWeightStyleItem;
|
|
|
+ public ComboDataItem FontWeightStyleItem
|
|
|
+ {
|
|
|
+ get { return _fontWeightStyleItem; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _fontWeightStyleItem, value);
|
|
|
+ if (_fontWeightStyleItem.ValueStr != null && string.IsNullOrEmpty((string)_fontWeightStyleItem.ValueStr) == false)
|
|
|
+ {
|
|
|
+ switch ((string)_fontWeightStyleItem.ValueStr)
|
|
|
+ {
|
|
|
+ case "Regular":
|
|
|
+ FontStyleItem = FontStyles.Normal;
|
|
|
+ FontWeightItem = FontWeights.Normal;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "Bold":
|
|
|
+ FontStyleItem = FontStyles.Normal;
|
|
|
+ FontWeightItem = FontWeights.Bold;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "Italic":
|
|
|
+ FontStyleItem = FontStyles.Italic;
|
|
|
+ FontWeightItem = FontWeights.Normal;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "Bold Italic":
|
|
|
+ FontStyleItem = FontStyles.Italic;
|
|
|
+ FontWeightItem = FontWeights.Bold;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ TextEditEvent.FontWeight = FontWeightItem;
|
|
|
+ TextEditEvent.FontStyle = FontStyleItem;
|
|
|
+ TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private ComboDataItem _fontSizeData = new ComboDataItem(6);
|
|
|
+ public ComboDataItem FontSizeData
|
|
|
+ {
|
|
|
+ get { return _fontSizeData; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _fontSizeData, value);
|
|
|
+ if (_fontSizeData != null && TextEditEvent != null)
|
|
|
+ {
|
|
|
+ TextEditEvent.FontSize = _fontSizeData.Value;
|
|
|
+ TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ComboDataItem> FontFamilyItems { get; private set; }
|
|
|
+ public List<ComboDataItem> FontStyleItems { get; private set; }
|
|
|
+ public List<ComboDataItem> PresetTextItems { get; private set; }
|
|
|
+
|
|
|
+
|
|
|
#region 属性
|
|
|
|
|
|
#region 文本属性
|
|
@@ -201,11 +312,48 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
|
|
|
private void InitVariable()
|
|
|
{
|
|
|
InitFontStyles();
|
|
|
+ InitFontFamilyComboBox();
|
|
|
+ InitFontStyleComboBox();
|
|
|
+ InitFontStyles();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitFontFamilyComboBox()
|
|
|
+ {
|
|
|
+ FontFamilyItems = new List<ComboDataItem>();
|
|
|
+ ComboDataItem item = new ComboDataItem("Courier", "Courier New");
|
|
|
+ FontFamilyItems.Add(item);
|
|
|
+ item = new ComboDataItem("Helvetica", "Helvetica");
|
|
|
+ FontFamilyItems.Add(item);
|
|
|
+ item = new ComboDataItem("Times-Roman", "Times New Roman");
|
|
|
+ FontFamilyItems.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitFontStyleComboBox()
|
|
|
+ {
|
|
|
+ FontStyleItems = new List<ComboDataItem>();
|
|
|
+ ComboDataItem item = new ComboDataItem("Regular", "Regular");
|
|
|
+ FontStyleItems.Add(item);
|
|
|
+ item = new ComboDataItem("Bold", "Bold");
|
|
|
+ FontStyleItems.Add(item);
|
|
|
+ item = new ComboDataItem("Italic", "Italic");
|
|
|
+ FontStyleItems.Add(item);
|
|
|
+
|
|
|
+ item = new ComboDataItem("Bold Italic", "Bold Italic");
|
|
|
+ FontStyleItems.Add(item);
|
|
|
}
|
|
|
|
|
|
private void InitFontStyles()
|
|
|
{
|
|
|
+ PresetTextItems = new List<ComboDataItem>();
|
|
|
FontStyleList = LoadFontStyle.Load();
|
|
|
+
|
|
|
+ foreach(var item in FontStyleList)
|
|
|
+ {
|
|
|
+ ComboDataItem itemData = new ComboDataItem(item.mTag, item.mTagContent);
|
|
|
+ PresetTextItems.Add(itemData);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void InitCommand()
|
|
@@ -279,8 +427,12 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
|
|
|
|
|
|
private void AntiClockwise()
|
|
|
{
|
|
|
- Angle = TextEditEvent.Rotate = TextEditEvent.Rotate - 90;
|
|
|
- TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
+ if ( TextEditEvent != null)
|
|
|
+ {
|
|
|
+ Angle = TextEditEvent.Rotate = TextEditEvent.Rotate - 90;
|
|
|
+ TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -439,6 +591,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
|
|
|
|
|
|
private void ReplaceImg()
|
|
|
{
|
|
|
+ if (TextEditEvent == null) return;
|
|
|
+
|
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
|
openFileDialog.Filter = "png|*.png;|Image|*.gif;*.jpg;*.jpeg;*.bmp;*.jfif;*.png;";
|
|
|
openFileDialog.Multiselect = true;
|
|
@@ -655,81 +809,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
|
|
|
e.Handle = true;
|
|
|
}
|
|
|
}
|
|
|
- ///// <summary>
|
|
|
- ///// 选中编辑PDF内容的事件
|
|
|
- ///// </summary>
|
|
|
- //private void PDFViewer_PDFEditActiveHandler(object sender, List<PDFEditEvent> e)
|
|
|
- //{
|
|
|
- // if (e != null && e.Count > 0)
|
|
|
- // {
|
|
|
-
|
|
|
- // ReLoadLayoutAlign(e.Count);
|
|
|
-
|
|
|
- // IsTextEdit = (e[0].EditType == ComPDFKit.PDFPage.CPDFEditType.EditText);
|
|
|
- // TextEditEvent = e[0];
|
|
|
-
|
|
|
- // if (IsTextEdit == false)
|
|
|
- // {
|
|
|
- // var list = PDFViewer.GetSelectedImages();
|
|
|
- // if (list != null && list.Count > 0)
|
|
|
- // {
|
|
|
- // System.Drawing.Bitmap bitmap = null;
|
|
|
- // foreach (var item in list)
|
|
|
- // {
|
|
|
- // if (item.Value.Count > 0)
|
|
|
- // {
|
|
|
- // bitmap = item.Value[0];
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // if (bitmap != null)
|
|
|
- // {
|
|
|
- // IntPtr ip = bitmap.GetHbitmap();
|
|
|
- // System.Windows.Media.Imaging.BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, Int32Rect.Empty,
|
|
|
- // System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
|
|
|
- // CurrentImg = bitmapSource;
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // bool isText = false;
|
|
|
- // bool isImg = false;
|
|
|
-
|
|
|
- // foreach (var item in e)
|
|
|
- // {
|
|
|
- // if (item.EditType == ComPDFKit.PDFPage.CPDFEditType.EditText)
|
|
|
- // {
|
|
|
- // isText = true;
|
|
|
- // }
|
|
|
-
|
|
|
- // if (item.EditType == ComPDFKit.PDFPage.CPDFEditType.EditImage)
|
|
|
- // {
|
|
|
- // isImg = true;
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // if (isImg == true && isText == true)
|
|
|
- // IsSelectTextAndImg = true;
|
|
|
- // else
|
|
|
- // IsSelectTextAndImg = false;
|
|
|
-
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // IsLayoutAlign = false;
|
|
|
- // IsLayoutAvgAlign = false;
|
|
|
- // IsSelectTextAndImg = false;
|
|
|
- // IsTextEdit = true;
|
|
|
-
|
|
|
- // ClearCheckedAglin?.Invoke(null, null);
|
|
|
-
|
|
|
- // }
|
|
|
- //}
|
|
|
+
|
|
|
#region 全局
|
|
|
|
|
|
public event EventHandler ClearCheckedAglin;
|
|
@@ -748,10 +828,23 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
|
|
|
{
|
|
|
TextEditEvent = TextEditEventList[0];
|
|
|
GetPDFEdit();
|
|
|
- }
|
|
|
|
|
|
- //PDFViewer.PDFEditActiveHandler -= PDFViewer_PDFEditActiveHandler;
|
|
|
- //PDFViewer.PDFEditActiveHandler += PDFViewer_PDFEditActiveHandler;
|
|
|
+ if (TextEditEventList.Count == 2)
|
|
|
+ {
|
|
|
+ IsLayoutAlign = true;
|
|
|
+ IsLayoutAvgAlign = false;
|
|
|
+ }
|
|
|
+ else if(TextEditEventList.Count >2)
|
|
|
+ {
|
|
|
+ IsLayoutAlign = true;
|
|
|
+ IsLayoutAvgAlign = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IsLayoutAlign = false;
|
|
|
+ IsLayoutAvgAlign = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
PDFViewer.PDFEditCommandHandler -= PDFViewer_PDFEditCommandHandler;
|
|
|
PDFViewer.PDFEditCommandHandler += PDFViewer_PDFEditCommandHandler;
|
|
@@ -764,11 +857,11 @@ namespace PDF_Office.ViewModels.PropertyPanel.PDFEdit
|
|
|
if(TextEditEvent != null)
|
|
|
{
|
|
|
TextFontFamily = TextEditEvent.FontFamily;
|
|
|
- TextFontSize = (int)TextEditEvent.FontSize;
|
|
|
+ //TextFontSize = (int)TextEditEvent.FontSize;
|
|
|
TextFontStyle = TextEditEvent.FontStyle;
|
|
|
TextFontWeights = TextEditEvent.FontWeight;
|
|
|
SelectColor = new SolidColorBrush(TextEditEvent.FontColor);
|
|
|
-
|
|
|
+ FontSizeData = new ComboDataItem(TextEditEvent.FontSize);
|
|
|
}
|
|
|
}
|
|
|
|