|
@@ -2,8 +2,10 @@
|
|
|
using ComPDFKit.PDFPage;
|
|
|
using ComPDFKit.PDFPage.Edit;
|
|
|
using ComPDFKit.Tool;
|
|
|
+using ComPDFKit.Tool.SettingParam;
|
|
|
using ComPDFKit.Tool.UndoManger;
|
|
|
using ComPDFKit.Viewer.Helper;
|
|
|
+using Compdfkit_Tools.PDFControl;
|
|
|
using ComPDFKitViewer;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -37,7 +39,7 @@ namespace Compdfkit_Tools.Edit
|
|
|
List<string> sysfontList = new List<string>();
|
|
|
if (textArea != null)
|
|
|
{
|
|
|
- sysfontList= textArea.GetFontList();
|
|
|
+ sysfontList = textArea.GetFontList();
|
|
|
}
|
|
|
if (sysfontList.Count == 0)
|
|
|
{
|
|
@@ -57,14 +59,14 @@ namespace Compdfkit_Tools.Edit
|
|
|
OpacityTextBox.Text = string.Format("{0}%", (int)(Math.Ceiling(newEvent.Transparency * 100 / 255D)));
|
|
|
FontOpacitySlider.Value = ((int)(Math.Ceiling(newEvent.Transparency * 100 / 255D))) / 100D;
|
|
|
TextAlignUI.SetFontAlign(newEvent.TextAlign);
|
|
|
- if(newEvent.FontColor != null && newEvent.FontColor.Length==3)
|
|
|
+ if (newEvent.FontColor != null && newEvent.FontColor.Length == 3)
|
|
|
{
|
|
|
FontColorUI.SetCheckedForColor(Color.FromRgb(
|
|
|
newEvent.FontColor[0],
|
|
|
newEvent.FontColor[1],
|
|
|
newEvent.FontColor[2]));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
EditEvent = newEvent;
|
|
|
}
|
|
@@ -79,8 +81,8 @@ namespace Compdfkit_Tools.Edit
|
|
|
GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
if (textArea != null)
|
|
|
{
|
|
|
- Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- if (textArea.SetCharsFontSize((float)slider.Value,false))
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ if (textArea.SetCharsFontSize((float)slider.Value, false))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
@@ -91,8 +93,15 @@ namespace Compdfkit_Tools.Edit
|
|
|
|
|
|
ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
ToolView.UpDateRender(oldRect, textArea);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
+ if (EditEvent != null && textArea == null)
|
|
|
+ {
|
|
|
+ EditEvent.FontSize = slider.Value;
|
|
|
+ DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetPDFEditParamm(EditEvent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void SliderOpacity_DragCompleted(object sender, DragCompletedEventArgs e)
|
|
@@ -105,8 +114,8 @@ namespace Compdfkit_Tools.Edit
|
|
|
GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
if (textArea != null)
|
|
|
{
|
|
|
- Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- if(textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255)))
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ if (textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255)))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
@@ -116,8 +125,15 @@ namespace Compdfkit_Tools.Edit
|
|
|
}
|
|
|
ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
ToolView.UpDateRender(oldRect, textArea);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
+ if (EditEvent != null && textArea == null)
|
|
|
+ {
|
|
|
+ EditEvent.Transparency = (byte)(FontOpacitySlider.Value * 255);
|
|
|
+ DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetPDFEditParamm(EditEvent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void SliderOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
|
@@ -135,7 +151,7 @@ namespace Compdfkit_Tools.Edit
|
|
|
GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
if (textArea != null)
|
|
|
{
|
|
|
- Rect oldRect=DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
if (textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255)))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
@@ -146,8 +162,15 @@ namespace Compdfkit_Tools.Edit
|
|
|
}
|
|
|
ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
ToolView.UpDateRender(oldRect, textArea);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
+ if (EditEvent != null && textArea == null)
|
|
|
+ {
|
|
|
+ EditEvent.Transparency = (byte)(FontOpacitySlider.Value * 255);
|
|
|
+ DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetPDFEditParamm(EditEvent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void Slider_DragStarted(object sender, DragStartedEventArgs e)
|
|
@@ -170,8 +193,8 @@ namespace Compdfkit_Tools.Edit
|
|
|
GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
if (textArea != null)
|
|
|
{
|
|
|
- Rect oldRect=DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- if (textArea.SetCharsFontSize((float)slider.Value,false))
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ if (textArea.SetCharsFontSize((float)slider.Value, false))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
@@ -181,8 +204,15 @@ namespace Compdfkit_Tools.Edit
|
|
|
}
|
|
|
ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
ToolView.UpDateRender(oldRect, textArea);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
+ if (EditEvent != null && textArea == null)
|
|
|
+ {
|
|
|
+ EditEvent.FontSize = slider.Value;
|
|
|
+ DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetPDFEditParamm(EditEvent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void PDFTextEditControl_Loaded(object sender, RoutedEventArgs e)
|
|
@@ -208,7 +238,7 @@ namespace Compdfkit_Tools.Edit
|
|
|
GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
if (textArea != null)
|
|
|
{
|
|
|
- Rect oldRect=DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
if (textArea.SetCharsFontSize((float)e, false))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
@@ -219,17 +249,24 @@ namespace Compdfkit_Tools.Edit
|
|
|
}
|
|
|
ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
ToolView.UpDateRender(oldRect, textArea);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
+ if (EditEvent != null && textArea == null)
|
|
|
+ {
|
|
|
+ EditEvent.FontSize = e;
|
|
|
+ DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetPDFEditParamm(EditEvent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void FontColorUI_ColorChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
SolidColorBrush newBrush = FontColorUI.Brush as SolidColorBrush;
|
|
|
GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
- if (textArea != null && newBrush!=null)
|
|
|
+ if (textArea != null && newBrush != null)
|
|
|
{
|
|
|
- Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
if (textArea.SetCharsFontColor(newBrush.Color.R, newBrush.Color.G, newBrush.Color.B))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
@@ -240,8 +277,19 @@ namespace Compdfkit_Tools.Edit
|
|
|
}
|
|
|
ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
ToolView.UpDateRender(oldRect, textArea);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
+ if (EditEvent != null && textArea == null && newBrush != null)
|
|
|
+ {
|
|
|
+ byte[] Color = new byte[3];
|
|
|
+ Color[0] = newBrush.Color.R;
|
|
|
+ Color[1] = newBrush.Color.G;
|
|
|
+ Color[2] = newBrush.Color.B;
|
|
|
+ EditEvent.FontColor = Color;
|
|
|
+ DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetPDFEditParamm(EditEvent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void TextAlignUI_TextAlignChanged(object sender, TextAlignType e)
|
|
@@ -250,14 +298,14 @@ namespace Compdfkit_Tools.Edit
|
|
|
if (textArea != null)
|
|
|
{
|
|
|
bool result = false;
|
|
|
- Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- if(textArea.SelectLineRects!=null && textArea.SelectLineRects.Count>0)
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ if (textArea.SelectLineRects != null && textArea.SelectLineRects.Count > 0)
|
|
|
{
|
|
|
result = textArea.SetTextRangeAlign(e);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- result= textArea.SetTextAreaAlign(e);
|
|
|
+ result = textArea.SetTextAreaAlign(e);
|
|
|
}
|
|
|
if (result)
|
|
|
{
|
|
@@ -269,8 +317,16 @@ namespace Compdfkit_Tools.Edit
|
|
|
}
|
|
|
ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
ToolView.UpDateRender(oldRect, textArea);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (EditEvent != null && textArea == null)
|
|
|
+ {
|
|
|
+ EditEvent.TextAlign = e;
|
|
|
+ DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetPDFEditParamm(EditEvent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void TextStyleUI_TextItalicChanged(object sender, bool e)
|
|
@@ -278,8 +334,8 @@ namespace Compdfkit_Tools.Edit
|
|
|
GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
if (textArea != null)
|
|
|
{
|
|
|
- Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- if(textArea.SetCharsFontItalic(e))
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ if (textArea.SetCharsFontItalic(e))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
@@ -289,8 +345,15 @@ namespace Compdfkit_Tools.Edit
|
|
|
}
|
|
|
ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
ToolView.UpDateRender(oldRect, textArea);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
+ if (EditEvent != null && textArea == null)
|
|
|
+ {
|
|
|
+ EditEvent.IsItalic = e;
|
|
|
+ DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetPDFEditParamm(EditEvent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void TextStyleUI_TextBoldChanged(object sender, bool e)
|
|
@@ -298,7 +361,7 @@ namespace Compdfkit_Tools.Edit
|
|
|
GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
if (textArea != null)
|
|
|
{
|
|
|
- Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
if (textArea.SetCharsFontBold(e))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
@@ -309,8 +372,15 @@ namespace Compdfkit_Tools.Edit
|
|
|
}
|
|
|
ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
ToolView.UpDateRender(oldRect, textArea);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
+ if (EditEvent != null && textArea == null)
|
|
|
+ {
|
|
|
+ EditEvent.IsBold = e;
|
|
|
+ DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetPDFEditParamm(EditEvent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void TextStyleUI_TextFontChanged(object sender, string e)
|
|
@@ -318,7 +388,7 @@ namespace Compdfkit_Tools.Edit
|
|
|
GetTextArea(out CPDFEditTextArea textArea, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
if (textArea != null)
|
|
|
{
|
|
|
- Rect oldRect= DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
if (textArea.SetCharsFontName(e))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
@@ -329,8 +399,15 @@ namespace Compdfkit_Tools.Edit
|
|
|
}
|
|
|
ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
ToolView.UpDateRender(oldRect, textArea);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
+ if (EditEvent != null && textArea == null)
|
|
|
+ {
|
|
|
+ EditEvent.FontName = e;
|
|
|
+ DefaultSettingParam defaultSettingParam = ToolView.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetPDFEditParamm(EditEvent);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void OpacityComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
@@ -351,26 +428,37 @@ namespace Compdfkit_Tools.Edit
|
|
|
textArea = null;
|
|
|
editPage = null;
|
|
|
pdfPage = null;
|
|
|
- if (ToolView == null || EditEvent == null)
|
|
|
+ if (ToolView == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- try
|
|
|
+ if (EditEvent != null)
|
|
|
{
|
|
|
- CPDFViewer pdfViewer = ToolView.GetCPDFViewer();
|
|
|
- CPDFDocument pdfDoc = pdfViewer.GetDocument();
|
|
|
- pdfPage = pdfDoc.PageAtIndex(EditEvent.PageIndex);
|
|
|
- editPage = pdfPage.GetEditPage();
|
|
|
- List<CPDFEditArea> editAreas = editPage.GetEditAreaList();
|
|
|
- if (editAreas != null && editAreas.Count > EditEvent.EditIndex)
|
|
|
+ try
|
|
|
{
|
|
|
- textArea = editAreas[EditEvent.EditIndex] as CPDFEditTextArea;
|
|
|
+ CPDFViewer pdfViewer = ToolView.GetCPDFViewer();
|
|
|
+ CPDFDocument pdfDoc = pdfViewer.GetDocument();
|
|
|
+ pdfPage = pdfDoc.PageAtIndex(EditEvent.PageIndex);
|
|
|
+ editPage = pdfPage.GetEditPage();
|
|
|
+ List<CPDFEditArea> editAreas = editPage.GetEditAreaList();
|
|
|
+ if (editAreas != null && editAreas.Count > EditEvent.EditIndex)
|
|
|
+ {
|
|
|
+ textArea = editAreas[EditEvent.EditIndex] as CPDFEditTextArea;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ else
|
|
|
{
|
|
|
-
|
|
|
+ CPDFViewer pdfViewer = ToolView.GetCPDFViewer();
|
|
|
+ CPDFDocument pdfDoc = pdfViewer.GetDocument();
|
|
|
+ pdfPage = pdfDoc.PageAtIndex(0);
|
|
|
+ editPage = pdfPage.GetEditPage();
|
|
|
+ editPage.BeginEdit(CPDFEditType.EditText);
|
|
|
+ editPage.EndEdit();
|
|
|
}
|
|
|
}
|
|
|
|