|
@@ -5,7 +5,6 @@ using ComPDFKit.Tool;
|
|
|
using ComPDFKit.Tool.SettingParam;
|
|
|
using ComPDFKit.Tool.UndoManger;
|
|
|
using ComPDFKit.Viewer.Helper;
|
|
|
-using ComPDFKit.Controls.PDFControl;
|
|
|
using ComPDFKitViewer;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -16,6 +15,7 @@ using System.Windows.Media;
|
|
|
using System.ComponentModel;
|
|
|
using System.Runtime.CompilerServices;
|
|
|
using System.Linq;
|
|
|
+
|
|
|
namespace ComPDFKit.Controls.Edit
|
|
|
{
|
|
|
public partial class PDFTextEditControl : UserControl, INotifyPropertyChanged
|
|
@@ -66,7 +66,6 @@ namespace ComPDFKit.Controls.Edit
|
|
|
#region UI
|
|
|
public void SetPDFTextEditData(List<TextEditParam> newEvents)
|
|
|
{
|
|
|
-
|
|
|
EditEvents = newEvents.Where(newEvent => newEvent.EditIndex >= 0 && newEvent.EditType == CPDFEditType.EditText).ToList();
|
|
|
TextEditParam defaultEvent = EditEvents.FirstOrDefault();
|
|
|
if (EditEvents.Count > 0)
|
|
@@ -151,47 +150,57 @@ namespace ComPDFKit.Controls.Edit
|
|
|
}
|
|
|
|
|
|
GetTextArea(out List<CPDFEditTextArea> textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
- if (textAreas.Count > 0)
|
|
|
+ if (textAreas.Count == 0 || pdfPage == null || editPage == null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (ToolView.CurrentEditAreaObject() != null)
|
|
|
{
|
|
|
- bool result = false;
|
|
|
- foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ bool result;
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textAreas[0].GetFrame());
|
|
|
+ if (string.IsNullOrEmpty(textAreas[0].SelectText))
|
|
|
{
|
|
|
- Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- if (string.IsNullOrEmpty(textArea.SelectText))
|
|
|
- {
|
|
|
- string fontName = "Helvetica";
|
|
|
- float fontSize = 14;
|
|
|
- byte[] fontColor = { 0, 0, 0 };
|
|
|
- byte transparency = 255;
|
|
|
- bool isBold = false;
|
|
|
- bool isItalic = false;
|
|
|
- textArea.GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
- result ^= textArea.SetCurTextStyle(fontName, fontSize, fontColor[0], fontColor[1], fontColor[2], (byte)(FontOpacitySlider.Value * 255), isBold, isItalic);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result ^= textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255));
|
|
|
- }
|
|
|
-
|
|
|
- if (result)
|
|
|
- {
|
|
|
- ToolView.UpdateRender(oldRect, textArea);
|
|
|
- editPage.EndEdit();
|
|
|
- }
|
|
|
+ string fontName = "Helvetica";
|
|
|
+ float fontSize = 14;
|
|
|
+ byte[] fontColor = { 0, 0, 0 };
|
|
|
+ byte transparency = 255;
|
|
|
+ bool isBold = false;
|
|
|
+ bool isItalic = false;
|
|
|
+ textAreas[0].GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
+ result = textAreas[0].SetCurTextStyle(fontName, fontSize, fontColor[0], fontColor[1], fontColor[2], (byte)(FontOpacitySlider.Value * 255), isBold, isItalic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = textAreas[0].SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255));
|
|
|
}
|
|
|
|
|
|
if (result)
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
|
- if (pdfPage != null)
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory);
|
|
|
+ ToolView.UpdateRender(oldRect, textAreas[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GroupHistory groupHistory = new GroupHistory();
|
|
|
+ foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ {
|
|
|
+ if (textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255)))
|
|
|
{
|
|
|
+ PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
+ editHistory.EditPage = editPage;
|
|
|
editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ groupHistory.Histories.Add(editHistory);
|
|
|
}
|
|
|
- ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
}
|
|
|
+
|
|
|
+ ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory);
|
|
|
+ ToolView.GetCPDFViewer()?.UpdateRenderFrame();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ editPage.EndEdit();
|
|
|
if (EditEvents.Count > 0 && textAreas.Count > 0)
|
|
|
{
|
|
|
EditEvents.FirstOrDefault().Transparency = (byte)(FontOpacitySlider.Value * 255);
|
|
@@ -214,45 +223,57 @@ namespace ComPDFKit.Controls.Edit
|
|
|
}
|
|
|
|
|
|
GetTextArea(out List<CPDFEditTextArea> textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
- if (textAreas.Count > 0)
|
|
|
+ if (textAreas.Count == 0 || pdfPage == null || editPage == null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (ToolView.CurrentEditAreaObject() != null)
|
|
|
{
|
|
|
- bool result = false;
|
|
|
+ bool result;
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textAreas[0].GetFrame());
|
|
|
+ if (string.IsNullOrEmpty(textAreas[0].SelectText))
|
|
|
+ {
|
|
|
+ string fontName = "Helvetica";
|
|
|
+ float fontSize = 14;
|
|
|
+ byte[] fontColor = { 0, 0, 0 };
|
|
|
+ byte transparency = 255;
|
|
|
+ bool isBold = false;
|
|
|
+ bool isItalic = false;
|
|
|
+ textAreas[0].GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
+ result = textAreas[0].SetCurTextStyle(fontName, fontSize, fontColor[0], fontColor[1], fontColor[2], (byte)(FontOpacitySlider.Value * 255), isBold, isItalic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = textAreas[0].SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255));
|
|
|
+ }
|
|
|
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
+ editHistory.EditPage = editPage;
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory);
|
|
|
+ ToolView.UpdateRender(oldRect, textAreas[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GroupHistory groupHistory = new GroupHistory();
|
|
|
foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
{
|
|
|
- Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- if (string.IsNullOrEmpty(textArea.SelectText))
|
|
|
+ if (textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255)))
|
|
|
{
|
|
|
- string fontName = "Helvetica";
|
|
|
- float fontSize = 14;
|
|
|
- byte[] fontColor = { 0, 0, 0 };
|
|
|
- byte transparency = 255;
|
|
|
- bool isBold = false;
|
|
|
- bool isItalic = false;
|
|
|
- textArea.GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
- result ^= textArea.SetCurTextStyle(fontName, fontSize, fontColor[0], fontColor[1], fontColor[2], (byte)(FontOpacitySlider.Value * 255), isBold, isItalic);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result ^= textArea.SetCharsFontTransparency((byte)(FontOpacitySlider.Value * 255));
|
|
|
- }
|
|
|
-
|
|
|
- if (result)
|
|
|
- {
|
|
|
- ToolView.UpdateRender(oldRect, textArea);
|
|
|
- editPage.EndEdit();
|
|
|
+ PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
+ editHistory.EditPage = editPage;
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ groupHistory.Histories.Add(editHistory);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
- editHistory.EditPage = editPage;
|
|
|
- if (pdfPage != null)
|
|
|
- {
|
|
|
- editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
- }
|
|
|
- ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
+ ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory);
|
|
|
+ ToolView.GetCPDFViewer()?.UpdateRenderFrame();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ editPage.EndEdit();
|
|
|
if (EditEvents?.Count > 0 && textAreas.Count > 0)
|
|
|
{
|
|
|
EditEvents.FirstOrDefault().Transparency = (byte)(FontOpacitySlider.Value * 255);
|
|
@@ -300,44 +321,57 @@ namespace ComPDFKit.Controls.Edit
|
|
|
private void TextStyleUI_TextSizeChanged(object sender, double e)
|
|
|
{
|
|
|
GetTextArea(out List<CPDFEditTextArea> textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
- if (textAreas.Count > 0)
|
|
|
+ if (textAreas.Count == 0 || pdfPage == null || editPage == null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (ToolView.CurrentEditAreaObject() != null)
|
|
|
{
|
|
|
- foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ bool result;
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textAreas[0].GetFrame());
|
|
|
+ if (string.IsNullOrEmpty(textAreas[0].SelectText))
|
|
|
{
|
|
|
- Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- bool result;
|
|
|
- if (string.IsNullOrEmpty(textArea.SelectText))
|
|
|
- {
|
|
|
- string fontName = "Helvetica";
|
|
|
- float fontSize = 14;
|
|
|
- byte[] fontColor = { 0, 0, 0 };
|
|
|
- byte transparency = 255;
|
|
|
- bool isBold = false;
|
|
|
- bool isItalic = false;
|
|
|
- textArea.GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
- result = textArea.SetCurTextStyle(fontName, (float)e, fontColor[0], fontColor[1], fontColor[2], transparency, isBold, isItalic);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result = textArea.SetCharsFontSize((float)e, true);
|
|
|
- }
|
|
|
+ string fontName = "Helvetica";
|
|
|
+ float fontSize = 14;
|
|
|
+ byte[] fontColor = { 0, 0, 0 };
|
|
|
+ byte transparency = 255;
|
|
|
+ bool isBold = false;
|
|
|
+ bool isItalic = false;
|
|
|
+ textAreas[0].GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
+ result = textAreas[0].SetCurTextStyle(fontName, (float)e, fontColor[0], fontColor[1], fontColor[2], transparency, isBold, isItalic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = textAreas[0].SetCharsFontSize((float)e, true);
|
|
|
+ }
|
|
|
|
|
|
- if (result)
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
+ editHistory.EditPage = editPage;
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory);
|
|
|
+ ToolView.UpdateRender(oldRect, textAreas[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GroupHistory groupHistory = new GroupHistory();
|
|
|
+ foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ {
|
|
|
+ if (textArea.SetCharsFontSize((float)e, true))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
|
- if (pdfPage != null)
|
|
|
- {
|
|
|
- editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
- }
|
|
|
- ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
- ToolView.UpdateRender(oldRect, textArea);
|
|
|
- editPage.EndEdit();
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ groupHistory.Histories.Add(editHistory);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory);
|
|
|
+ ToolView.GetCPDFViewer()?.UpdateRenderFrame();
|
|
|
}
|
|
|
|
|
|
+ editPage.EndEdit();
|
|
|
if (EditEvents.Count > 0 && textAreas.Count > 0)
|
|
|
{
|
|
|
EditEvents.FirstOrDefault().FontSize = e;
|
|
@@ -359,45 +393,57 @@ namespace ComPDFKit.Controls.Edit
|
|
|
{
|
|
|
SolidColorBrush newBrush = FontColorUI.Brush as SolidColorBrush;
|
|
|
GetTextArea(out List<CPDFEditTextArea> textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
- if (textAreas.Count > 0 && newBrush != null)
|
|
|
+ if (textAreas.Count == 0 || pdfPage == null || editPage == null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (ToolView.CurrentEditAreaObject() != null)
|
|
|
{
|
|
|
- foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ bool result;
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textAreas[0].GetFrame());
|
|
|
+ if (string.IsNullOrEmpty(textAreas[0].SelectText))
|
|
|
{
|
|
|
+ string fontName = "Helvetica";
|
|
|
+ float fontSize = 14;
|
|
|
+ byte[] fontColor = { 0, 0, 0 };
|
|
|
+ byte transparency = 255;
|
|
|
+ bool isBold = false;
|
|
|
+ bool isItalic = false;
|
|
|
+ textAreas[0].GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
+ result = textAreas[0].SetCurTextStyle(fontName, fontSize, newBrush.Color.R, newBrush.Color.G, newBrush.Color.B, transparency, isBold, isItalic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = textAreas[0].SetCharsFontColor(newBrush.Color.R, newBrush.Color.G, newBrush.Color.B);
|
|
|
+ }
|
|
|
|
|
|
- Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- bool result;
|
|
|
- if (string.IsNullOrEmpty(textArea.SelectText))
|
|
|
- {
|
|
|
- string fontName = "Helvetica";
|
|
|
- float fontSize = 14;
|
|
|
- byte[] fontColor = { 0, 0, 0 };
|
|
|
- byte transparency = 255;
|
|
|
- bool isBold = false;
|
|
|
- bool isItalic = false;
|
|
|
- textArea.GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
- result = textArea.SetCurTextStyle(fontName, fontSize, newBrush.Color.R, newBrush.Color.G, newBrush.Color.B, transparency, isBold, isItalic);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result = textArea.SetCharsFontColor(newBrush.Color.R, newBrush.Color.G, newBrush.Color.B);
|
|
|
- }
|
|
|
-
|
|
|
- if (result)
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
+ editHistory.EditPage = editPage;
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory);
|
|
|
+ ToolView.UpdateRender(oldRect, textAreas[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GroupHistory groupHistory = new GroupHistory();
|
|
|
+ foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ {
|
|
|
+ if (textArea.SetCharsFontColor(newBrush.Color.R, newBrush.Color.G, newBrush.Color.B))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
|
- if (pdfPage != null)
|
|
|
- {
|
|
|
- editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
- }
|
|
|
-
|
|
|
- ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
- ToolView.UpdateRender(oldRect, textArea);
|
|
|
- editPage.EndEdit();
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ groupHistory.Histories.Add(editHistory);
|
|
|
}
|
|
|
+
|
|
|
+ ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory);
|
|
|
+ ToolView.GetCPDFViewer()?.UpdateRenderFrame();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ editPage.EndEdit();
|
|
|
if (EditEvents.Count > 0 && newBrush != null)
|
|
|
{
|
|
|
byte[] Color = new byte[3];
|
|
@@ -413,12 +459,37 @@ namespace ComPDFKit.Controls.Edit
|
|
|
private void TextAlignUI_TextAlignChanged(object sender, TextAlignType e)
|
|
|
{
|
|
|
GetTextArea(out List<CPDFEditTextArea> textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
- if (textAreas.Count > 0)
|
|
|
+ if (textAreas.Count == 0 || pdfPage == null || editPage == null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (ToolView.CurrentEditAreaObject() != null)
|
|
|
+ {
|
|
|
+ bool result;
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textAreas[0].GetFrame());
|
|
|
+ if (textAreas[0].SelectLineRects != null && textAreas[0].SelectLineRects.Count > 0)
|
|
|
+ {
|
|
|
+ result = textAreas[0].SetTextRangeAlign(e);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = textAreas[0].SetTextAreaAlign(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
+ editHistory.EditPage = editPage;
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory);
|
|
|
+ ToolView.UpdateRender(oldRect, textAreas[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
+ GroupHistory groupHistory = new GroupHistory();
|
|
|
foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
{
|
|
|
- bool result = false;
|
|
|
- Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
+ bool result;
|
|
|
if (textArea.SelectLineRects != null && textArea.SelectLineRects.Count > 0)
|
|
|
{
|
|
|
result = textArea.SetTextRangeAlign(e);
|
|
@@ -427,21 +498,21 @@ namespace ComPDFKit.Controls.Edit
|
|
|
{
|
|
|
result = textArea.SetTextAreaAlign(e);
|
|
|
}
|
|
|
+
|
|
|
if (result)
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
|
- if (pdfPage != null)
|
|
|
- {
|
|
|
- editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
- }
|
|
|
- ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
- ToolView.UpdateRender(oldRect, textArea);
|
|
|
- editPage.EndEdit();
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ groupHistory.Histories.Add(editHistory);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory);
|
|
|
+ ToolView.GetCPDFViewer()?.UpdateRenderFrame();
|
|
|
}
|
|
|
|
|
|
+ editPage.EndEdit();
|
|
|
if (EditEvents.Count > 0 && textAreas.Count > 0)
|
|
|
{
|
|
|
EditEvents.FirstOrDefault().TextAlign = e;
|
|
@@ -462,44 +533,57 @@ namespace ComPDFKit.Controls.Edit
|
|
|
private void TextStyleUI_TextItalicChanged(object sender, bool e)
|
|
|
{
|
|
|
GetTextArea(out List<CPDFEditTextArea> textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
- if (textAreas.Count > 0)
|
|
|
+ if (textAreas.Count == 0 || pdfPage == null || editPage == null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (ToolView.CurrentEditAreaObject() != null)
|
|
|
{
|
|
|
- foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ bool result;
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textAreas[0].GetFrame());
|
|
|
+ if (string.IsNullOrEmpty(textAreas[0].SelectText))
|
|
|
{
|
|
|
- Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- bool result;
|
|
|
- if (string.IsNullOrEmpty(textArea.SelectText))
|
|
|
- {
|
|
|
- string fontName = "Helvetica";
|
|
|
- float fontSize = 14;
|
|
|
- byte[] fontColor = { 0, 0, 0 };
|
|
|
- byte transparency = 255;
|
|
|
- bool isBold = false;
|
|
|
- bool isItalic = false;
|
|
|
- textArea.GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
- result = textArea.SetCurTextStyle(fontName, fontSize, fontColor[0], fontColor[1], fontColor[2], transparency, isBold, e);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result = textArea.SetCharsFontItalic(e);
|
|
|
- }
|
|
|
+ string fontName = "Helvetica";
|
|
|
+ float fontSize = 14;
|
|
|
+ byte[] fontColor = { 0, 0, 0 };
|
|
|
+ byte transparency = 255;
|
|
|
+ bool isBold = false;
|
|
|
+ bool isItalic = false;
|
|
|
+ textAreas[0].GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
+ result = textAreas[0].SetCurTextStyle(fontName, fontSize, fontColor[0], fontColor[1], fontColor[2], transparency, isBold, e);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = textAreas[0].SetCharsFontItalic(e);
|
|
|
+ }
|
|
|
|
|
|
- if (result)
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
+ editHistory.EditPage = editPage;
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory);
|
|
|
+ ToolView.UpdateRender(oldRect, textAreas[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GroupHistory groupHistory = new GroupHistory();
|
|
|
+ foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ {
|
|
|
+ if (textArea.SetCharsFontItalic(e))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
|
- if (pdfPage != null)
|
|
|
- {
|
|
|
- editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
- }
|
|
|
-
|
|
|
- ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
- ToolView.UpdateRender(oldRect, textArea);
|
|
|
- editPage.EndEdit();
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ groupHistory.Histories.Add(editHistory);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory);
|
|
|
+ ToolView.GetCPDFViewer()?.UpdateRenderFrame();
|
|
|
}
|
|
|
|
|
|
+ editPage.EndEdit();
|
|
|
if (EditEvents.Count > 0 && textAreas.Count > 0)
|
|
|
{
|
|
|
EditEvents.FirstOrDefault().IsItalic = e;
|
|
@@ -520,43 +604,57 @@ namespace ComPDFKit.Controls.Edit
|
|
|
private void TextStyleUI_TextBoldChanged(object sender, bool e)
|
|
|
{
|
|
|
GetTextArea(out List<CPDFEditTextArea> textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
- if (textAreas.Count > 0)
|
|
|
+ if (textAreas.Count == 0 || pdfPage == null || editPage == null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (ToolView.CurrentEditAreaObject() != null)
|
|
|
{
|
|
|
- foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ bool result;
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textAreas[0].GetFrame());
|
|
|
+ if (string.IsNullOrEmpty(textAreas[0].SelectText))
|
|
|
{
|
|
|
- Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- bool result;
|
|
|
- if (string.IsNullOrEmpty(textArea.SelectText))
|
|
|
- {
|
|
|
- string fontName = "Helvetica";
|
|
|
- float fontSize = 14;
|
|
|
- byte[] fontColor = { 0, 0, 0 };
|
|
|
- byte transparency = 255;
|
|
|
- bool isBold = false;
|
|
|
- bool isItalic = false;
|
|
|
- textArea.GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
- result = textArea.SetCurTextStyle(fontName, fontSize, fontColor[0], fontColor[1], fontColor[2], transparency, e, isItalic);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result = textArea.SetCharsFontBold(e);
|
|
|
- }
|
|
|
+ string fontName = "Helvetica";
|
|
|
+ float fontSize = 14;
|
|
|
+ byte[] fontColor = { 0, 0, 0 };
|
|
|
+ byte transparency = 255;
|
|
|
+ bool isBold = false;
|
|
|
+ bool isItalic = false;
|
|
|
+ textAreas[0].GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
+ result = textAreas[0].SetCurTextStyle(fontName, fontSize, fontColor[0], fontColor[1], fontColor[2], transparency, e, isItalic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = textAreas[0].SetCharsFontBold(e);
|
|
|
+ }
|
|
|
|
|
|
- if (result)
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
+ editHistory.EditPage = editPage;
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory);
|
|
|
+ ToolView.UpdateRender(oldRect, textAreas[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GroupHistory groupHistory = new GroupHistory();
|
|
|
+ foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ {
|
|
|
+ if (textArea.SetCharsFontBold(e))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
|
- if (pdfPage != null)
|
|
|
- {
|
|
|
- editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
- }
|
|
|
- ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
- ToolView.UpdateRender(oldRect, textArea);
|
|
|
- editPage.EndEdit();
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ groupHistory.Histories.Add(editHistory);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory);
|
|
|
+ ToolView.GetCPDFViewer()?.UpdateRenderFrame();
|
|
|
}
|
|
|
|
|
|
+ editPage.EndEdit();
|
|
|
if (EditEvents.Count > 0 && textAreas.Count > 0)
|
|
|
{
|
|
|
EditEvents.FirstOrDefault().IsBold = e;
|
|
@@ -577,43 +675,57 @@ namespace ComPDFKit.Controls.Edit
|
|
|
private void TextStyleUI_TextFontChanged(object sender, string e)
|
|
|
{
|
|
|
GetTextArea(out List<CPDFEditTextArea> textAreas, out CPDFPage pdfPage, out CPDFEditPage editPage);
|
|
|
- if (textAreas.Count > 0)
|
|
|
+ if (textAreas.Count == 0 || pdfPage == null || editPage == null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (ToolView.CurrentEditAreaObject() != null)
|
|
|
{
|
|
|
- foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ bool result;
|
|
|
+ Rect oldRect = DataConversionForWPF.CRectConversionForRect(textAreas[0].GetFrame());
|
|
|
+ if (string.IsNullOrEmpty(textAreas[0].SelectText))
|
|
|
{
|
|
|
- Rect oldRect = DataConversionForWPF.CRectConversionForRect(textArea.GetFrame());
|
|
|
- bool result;
|
|
|
- if (string.IsNullOrEmpty(textArea.SelectText))
|
|
|
- {
|
|
|
- string fontName = "Helvetica";
|
|
|
- float fontSize = 14;
|
|
|
- byte[] fontColor = { 0, 0, 0 };
|
|
|
- byte transparency = 255;
|
|
|
- bool isBold = false;
|
|
|
- bool isItalic = false;
|
|
|
- textArea.GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
- result = textArea.SetCurTextStyle(e, fontSize, fontColor[0], fontColor[1], fontColor[2], transparency, isBold, isItalic);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result = textArea.SetCharsFontName(e);
|
|
|
- }
|
|
|
+ string fontName = "Helvetica";
|
|
|
+ float fontSize = 14;
|
|
|
+ byte[] fontColor = { 0, 0, 0 };
|
|
|
+ byte transparency = 255;
|
|
|
+ bool isBold = false;
|
|
|
+ bool isItalic = false;
|
|
|
+ textAreas[0].GetTextStyle(ref fontName, ref fontSize, ref fontColor, ref transparency, ref isBold, ref isItalic);
|
|
|
+ result = textAreas[0].SetCurTextStyle(e, fontSize, fontColor[0], fontColor[1], fontColor[2], transparency, isBold, isItalic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = textAreas[0].SetCharsFontName(e);
|
|
|
+ }
|
|
|
|
|
|
- if (result)
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
+ editHistory.EditPage = editPage;
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ ToolView.GetCPDFViewer().UndoManager.AddHistory(editHistory);
|
|
|
+ ToolView.UpdateRender(oldRect, textAreas[0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GroupHistory groupHistory = new GroupHistory();
|
|
|
+ foreach (CPDFEditTextArea textArea in textAreas)
|
|
|
+ {
|
|
|
+ if (textArea.SetCharsFontName(e))
|
|
|
{
|
|
|
PDFEditHistory editHistory = new PDFEditHistory();
|
|
|
editHistory.EditPage = editPage;
|
|
|
- if (pdfPage != null)
|
|
|
- {
|
|
|
- editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
- }
|
|
|
- ToolView.GetCPDFViewer()?.UndoManager.AddHistory(editHistory);
|
|
|
- ToolView.UpdateRender(oldRect, textArea);
|
|
|
- editPage.EndEdit();
|
|
|
+ editHistory.PageIndex = pdfPage.PageIndex;
|
|
|
+ groupHistory.Histories.Add(editHistory);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ ToolView.GetCPDFViewer()?.UndoManager.AddHistory(groupHistory);
|
|
|
+ ToolView.GetCPDFViewer()?.UpdateRenderFrame();
|
|
|
}
|
|
|
|
|
|
+ editPage.EndEdit();
|
|
|
if (EditEvents.Count > 0 && textAreas.Count > 0)
|
|
|
{
|
|
|
EditEvents.FirstOrDefault().FontName = e;
|
|
@@ -656,7 +768,7 @@ namespace ComPDFKit.Controls.Edit
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- if (EditEvents != null)
|
|
|
+ if (EditEvents != null && EditEvents.Count>0 )
|
|
|
{
|
|
|
try
|
|
|
{
|