|
@@ -29,7 +29,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
{
|
|
|
|
|
|
#region 属性
|
|
|
-
|
|
|
+ public event EventHandler ClearCheckedAglin;
|
|
|
public TextEditPropertyViewModel()
|
|
|
{
|
|
|
InitVariable();
|
|
@@ -98,7 +98,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- #region Command初始化
|
|
|
+ #region 初始化
|
|
|
|
|
|
|
|
|
private void InitCommand()
|
|
@@ -115,7 +115,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
AddImgCommand = new DelegateCommand(AddImg);
|
|
|
//选择颜色
|
|
|
SelectedColorCommand = new DelegateCommand<object>(SelectedColor);
|
|
|
-
|
|
|
+ //选择字体样式
|
|
|
SelectedFontStyleCommand = new DelegateCommand<object>(SelectedFontStyle);
|
|
|
//大小
|
|
|
FontSizeChangedCommand = new DelegateCommand<object>(FontSizeChanged);
|
|
@@ -129,15 +129,17 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
ReDefineFontStyleCommand = new DelegateCommand(ReDefineFontStyle);
|
|
|
//恢复默认
|
|
|
RestoreDefaultStyleCommand = new DelegateCommand(RestoreDefaultStyle);
|
|
|
+ //文本对齐
|
|
|
LayoutAlignCheckedCommand = new DelegateCommand<object>(LayoutAlignChecked);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- #region 文本处理
|
|
|
+ #region 文本处理逻辑
|
|
|
|
|
|
private void AddText()
|
|
|
{
|
|
|
+ //设置对应创建模式
|
|
|
PDFViewer.SetPDFEditCreateType(ComPDFKit.PDFPage.CPDFEditType.EditText);
|
|
|
}
|
|
|
|
|
@@ -222,11 +224,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
//设置字体样式
|
|
|
private void FontFamilyChanged()
|
|
|
{
|
|
|
- if (string.IsNullOrEmpty(CurrentFontFamily.ValueStr) == false)
|
|
|
- {
|
|
|
-
|
|
|
- //GetCurrentFontFamily(TextEditEvent.FontName, TextEditEvent.FontName);
|
|
|
- }
|
|
|
if (CurrentPresetFont != null)
|
|
|
{
|
|
|
var currentItem = PresetFontList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
|
|
@@ -263,13 +260,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- //bool isExist = GetCurrentPresetFont(Annot);
|
|
|
- //if (isExist)
|
|
|
- //{
|
|
|
- //}
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -284,13 +274,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
FontStyleItem = TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal;
|
|
|
FontWeightItem = TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal;
|
|
|
|
|
|
- //Dictionary<AnnotAttrib, object> AnnotAttribDir = new Dictionary<AnnotAttrib, object>();
|
|
|
- //AnnotAttribDir.Add(AnnotAttrib.IsItalic,FontStyleItem == FontStyles.Italic);
|
|
|
- //AnnotAttribDir.Add(AnnotAttrib.IsBold, FontWeightItem == FontWeights.Bold);
|
|
|
- //PropertyPanel.UpdateAnnotAllAttribs(AnnotAttribDir);
|
|
|
- //GetFontWeights_Style(TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal, TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal);
|
|
|
-
|
|
|
-
|
|
|
if (CurrentPresetFont != null)
|
|
|
{
|
|
|
var currentItem = PresetFontList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
|
|
@@ -327,13 +310,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- //bool isExist = GetCurrentPresetFont(Annot);
|
|
|
- //if (isExist)
|
|
|
- //{
|
|
|
- //}
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -381,7 +357,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
//重置定义
|
|
|
private void RestoreDefaultStyle()
|
|
|
{
|
|
|
- //var item = PresetFontList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
|
|
|
var defaultlists = TextFont.GetPresetFontStyle();
|
|
|
if (CurrentPresetFont.ValueStr != "Custom")
|
|
|
{
|
|
@@ -396,10 +371,9 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
currentItem.mFontWeight = defaulItem.mFontWeight;
|
|
|
currentItem.mFontFamily = defaulItem.mFontFamily;
|
|
|
currentItem.mFontSize = defaulItem.mFontSize;
|
|
|
- GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
|
|
|
+ GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
|
|
|
GetCurrentFontSize(currentItem.mFontSize);
|
|
|
GetFontWeights_Style(currentItem.mFontStyle, currentItem.mFontWeight);
|
|
|
-
|
|
|
CurrentPresetFont = new ComboDataItem(defaulItem.mTag, defaulItem.mTagContent);
|
|
|
SelectedPresetFont();
|
|
|
}
|
|
@@ -408,6 +382,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //设置多选对齐方式
|
|
|
private void LayoutAlignChecked(object obj)
|
|
|
{
|
|
|
if (obj != null)
|
|
@@ -447,7 +422,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+ //设置文本框内对齐方式
|
|
|
private void TextAlignChecked(object obj)
|
|
|
{
|
|
|
if ((string)obj != null && TextEditEvent != null)
|
|
@@ -479,7 +454,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //文本内容对齐
|
|
|
+ //设置文本内容对齐属性面板显示
|
|
|
private void GetAnnotAlign(TextAlignment align)
|
|
|
{
|
|
|
switch (align)
|
|
@@ -505,6 +480,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //设置文本颜色
|
|
|
private void SelectedColor(object obj)
|
|
|
{
|
|
|
if (obj != null)
|
|
@@ -518,6 +495,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //设置文本样式
|
|
|
private void SelectedFontStyle(object obj)
|
|
|
{
|
|
|
if (obj != null && (PresetFontItem)obj != null)
|
|
@@ -528,14 +506,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
|
|
|
|
|
|
+ //设置字体大小
|
|
|
private void FontSizeChanged(object obj)
|
|
|
{
|
|
|
if (CurrentFontSize != null)
|
|
|
{
|
|
|
CurrentFontSize = new ComboDataItem(TextEditEvent.FontSize);
|
|
|
- //GetCurrentFontSize((int)CurrentFontSize.Value);
|
|
|
- //PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.FontSize,CurrentFontSize.Value);
|
|
|
-
|
|
|
}
|
|
|
if (CurrentPresetFont != null)
|
|
|
{
|
|
@@ -573,80 +549,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- //bool isExist = GetCurrentPresetFont(Annot);
|
|
|
- //if (isExist)
|
|
|
- //{
|
|
|
- //}
|
|
|
- }
|
|
|
}
|
|
|
- //if (obj != null)
|
|
|
- //{
|
|
|
- // var item = (ComboBoxItem)obj;
|
|
|
- // var content = (string)item.Content;
|
|
|
- // if (content != null)
|
|
|
- // {
|
|
|
- // var intData = int.Parse(content);
|
|
|
- // //TextFontSize = intData;
|
|
|
- // }
|
|
|
- //}
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
- #region 布局处理
|
|
|
- private void ImgAlignChecked(object obj)
|
|
|
- {
|
|
|
- if (obj != null)
|
|
|
- {
|
|
|
- switch ((string)obj)
|
|
|
- {
|
|
|
- case "AlignLeft":
|
|
|
- PDFViewer.SetPDFEditAligment(AlignModes.AlignLeft);
|
|
|
- break;
|
|
|
- case "AlignHorizonCenter":
|
|
|
- PDFViewer.SetPDFEditAligment(AlignModes.AlignHorizonCenter);
|
|
|
- break;
|
|
|
- case "AlignRight":
|
|
|
- PDFViewer.SetPDFEditAligment(AlignModes.AlignRight);
|
|
|
- break;
|
|
|
- case "DistributeHorizontal":
|
|
|
- PDFViewer.SetPDFEditAligment(AlignModes.DistributeHorizontal);
|
|
|
- break;
|
|
|
- case "AlignTop":
|
|
|
- PDFViewer.SetPDFEditAligment(AlignModes.AlignTop);
|
|
|
- break;
|
|
|
- case "AlignVerticalCenter":
|
|
|
- PDFViewer.SetPDFEditAligment(AlignModes.AlignVerticalCenter);
|
|
|
- break;
|
|
|
- case "AlignBottom":
|
|
|
- PDFViewer.SetPDFEditAligment(AlignModes.AlignBottom);
|
|
|
- break;
|
|
|
- case "DistributeVertical":
|
|
|
- PDFViewer.SetPDFEditAligment(AlignModes.DistributeVertical);
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void ReLoadLayoutAlign(int count)
|
|
|
- {
|
|
|
- if (count >= 2)
|
|
|
- IsLayoutAlign = true;
|
|
|
- else
|
|
|
- IsLayoutAlign = false;
|
|
|
-
|
|
|
- if (count >= 3)
|
|
|
- IsLayoutAvgAlign = true;
|
|
|
- else
|
|
|
- IsLayoutAvgAlign = false;
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
#region 右键菜单
|
|
|
|
|
|
//点击空白处时
|
|
@@ -664,86 +572,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
return popMenu;
|
|
|
}
|
|
|
|
|
|
- //选中文字的框
|
|
|
- private ContextMenu SelectTextBorder(object sender)
|
|
|
- {
|
|
|
- var popMenu = App.Current.FindResource("SelectTextMenu") as ContextMenu;
|
|
|
- CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
|
|
|
- //编辑
|
|
|
- customMenu.SetMenuBinding(0, EditTextModeCommand);
|
|
|
-
|
|
|
-
|
|
|
- //复制
|
|
|
- customMenu.SetMenuBinding(1, ApplicationCommands.Copy);
|
|
|
- //剪切
|
|
|
- customMenu.SetMenuBinding(2, ApplicationCommands.Cut);
|
|
|
- //粘贴
|
|
|
- customMenu.SetMenuBinding(3, ApplicationCommands.Paste);
|
|
|
- //删除
|
|
|
- customMenu.SetMenuBinding(4, ApplicationCommands.Delete);
|
|
|
-
|
|
|
- return popMenu;
|
|
|
- }
|
|
|
- //多选文本框
|
|
|
- private ContextMenu SelectMoreText(object sender)
|
|
|
- {
|
|
|
- var popMenu = App.Current.FindResource("SelectMoreTextMenu") as ContextMenu;
|
|
|
- CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
|
|
|
-
|
|
|
- //复制
|
|
|
- customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
|
|
|
- //剪切
|
|
|
- customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
|
|
|
- //粘贴
|
|
|
- customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
|
|
|
- //删除
|
|
|
- customMenu.SetMenuBinding(3, ApplicationCommands.Delete);
|
|
|
-
|
|
|
- return popMenu;
|
|
|
- }
|
|
|
-
|
|
|
- //选中文字内容
|
|
|
- private ContextMenu SelectTextContent(object sender)
|
|
|
- {
|
|
|
- var popMenu = App.Current.FindResource("SelectContentMenu") as ContextMenu;
|
|
|
- CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
|
|
|
- //复制
|
|
|
- customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
|
|
|
- //剪切
|
|
|
- customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
|
|
|
- //粘贴
|
|
|
- customMenu.SetMenuBinding(2, ApplicationCommands.Paste);
|
|
|
- //粘贴并匹配样式
|
|
|
- customMenu.SetVisibilityProperty(3, false);
|
|
|
- //删除
|
|
|
- customMenu.SetMenuBinding(4, ApplicationCommands.Delete);
|
|
|
- //全部选定
|
|
|
- customMenu.SetMenuBinding(5, ApplicationCommands.SelectAll);
|
|
|
-
|
|
|
- return popMenu;
|
|
|
- }
|
|
|
-
|
|
|
- //编辑中右键
|
|
|
- private ContextMenu EditTextContent(object sender)
|
|
|
- {
|
|
|
- var popMenu = App.Current.FindResource("NoneSelectContentMenu") as ContextMenu;
|
|
|
- CustomPopMenu customMenu = new CustomPopMenu(popMenu, sender);
|
|
|
- ////复制
|
|
|
- //customMenu.SetMenuBinding(0, ApplicationCommands.Copy);
|
|
|
- ////剪切
|
|
|
- //customMenu.SetMenuBinding(1, ApplicationCommands.Cut);
|
|
|
- //全部选定
|
|
|
- customMenu.SetMenuBinding(0, ApplicationCommands.SelectAll);
|
|
|
- //粘贴
|
|
|
- customMenu.SetMenuBinding(1, ApplicationCommands.Paste);
|
|
|
- //粘贴并匹配样式
|
|
|
- customMenu.SetVisibilityProperty(2, false);
|
|
|
- ////删除
|
|
|
- //customMenu.SetMenuBinding(4, ApplicationCommands.Delete);
|
|
|
-
|
|
|
|
|
|
- return popMenu;
|
|
|
- }
|
|
|
#endregion
|
|
|
|
|
|
|
|
@@ -761,32 +590,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
switch (e.CommandType)
|
|
|
{
|
|
|
case CommandType.Context:
|
|
|
-
|
|
|
-
|
|
|
- // if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.EditText)
|
|
|
- // {
|
|
|
- // //文字编辑
|
|
|
- // if (e.PressOnBorder == true)
|
|
|
- // {
|
|
|
- // e.PopupMenu = SelectTextBorder(sender);
|
|
|
- // }
|
|
|
-
|
|
|
- // else if(e.PressOnSelectedText == true)
|
|
|
- // {
|
|
|
- // e.PopupMenu = SelectTextContent(sender);
|
|
|
- // }
|
|
|
-
|
|
|
- // else if(e.SelectText=="")
|
|
|
- // {
|
|
|
- // e.PopupMenu= EditTextContent(sender);
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // e.PopupMenu = SelectTextContent(sender);
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
- //else
|
|
|
if (e.EditType == ComPDFKit.PDFPage.CPDFEditType.None)
|
|
|
{
|
|
|
e.PopupMenu = EmptyStateMenu(sender);
|
|
@@ -826,11 +629,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
return popMenu;
|
|
|
}
|
|
|
-
|
|
|
- #region 全局
|
|
|
-
|
|
|
- public event EventHandler ClearCheckedAglin;
|
|
|
- #endregion
|
|
|
#endregion
|
|
|
|
|
|
protected List<PDFEditEvent> TextEditEventList;
|
|
@@ -876,6 +674,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //文本内容改变触发
|
|
|
private void FontMode_ChangedValue(object sender, FontSetModeType e)
|
|
|
{
|
|
|
if (sender != null)
|
|
@@ -955,6 +754,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //获取文本参数
|
|
|
private void GetPDFEdit()
|
|
|
{
|
|
|
|
|
@@ -966,10 +766,8 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
FontWeightItem = TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal;
|
|
|
GetFontWeights_Style(FontStyleItem, FontWeightItem);
|
|
|
|
|
|
-
|
|
|
+ //判断样式列表中是否存在对应样式
|
|
|
bool isExist = false;
|
|
|
- //List<PresetFontItem> presetFontItems = TextFont.GetCachePresetFontList();
|
|
|
- //遍历样式
|
|
|
foreach (var item in PresetFontList)
|
|
|
{
|
|
|
if (TextEditEvent.FontSize == item.mFontSize && TextEditEvent.IsBold == (item.mFontWeight == FontWeights.Bold) && TextEditEvent.IsItalic == (item.mFontStyle == FontStyles.Italic)
|
|
@@ -1013,15 +811,11 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
{
|
|
|
if (item.mTag != "Custom")
|
|
|
{
|
|
|
- //CurrentFontSize = new ComboDataItem(TextEditEvent.FontSize);
|
|
|
GetCurrentFontSize(item.mFontSize);
|
|
|
if (item.mFontFamily != null)
|
|
|
{
|
|
|
- //CurrentFontFamily = new ComboDataItem(TextEditEvent.FontName, TextEditEvent.FontName);
|
|
|
GetCurrentFontFamily(item.mFontFamily.ToString(), item.mFontFamily.ToString());
|
|
|
}
|
|
|
- //FontStyleItem = item.mFontStyle;
|
|
|
- //FontWeightItem = item.mFontWeight;
|
|
|
GetFontWeights_Style(TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal, TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal);
|
|
|
}
|
|
|
|
|
@@ -1050,22 +844,6 @@ namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
|
|
|
TextAlign = TextEditEvent.TextAlign;
|
|
|
TextEditEvent.UpdatePDFEditByEventArgs();
|
|
|
|
|
|
- //if (TextEditEvent != null && TextEditEventList.Count == 1)
|
|
|
- //{
|
|
|
- // SelectColor = new SolidColorBrush(TextEditEvent.FontColor);
|
|
|
-
|
|
|
- // GetCurrentFontSize((int)TextEditEvent.FontSize);
|
|
|
-
|
|
|
- // if (TextEditEvent.FontName != null)
|
|
|
- // {
|
|
|
- // GetCurrentFontFamily(TextEditEvent.FontName, TextEditEvent.FontName);
|
|
|
- // }
|
|
|
-
|
|
|
- // GetFontWeights_Style(TextEditEvent.IsItalic ? FontStyles.Italic : FontStyles.Normal, TextEditEvent.IsBold ? FontWeights.Bold : FontWeights.Normal);
|
|
|
- // TextAlign = TextEditEvent.TextAlign;
|
|
|
-
|
|
|
-
|
|
|
- //}
|
|
|
}
|
|
|
|
|
|
public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
|