|
@@ -1,4 +1,5 @@
|
|
-using ComPDFKitViewer.PdfViewer;
|
|
+using ComPDFKitViewer.AnnotEvent;
|
|
|
|
+using ComPDFKitViewer.PdfViewer;
|
|
using PDF_Office.Model;
|
|
using PDF_Office.Model;
|
|
using Prism.Commands;
|
|
using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using Prism.Mvvm;
|
|
@@ -10,15 +11,21 @@ using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls;
|
|
-
|
|
+using PDF_Office.ViewModels.Tools;
|
|
|
|
+using ComPDFKitViewer;
|
|
|
|
+using PDF_Office.Helper;
|
|
|
|
+using PDF_Office.Properties;
|
|
|
|
+using PDFSettings;
|
|
|
|
+using System.Windows.Media;
|
|
|
|
+
|
|
namespace PDF_Office.ViewModels.FillAndSign
|
|
namespace PDF_Office.ViewModels.FillAndSign
|
|
{
|
|
{
|
|
public class FillAndSignContentViewModel : BindableBase, INavigationAware
|
|
public class FillAndSignContentViewModel : BindableBase, INavigationAware
|
|
{
|
|
{
|
|
#region
|
|
#region
|
|
- private CPDFViewer pdfViewer;
|
|
+ private CPDFViewer PDFViewer;
|
|
-
|
|
+ private AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
|
|
- private ViewContentViewModel viewContentViewMode;
|
|
+ private ViewContentViewModel viewContentViewModel;
|
|
|
|
|
|
private IRegionManager regions { get; set; }
|
|
private IRegionManager regions { get; set; }
|
|
#endregion
|
|
#endregion
|
|
@@ -46,14 +53,198 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
var control = e.OriginalSource as Control;
|
|
var control = e.OriginalSource as Control;
|
|
|
|
|
|
NavigateToProperty(control.Name);
|
|
NavigateToProperty(control.Name);
|
|
|
|
+
|
|
|
|
+ if(control.Name== "RbtnSign") { AnnotHandlerEventArgs annotArgs = null; FindAnnotTypeKey("Signature", ref annotArgs); }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void FindAnnotTypeKey(string tag, ref AnnotHandlerEventArgs annotArgs, bool isRightMenuAdd = false)
|
|
|
|
+ {
|
|
|
|
+ switch (tag)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case "Freetext":
|
|
|
|
+ annotArgs = GetFreetext();
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Stamp":
|
|
|
|
+ annotArgs = GetStamp();
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Signature":
|
|
|
|
+ annotArgs = GetSignature();
|
|
|
|
+ PDFViewer.SetMouseMode(MouseModes.PanTool);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private AnnotHandlerEventArgs GetSignature()
|
|
|
|
+ {
|
|
|
|
+ AddToPropertyPanel("SignatureAnnotProperty");
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private AnnotHandlerEventArgs GetStamp()
|
|
|
|
+ {
|
|
|
|
+ StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
|
|
|
|
+ stampAnnotArgs.Opacity = 1;
|
|
|
|
+ stampAnnotArgs.StampText = "APPROVED";
|
|
|
|
+ stampAnnotArgs.Type = StampType.STANDARD_STAMP;
|
|
|
|
+ Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
|
|
+ annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
|
|
|
|
+
|
|
|
|
+ List<AnnotHandlerEventArgs> stampAnnotArgsList = new List<AnnotHandlerEventArgs>();
|
|
|
|
+ if (stampAnnotArgs != null)
|
|
|
|
+ stampAnnotArgsList.Add(stampAnnotArgs);
|
|
|
|
+
|
|
|
|
+ AddToPropertyPanel("StampAnnotProperty", null, stampAnnotArgsList, annotAttribsList);
|
|
|
|
+ return stampAnnotArgs;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private AnnotHandlerEventArgs GetFreetext(List<AnnotHandlerEventArgs> selectedArgs = null)
|
|
|
|
+ {
|
|
|
|
+ Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
|
|
+ FreeTextAnnotArgs freetextArgs = null;
|
|
|
|
+ TextAlignment textAlignment;
|
|
|
|
+
|
|
|
|
+ if (selectedArgs == null || selectedArgs.Count == 0)
|
|
|
|
+ {
|
|
|
|
+ freetextArgs = new FreeTextAnnotArgs();
|
|
|
|
+ freetextArgs.Align = TextAlignment.Left;
|
|
|
|
+ freetextArgs.BgColor = Colors.Transparent;
|
|
|
|
+ freetextArgs.FontFamily = new FontFamily(Settings.Default.AppProperties.Annotate.TextFontFamaily);
|
|
|
|
+ freetextArgs.FontColor = Colors.Black;
|
|
|
|
+ freetextArgs.FontSize = 14;
|
|
|
|
+ freetextArgs.Transparency = 1;
|
|
|
|
+ freetextArgs.LineColor = Colors.Black;
|
|
|
|
+ freetextArgs.LineWidth = 0;
|
|
|
|
+ freetextArgs.TextContent = string.Empty;
|
|
|
|
+
|
|
|
|
+ DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotFreeText);
|
|
|
|
+ if (annotProperty != null)
|
|
|
|
+ {
|
|
|
|
+ freetextArgs.Align = annotProperty.TextAlign;
|
|
|
|
+ freetextArgs.BgColor = annotProperty.BackgroundColor;
|
|
|
|
+ freetextArgs.FontFamily = new FontFamily(annotProperty.FontFamily);
|
|
|
|
+ freetextArgs.FontColor = annotProperty.ForgoundColor;
|
|
|
|
+ freetextArgs.FontSize = annotProperty.FontSize;
|
|
|
|
+ freetextArgs.Transparency = annotProperty.Opacity;
|
|
|
|
+ freetextArgs.LineColor = annotProperty.BorderColor;
|
|
|
|
+ freetextArgs.LineWidth = annotProperty.Thickness;
|
|
|
|
+ freetextArgs.TextContent = annotProperty.NoteText;
|
|
|
|
+ freetextArgs.FontWeight = annotProperty.FontWeight;
|
|
|
|
+ freetextArgs.FontStyle = annotProperty.FontStyle;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int align = (int)Settings.Default.AppProperties.Annotate.TextAlign;
|
|
|
|
+
|
|
|
|
+ if (align == 0)
|
|
|
|
+ textAlignment = TextAlignment.Left;
|
|
|
|
+ else if (align == 1)
|
|
|
|
+ textAlignment = TextAlignment.Center;
|
|
|
|
+ else
|
|
|
|
+ textAlignment = TextAlignment.Right;
|
|
|
|
+
|
|
|
|
+ if (freetextArgs != null)
|
|
|
|
+ {
|
|
|
|
+ selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
|
+ selectedArgs.Add(freetextArgs);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ freetextArgs = selectedArgs[0] as FreeTextAnnotArgs;
|
|
|
|
+ textAlignment = freetextArgs.Align;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
|
|
|
|
+ annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
|
|
|
|
+ annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
|
|
|
|
+ annotAttribsList[AnnotAttrib.Transparency] = freetextArgs.Transparency;
|
|
|
|
+ annotAttribsList[AnnotAttrib.FontColor] = freetextArgs.FontColor;
|
|
|
|
+ annotAttribsList[AnnotAttrib.FontSize] = freetextArgs.FontSize;
|
|
|
|
+ annotAttribsList[AnnotAttrib.FontFamily] = freetextArgs.FontFamily;
|
|
|
|
+ annotAttribsList[AnnotAttrib.FontStyle] = freetextArgs.FontStyle;
|
|
|
|
+ annotAttribsList[AnnotAttrib.FontWeight] = freetextArgs.FontWeight;
|
|
|
|
+ annotAttribsList[AnnotAttrib.TextAlign] = textAlignment;
|
|
|
|
+ annotAttribsList[AnnotAttrib.NoteText] = freetextArgs.TextContent;
|
|
|
|
+
|
|
|
|
+ AddToPropertyPanel("FreetextAnnotProperty", "Freetext", selectedArgs, annotAttribsList);
|
|
|
|
+ return freetextArgs;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void AddToPropertyPanel(string viewContent, string toolTag = null, List<AnnotHandlerEventArgs> annots = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ if (annots != null)
|
|
|
|
+ {
|
|
|
|
+ propertyPanel.annotlists = annots;
|
|
|
|
+ propertyPanel.annot = annots[0];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ propertyPanel.annotlists = null;
|
|
|
|
+ propertyPanel.annot = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (annotAttribsList != null)
|
|
|
|
+ {
|
|
|
|
+ if (annots.Count > 1)
|
|
|
|
+ {
|
|
|
|
+ if (propertyPanel.AnnotEvents == null)
|
|
|
|
+ propertyPanel.AnnotEvents = new List<AnnotAttribEvent>();
|
|
|
|
+
|
|
|
|
+ propertyPanel.AnnotEvents.Clear();
|
|
|
|
+
|
|
|
|
+ foreach (var itemAnnot in annots)
|
|
|
|
+ {
|
|
|
|
+ var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, annotAttribsList);
|
|
|
|
+ propertyPanel.AnnotEvents.Add(eventitem);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annotAttribsList);
|
|
|
|
+ if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
|
|
|
|
+ {
|
|
|
|
+ propertyPanel.AnnotEvent = annotAttribEvent;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (string.IsNullOrEmpty(viewContent) == false)
|
|
|
|
+ {
|
|
|
|
+ viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void NavigateToProperty(string btnName)
|
|
private void NavigateToProperty(string btnName)
|
|
{
|
|
{
|
|
NavigationParameters values = new NavigationParameters();
|
|
NavigationParameters values = new NavigationParameters();
|
|
- values.Add(ParameterNames.PDFViewer, pdfViewer);
|
|
+ values.Add(ParameterNames.PDFViewer, PDFViewer);
|
|
regions.RequestNavigate(RegionNames.PropertyRegionName,btnToProperty[btnName]);
|
|
regions.RequestNavigate(RegionNames.PropertyRegionName,btnToProperty[btnName]);
|
|
- viewContentViewMode.IsPropertyOpen = true;
|
|
+ viewContentViewModel.IsPropertyOpen = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -86,8 +277,8 @@ namespace PDF_Office.ViewModels.FillAndSign
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
{
|
|
{
|
|
- navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewMode);
|
|
+ navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
|
|
- navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer);
|
|
+ navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
}
|
|
}
|