PK
rE HighlightsUILayerDemo/PK
rE , HighlightsUILayerDemo/HighlightsUILayerDemo/PK
אEy@λ 6 HighlightsUILayerDemo/HighlightsUILayerDemo/App.config
PK
אEƨL L 4 HighlightsUILayerDemo/HighlightsUILayerDemo/App.xaml
PK
אEOrb b 7 HighlightsUILayerDemo/HighlightsUILayerDemo/App.xaml.csusing System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace HighlightsUILayerDemo
{
///
/// Interaction logic for App.xaml
///
public partial class App : Application
{
}
}
PK
jEoYYе B HighlightsUILayerDemo/HighlightsUILayerDemo/CustomLayersBuilder.csusing System;
using Telerik.Windows.Documents.Fixed.UI.Layers;
namespace HighlightsUILayerDemo
{
public class CustomLayersBuilder : UILayersBuilder
{
private readonly HighlightsManager highlightsManager;
public CustomLayersBuilder(HighlightsManager highlightsManager)
{
this.highlightsManager = highlightsManager;
}
protected override void BuildUILayersOverride(IUILayerContainer uiLayerContainer)
{
base.BuildUILayersOverride(uiLayerContainer);
uiLayerContainer.UILayers.AddBefore("ContentElementsUILayer", new HighlightsUILayer(this.highlightsManager));
}
}
}
PK
)mE
\ \ @ HighlightsUILayerDemo/HighlightsUILayerDemo/HighlightsManager.csusing System;
using System.Collections.Generic;
using System.Windows.Media;
namespace HighlightsUILayerDemo
{
public class HighlightsManager
{
private readonly Dictionary pageIndexToGeometry;
public HighlightsManager()
{
this.pageIndexToGeometry = new Dictionary();
}
public void AddHighlight(int pageIndex, PathFigure figure)
{
PathGeometry geometry = GetHighlights(pageIndex);
geometry.Figures.Add(figure);
}
public PathGeometry GetHighlights(int pageIndex)
{
PathGeometry geometry;
if (!this.pageIndexToGeometry.TryGetValue(pageIndex, out geometry))
{
geometry = new PathGeometry();
geometry.FillRule = FillRule.Nonzero;
this.pageIndexToGeometry[pageIndex] = geometry;
}
return geometry;
}
public void Clear()
{
this.pageIndexToGeometry.Clear();
}
}
}
PK
mEC-G G @ HighlightsUILayerDemo/HighlightsUILayerDemo/HighlightsUILayer.csusing System;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using Telerik.Windows.Documents.Fixed.UI.Layers;
namespace HighlightsUILayerDemo
{
public class HighlightsUILayer : IUILayer
{
private readonly HighlightsManager highlightsManager;
private readonly Canvas container;
private Path path = null;
private int pageIndex = -1;
public HighlightsUILayer(HighlightsManager highlightsManager)
{
this.highlightsManager = highlightsManager;
this.container = new Canvas();
}
public string Name
{
get
{
return "HighlightsUILayer";
}
}
public void Initialize(UILayerInitializeContext context)
{
this.path = new Path()
{
Fill = new SolidColorBrush(Colors.Yellow)
};
this.pageIndex = context.Page.PageNo - 1;
this.container.Children.Add(this.path);
}
public void Update(UILayerUpdateContext context)
{
if (this.path != null)
{
this.path.Data = this.highlightsManager.GetHighlights(this.pageIndex);
}
}
public void Clear()
{
this.container.Children.Clear();
}
public Canvas UIElement
{
get
{
return this.container;
}
}
}
}
PK
gZE6? H HighlightsUILayerDemo/HighlightsUILayerDemo/HighlightsUILayerDemo.csproj
Debug
AnyCPU
{605BDE30-6497-46E0-84A9-A16CE9DF8366}
WinExe
Properties
HighlightsUILayerDemo
HighlightsUILayerDemo
v4.5
512
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4
AnyCPU
true
full
false
bin\Debug\
DEBUG;TRACE
prompt
4
AnyCPU
pdbonly
true
bin\Release\
TRACE
prompt
4
4.0
..\..\..\..\..\WPF_Scrum\Current\Binaries\WPF\Telerik.Windows.Controls.dll
..\..\..\..\..\WPF_Scrum\Current\Binaries\WPF\Telerik.Windows.Controls.FixedDocumentViewers.dll
..\..\..\..\..\WPF_Scrum\Current\Binaries\WPF\Telerik.Windows.Controls.FixedDocumentViewersUI.dll
..\..\..\..\..\WPF_Scrum\Current\Binaries\WPF\Telerik.Windows.Controls.Input.dll
..\..\..\..\..\WPF_Scrum\Current\Binaries\WPF\Telerik.Windows.Controls.Navigation.dll
..\..\..\..\..\WPF_Scrum\Current\Binaries\WPF\Telerik.Windows.Documents.Core.dll
..\..\..\..\..\WPF_Scrum\Current\Binaries\WPF\Telerik.Windows.Documents.Fixed.dll
..\..\..\..\..\WPF_Scrum\Current\Binaries\WPF\Telerik.Windows.Zip.dll
MSBuild:Compile
Designer
MSBuild:Compile
Designer
App.xaml
Code
MainWindow.xaml
Code
Code
True
True
Resources.resx
True
Settings.settings
True
ResXFileCodeGenerator
Resources.Designer.cs
SettingsSingleFileGenerator
Settings.Designer.cs
PK
UEo o ; HighlightsUILayerDemo/HighlightsUILayerDemo/MainWindow.xaml
PK
hqE" > HighlightsUILayerDemo/HighlightsUILayerDemo/MainWindow.xaml.csusing System;
using System.Diagnostics;
using System.IO;
using System.Windows;
using Telerik.Windows.Documents.Fixed;
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf;
using Telerik.Windows.Documents.Fixed.Model;
using Telerik.Windows.Documents.Fixed.Model.ColorSpaces;
using Telerik.Windows.Documents.Fixed.Model.Graphics;
using Telerik.Windows.Documents.Fixed.UI.Extensibility;
namespace HighlightsUILayerDemo
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
private const string ResourceFilePath = "/HighlightsUILayerDemo;component/Resources/TestFileWithHighlights.pdf";
private const string SaveFileName = "TestFileWithHighlights.pdf";
private readonly PdfFormatProvider pdfFormatProvider;
private readonly HighlightsManager highlightsManager;
public MainWindow()
{
this.highlightsManager = new HighlightsManager();
ExtensibilityManager.RegisterLayersBuilder(new CustomLayersBuilder(this.highlightsManager));
InitializeComponent();
this.pdfFormatProvider = new PdfFormatProvider();
this.pdfViewer.Mode = Telerik.Windows.Documents.Fixed.UI.FixedDocumentViewerMode.TextSelection;
this.pdfViewer.DocumentChanged += this.PdfViewerDocumentChanged;
}
private void SaveAndView_Click(object sender, RoutedEventArgs e)
{
RadFixedDocument document = this.ImportDocument();
for (int pageIndex = 0; pageIndex < document.Pages.Count; pageIndex++)
{
var path = new Telerik.Windows.Documents.Fixed.Model.Graphics.Path();
path.IsFilled = true;
path.IsStroked = false;
path.Fill = new RgbColor(255, 255, 0);
path.Geometry = this.ConvertGeometry(this.highlightsManager.GetHighlights(pageIndex));
document.Pages[pageIndex].Content.Insert(0, path);
}
this.SaveAndView(document);
}
private void AddHighlights_Click(object sender, RoutedEventArgs e)
{
RadFixedDocument document = this.pdfViewer.Document;
int startPageIndex = document.Pages.IndexOf(document.Selection.StartPosition.Page);
int endPageIndex = document.Pages.IndexOf(document.Selection.EndPosition.Page);
for (int pageIndex = startPageIndex; pageIndex <= endPageIndex; pageIndex++)
{
System.Windows.Media.PathGeometry geometry = document.Selection.GetSelectionGeometry(this.pdfViewer.Document.Pages[pageIndex]);
foreach (System.Windows.Media.PathFigure figure in geometry.Figures)
{
this.highlightsManager.AddHighlight(pageIndex, figure);
}
}
}
private void SaveAndView(RadFixedDocument document)
{
if (File.Exists(SaveFileName))
{
File.Delete(SaveFileName);
}
using (Stream fileStream = new FileStream(SaveFileName, FileMode.OpenOrCreate))
{
this.pdfFormatProvider.Export(document, fileStream);
}
Process.Start(SaveFileName);
}
private RadFixedDocument ImportDocument()
{
using (Stream fileStream = Application.GetResourceStream(new Uri(ResourceFilePath, UriKind.Relative)).Stream)
{
return this.pdfFormatProvider.Import(fileStream);
}
}
private PathGeometry ConvertGeometry(System.Windows.Media.PathGeometry geometry)
{
PathGeometry pathGeometry = new PathGeometry();
foreach (var figure in geometry.Figures)
{
PathFigure pathFigure = pathGeometry.Figures.AddPathFigure();
pathFigure.StartPoint = figure.StartPoint;
pathFigure.IsClosed = true;
var polyline = (System.Windows.Media.PolyLineSegment)figure.Segments[0];
foreach (Point point in polyline.Points)
{
pathFigure.Segments.AddLineSegment(point);
}
}
return pathGeometry;
}
private void PdfViewerDocumentChanged(object sender, DocumentChangedEventArgs e)
{
this.highlightsManager.Clear();
}
}
}
PK
אE 7 HighlightsUILayerDemo/HighlightsUILayerDemo/Properties/PK
אE/"v> F HighlightsUILayerDemo/HighlightsUILayerDemo/Properties/AssemblyInfo.csusing System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("HighlightsUILayerDemo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HighlightsUILayerDemo")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//CultureYouAreCodingWith in your .csproj file
//inside a . For example, if you are using US english
//in your source files, set the to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
PK
אE8 8 L HighlightsUILayerDemo/HighlightsUILayerDemo/Properties/Resources.Designer.cs//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.18449
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
namespace HighlightsUILayerDemo.Properties
{
///
/// A strongly-typed resource class, for looking up localized strings, etc.
///
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
///
/// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HighlightsUILayerDemo.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
///
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
PK
אEZtv E HighlightsUILayerDemo/HighlightsUILayerDemo/Properties/Resources.resx
text/microsoft-resx
2.0
System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
PK
אE?%T T K HighlightsUILayerDemo/HighlightsUILayerDemo/Properties/Settings.Designer.cs//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.18449
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
namespace HighlightsUILayerDemo.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
PK
אEڥ! H HighlightsUILayerDemo/HighlightsUILayerDemo/Properties/Settings.settings
PK
XE 6 HighlightsUILayerDemo/HighlightsUILayerDemo/Resources/PK
XE%Ǐ Ǐ P HighlightsUILayerDemo/HighlightsUILayerDemo/Resources/TestFileWithHighlights.pdf%PDF-1.7
%
4 0 obj
<>
endobj
5 0 obj
<>
endobj
6 0 obj
<> >> /Contents 8 0 R >>
endobj
7 0 obj
<> >> /Contents 9 0 R >>
endobj
8 0 obj
<>
stream
x\K6|0?@E A_ہb(Ud2n{il5Rx8IIG>/IhvI(Gv<4?ɸxEJ~=s<#
433|9|y|i|Ig|Y0qИ0w5Γ~aNuUz @x-G7E|31,8K&QޙfA_+VV0^hE
/(;d&sA:= }F:~LKԨ?'[G{>SxZMY'7Ao6f>DIsVdlfHa=5ujY{cc4/r@&yH8~?%luJڬ"x2XңBy/XqV(nNЂQpV\8î(xFK
a