|
@@ -64,175 +64,55 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
public class TextAnnotPropertyViewModel:BindableBase, INavigationAware
|
|
|
{
|
|
|
-
|
|
|
|
|
|
#region 属性
|
|
|
-
|
|
|
- private AnnotArgsType annotType;
|
|
|
- public AnnotArgsType AnnotType
|
|
|
- {
|
|
|
- get { return annotType; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref annotType, value);
|
|
|
- SetAnnotType();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private string annotTypeTitle;
|
|
|
- public string AnnotTypeTitle
|
|
|
- {
|
|
|
- get { return annotTypeTitle; }
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref annotTypeTitle, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private double annotOpacity;
|
|
|
- public double AnnotOpacity
|
|
|
- {
|
|
|
- get {return annotOpacity;}
|
|
|
- set
|
|
|
- {
|
|
|
- SetProperty(ref annotOpacity, value);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 示例背景
|
|
|
- /// </summary>
|
|
|
- private Brush sampleTextBg = new SolidColorBrush(Colors.Transparent);
|
|
|
- public Brush SampleTextBg
|
|
|
- {
|
|
|
- get { return sampleTextBg; }
|
|
|
- set { SetProperty(ref sampleTextBg, value);
|
|
|
- if(Annot.EventType == AnnotArgsType.AnnotHighlight)
|
|
|
- {
|
|
|
- CurrentColor = sampleTextBg;
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, (sampleTextBg as SolidColorBrush).Color);
|
|
|
- AnnotEvent?.UpdateAnnot();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- 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();
|
|
|
- CurrentColor = selectColor;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private Brush _currentColor = new SolidColorBrush(Colors.Transparent);
|
|
|
- public Brush CurrentColor
|
|
|
- {
|
|
|
- get { return _currentColor; }
|
|
|
+ get { return _basicVm; }
|
|
|
set
|
|
|
{
|
|
|
- SetProperty(ref _currentColor, value);
|
|
|
+ SetProperty(ref _basicVm, value);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private bool _isMultiSelected = false;
|
|
|
- public bool IsMultiSelected
|
|
|
- {
|
|
|
- get { return _isMultiSelected; }
|
|
|
- set => SetProperty(ref _isMultiSelected, value);
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
+ #endregion 属性
|
|
|
|
|
|
public AnnotAttribEvent AnnotEvent { get; set; }
|
|
|
private AnnotHandlerEventArgs Annot;
|
|
|
private AnnotPropertyPanel PropertyPanel;
|
|
|
public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
|
|
|
- public DelegateCommand<object> OpacityItemCommand { get; set; }
|
|
|
- public DelegateCommand<object> OpacityValueChangedCommand { get; set; }
|
|
|
- public DelegateCommand<object> SelectedValueChangedCommand { get; set; }
|
|
|
-
|
|
|
- public event EventHandler<object> LoadPropertyHandler;
|
|
|
+ public DelegateCommand<object> SelectedOpacityChangedCommand { get; set; }
|
|
|
|
|
|
public TextAnnotPropertyViewModel()
|
|
|
{
|
|
|
- SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged_Click);
|
|
|
- OpacityItemCommand = new DelegateCommand<object>(OpacityItemCommand_Click);
|
|
|
- OpacityValueChangedCommand = new DelegateCommand<object>(OpacityValueChanged_Command);
|
|
|
- SelectedValueChangedCommand = new DelegateCommand<object>(SelectedValueChanged_Command);
|
|
|
+ SelectedColorChangedCommand = new DelegateCommand<object>(SelectedColorChanged);
|
|
|
+ SelectedOpacityChangedCommand = new DelegateCommand<object>(SelectedOpacityChanged);
|
|
|
}
|
|
|
|
|
|
- private void SelectedValueChanged_Command(object obj)
|
|
|
+ //设置不透明度
|
|
|
+ private void SelectedOpacityChanged(object obj)
|
|
|
{
|
|
|
if (obj != null)
|
|
|
{
|
|
|
- annotOpacity = (double)obj;
|
|
|
- if (AnnotType == AnnotArgsType.AnnotHighlight)
|
|
|
- SampleTextBg.Opacity = annotOpacity;
|
|
|
- else
|
|
|
- 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();
|
|
|
-
|
|
|
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
|
|
|
- changeData[AnnotType] = annotOpacity;
|
|
|
- PropertyPanel.DataChangedInvoke(this, changeData);
|
|
|
+ PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, BasicVm.FillOpacity);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void OpacityItemCommand_Click(object obj)
|
|
|
- {
|
|
|
- if (obj != null)
|
|
|
- {
|
|
|
- if (AnnotType == AnnotArgsType.AnnotHighlight)
|
|
|
- SampleTextBg.Opacity = annotOpacity;
|
|
|
- else
|
|
|
- SelectColor.Opacity = annotOpacity;
|
|
|
-
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
|
|
|
- AnnotEvent?.UpdateAnnot();
|
|
|
-
|
|
|
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
|
|
|
- changeData[AnnotType] = annotOpacity;
|
|
|
- PropertyPanel.DataChangedInvoke(this, changeData);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void OpacityValueChanged_Command(object obj)
|
|
|
- {
|
|
|
- if (obj != null)
|
|
|
- {
|
|
|
- if (AnnotType == AnnotArgsType.AnnotHighlight)
|
|
|
- SampleTextBg.Opacity = annotOpacity;
|
|
|
- else
|
|
|
- SelectColor.Opacity = annotOpacity;
|
|
|
-
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, annotOpacity);
|
|
|
- AnnotEvent?.UpdateAnnot();
|
|
|
-
|
|
|
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
|
|
|
- changeData[AnnotType] = annotOpacity;
|
|
|
- PropertyPanel.DataChangedInvoke(this, changeData);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void SelectedColorChanged_Click(object color)
|
|
|
+ //设置颜色
|
|
|
+ public void SelectedColorChanged(object color)
|
|
|
{
|
|
|
if (color != null && PropertyPanel != null)
|
|
|
{
|
|
|
var colorValue = (Color)color;
|
|
|
if (colorValue != null)
|
|
|
{
|
|
|
- if(IsMultiSelected)
|
|
|
+ if(BasicVm.IsMultiSelected)
|
|
|
{
|
|
|
foreach (var item in PropertyPanel.AnnotEvents)
|
|
|
{
|
|
@@ -242,24 +122,11 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- switch (AnnotType)
|
|
|
- {
|
|
|
- case AnnotArgsType.AnnotHighlight:
|
|
|
- SampleTextBg = new SolidColorBrush(colorValue);
|
|
|
- SampleTextBg.Opacity = AnnotOpacity;
|
|
|
- break;
|
|
|
- case AnnotArgsType.AnnotUnderline:
|
|
|
- case AnnotArgsType.AnnotStrikeout:
|
|
|
- case AnnotArgsType.AnnotSquiggly:
|
|
|
- case AnnotArgsType.AnnotSticky:
|
|
|
- SelectColor = new SolidColorBrush(colorValue);
|
|
|
- SelectColor.Opacity = AnnotOpacity;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
|
|
|
- changeData[AnnotType] = color;
|
|
|
- PropertyPanel.DataChangedInvoke(this, changeData);
|
|
|
+ BasicVm.FontColor = new SolidColorBrush(colorValue);
|
|
|
+ BasicVm.FontColor.Opacity = BasicVm.FillOpacity;
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, colorValue);
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+ PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, color);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -269,22 +136,19 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
|
|
|
private void SetAnnotType()
|
|
|
{
|
|
|
- switch (AnnotType)
|
|
|
+ switch (BasicVm.AnnotType)
|
|
|
{
|
|
|
case AnnotArgsType.AnnotHighlight:
|
|
|
- AnnotTypeTitle = "高亮";
|
|
|
+ BasicVm.AnnotTypeTitle = "高亮";
|
|
|
break;
|
|
|
case AnnotArgsType.AnnotUnderline:
|
|
|
- AnnotTypeTitle = "下划线";
|
|
|
+ BasicVm.AnnotTypeTitle = "下划线";
|
|
|
break;
|
|
|
case AnnotArgsType.AnnotStrikeout:
|
|
|
- AnnotTypeTitle = "删除线";
|
|
|
+ BasicVm.AnnotTypeTitle = "删除线";
|
|
|
break;
|
|
|
case AnnotArgsType.AnnotSquiggly:
|
|
|
- AnnotTypeTitle = "波浪线";
|
|
|
- break;
|
|
|
- case AnnotArgsType.AnnotSticky:
|
|
|
- AnnotTypeTitle = "??";
|
|
|
+ BasicVm.AnnotTypeTitle = "波浪线";
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -296,48 +160,52 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
|
|
{
|
|
|
- IsMultiSelected = false;
|
|
|
+ BasicVm.IsMultiSelected = false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
|
{
|
|
|
|
|
|
navigationContext.Parameters.TryGetValue<AnnotPropertyPanel>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
|
|
|
if(PropertyPanel != null)
|
|
|
{
|
|
|
- AnnotEvent = PropertyPanel.AnnotEvent;
|
|
|
- Annot = PropertyPanel.annot;
|
|
|
- AnnotType = Annot.EventType;
|
|
|
|
|
|
- if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
|
|
|
- {
|
|
|
- IsMultiSelected = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- IsMultiSelected = false;
|
|
|
- }
|
|
|
+ readyData();
|
|
|
+ SetAnnotType();
|
|
|
|
|
|
- if(IsMultiSelected)
|
|
|
+ //多选注释,默认通用属性颜色为高亮注释的预设颜色
|
|
|
+ if(BasicVm.IsMultiSelected)
|
|
|
{
|
|
|
DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
|
|
|
if (annotProperty != null)
|
|
|
{
|
|
|
- SelectColor = new SolidColorBrush(annotProperty.ForgoundColor);
|
|
|
+ BasicVm.FontColor = new SolidColorBrush(annotProperty.ForgoundColor);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
GetAnnotProperty();
|
|
|
}
|
|
|
-
|
|
|
- LoadPropertyHandler?.Invoke(null, Annot);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void readyData()
|
|
|
+ {
|
|
|
+ AnnotEvent = PropertyPanel.AnnotEvent;
|
|
|
+ Annot = PropertyPanel.annot;
|
|
|
+ BasicVm.AnnotType = Annot.EventType;
|
|
|
+ if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
|
|
|
+ {
|
|
|
+ BasicVm.IsMultiSelected = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BasicVm.IsMultiSelected = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private void GetAnnotProperty()
|
|
|
{
|
|
|
if (Annot != null)
|
|
@@ -348,8 +216,8 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
if (Annot is TextHighlightAnnotArgs)
|
|
|
{
|
|
|
var Hightlight = Annot as TextHighlightAnnotArgs;
|
|
|
- AnnotOpacity = Hightlight.Transparency;
|
|
|
- SampleTextBg = new SolidColorBrush(Hightlight.Color);
|
|
|
+ BasicVm.FillOpacity = Hightlight.Transparency;
|
|
|
+ BasicVm.FontColor = new SolidColorBrush(Hightlight.Color);
|
|
|
|
|
|
}
|
|
|
break;
|
|
@@ -357,27 +225,24 @@ namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
|
|
|
case AnnotArgsType.AnnotUnderline:
|
|
|
{
|
|
|
var Underline = Annot as TextUnderlineAnnotArgs;
|
|
|
- AnnotOpacity = Underline.Transparency;
|
|
|
- SampleTextBg = new SolidColorBrush(Colors.Transparent);
|
|
|
- SelectColor = new SolidColorBrush(Underline.Color);
|
|
|
+ BasicVm.FillOpacity = Underline.Transparency;
|
|
|
+ BasicVm.FontColor = new SolidColorBrush(Underline.Color);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case AnnotArgsType.AnnotStrikeout:
|
|
|
{
|
|
|
var Strikeout = Annot as TextStrikeoutAnnotArgs;
|
|
|
- AnnotOpacity = Strikeout.Transparency;
|
|
|
- SampleTextBg = new SolidColorBrush(Colors.Transparent);
|
|
|
- SelectColor = new SolidColorBrush(Strikeout.Color);
|
|
|
+ BasicVm.FillOpacity = Strikeout.Transparency;
|
|
|
+ BasicVm.FontColor = new SolidColorBrush(Strikeout.Color);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case AnnotArgsType.AnnotSquiggly:
|
|
|
{
|
|
|
var Squiggly = Annot as TextSquigglyAnnotArgs;
|
|
|
- AnnotOpacity = Squiggly.Transparency;
|
|
|
- SampleTextBg = new SolidColorBrush(Colors.Transparent);
|
|
|
- SelectColor = new SolidColorBrush(Squiggly.Color);
|
|
|
+ BasicVm.FillOpacity = Squiggly.Transparency;
|
|
|
+ BasicVm.FontColor = new SolidColorBrush(Squiggly.Color);
|
|
|
}
|
|
|
break;
|
|
|
|