|
@@ -38,71 +38,30 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
|
|
|
public class FreehandAnnotPropertyViewModel : BindableBase, INavigationAware
|
|
|
{
|
|
|
- private bool isPen = true;
|
|
|
- public bool IsPen
|
|
|
- {
|
|
|
- get { return isPen; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref isPen, value);
|
|
|
- }
|
|
|
- }
|
|
|
+ #region 属性
|
|
|
|
|
|
- private Brush selectColor = new SolidColorBrush(Colors.Transparent);
|
|
|
- public Brush SelectColor
|
|
|
+ private AnnotBasePropertyVM _basicVm = new AnnotBasePropertyVM();
|
|
|
+ public AnnotBasePropertyVM BasicVm
|
|
|
{
|
|
|
- get { return selectColor; }
|
|
|
- set { SetProperty(ref selectColor, value);
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (SelectColor as SolidColorBrush).Color);
|
|
|
- AnnotEvent?.UpdateAnnot();
|
|
|
- }
|
|
|
+ get { return _basicVm; }
|
|
|
+ set => SetProperty(ref _basicVm, value);
|
|
|
}
|
|
|
|
|
|
- private double annotOpacity = 1;
|
|
|
- public double AnnotOpacity
|
|
|
+ private bool _isPen = true;
|
|
|
+ public bool IsPen
|
|
|
{
|
|
|
- get { return annotOpacity; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref annotOpacity, value);
|
|
|
- }
|
|
|
+ get { return _isPen; }
|
|
|
+ set => SetProperty(ref _isPen, value);
|
|
|
}
|
|
|
|
|
|
- bool isCanSave = false;
|
|
|
- private double thicknessLine = 1;
|
|
|
- public double ThicknessLine
|
|
|
- {
|
|
|
- get { return thicknessLine; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref thicknessLine, value);
|
|
|
- if(isCanSave)
|
|
|
- {
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, thicknessLine);
|
|
|
- AnnotEvent?.UpdateAnnot();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private double erasethicknessLine = 1;
|
|
|
+ private double _erasethicknessLine = 1;
|
|
|
public double EraseThicknessLine
|
|
|
{
|
|
|
- get { return erasethicknessLine; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref erasethicknessLine, value);
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, erasethicknessLine);
|
|
|
- AnnotEvent?.UpdateAnnot();
|
|
|
- }
|
|
|
+ get { return _erasethicknessLine; }
|
|
|
+ set => SetProperty(ref _erasethicknessLine, value);
|
|
|
}
|
|
|
|
|
|
- private bool _isMultiSelected = false;
|
|
|
- public bool IsMultiSelected
|
|
|
- {
|
|
|
- get { return _isMultiSelected; }
|
|
|
- set => SetProperty(ref _isMultiSelected, value);
|
|
|
- }
|
|
|
+ #endregion 属性
|
|
|
|
|
|
public AnnotAttribEvent AnnotEvent { get; set; }
|
|
|
private AnnotHandlerEventArgs Annot;
|
|
@@ -116,17 +75,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
public DelegateCommand<object> LineModeCheckedCommand { get; set; }
|
|
|
public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
|
|
|
|
|
|
- public event EventHandler<object> LoadPropertyHandler;
|
|
|
-
|
|
|
-
|
|
|
public FreehandAnnotPropertyViewModel()
|
|
|
{
|
|
|
EraseCommand = new DelegateCommand<object>(Erase_Command);
|
|
|
PenCommand = new DelegateCommand<object>(Pen_Command);
|
|
|
|
|
|
- SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged_Click);
|
|
|
- SelectPenThickChangedCommand = new DelegateCommand<object>(SelectPenThickChanged_Command);
|
|
|
- SetEraserThickCommand = new DelegateCommand<object>(SelectEraserThickChanged_Command);
|
|
|
+ SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged);
|
|
|
+ SelectPenThickChangedCommand = new DelegateCommand<object>(SelectPenThickChanged);
|
|
|
+ SetEraserThickCommand = new DelegateCommand<object>(SelectEraserThickChanged);
|
|
|
LineModeCheckedCommand = new DelegateCommand<object>(LineMode_Checked);
|
|
|
SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
|
|
|
|
|
@@ -138,22 +94,71 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void SelectEraserThickChanged_Command(object obj)
|
|
|
+ //设置颜色
|
|
|
+ private void SelectedColorChanged(object obj)
|
|
|
{
|
|
|
if (obj != null)
|
|
|
{
|
|
|
- var item = (ComboBoxItem)obj;
|
|
|
- var content = (string)item.Content;
|
|
|
- if (content != null)
|
|
|
+ var colorValue = (Color)obj;
|
|
|
+ if (colorValue != null)
|
|
|
+ {
|
|
|
+ if (BasicVm.IsMultiSelected)
|
|
|
+ {
|
|
|
+ foreach (var item in PropertyPanel.AnnotEvents)
|
|
|
+ {
|
|
|
+ item?.UpdateAttrib(AnnotAttrib.Color, colorValue);
|
|
|
+ item?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BasicVm.FontColor = new SolidColorBrush(colorValue);
|
|
|
+ BasicVm.FontColor.Opacity = BasicVm.FillOpacity;
|
|
|
+
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, colorValue);
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+
|
|
|
+ PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, colorValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置线条大小
|
|
|
+ private void SelectPenThickChanged(object obj)
|
|
|
+ {
|
|
|
+ if (obj != null && obj is double)
|
|
|
+ {
|
|
|
+ var thick = (double)obj;
|
|
|
+ if (BasicVm.IsMultiSelected)
|
|
|
+ {
|
|
|
+ foreach (var itemEvent in PropertyPanel.AnnotEvents)
|
|
|
+ {
|
|
|
+ itemEvent?.UpdateAttrib(AnnotAttrib.Thickness, thick);
|
|
|
+ itemEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- var intData = double.Parse(content);
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, intData);
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, thick);
|
|
|
AnnotEvent?.UpdateAnnot();
|
|
|
- EraseThicknessLine = intData;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //设置橡皮擦大小
|
|
|
+ private void SelectEraserThickChanged(object obj)
|
|
|
+ {
|
|
|
+ if (obj != null && obj is double)
|
|
|
+ {
|
|
|
+ var eraser = (double)obj;
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, eraser);
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置线条样式
|
|
|
private void LineMode_Checked(object obj)
|
|
|
{
|
|
|
if (obj != null)
|
|
@@ -163,16 +168,15 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
switch (tag)
|
|
|
{
|
|
|
case "Dashed":
|
|
|
-
|
|
|
newDash.Dashes.Add(2);
|
|
|
newDash.Dashes.Add(2);
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Dash);
|
|
|
+ // AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Dash);
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, newDash);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "Solid":
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, newDash);
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Solid);
|
|
|
break;
|
|
|
|
|
|
}
|
|
@@ -181,76 +185,21 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- private void SelectPenThickChanged_Command(object obj)
|
|
|
- {
|
|
|
- if (obj != null)
|
|
|
- {
|
|
|
- var item = (ComboBoxItem)obj;
|
|
|
- var content = (string)item.Content;
|
|
|
- if (content != null)
|
|
|
- {
|
|
|
- var intData = double.Parse(content);
|
|
|
- if (IsMultiSelected)
|
|
|
- {
|
|
|
- foreach (var itemEvent in PropertyPanel.AnnotEvents)
|
|
|
- {
|
|
|
- itemEvent?.UpdateAttrib(AnnotAttrib.Thickness, intData);
|
|
|
- itemEvent?.UpdateAnnot();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Thickness, intData);
|
|
|
- AnnotEvent?.UpdateAnnot();
|
|
|
- }
|
|
|
-
|
|
|
- ThicknessLine = intData;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ //设置不透明度
|
|
|
private void SelectedOpacityValue(object obj)
|
|
|
{
|
|
|
if (obj != null)
|
|
|
{
|
|
|
- annotOpacity = (double)obj;
|
|
|
- SelectColor.Opacity = annotOpacity;
|
|
|
+ BasicVm.FillOpacity = (double)obj;
|
|
|
+ BasicVm.FontColor.Opacity = BasicVm.FillOpacity;
|
|
|
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
|
|
|
AnnotEvent?.UpdateAnnot();
|
|
|
- PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, annotOpacity);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private void SelectedColorChanged_Click(object obj)
|
|
|
- {
|
|
|
- if (obj != null)
|
|
|
- {
|
|
|
- var colorValue = (Color)obj;
|
|
|
- if (colorValue != null)
|
|
|
- {
|
|
|
- if (IsMultiSelected)
|
|
|
- {
|
|
|
- foreach (var item in PropertyPanel.AnnotEvents)
|
|
|
- {
|
|
|
- item?.UpdateAttrib(AnnotAttrib.Color, colorValue);
|
|
|
- item?.UpdateAnnot();
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SelectColor = new SolidColorBrush(colorValue);
|
|
|
- SelectColor.Opacity = AnnotOpacity;
|
|
|
- PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, obj);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ PropertyPanel.InvokeToMyTools(AnnotArgsType.AnnotFreehand, BasicVm.FillOpacity);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //选择橡皮擦
|
|
|
private void Erase_Command(object obj)
|
|
|
{
|
|
|
var btn = obj as ToggleButton;
|
|
@@ -261,6 +210,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //选择画笔
|
|
|
private void Pen_Command(object obj)
|
|
|
{
|
|
|
var btn = obj as ToggleButton;
|
|
@@ -279,8 +229,7 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
{
|
|
|
- IsMultiSelected = false;
|
|
|
- isCanSave = false;
|
|
|
+ BasicVm.IsMultiSelected = false;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -294,14 +243,14 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
Annot = PropertyPanel.annot;
|
|
|
if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
|
|
|
{
|
|
|
- IsMultiSelected = true;
|
|
|
+ BasicVm.IsMultiSelected = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- IsMultiSelected = false;
|
|
|
+ BasicVm.IsMultiSelected = false;
|
|
|
}
|
|
|
|
|
|
- if (IsMultiSelected)
|
|
|
+ if (BasicVm.IsMultiSelected)
|
|
|
{
|
|
|
double thickness = 0;
|
|
|
foreach(var item in PropertyPanel.annotlists)
|
|
@@ -309,19 +258,16 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
if ((item as FreehandAnnotArgs).LineWidth >= thickness)
|
|
|
thickness = (item as FreehandAnnotArgs).LineWidth;
|
|
|
}
|
|
|
-
|
|
|
- ThicknessLine = thickness;
|
|
|
+
|
|
|
+ BasicVm.AnnotThickness = thickness;
|
|
|
+ BasicVm.SetStrDashStyle("None");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
GetAnnotProperty();
|
|
|
- if (Annot is FreehandAnnotArgs)
|
|
|
- LoadPropertyHandler?.Invoke(null, (Annot as FreehandAnnotArgs).InkColor);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- isCanSave = true;
|
|
|
}
|
|
|
|
|
|
private void GetAnnotProperty()
|
|
@@ -331,9 +277,24 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
var annot = Annot as FreehandAnnotArgs;
|
|
|
if (annot != null)
|
|
|
{
|
|
|
- AnnotOpacity = annot.Transparency;
|
|
|
- SelectColor = new SolidColorBrush(annot.InkColor);
|
|
|
- ThicknessLine = annot.LineWidth;
|
|
|
+ BasicVm.FillOpacity = annot.Transparency;
|
|
|
+ BasicVm.FontColor = new SolidColorBrush(annot.InkColor);
|
|
|
+ BasicVm.AnnotThickness = annot.LineWidth;
|
|
|
+ BasicVm.Dash = annot.LineDash;
|
|
|
+ bool isSolid = true;
|
|
|
+ if(annot.LineDash != null && annot.LineDash.Dashes.Count > 0)
|
|
|
+ {
|
|
|
+ foreach(var item in annot.LineDash.Dashes)
|
|
|
+ {
|
|
|
+ if(item > 0)
|
|
|
+ {
|
|
|
+ isSolid = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BasicVm.SetStrDashStyle(isSolid ? "Solid" : "Dash");
|
|
|
IsPen = true;
|
|
|
}
|
|
|
}
|