|
@@ -50,6 +50,7 @@ using System.Windows.Controls.Primitives;
|
|
|
using Window = System.Windows.Window;
|
|
|
using Task = System.Threading.Tasks.Task;
|
|
|
using Size = System.Windows.Size;
|
|
|
+using System.Windows.Markup;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.FillAndSign
|
|
|
{
|
|
@@ -66,6 +67,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
private PopMenu FreeHandAnnotPopMenu;
|
|
|
private PopMenu FreeTextAnnotPopMenu;
|
|
|
private PopMenu MultiAnnotPopMenu;
|
|
|
+ public bool isFirst=true;
|
|
|
private IRegionManager regions { get; set; }
|
|
|
private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
|
|
|
public static bool IsEdit = false;
|
|
@@ -100,7 +102,8 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
#endregion
|
|
|
|
|
|
public FillAndSignContentViewModel(IRegionManager regionManager, IEventAggregator events)
|
|
|
- {
|
|
|
+ {
|
|
|
+
|
|
|
regions = regionManager;
|
|
|
this.events = events;
|
|
|
CheckCommand = new DelegateCommand<RoutedEventArgs>(CheckedEvent);
|
|
@@ -112,6 +115,15 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
FreeTextAglin_MenuCommand = new DelegateCommand<object>(FreeTextAglin_Menu);
|
|
|
InitSelectFreeHandAnnotMenu();
|
|
|
InitSelectFreeTextAnnotMenu();
|
|
|
+
|
|
|
+ }
|
|
|
+ private void InitFillAndSignProperty()
|
|
|
+ {
|
|
|
+
|
|
|
+ var FreehandDefault = GetAnnotDefault(AnnotArgsType.AnnotFreehand, "FillAndSign");
|
|
|
+ SelectColor = new SolidColorBrush(FreehandDefault.BorderColor != Color.FromArgb(0, 0, 0, 0) ? FreehandDefault.BorderColor : Colors.GreenYellow);
|
|
|
+ FillOpacity = FreehandDefault.Opacity > 0 ? FreehandDefault.Opacity : 1;
|
|
|
+ LineWidth = FreehandDefault.Thickness > 0 ? FreehandDefault.Thickness : 1;
|
|
|
}
|
|
|
private System.Windows.Controls.Primitives.Popup popup = null;
|
|
|
private async void AnnotColorPalette_Menu(object obj)
|
|
@@ -276,13 +288,13 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
var freeHand = annot as FreehandAnnotArgs;
|
|
|
var color = freeHand.InkColor;
|
|
|
|
|
|
- Settings.Default.AppProperties.Annotate.FreeHandColor = color;
|
|
|
+ //Settings.Default.AppProperties.Annotate.FreeHandColor = color;
|
|
|
|
|
|
- var FreehandDefault = GetAnnotDefault(AnnotArgsType.AnnotFreehand);
|
|
|
- FreehandDefault.ForgoundColor = color;
|
|
|
+ var FreehandDefault = GetAnnotDefault(AnnotArgsType.AnnotFreehand, "FillAndSign");
|
|
|
+ FreehandDefault.BorderColor = color;
|
|
|
FreehandDefault.Opacity = freeHand.Transparency;
|
|
|
FreehandDefault.Thickness = freeHand.LineWidth;
|
|
|
-
|
|
|
+ FreehandDefault.SaveKey = "FillAndSign";
|
|
|
var isSolid = AnnotPropertyPanel.IsSolidStyle(freeHand.LineDash);
|
|
|
if (isSolid)
|
|
|
{
|
|
@@ -299,13 +311,32 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
|
|
|
SettingHelper.SetAnnotDefaultProperty(FreehandDefault);
|
|
|
}
|
|
|
+
|
|
|
+ else if (annot is FreeTextAnnotArgs)
|
|
|
+ {
|
|
|
+ var freeText = annot as FreeTextAnnotArgs;
|
|
|
+ Settings.Default.AppProperties.Annotate.TextAnnoteColor = freeText.FontColor;
|
|
|
+ Settings.Default.AppProperties.Annotate.TextFontFamaily = freeText.FontFamily.ToString();
|
|
|
+ Settings.Default.AppProperties.Annotate.TextAlign = freeText.Align;
|
|
|
+
|
|
|
+ var FreeTextDefalut = GetAnnotDefault(AnnotArgsType.AnnotFreeText);
|
|
|
+ FreeTextDefalut.ForgoundColor = freeText.FontColor;
|
|
|
+ FreeTextDefalut.FontFamily = freeText.FontFamily.ToString();
|
|
|
+ FreeTextDefalut.TextAlign = freeText.Align;
|
|
|
+ FreeTextDefalut.FontSize = freeText.FontSize;
|
|
|
+ FreeTextDefalut.FontWeight = freeText.FontWeight;
|
|
|
+ FreeTextDefalut.FontStyle = freeText.FontStyle;
|
|
|
+ FreeTextDefalut.BackgroundColor = freeText.BgColor;
|
|
|
+ FreeTextDefalut.Opacity = (annot as FreeTextAnnotArgs).Transparency;
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(FreeTextDefalut);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType)
|
|
|
+ private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType,string savaKey="")
|
|
|
{
|
|
|
- var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType);
|
|
|
+ var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType, savaKey);
|
|
|
if (Annot == null)
|
|
|
{
|
|
|
Annot = new DefaultAnnotProperty();
|
|
@@ -371,7 +402,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
private void InitCheckedEvent(string e)
|
|
|
{
|
|
|
IsEdit = false;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
//NavigateToProperty(control.Name);
|
|
|
//不创建注释,属于注释模板
|
|
@@ -421,7 +452,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
ShowPropertyPanel(true);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
//注释工具
|
|
|
private void FindAnnotTypeKey(string tag, ref AnnotHandlerEventArgs annotArgs, bool isRightMenuAdd = false)
|
|
@@ -509,6 +540,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
List<AnnotHandlerEventArgs> stampAnnotArgsList = new List<AnnotHandlerEventArgs>();
|
|
|
if (stampAnnotArgs != null)
|
|
|
stampAnnotArgsList.Add(stampAnnotArgs);
|
|
|
+
|
|
|
//if (selectedArgs != null) {
|
|
|
//var annot = selectedArgs[0];
|
|
|
//if (annot != null)
|
|
@@ -547,7 +579,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
if (stampAnnotArgs != null)
|
|
|
stampAnnotArgsList.Add(stampAnnotArgs);
|
|
|
|
|
|
- AddToPropertyPanel("ShapFillProperty", "", stampAnnotArgsList, annotAttribsList);
|
|
|
+ //AddToPropertyPanel("ShapFillProperty", "", stampAnnotArgsList, annotAttribsList);
|
|
|
bool isTemplateAnnot = false;
|
|
|
bool isSnapshotEdit = false;
|
|
|
AnnotHandlerEventArgs annotArgs = stampAnnotArgs;
|
|
@@ -558,6 +590,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
annotArgs.Author = Settings.Default.AppProperties.Description.Author;
|
|
|
PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
PDFViewer.SetToolParam(annotArgs);
|
|
|
+
|
|
|
isRightMenuAddAnnot = false;
|
|
|
}
|
|
|
|
|
@@ -775,13 +808,15 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
{
|
|
|
if (propertyPanel.AnnotEvents == null)
|
|
|
propertyPanel.AnnotEvents = new List<AnnotAttribEvent>();
|
|
|
-
|
|
|
+
|
|
|
propertyPanel.AnnotEvents.Clear();
|
|
|
|
|
|
foreach (var itemAnnot in annots)
|
|
|
{
|
|
|
- var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, annotAttribsList);
|
|
|
+ var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, annotAttribsList);
|
|
|
+ PDFViewer.SelectAnnotation(itemAnnot.PageIndex, itemAnnot.AnnotIndex);
|
|
|
propertyPanel.AnnotEvents.Add(eventitem);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -789,6 +824,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
|
|
|
{
|
|
|
propertyPanel.AnnotEvent = annotAttribEvent;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -806,7 +842,9 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
|
|
|
if (isUpData) { return; }
|
|
|
|
|
|
- if (viewContent == "ShapFillProperty") { NavigateToProperty(viewContent, propertyPanel); return; }
|
|
|
+ if (viewContent == "ShapFillProperty") {
|
|
|
+
|
|
|
+ NavigateToProperty(viewContent, propertyPanel); return; }
|
|
|
viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
|
|
|
}
|
|
|
|
|
@@ -1349,6 +1387,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+ //注释编辑事件
|
|
|
|
|
|
private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
|
|
|
{
|
|
@@ -1363,6 +1402,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
int pageindex = editEvent.PageIndex;
|
|
|
int annotindex = editEvent.AnnotIndex;
|
|
|
viewContentViewModel.FillAndSign.Add(new Point(pageindex, annotindex));
|
|
|
+ PDFViewer.SelectAnnotation(pageindex, annotindex);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -1387,12 +1427,12 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
{
|
|
|
|
|
|
GetSelectedAnnots(e);
|
|
|
+
|
|
|
//记录这次选中的注释,之后创建注释会跟随上次选中注释的属性值
|
|
|
//PDFViewer.SetToolParam(annot);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
//TODO: 设计已重新调整为(仅限高亮注释):修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
|
|
|
if (annot.EventType != AnnotArgsType.AnnotStrikeout &&
|
|
|
annot.EventType != AnnotArgsType.AnnotUnderline &&
|
|
@@ -1427,7 +1467,7 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
else
|
|
|
{
|
|
|
ShowPropertyPanel();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1593,9 +1633,11 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
|
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
|
BindingPDFViewerHandler();
|
|
|
- HookShapeIsCheck = true;
|
|
|
+ HookShapeIsCheck = true;
|
|
|
+ InitFillAndSignProperty();
|
|
|
InitCheckedEvent("RbtnTick");
|
|
|
IsEdit = false;
|
|
|
+
|
|
|
}
|
|
|
#endregion
|
|
|
}
|