|
@@ -1,6 +1,14 @@
|
|
|
-using ComPDFKitViewer.PdfViewer;
|
|
|
+using ComPDFKit.PDFWatermark;
|
|
|
+using ComPDFKitViewer.PdfViewer;
|
|
|
+using Microsoft.Office.Interop.Word;
|
|
|
using PDF_Office.EventAggregators;
|
|
|
+using PDF_Office.Helper;
|
|
|
using PDF_Office.Model;
|
|
|
+using PDF_Office.Model.EditTools.Background;
|
|
|
+using PDF_Office.Model.EditTools.Bates;
|
|
|
+using PDF_Office.Model.EditTools.HeaderFooter;
|
|
|
+using PDF_Office.Model.EditTools.Watermark;
|
|
|
+using PDF_Office.Properties;
|
|
|
using PDFSettings;
|
|
|
using Prism.Commands;
|
|
|
using Prism.Events;
|
|
@@ -8,8 +16,11 @@ using Prism.Mvvm;
|
|
|
using Prism.Regions;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Diagnostics;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Windows;
|
|
|
+using System.Windows.Media;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.EditTools.HeaderFooter
|
|
|
{
|
|
@@ -18,7 +29,9 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
|
|
|
|
|
|
private CPDFViewer PDFViewer;
|
|
|
|
|
|
- public BatesHeaderFooterItem HeaderFooterItem;
|
|
|
+ public HeaderFooterInfo HeaderFooterInfo = new HeaderFooterInfo();
|
|
|
+
|
|
|
+ public BatesHeaderFooterItem TemplateHeaderFooterItem;
|
|
|
|
|
|
public enum EnumCreateOrEdit
|
|
|
{
|
|
@@ -27,6 +40,284 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
|
|
|
StatusEdit
|
|
|
}
|
|
|
|
|
|
+ private List<string> _fontNameList = new List<string>();
|
|
|
+ public List<string> FontNameList
|
|
|
+ {
|
|
|
+ get { return _fontNameList; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _fontNameList, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitFontNameList()
|
|
|
+ {
|
|
|
+ FontNameList.Clear();
|
|
|
+ FontNameList.Add("Courier");
|
|
|
+ FontNameList.Add("Courier-Bold");
|
|
|
+ FontNameList.Add("Courier-Oblique");
|
|
|
+ FontNameList.Add("Courier-BoldOblique");
|
|
|
+ FontNameList.Add("Helvetica");
|
|
|
+ FontNameList.Add("Helvetica-Bold");
|
|
|
+ FontNameList.Add("Helvetica-Oblique");
|
|
|
+ FontNameList.Add("Helvetica-BoldOblique");
|
|
|
+ FontNameList.Add("Times-Roman");
|
|
|
+ FontNameList.Add("Times-Bold");
|
|
|
+ FontNameList.Add("Times-Italic");
|
|
|
+ FontNameList.Add("Times-BoldItalic");
|
|
|
+ }
|
|
|
+
|
|
|
+ private int _fontNameSelectedIndex = 0;
|
|
|
+ public int FontNameSelectedIndex
|
|
|
+ {
|
|
|
+ get { return _fontNameSelectedIndex; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _fontNameSelectedIndex, value);
|
|
|
+ SetFontName(FontNameSelectedIndex);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<string> _fontSizeList = new List<string>();
|
|
|
+ public List<string> FontSizeList
|
|
|
+ {
|
|
|
+ get { return _fontSizeList; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _fontSizeList, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitFontSizeList()
|
|
|
+ {
|
|
|
+ FontSizeList.Clear();
|
|
|
+ for (int temp = 10; temp <= 15; temp += 1)
|
|
|
+ {
|
|
|
+ FontSizeList.Add(temp.ToString() + "pt");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int _fontSizeSelectedIndex = 0;
|
|
|
+ public int FontSizeSelectedIndex
|
|
|
+ {
|
|
|
+ get { return _fontSizeSelectedIndex; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _fontSizeSelectedIndex, value);
|
|
|
+ SetFontSize(FontSizeSelectedIndex);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<string> _starPagetNumberList = new List<string>();
|
|
|
+ public List<string> StarPagetNumberList
|
|
|
+ {
|
|
|
+ get { return _starPagetNumberList; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _starPagetNumberList, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitStarPagetNumberList()
|
|
|
+ {
|
|
|
+ StarPagetNumberList.Clear();
|
|
|
+ for (int temp = 10; temp <= 15; temp += 1)
|
|
|
+ {
|
|
|
+ StarPagetNumberList.Add(temp.ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int _starPagetNumberIndex = 0;
|
|
|
+ public int StarPagetNumberIndex
|
|
|
+ {
|
|
|
+ get { return _starPagetNumberIndex; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _starPagetNumberIndex, value);
|
|
|
+ SetStarPagetNumber(StarPagetNumberIndex);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<string> _pageNumberFormatList = new List<string>();
|
|
|
+ public List<string> PageNumberFormatList
|
|
|
+ {
|
|
|
+ get { return _pageNumberFormatList; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _pageNumberFormatList, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitPageNumberFormatList()
|
|
|
+ {
|
|
|
+ PageNumberFormatList.Clear();
|
|
|
+ PageNumberFormatList.Add("1");
|
|
|
+ PageNumberFormatList.Add("1 of n");
|
|
|
+ PageNumberFormatList.Add("1/n");
|
|
|
+ PageNumberFormatList.Add("Page 1");
|
|
|
+ PageNumberFormatList.Add("Page 1 of n");
|
|
|
+ }
|
|
|
+
|
|
|
+ private int _pageNumberFormatIndex = 0;
|
|
|
+ public int PageNumberFormatIndex
|
|
|
+ {
|
|
|
+ get { return _pageNumberFormatIndex; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _pageNumberFormatIndex, value);
|
|
|
+ SetPageNumberFormat(PageNumberFormatIndex);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<string> _dateTimeFormatList = new List<string>();
|
|
|
+ public List<string> DateTimeFormatList
|
|
|
+ {
|
|
|
+ get { return _dateTimeFormatList; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _dateTimeFormatList, value);
|
|
|
+ SetDateTimeFormat(DateTimeFormatIndex);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitDateTimeFormatList()
|
|
|
+ {
|
|
|
+ DateTimeFormatList.Clear();
|
|
|
+ DateTimeFormatList.Add("m/d");
|
|
|
+ DateTimeFormatList.Add("m/d/yy");
|
|
|
+ DateTimeFormatList.Add("m/d/yyyy");
|
|
|
+ DateTimeFormatList.Add("mm/dd/yy");
|
|
|
+ DateTimeFormatList.Add("mm/dd/yyyy");
|
|
|
+ DateTimeFormatList.Add("d/m/yy");
|
|
|
+ DateTimeFormatList.Add("d/m/yyyy");
|
|
|
+ DateTimeFormatList.Add("dd/mm/yy");
|
|
|
+ DateTimeFormatList.Add("dd/mm/yyyy");
|
|
|
+ DateTimeFormatList.Add("mm/yy");
|
|
|
+ DateTimeFormatList.Add("mm/yyyy");
|
|
|
+ DateTimeFormatList.Add("m.d.yy");
|
|
|
+ DateTimeFormatList.Add("m.d.yyyy");
|
|
|
+ DateTimeFormatList.Add("mm.dd.yy");
|
|
|
+ DateTimeFormatList.Add("mm.dd.yyyy");
|
|
|
+ DateTimeFormatList.Add("mm.yy");
|
|
|
+ DateTimeFormatList.Add("mm.yyyy");
|
|
|
+ DateTimeFormatList.Add("d.m.yy");
|
|
|
+ DateTimeFormatList.Add("dd.mm.yy");
|
|
|
+ DateTimeFormatList.Add("dd.mm.yyyy");
|
|
|
+ DateTimeFormatList.Add("yy-mm-dd");
|
|
|
+ DateTimeFormatList.Add("yyyy-mm-dd");
|
|
|
+ }
|
|
|
+
|
|
|
+ private int _dateTimeFormatIndex = 0;
|
|
|
+ public int DateTimeFormatIndex
|
|
|
+ {
|
|
|
+ get { return _dateTimeFormatIndex; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _dateTimeFormatIndex, value);
|
|
|
+ SetDateTimeFormat(DateTimeFormatIndex);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public string _pageRangeText = "0";
|
|
|
+ public string PageRangeText
|
|
|
+ {
|
|
|
+ get { return _pageRangeText; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _pageRangeText = value;
|
|
|
+ EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int _pageRangeSelectIndex = 0;
|
|
|
+ public int PageRangeSelectIndex
|
|
|
+ {
|
|
|
+ get { return _pageRangeSelectIndex; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _pageRangeSelectIndex, value);
|
|
|
+ HeaderFooterInfo.PageRangeIndex = PageRangeSelectIndex;
|
|
|
+ EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private SolidColorBrush _solidColorBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
|
|
|
+ public SolidColorBrush SolidColorBrush
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return _solidColorBrush;
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+
|
|
|
+ SetProperty(ref _solidColorBrush, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Color _stringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
|
|
|
+ public Color StringColor
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return _stringColor;
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _stringColor, value);
|
|
|
+ SolidColorBrush = new SolidColorBrush(StringColor);
|
|
|
+ for (int i = 0; i <= 5; i++)
|
|
|
+ {
|
|
|
+ HeaderFooterInfo.TextData[i].Color = EditToolsHelper.ConvertColor(value);
|
|
|
+ }
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private EnumCreateOrEdit _createOrEdit;
|
|
|
public EnumCreateOrEdit CreateOrEdit
|
|
|
{
|
|
@@ -61,20 +352,209 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
|
|
|
set => SetProperty(ref _editBaseVisible, value);
|
|
|
}
|
|
|
|
|
|
+ private string _marginTopValue = "3";
|
|
|
+ public string MarginTopValue
|
|
|
+ {
|
|
|
+ get { return _marginTopValue; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _marginTopValue, value);
|
|
|
+ HeaderFooterInfo.margin[1] = float.Parse(MarginTopValue);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private string _marginDownValue = "3";
|
|
|
+ public string MarginDownValue
|
|
|
+ {
|
|
|
+ get { return _marginDownValue; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _marginDownValue, value);
|
|
|
+ HeaderFooterInfo.margin[3] = float.Parse(MarginDownValue);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private string _marginLeftValue = "3";
|
|
|
+ public string MarginLeftValue
|
|
|
+ {
|
|
|
+ get { return _marginLeftValue; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _marginLeftValue, value);
|
|
|
+ HeaderFooterInfo.margin[0] = float.Parse(MarginLeftValue);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private string _marginRightValue = "3";
|
|
|
+ public string MarginRightValue
|
|
|
+ {
|
|
|
+ get { return _marginRightValue; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _marginRightValue, value);
|
|
|
+ HeaderFooterInfo.margin[2] = float.Parse(MarginRightValue);
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private string _textValue = "";
|
|
|
+ public string TextValue
|
|
|
+ {
|
|
|
+ get { return _textValue; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref _textValue, value);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public int GetLocationIndex = 0;
|
|
|
+
|
|
|
+ private Dictionary<string, string> _getTextValueFromNumber = new Dictionary<string, string>();
|
|
|
+ public Dictionary<string, string> GetTextValueFromNumber
|
|
|
+ {
|
|
|
+ get { return _getTextValueFromNumber; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ _getTextValueFromNumber = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public IEventAggregator eventAggregator;
|
|
|
|
|
|
+ public DelegateCommand<object> ChangeLocationCommand { get; set; }
|
|
|
public DelegateCommand EnterTemplateListCommand { get; set; }
|
|
|
public DelegateCommand SaveToTemplateListCommand { get; set; }
|
|
|
public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
|
|
|
-
|
|
|
+ public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
|
|
|
+ public DelegateCommand<object> TextValueChangedCommand { get; set; }
|
|
|
+ public DelegateCommand ADDDateCommand { get; set; }
|
|
|
+ public DelegateCommand ADDPagesCommand { get; set; }
|
|
|
public string Unicode = null;
|
|
|
public HeaderFooterCreateContentViewModel(IEventAggregator eventAggregator)
|
|
|
{
|
|
|
this.eventAggregator = eventAggregator;
|
|
|
Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
|
|
|
+ for (int i = 0; i <= 5; i++)
|
|
|
+ {
|
|
|
+ HeaderFooterInfo.TextData[i].Color = EditToolsHelper.ConvertColor(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
|
|
|
+ }
|
|
|
+ InitList();
|
|
|
+ InitHeaderFooterInfo();
|
|
|
+ ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
|
|
|
+ SelectedColorChangedCommand = new DelegateCommand<object>(ChangedColor);
|
|
|
EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
|
|
|
SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
|
|
|
SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
|
|
|
+ TextValueChangedCommand = new DelegateCommand<object>(TextValueChanged);
|
|
|
+ ADDDateCommand = new DelegateCommand(ADDDate);
|
|
|
+ ADDPagesCommand = new DelegateCommand(ADDPages);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitList()
|
|
|
+ {
|
|
|
+
|
|
|
+ InitFontNameList();
|
|
|
+ InitFontSizeList();
|
|
|
+ InitStarPagetNumberList();
|
|
|
+ InitDateTimeFormatList();
|
|
|
+ InitPageNumberFormatList();
|
|
|
+ InitLocationButtonMatrix();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitLocationButtonMatrix()
|
|
|
+ {
|
|
|
+ GetTextValueFromNumber.Clear();
|
|
|
+ for (var temp = 0; temp <= 5; temp++)
|
|
|
+ {
|
|
|
+ GetTextValueFromNumber.Add(temp.ToString(), "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitHeaderFooterInfo()
|
|
|
+ {
|
|
|
+ for (int i = 0; i <= 5; i++)
|
|
|
+ {
|
|
|
+ HeaderFooterInfo.TextData[i].text = GetTextValueFromNumber[i.ToString()];
|
|
|
+ }
|
|
|
+ HeaderFooterInfo.margin[0] = float.Parse(MarginTopValue);
|
|
|
+ HeaderFooterInfo.margin[1] = float.Parse(MarginRightValue);
|
|
|
+ HeaderFooterInfo.margin[2] = float.Parse(MarginDownValue);
|
|
|
+ HeaderFooterInfo.margin[3] = float.Parse(MarginLeftValue);
|
|
|
+ SetFontName(FontNameSelectedIndex);
|
|
|
+ SetFontSize(FontSizeSelectedIndex);
|
|
|
+ SetDateTimeFormat(DateTimeFormatIndex);
|
|
|
+ SetPageNumberFormat(PageNumberFormatIndex);
|
|
|
+ SetStarPagetNumber(StarPagetNumberIndex);
|
|
|
+ StringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetFontName(int Index)
|
|
|
+ {
|
|
|
+ for (int i = 0; i <= 5; i++) { HeaderFooterInfo.TextData[i].fontName = FontNameList[Index]; }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetFontSize(int Index)
|
|
|
+ {
|
|
|
+ for (int i = 0; i <= 5; i++) { HeaderFooterInfo.TextData[i].fontSize = (Index + 7) * 1.33f; }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetDateTimeFormat(int Index)
|
|
|
+ {
|
|
|
+ HeaderFooterInfo.DateTimeFormat = DateTimeFormatList[Index];
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetPageNumberFormat(int Index)
|
|
|
+ {
|
|
|
+ HeaderFooterInfo.PageNumberFormat = PageNumberFormatList[Index];
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetStarPagetNumber(int Index)
|
|
|
+ {
|
|
|
+ HeaderFooterInfo.StarPagetNumber = Index;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void ChangeLocation(object e)
|
|
|
+ {
|
|
|
+ string args = e as string;
|
|
|
+ if (args != null)
|
|
|
+ {
|
|
|
+ GetLocationIndex = int.Parse(args);
|
|
|
+ TextValue = GetTextValueFromNumber[args];
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void ChangedColor(object obj)
|
|
|
+ {
|
|
|
+ if (obj != null)
|
|
|
+ {
|
|
|
+ var colorValue = (Color)obj;
|
|
|
+ if (colorValue != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ StringColor = colorValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void EnterTemplateList()
|
|
@@ -84,14 +564,169 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
|
|
|
|
|
|
public void SaveToTemplateList()
|
|
|
{
|
|
|
+ SaveCurrentTemplate();
|
|
|
this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
|
|
|
}
|
|
|
|
|
|
public void SaveToCurrentTemplateList()
|
|
|
{
|
|
|
+ ConfirmEditBackgroundTemplateItem();
|
|
|
this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
|
|
|
}
|
|
|
|
|
|
+ private void TextValueChanged(object obj)
|
|
|
+ {
|
|
|
+ if (obj != null)
|
|
|
+ {
|
|
|
+ var textValue = obj as System.Windows.Controls.TextBox;
|
|
|
+ if (textValue != null)
|
|
|
+ {
|
|
|
+ bool TextEQ=true;
|
|
|
+ if (GetTextValueFromNumber[GetLocationIndex.ToString()] == textValue.Text) {
|
|
|
+ TextEQ = false;
|
|
|
+ }
|
|
|
+ GetTextValueFromNumber[GetLocationIndex.ToString()] = textValue.Text;
|
|
|
+ HeaderFooterInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
|
|
|
+ if (TextEQ)
|
|
|
+ {
|
|
|
+ eventAggregator.GetEvent<SetHeaderFooterEvent>().Publish(new HeaderFooterInfoUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = HeaderFooterInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void ADDDate() {
|
|
|
+ GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<"+DateTimeFormatList[DateTimeFormatIndex]+">>";
|
|
|
+ TextValue = GetTextValueFromNumber[GetLocationIndex.ToString()];
|
|
|
+ }
|
|
|
+ public void ADDPages() {
|
|
|
+ GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + PageNumberFormatList[PageNumberFormatIndex] + ">>";
|
|
|
+ TextValue = GetTextValueFromNumber[GetLocationIndex.ToString()];
|
|
|
+ }
|
|
|
+
|
|
|
+ public void ConvertInfoToItem(ref BatesHeaderFooterItem headerFooterItem, HeaderFooterInfo headerFooterInfo)
|
|
|
+ {
|
|
|
+ headerFooterItem.TextData = headerFooterInfo.TextData ;
|
|
|
+ headerFooterItem.DateTimeFormat = headerFooterInfo.DateTimeFormat;
|
|
|
+ headerFooterItem.StarPagetNumber= headerFooterInfo.StarPagetNumber ;
|
|
|
+ headerFooterItem.PageNumberFormat= headerFooterInfo.PageNumberFormat ;
|
|
|
+ headerFooterItem.margin= headerFooterInfo.margin ;
|
|
|
+ headerFooterItem.PageRange= headerFooterInfo.PageRange ;
|
|
|
+ headerFooterItem.PageRangeIndex= headerFooterInfo.PageRangeIndex ;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void ConvertItemToInfo(BatesHeaderFooterItem headerFooterItem, ref HeaderFooterInfo headerFooterInfo)
|
|
|
+ {
|
|
|
+ headerFooterInfo.TextData = headerFooterItem.TextData;
|
|
|
+ headerFooterInfo.DateTimeFormat = headerFooterItem.DateTimeFormat;
|
|
|
+ headerFooterInfo.StarPagetNumber = headerFooterItem.StarPagetNumber;
|
|
|
+ headerFooterInfo.PageNumberFormat = headerFooterItem.PageNumberFormat;
|
|
|
+ headerFooterInfo.margin = headerFooterItem.margin;
|
|
|
+ headerFooterInfo.PageRange = headerFooterItem.PageRange;
|
|
|
+ headerFooterInfo.PageRangeIndex = headerFooterItem.PageRangeIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SaveCurrentTemplate()
|
|
|
+ {
|
|
|
+ var headerFooterItem = new BatesHeaderFooterItem();
|
|
|
+ ConvertInfoToItem(ref headerFooterItem, HeaderFooterInfo);
|
|
|
+ headerFooterItem.ItemName += Settings.Default.HeaderFooterIndex.ToString();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //创建缓存文件夹
|
|
|
+ string folderPath = Path.Combine(App.CurrentPath, "HeaderFooter");
|
|
|
+ //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
|
|
|
+ //保险措施(猜测)
|
|
|
+ if (File.Exists(folderPath))
|
|
|
+ {
|
|
|
+ File.Delete(folderPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
|
|
|
+ if (!tempfolder.Exists)
|
|
|
+ {
|
|
|
+ tempfolder.Create();
|
|
|
+ }
|
|
|
+ //预览图缓存
|
|
|
+ string saveName = Guid.NewGuid().ToString();
|
|
|
+ string savePath = Path.Combine(folderPath, saveName);
|
|
|
+ Settings.Default.HeaderFooterTemplateList.Add(headerFooterItem);
|
|
|
+ Settings.Default.Save();
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = EnumTemplateListOrCreate.StatusTemplate
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public void ConfirmEditBackgroundTemplateItem()
|
|
|
+ {
|
|
|
+
|
|
|
+ var headerFooterItem = new BatesHeaderFooterItem();
|
|
|
+ ConvertInfoToItem(ref headerFooterItem, HeaderFooterInfo);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //创建缓存文件夹
|
|
|
+ string folderPath = Path.Combine(App.CurrentPath, "Background");
|
|
|
+ //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
|
|
|
+ //保险措施(猜测)
|
|
|
+ if (File.Exists(folderPath))
|
|
|
+ {
|
|
|
+ File.Delete(folderPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
|
|
|
+ if (!tempfolder.Exists)
|
|
|
+ {
|
|
|
+ tempfolder.Create();
|
|
|
+ }
|
|
|
+ Settings.Default.HeaderFooterTemplateList[TemplateHeaderFooterItem.listIndex] = headerFooterItem;
|
|
|
+ Settings.Default.Save();
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
|
|
|
+ {
|
|
|
+ Unicode = Unicode,
|
|
|
+ Status = EnumTemplateListOrCreate.StatusTemplate
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void InitComponentBySelectedInfo()
|
|
|
+ {
|
|
|
+ ConvertItemToInfo(TemplateHeaderFooterItem, ref HeaderFooterInfo);
|
|
|
+ for (int i = 0; i <= 5; i++)
|
|
|
+ {
|
|
|
+ GetTextValueFromNumber[i.ToString()] = HeaderFooterInfo.TextData[i].text;
|
|
|
+ }
|
|
|
+ MarginTopValue = HeaderFooterInfo.margin[0].ToString();
|
|
|
+ MarginRightValue = HeaderFooterInfo.margin[1].ToString();
|
|
|
+ MarginDownValue = HeaderFooterInfo.margin[2].ToString();
|
|
|
+ MarginLeftValue = HeaderFooterInfo.margin[3].ToString();
|
|
|
+ DateTimeFormatIndex=DateTimeFormatList.IndexOf(HeaderFooterInfo.DateTimeFormat);
|
|
|
+ PageNumberFormatIndex=PageNumberFormatList.IndexOf(HeaderFooterInfo.PageNumberFormat);
|
|
|
+ FontNameSelectedIndex = FontNameList.IndexOf(HeaderFooterInfo.TextData[0].fontName);
|
|
|
+ FontSizeSelectedIndex = FontSizeList.IndexOf(HeaderFooterInfo.TextData[0].fontSize.ToString());
|
|
|
+ StarPagetNumberIndex = StarPagetNumberList.IndexOf(HeaderFooterInfo.StarPagetNumber.ToString());
|
|
|
+ StringColor = EditToolsHelper.ConvertColor(HeaderFooterInfo.TextData[0].Color);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
|
{
|
|
|
return true;
|
|
@@ -104,9 +739,11 @@ namespace PDF_Office.ViewModels.EditTools.HeaderFooter
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
|
{
|
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
|
- if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("HeaderFooterItem", out HeaderFooterItem))
|
|
|
+ EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref HeaderFooterInfo.PageRange, PageRangeText);
|
|
|
+ if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("HeaderFooterItem", out TemplateHeaderFooterItem))
|
|
|
{
|
|
|
CreateOrEdit = EnumCreateOrEdit.StatusEdit;
|
|
|
+ InitComponentBySelectedInfo();
|
|
|
}
|
|
|
else
|
|
|
{
|