|
@@ -1,4 +1,6 @@
|
|
|
-using ComPDFKitViewer.AnnotEvent;
|
|
|
+using compdfkit_tools.PDFControl;
|
|
|
+using ComPDFKitViewer;
|
|
|
+using ComPDFKitViewer.AnnotEvent;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
@@ -29,6 +31,7 @@ namespace compdfkit_tools.Annotation.PDFAnnotationUI
|
|
|
int LinkPage = 0;
|
|
|
bool DrawLink = false;
|
|
|
private LinkAnnotArgs LinkAnnot;
|
|
|
+ private AnnotAttribEvent annotAttribEvent;
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
protected virtual void OnPropertyChanged(string propertyName)
|
|
@@ -53,6 +56,41 @@ namespace compdfkit_tools.Annotation.PDFAnnotationUI
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
+ public void SetPresentAnnotAttrib(AnnotAttribEvent annotAttribEvent, int PageCount)
|
|
|
+ {
|
|
|
+ UrlText.Text = "";
|
|
|
+ PageText.Text = "";
|
|
|
+ EmailText.Text = "";
|
|
|
+ SaveBtn.IsEnabled = true;
|
|
|
+ totalPage = PageCount;
|
|
|
+ if (annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkDestIndx))
|
|
|
+ {
|
|
|
+ int pageNum = (int)annotAttribEvent.Attribs[AnnotAttrib.LinkDestIndx] + 1;
|
|
|
+ if (pageNum > 0 && pageNum <= totalPage)
|
|
|
+ {
|
|
|
+ PageText.Text = pageNum.ToString();
|
|
|
+ SelectedIndex = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (annotAttribEvent.Attribs.ContainsKey(AnnotAttrib.LinkUri))
|
|
|
+ {
|
|
|
+ string linkUrl = (string)annotAttribEvent.Attribs[AnnotAttrib.LinkUri];
|
|
|
+ if (!string.IsNullOrEmpty(linkUrl))
|
|
|
+ {
|
|
|
+
|
|
|
+ if (linkUrl.StartsWith("mailto:", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ EmailText.Text = linkUrl.ToLower().TrimStart("mailto:".ToCharArray());
|
|
|
+ SelectedIndex = 2;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ UrlText.Text = linkUrl;
|
|
|
+ SelectedIndex = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public void InitLinkAnnotArgs(LinkAnnotArgs linkAnnotArgs, int PageCount)
|
|
|
{
|
|
@@ -64,26 +102,56 @@ namespace compdfkit_tools.Annotation.PDFAnnotationUI
|
|
|
private void LinkAnnot_LinkDrawFinished(object sender, bool e)
|
|
|
{
|
|
|
DrawLink = e;
|
|
|
+ UrlText.Text = "";
|
|
|
+ PageText.Text = "";
|
|
|
+ EmailText.Text = "";
|
|
|
}
|
|
|
|
|
|
private void Save_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- switch (SelectedIndex)
|
|
|
+ if (LinkAnnot != null)
|
|
|
{
|
|
|
- case 0:
|
|
|
- LinkAnnot.DestIndex = LinkPage - 1;
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- LinkAnnot.URI = "http://" + UrlText.Text.Trim().ToLower();
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- LinkAnnot.URI = "mailto:" + EmailText.Text.Trim();
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
+ switch (SelectedIndex)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ LinkAnnot.LinkType = LINK_TYPE.URI;
|
|
|
+ LinkAnnot.URI = "http://" + UrlText.Text.Trim().ToLower();
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ LinkAnnot.LinkType = LINK_TYPE.GOTO;
|
|
|
+ LinkAnnot.DestIndex = LinkPage - 1;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ LinkAnnot.LinkType = LINK_TYPE.URI;
|
|
|
+ LinkAnnot.URI = "mailto:" + EmailText.Text.Trim();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- LinkAnnot.InvokeLinkSaveCalled(null, null);
|
|
|
+ LinkAnnot.InvokeLinkSaveCalled(null, null);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ switch (SelectedIndex)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ annotAttribEvent.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.URI);
|
|
|
+ annotAttribEvent.UpdateAttrib(AnnotAttrib.LinkUri, "http://" + UrlText.Text.Trim().ToLower());
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ annotAttribEvent.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.GOTO);
|
|
|
+ annotAttribEvent.UpdateAttrib(AnnotAttrib.LinkDestIndx, LinkPage - 1);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ annotAttribEvent.UpdateAttrib(AnnotAttrib.LinkType, LINK_TYPE.URI);
|
|
|
+ annotAttribEvent.UpdateAttrib(AnnotAttrib.LinkUri, "mailto:" + EmailText.Text.Trim());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ annotAttribEvent.UpdateAnnot();
|
|
|
+ }
|
|
|
DrawLink = false;
|
|
|
SaveBtn.IsEnabled = false;
|
|
|
}
|
|
@@ -147,56 +215,119 @@ namespace compdfkit_tools.Annotation.PDFAnnotationUI
|
|
|
|
|
|
private void UrlText_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
{
|
|
|
- if (CheckPageWebVaild((sender as TextBox).Text) && DrawLink)
|
|
|
+ if (LinkAnnot != null)
|
|
|
{
|
|
|
- SaveBtn.IsEnabled = true;
|
|
|
+ if (CheckPageWebVaild((sender as TextBox).Text) && DrawLink)
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = false;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- SaveBtn.IsEnabled = false;
|
|
|
+ if (CheckPageWebVaild((sender as TextBox).Text))
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void PageText_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
{
|
|
|
- if (CheckPageNumVaild(out LinkPage, (sender as TextBox).Text)&& DrawLink)
|
|
|
+ if (LinkAnnot != null)
|
|
|
{
|
|
|
- SaveBtn.IsEnabled = true;
|
|
|
+ if (CheckPageNumVaild(out LinkPage, (sender as TextBox).Text) && DrawLink)
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = false;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- SaveBtn.IsEnabled = false;
|
|
|
+ if (CheckPageNumVaild(out LinkPage, (sender as TextBox).Text))
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void EmailText_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
{
|
|
|
- if (CheckPageMailVaild((sender as TextBox).Text)&& DrawLink)
|
|
|
+ if (LinkAnnot != null)
|
|
|
{
|
|
|
- SaveBtn.IsEnabled = true;
|
|
|
+ if (CheckPageMailVaild((sender as TextBox).Text) && DrawLink)
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = false;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- SaveBtn.IsEnabled = false;
|
|
|
+ if (CheckPageMailVaild((sender as TextBox).Text))
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SaveBtn.IsEnabled = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void CheckingItem(int ItemIndex)
|
|
|
{
|
|
|
bool BtnIsEnabled = false;
|
|
|
- switch (ItemIndex)
|
|
|
+
|
|
|
+ if (LinkAnnot != null)
|
|
|
{
|
|
|
- case 0:
|
|
|
- BtnIsEnabled = CheckPageWebVaild(UrlText.Text)&& DrawLink;
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- BtnIsEnabled = CheckPageNumVaild(out LinkPage, PageText.Text)&& DrawLink;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- BtnIsEnabled = CheckPageMailVaild(EmailText.Text) && DrawLink;
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ switch (ItemIndex)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ BtnIsEnabled = CheckPageWebVaild(UrlText.Text) && DrawLink;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ BtnIsEnabled = CheckPageNumVaild(out LinkPage, PageText.Text) && DrawLink;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ BtnIsEnabled = CheckPageMailVaild(EmailText.Text) && DrawLink;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ switch (ItemIndex)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ BtnIsEnabled = CheckPageWebVaild(UrlText.Text);
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ BtnIsEnabled = CheckPageNumVaild(out LinkPage, PageText.Text);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ BtnIsEnabled = CheckPageMailVaild(EmailText.Text);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
SaveBtn.IsEnabled = BtnIsEnabled;
|
|
|
}
|
|
@@ -205,7 +336,7 @@ namespace compdfkit_tools.Annotation.PDFAnnotationUI
|
|
|
{
|
|
|
Binding Indexbinding = new Binding();
|
|
|
Indexbinding.Source = this;
|
|
|
- Indexbinding.Path = new System.Windows.PropertyPath("SelectedIndex");
|
|
|
+ Indexbinding.Path = new System.Windows.PropertyPath("SelectedIndex");
|
|
|
HeadTabControl.SetBinding(TabControl.SelectedIndexProperty, Indexbinding);
|
|
|
}
|
|
|
|
|
@@ -214,7 +345,7 @@ namespace compdfkit_tools.Annotation.PDFAnnotationUI
|
|
|
switch (SelectedIndex)
|
|
|
{
|
|
|
case 0:
|
|
|
- UrlText.Text="";
|
|
|
+ UrlText.Text = "";
|
|
|
break;
|
|
|
case 1:
|
|
|
PageText.Text = "";
|