|
@@ -4,6 +4,7 @@ using PDF_Office.CustomControl.CompositeControl;
|
|
|
using PDF_Office.Model;
|
|
|
using PDF_Office.Model.PropertyPanel.AnnotPanel;
|
|
|
using PDF_Office.ViewModels.Tools;
|
|
|
+using PDFSettings;
|
|
|
using Prism.Commands;
|
|
|
using Prism.Mvvm;
|
|
|
using Prism.Regions;
|
|
@@ -18,8 +19,15 @@ using System.Windows.Media;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
{
|
|
|
- public class FreetextAnnotPropertyViewModel : BindableBase, INavigationAware
|
|
|
+ public class FreetextAnnotPropertyViewModel : FontBoard, INavigationAware
|
|
|
{
|
|
|
+ private bool isSelectedEmpty;
|
|
|
+ public bool IsSelectedEmpty
|
|
|
+ {
|
|
|
+ get { return isSelectedEmpty; }
|
|
|
+ set { SetProperty(ref isSelectedEmpty, value); }
|
|
|
+ }
|
|
|
+
|
|
|
private double fillOpacity = 1;
|
|
|
public double FillOpacity
|
|
|
{
|
|
@@ -30,18 +38,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Brush selectColor = new SolidColorBrush(Colors.Black);
|
|
|
- public Brush SelectColor
|
|
|
- {
|
|
|
- get { return selectColor; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref selectColor, value);
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, (selectColor as SolidColorBrush).Color);
|
|
|
- AnnotEvent?.UpdateAnnot();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private Brush fillColor = new SolidColorBrush(Colors.Transparent);
|
|
|
public Brush FillColor
|
|
|
{
|
|
@@ -54,147 +50,71 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private FontFamily fontFamily = new FontFamily("Courier");
|
|
|
- public FontFamily TextFontFamily
|
|
|
- {
|
|
|
- get { return fontFamily; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref fontFamily, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private FontWeight fontWeights = FontWeights.Normal;
|
|
|
- public FontWeight TextFontWeights
|
|
|
- {
|
|
|
- get { return fontWeights; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref fontWeights, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private FontStyle fontStyle = FontStyles.Normal;
|
|
|
- public FontStyle TextFontStyle
|
|
|
- {
|
|
|
- get { return fontStyle; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref fontStyle, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private int fontSize = 24;
|
|
|
- public int TextFontSize
|
|
|
- {
|
|
|
- get { return fontSize; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref fontSize, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private List<PresetFontItem> fontStyleList = new List<PresetFontItem>();
|
|
|
- public List<PresetFontItem> FontStyleList
|
|
|
- {
|
|
|
- get { return fontStyleList; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref fontStyleList, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private ComboDataItem _presetTextData;
|
|
|
- public ComboDataItem PresetTextData
|
|
|
- {
|
|
|
- get { return _presetTextData; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref _presetTextData, value);
|
|
|
- if (_presetTextData != null && FontStyleList != null)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private ComboDataItem _fontSizeData = new ComboDataItem(6);
|
|
|
- public ComboDataItem FontSizeData
|
|
|
- {
|
|
|
- get { return _fontSizeData; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref _fontSizeData, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private ComboDataItem _fontFamilyData;
|
|
|
- public ComboDataItem FontFamilyData
|
|
|
- {
|
|
|
- get { return _fontFamilyData; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref _fontFamilyData, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- 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;
|
|
|
- }
|
|
|
+ //private FontFamily fontFamily = new FontFamily("Courier");
|
|
|
+ //public FontFamily TextFontFamily
|
|
|
+ //{
|
|
|
+ // get { return fontFamily; }
|
|
|
+ // set
|
|
|
+ // {
|
|
|
+ // SetProperty(ref fontFamily, value);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ //private FontWeight fontWeights = FontWeights.Normal;
|
|
|
+ //public FontWeight TextFontWeights
|
|
|
+ //{
|
|
|
+ // get { return fontWeights; }
|
|
|
+ // set
|
|
|
+ // {
|
|
|
+ // SetProperty(ref fontWeights, value);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ //private FontStyle fontStyle = FontStyles.Normal;
|
|
|
+ //public FontStyle TextFontStyle
|
|
|
+ //{
|
|
|
+ // get { return fontStyle; }
|
|
|
+ // set
|
|
|
+ // {
|
|
|
+ // SetProperty(ref fontStyle, 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;
|
|
|
+ // }
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public List<ComboDataItem> PresetTextItems { get; private set; }
|
|
|
- public List<ComboDataItem> FontFamilyItems { get; private set; }
|
|
|
- public List<ComboDataItem> FontStyleItems { get; private set; }
|
|
|
-
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
public DelegateCommand<object> SelectedFillOpacityCommand { get; set; }
|
|
|
public DelegateCommand<object> SelectedFontStyleCommand { get; set; }
|
|
|
public DelegateCommand<object> SelectedColorCommand { get; set; }
|
|
@@ -205,8 +125,11 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
public DelegateCommand<object> TextAlignCheckedCommand { get; set; }
|
|
|
public DelegateCommand<object> LineModeCheckedCommand { get; set; }
|
|
|
public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
|
|
|
-
|
|
|
|
|
|
+ public DelegateCommand CustomFontStyleCommand { get; set; }
|
|
|
+
|
|
|
+ public DelegateCommand ReDefineFontStyleCommand { get; set; }
|
|
|
+ public DelegateCommand RestoreDefaultStyleCommand { get; set; }
|
|
|
|
|
|
public event EventHandler<object> LoadPropertyHandler;
|
|
|
|
|
@@ -222,6 +145,10 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
TextAlignCheckedCommand = new DelegateCommand<object>(TextAlignChecked);
|
|
|
LineModeCheckedCommand = new DelegateCommand<object>(LineMode_Checked);
|
|
|
SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
|
|
|
+
|
|
|
+ CustomFontStyleCommand = new DelegateCommand(CustomFontStyle);
|
|
|
+ ReDefineFontStyleCommand = new DelegateCommand(ReDefineFontStyle);
|
|
|
+ RestoreDefaultStyleCommand = new DelegateCommand(RestoreDefaultStyle);
|
|
|
InitVariable();
|
|
|
}
|
|
|
|
|
@@ -244,13 +171,13 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
|
|
|
private void InitFontStyles()
|
|
|
{
|
|
|
- PresetTextItems = new List<ComboDataItem>();
|
|
|
- FontStyleList = TextFont.GetPresetFontStyle();
|
|
|
+ PresetFontItems = new List<ComboDataItem>();
|
|
|
+ PresetFontList = TextFont.GetCachePresetFontList();
|
|
|
|
|
|
- foreach (var item in FontStyleList)
|
|
|
+ foreach (var item in PresetFontList)
|
|
|
{
|
|
|
ComboDataItem itemData = new ComboDataItem(item.mTag, item.mTagContent);
|
|
|
- PresetTextItems.Add(itemData);
|
|
|
+ PresetFontItems.Add(itemData);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -299,7 +226,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private void SelectedFontStyle(object obj)
|
|
|
{
|
|
|
if (obj != null && (PresetFontItem)obj != null)
|
|
@@ -346,7 +272,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
if (content != null)
|
|
|
{
|
|
|
var intData = int.Parse(content);
|
|
|
- TextFontSize = intData;
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.FontSize, intData);
|
|
|
|
|
|
AnnotEvent?.UpdateAnnot();
|
|
@@ -366,8 +291,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
{
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Normal);
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Normal);
|
|
|
- TextFontWeights = FontWeights.Normal;
|
|
|
- TextFontStyle = FontStyles.Normal;
|
|
|
+ // TextFontWeights = FontWeights.Normal;
|
|
|
+ //TextFontStyle = FontStyles.Normal;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -375,8 +300,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
{
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Normal);
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Bold);
|
|
|
- TextFontWeights = FontWeights.Bold;
|
|
|
- TextFontStyle = FontStyles.Normal;
|
|
|
+ //TextFontWeights = FontWeights.Bold;
|
|
|
+ // TextFontStyle = FontStyles.Normal;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -384,16 +309,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
{
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Italic);
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Normal);
|
|
|
- TextFontWeights = FontWeights.Normal;
|
|
|
- TextFontStyle = FontStyles.Italic;
|
|
|
+ // TextFontWeights = FontWeights.Normal;
|
|
|
+ // TextFontStyle = FontStyles.Italic;
|
|
|
}
|
|
|
|
|
|
if (content == "Bold Italic")
|
|
|
{
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.FontStyle, FontStyles.Italic);
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.FontWeight, FontWeights.Bold);
|
|
|
- TextFontWeights = FontWeights.Bold;
|
|
|
- TextFontStyle = FontStyles.Italic;
|
|
|
+ //TextFontWeights = FontWeights.Bold;
|
|
|
+ // TextFontStyle = FontStyles.Italic;
|
|
|
}
|
|
|
|
|
|
AnnotEvent?.UpdateAnnot();
|
|
@@ -403,34 +328,6 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
|
|
|
private void FontFamilyChanged_Command(object obj)
|
|
|
{
|
|
|
- if (obj != null)
|
|
|
- {
|
|
|
- if ((int)obj > -1)
|
|
|
- {
|
|
|
- if ((int)obj == 0)
|
|
|
- {
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.FontFamily, new FontFamily("Courier"));
|
|
|
- TextFontFamily = new FontFamily("Courier");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if ((int)obj == 1)
|
|
|
- {
|
|
|
- TextFontFamily = new FontFamily("Helvetica");
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.FontFamily, new FontFamily("Helvetica"));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if ((int)obj == 2)
|
|
|
- {
|
|
|
- TextFontFamily = new FontFamily("Times");
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.FontFamily, new FontFamily("Times"));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- AnnotEvent?.UpdateAnnot();
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -462,7 +359,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
|
|
|
SelectColor = new SolidColorBrush(colorValue);
|
|
|
SelectColor.Opacity = FillOpacity;
|
|
|
-
|
|
|
+
|
|
|
Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
|
|
|
changeData[AnnotArgsType.AnnotFreehand] = obj;
|
|
|
PropertyPanel.DataChangedInvoke(this, changeData);
|
|
@@ -470,6 +367,74 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void CustomFontStyle()
|
|
|
+ {
|
|
|
+ if (CurrentPresetFont != null)
|
|
|
+ {
|
|
|
+ ContextMenu menu;
|
|
|
+ if (CurrentPresetFont.ValueStr == "custom")
|
|
|
+ {
|
|
|
+ menu = SelectAnnotContextMenu(false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ menu = SelectAnnotContextMenu(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (menu != null)
|
|
|
+ {
|
|
|
+ menu.IsOpen = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private ContextMenu SelectAnnotContextMenu(bool isEnable)
|
|
|
+ {
|
|
|
+ var popMenu = App.Current.FindResource("CustomFontStyleFlyoutMenu") as ContextMenu;
|
|
|
+ if (popMenu != null && popMenu.Items.Count == 2)
|
|
|
+ {
|
|
|
+ //用所选部分重新定义
|
|
|
+ MenuItem menuItem = popMenu.Items[0] as MenuItem;
|
|
|
+ menuItem.IsEnabled = isEnable;
|
|
|
+ menuItem.Command = ReDefineFontStyleCommand;
|
|
|
+ //恢复默认预设样式
|
|
|
+ menuItem = popMenu.Items[1] as MenuItem;
|
|
|
+ menuItem.IsEnabled = isEnable;
|
|
|
+ menuItem.Command = RestoreDefaultStyleCommand;
|
|
|
+ }
|
|
|
+ return popMenu;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<PresetFontItem> FontStyleList = new List<PresetFontItem>();
|
|
|
+ private void ReDefineFontStyle()
|
|
|
+ {
|
|
|
+ var item = FontStyleList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
|
|
|
+
|
|
|
+ if (CurrentFontFamily.ValueStr == "Bold")
|
|
|
+ {
|
|
|
+ item.mFontStyle = FontStyles.Normal;
|
|
|
+ item.mFontWeight = FontWeights.Bold;
|
|
|
+ }
|
|
|
+ else if (CurrentFontFamily.ValueStr == "Regular")
|
|
|
+ {
|
|
|
+ item.mFontStyle = FontStyles.Normal;
|
|
|
+ item.mFontWeight = FontWeights.Normal;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ item.mFontStyle = FontStyles.Italic;
|
|
|
+ item.mFontWeight = FontWeights.Bold;
|
|
|
+ }
|
|
|
+
|
|
|
+ item.mFontSize = (int)CurrentFontSize.Value;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void RestoreDefaultStyle()
|
|
|
+ {
|
|
|
+ var item = FontStyleList.FirstOrDefault(temp => temp.mTag == CurrentPresetFont.ValueStr);
|
|
|
+ }
|
|
|
+
|
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
|
{
|
|
|
return true;
|
|
@@ -477,6 +442,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
{
|
|
|
+ IsCanSave = false;
|
|
|
+ ChangedValue -= FontMode_ChangedValue;
|
|
|
}
|
|
|
|
|
|
public AnnotAttribEvent AnnotEvent { get; set; }
|
|
@@ -490,6 +457,43 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
AnnotEvent = PropertyPanel.AnnotEvent;
|
|
|
Annot = PropertyPanel.annot as FreeTextAnnotArgs;
|
|
|
LoadPropertyHandler?.Invoke(this, Annot);
|
|
|
+ ChangedValue -= FontMode_ChangedValue;
|
|
|
+ ChangedValue += FontMode_ChangedValue;
|
|
|
+ IsCanSave = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FontMode_ChangedValue(object sender, FontSetModeType e)
|
|
|
+ {
|
|
|
+ if (sender != null)
|
|
|
+ {
|
|
|
+ switch (e)
|
|
|
+ {
|
|
|
+ case FontSetModeType.PresetFontStyes:
|
|
|
+
|
|
|
+ break;
|
|
|
+ case FontSetModeType.FontFamilys:
|
|
|
+
|
|
|
+ break;
|
|
|
+ case FontSetModeType.FontSizes:
|
|
|
+
|
|
|
+ break;
|
|
|
+ case FontSetModeType.FontWeight_Style:
|
|
|
+ UpdateFontWeight_Style();
|
|
|
+
|
|
|
+ break;
|
|
|
+ case FontSetModeType.FontColor:
|
|
|
+ if (sender is Color == true)
|
|
|
+ {
|
|
|
+ AnnotEvent.UpdateAttrib(AnnotAttrib.FontColor, CurrentFontColor);
|
|
|
+ AnnotEvent.UpdateAnnot();
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case FontSetModeType.TextAlignment:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|