First commit
Send all results
This commit is contained in:
202
PdfSharp/Forms/ColorComboBox.cs
Normal file
202
PdfSharp/Forms/ColorComboBox.cs
Normal file
@@ -0,0 +1,202 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Stefan Lange
|
||||
//
|
||||
// Copyright (c) 2005-2017 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.pdfsharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
#if GDI
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
#endif
|
||||
using PdfSharp.Drawing;
|
||||
|
||||
#if GDI
|
||||
namespace PdfSharp.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// A combo box control for selection XColor values.
|
||||
/// </summary>
|
||||
public class ColorComboBox : ComboBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ColorComboBox"/> class.
|
||||
/// </summary>
|
||||
public ColorComboBox()
|
||||
{
|
||||
DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
DrawMode = DrawMode.OwnerDrawFixed;
|
||||
Fill();
|
||||
}
|
||||
|
||||
readonly XColorResourceManager _crm = new XColorResourceManager();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom color.
|
||||
/// </summary>
|
||||
public XColor Color
|
||||
{
|
||||
get { return _color; }
|
||||
set
|
||||
{
|
||||
_color = value;
|
||||
if (value.IsKnownColor)
|
||||
{
|
||||
XKnownColor color = XColorResourceManager.GetKnownColor(value.Argb);
|
||||
for (int idx = 1; idx < Items.Count; idx++)
|
||||
{
|
||||
if (((ColorItem)Items[idx]).Color.Argb == value.Argb)
|
||||
{
|
||||
SelectedIndex = idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
SelectedIndex = 0;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
XColor _color = XColor.Empty;
|
||||
|
||||
void Fill()
|
||||
{
|
||||
Items.Add(new ColorItem(XColor.Empty, "custom"));
|
||||
XKnownColor[] knownColors = XColorResourceManager.GetKnownColors(false);
|
||||
int count = knownColors.Length;
|
||||
for (int idx = 0; idx < knownColors.Length; idx++)
|
||||
{
|
||||
XKnownColor color = knownColors[idx];
|
||||
Items.Add(new ColorItem(XColor.FromKnownColor(color), _crm.ToColorName(color)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Keep control a drop down combo box.
|
||||
/// </summary>
|
||||
protected override void OnDropDownStyleChanged(EventArgs e)
|
||||
{
|
||||
DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
base.OnDropDownStyleChanged(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the color with the selected item.
|
||||
/// </summary>
|
||||
protected override void OnSelectedIndexChanged(EventArgs e)
|
||||
{
|
||||
int index = SelectedIndex;
|
||||
if (index > 0)
|
||||
{
|
||||
ColorItem item = (ColorItem)Items[index];
|
||||
_color = item.Color;
|
||||
}
|
||||
base.OnSelectedIndexChanged(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw a color entry.
|
||||
/// </summary>
|
||||
protected override void OnDrawItem(DrawItemEventArgs e)
|
||||
{
|
||||
int idx = e.Index;
|
||||
|
||||
// Nothing selected?
|
||||
if (idx < 0)
|
||||
return;
|
||||
|
||||
object obj = Items[idx];
|
||||
if (obj is ColorItem)
|
||||
{
|
||||
ColorItem item = (ColorItem)obj;
|
||||
|
||||
// Is custom color?
|
||||
if (idx == 0)
|
||||
{
|
||||
string name;
|
||||
if (_color.IsEmpty)
|
||||
name = "custom";
|
||||
else
|
||||
name = _crm.ToColorName(_color);
|
||||
|
||||
item = new ColorItem(_color, name);
|
||||
}
|
||||
|
||||
XColor clr = item.Color;
|
||||
Graphics gfx = e.Graphics;
|
||||
Rectangle rect = e.Bounds;
|
||||
Brush textbrush = SystemBrushes.ControlText;
|
||||
if ((e.State & DrawItemState.Selected) == 0)
|
||||
{
|
||||
gfx.FillRectangle(SystemBrushes.Window, rect);
|
||||
textbrush = SystemBrushes.ControlText;
|
||||
}
|
||||
else
|
||||
{
|
||||
gfx.FillRectangle(SystemBrushes.Highlight, rect);
|
||||
textbrush = SystemBrushes.HighlightText;
|
||||
}
|
||||
|
||||
// Draw color box
|
||||
if (!clr.IsEmpty)
|
||||
{
|
||||
Rectangle box = new Rectangle(rect.X + 3, rect.Y + 1, rect.Height * 2, rect.Height - 3);
|
||||
gfx.FillRectangle(new SolidBrush(clr.ToGdiColor()), box);
|
||||
gfx.DrawRectangle(Pens.Black, box);
|
||||
}
|
||||
|
||||
StringFormat format = new StringFormat(StringFormat.GenericDefault);
|
||||
format.Alignment = StringAlignment.Near;
|
||||
format.LineAlignment = StringAlignment.Center;
|
||||
rect.X += rect.Height * 2 + 3 + 3;
|
||||
gfx.DrawString(item.Name, Font, textbrush, rect, format);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a combo box item.
|
||||
/// </summary>
|
||||
struct ColorItem
|
||||
{
|
||||
public ColorItem(XColor color, string name)
|
||||
{
|
||||
Color = color;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public XColor Color;
|
||||
public string Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
128
PdfSharp/Forms/DeviceInfos.cs
Normal file
128
PdfSharp/Forms/DeviceInfos.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Stefan Lange
|
||||
//
|
||||
// Copyright (c) 2005-2017 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.pdfsharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Security;
|
||||
//using System.Security.Permissions;
|
||||
|
||||
#if GDI
|
||||
namespace PdfSharp.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information about a physical device like a display or a printer.
|
||||
/// </summary>
|
||||
public struct DeviceInfos
|
||||
{
|
||||
/// <summary>
|
||||
/// Width, in millimeters, of the physical screen or device.
|
||||
/// </summary>
|
||||
public int HorizontalSize;
|
||||
|
||||
/// <summary>
|
||||
/// Height, in millimeters, of the physical screen or device.
|
||||
/// </summary>
|
||||
public int VerticalSize;
|
||||
|
||||
/// <summary>
|
||||
/// Width, in pixels, of the screen or device.
|
||||
/// </summary>
|
||||
public int HorizontalResolution;
|
||||
|
||||
/// <summary>
|
||||
/// Height, in pixels, of the screen or device.
|
||||
/// </summary>
|
||||
public int VerticalResolution;
|
||||
|
||||
/// <summary>
|
||||
/// Number of pixels per logical inch along the screen or device width.
|
||||
/// </summary>
|
||||
public int LogicalDpiX;
|
||||
|
||||
/// <summary>
|
||||
/// Number of pixels per logical inch along the screen or device height.
|
||||
/// </summary>
|
||||
public int LogicalDpiY;
|
||||
|
||||
/// <summary>
|
||||
/// Number of pixels per physical inch along the screen or device width.
|
||||
/// </summary>
|
||||
public float PhysicalDpiX;
|
||||
|
||||
/// <summary>
|
||||
/// Number of pixels per physical inch along the screen or device height.
|
||||
/// </summary>
|
||||
public float PhysicalDpiY;
|
||||
|
||||
/// <summary>
|
||||
/// The ratio of LogicalDpiX and PhysicalDpiX.
|
||||
/// </summary>
|
||||
public float ScaleX;
|
||||
|
||||
/// <summary>
|
||||
/// The ratio of LogicalDpiY and PhysicalDpiY.
|
||||
/// </summary>
|
||||
public float ScaleY;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a DeviceInfo for the specifed device context.
|
||||
/// </summary>
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
public static DeviceInfos GetInfos(IntPtr hdc)
|
||||
{
|
||||
DeviceInfos devInfo;
|
||||
|
||||
devInfo.HorizontalSize = GetDeviceCaps(hdc, HORZSIZE);
|
||||
devInfo.VerticalSize = GetDeviceCaps(hdc, VERTSIZE);
|
||||
devInfo.HorizontalResolution = GetDeviceCaps(hdc, HORZRES);
|
||||
devInfo.VerticalResolution = GetDeviceCaps(hdc, VERTRES);
|
||||
devInfo.LogicalDpiX = GetDeviceCaps(hdc, LOGPIXELSX);
|
||||
devInfo.LogicalDpiY = GetDeviceCaps(hdc, LOGPIXELSY);
|
||||
devInfo.PhysicalDpiX = devInfo.HorizontalResolution * 25.4f / devInfo.HorizontalSize;
|
||||
devInfo.PhysicalDpiY = devInfo.VerticalResolution * 25.4f / devInfo.VerticalSize;
|
||||
devInfo.ScaleX = devInfo.LogicalDpiX / devInfo.PhysicalDpiX;
|
||||
devInfo.ScaleY = devInfo.LogicalDpiY / devInfo.PhysicalDpiY;
|
||||
|
||||
return devInfo;
|
||||
}
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
static extern int GetDeviceCaps(IntPtr hdc, int capability);
|
||||
// ReSharper disable InconsistentNaming
|
||||
const int HORZSIZE = 4;
|
||||
const int VERTSIZE = 6;
|
||||
const int HORZRES = 8;
|
||||
const int VERTRES = 10;
|
||||
const int LOGPIXELSX = 88;
|
||||
const int LOGPIXELSY = 90;
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
}
|
||||
#endif
|
1077
PdfSharp/Forms/PagePreview.cs
Normal file
1077
PdfSharp/Forms/PagePreview.cs
Normal file
File diff suppressed because it is too large
Load Diff
130
PdfSharp/Forms/PagePreview.resx
Normal file
130
PdfSharp/Forms/PagePreview.resx
Normal file
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used forserialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</data>
|
||||
<data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.Name">
|
||||
<value>PagePreview</value>
|
||||
</data>
|
||||
<data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>80</value>
|
||||
</data>
|
||||
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>(Default)</value>
|
||||
</data>
|
||||
<data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>Private</value>
|
||||
</data>
|
||||
<data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>4, 4</value>
|
||||
</data>
|
||||
</root>
|
87
PdfSharp/Forms/PagePreviewCanvas.cs
Normal file
87
PdfSharp/Forms/PagePreviewCanvas.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Stefan Lange
|
||||
//
|
||||
// Copyright (c) 2005-2017 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.pdfsharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
#if GDI
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
#endif
|
||||
#if Wpf
|
||||
using System.Windows.Media;
|
||||
#endif
|
||||
|
||||
#if !GDI
|
||||
#error This file must only be included in GDI build.
|
||||
#endif
|
||||
|
||||
namespace PdfSharp.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the control that previews the page.
|
||||
/// </summary>
|
||||
class PagePreviewCanvas : System.Windows.Forms.Control
|
||||
{
|
||||
public PagePreviewCanvas(PagePreview preview)
|
||||
{
|
||||
_preview = preview;
|
||||
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
|
||||
}
|
||||
PagePreview _preview;
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
if (!_preview._showPage)
|
||||
return;
|
||||
|
||||
Graphics gfx = e.Graphics;
|
||||
bool zoomChanged;
|
||||
_preview.CalculatePreviewDimension(out zoomChanged);
|
||||
_preview.RenderPage(gfx);
|
||||
}
|
||||
|
||||
protected override void OnPaintBackground(PaintEventArgs e)
|
||||
{
|
||||
if (!_preview._showPage)
|
||||
{
|
||||
e.Graphics.Clear(_preview._desktopColor);
|
||||
return;
|
||||
}
|
||||
bool zoomChanged;
|
||||
_preview.CalculatePreviewDimension(out zoomChanged);
|
||||
_preview.PaintBackground(e.Graphics);
|
||||
}
|
||||
|
||||
protected override void OnSizeChanged(EventArgs e)
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
42
PdfSharp/Forms/PagePreviewCanvas.resx
Normal file
42
PdfSharp/Forms/PagePreviewCanvas.resx
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="ResMimeType">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="Version">
|
||||
<value>1.0.0.0</value>
|
||||
</resheader>
|
||||
<resheader name="Reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="Writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
54
PdfSharp/Forms/enums/RenderMode.cs
Normal file
54
PdfSharp/Forms/enums/RenderMode.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Stefan Lange
|
||||
//
|
||||
// Copyright (c) 2005-2017 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.pdfsharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if GDI
|
||||
namespace PdfSharp.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies how to reander the preview.
|
||||
/// </summary>
|
||||
public enum RenderMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Draw immediately.
|
||||
/// </summary>
|
||||
Direct = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Draw using a metafile.
|
||||
/// </summary>
|
||||
Metafile = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Draw using a bitmap image.
|
||||
/// </summary>
|
||||
Bitmap = 2
|
||||
}
|
||||
}
|
||||
#endif
|
120
PdfSharp/Forms/enums/Zoom.cs
Normal file
120
PdfSharp/Forms/enums/Zoom.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
#region PDFsharp - A .NET library for processing PDF
|
||||
//
|
||||
// Authors:
|
||||
// Stefan Lange
|
||||
//
|
||||
// Copyright (c) 2005-2017 empira Software GmbH, Cologne Area (Germany)
|
||||
//
|
||||
// http://www.pdfsharp.com
|
||||
// http://sourceforge.net/projects/pdfsharp
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
#endregion
|
||||
|
||||
#if GDI
|
||||
namespace PdfSharp.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a zoom factor used in the preview control.
|
||||
/// </summary>
|
||||
public enum Zoom
|
||||
{
|
||||
/// <summary>
|
||||
/// The smallest possible zoom factor.
|
||||
/// </summary>
|
||||
Mininum = 10,
|
||||
|
||||
/// <summary>
|
||||
/// The largest possible zoom factor.
|
||||
/// </summary>
|
||||
Maximum = 800,
|
||||
|
||||
/// <summary>
|
||||
/// A pre-defined zoom factor.
|
||||
/// </summary>
|
||||
Percent800 = 800,
|
||||
|
||||
/// <summary>
|
||||
/// A pre-defined zoom factor.
|
||||
/// </summary>
|
||||
Percent600 = 600,
|
||||
|
||||
/// <summary>
|
||||
/// A pre-defined zoom factor.
|
||||
/// </summary>
|
||||
Percent400 = 400,
|
||||
|
||||
/// <summary>
|
||||
/// A pre-defined zoom factor.
|
||||
/// </summary>
|
||||
Percent200 = 200,
|
||||
|
||||
/// <summary>
|
||||
/// A pre-defined zoom factor.
|
||||
/// </summary>
|
||||
Percent150 = 150,
|
||||
|
||||
/// <summary>
|
||||
/// A pre-defined zoom factor.
|
||||
/// </summary>
|
||||
Percent100 = 100,
|
||||
|
||||
/// <summary>
|
||||
/// A pre-defined zoom factor.
|
||||
/// </summary>
|
||||
Percent75 = 75,
|
||||
|
||||
/// <summary>
|
||||
/// A pre-defined zoom factor.
|
||||
/// </summary>
|
||||
Percent50 = 50,
|
||||
|
||||
/// <summary>
|
||||
/// A pre-defined zoom factor.
|
||||
/// </summary>
|
||||
Percent25 = 25,
|
||||
|
||||
/// <summary>
|
||||
/// A pre-defined zoom factor.
|
||||
/// </summary>
|
||||
Percent10 = 10,
|
||||
|
||||
/// <summary>
|
||||
/// Sets the zoom factor so that the document fits horizontally into the window.
|
||||
/// </summary>
|
||||
BestFit = -1,
|
||||
|
||||
/// <summary>
|
||||
/// Sets the zoom factor so that the printable area of the document fits horizontally into the window.
|
||||
/// Currently not yet implemented and the same as ZoomBestFit.
|
||||
/// </summary>
|
||||
TextFit = -2,
|
||||
|
||||
/// <summary>
|
||||
/// Sets the zoom factor so that the whole document fits completely into the window.
|
||||
/// </summary>
|
||||
FullPage = -3,
|
||||
|
||||
/// <summary>
|
||||
/// Sets the zoom factor so that the document is displayed in its real physical size (based on the DPI information returned from the OS for the current monitor).
|
||||
/// </summary>
|
||||
OriginalSize = -4,
|
||||
}
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user