├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
└── src
├── FastReport.OpenSource.Winforms.Demo
├── App.config
├── FastReport.OpenSource.Winforms.Demo.csproj
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Reports
│ ├── CheckBox.frx
│ ├── Image.frx
│ ├── Lines and Shapes.frx
│ ├── Master-Detail.frx
│ ├── Matrix.frx
│ ├── Pharmacode.frx
│ ├── Polygon.frx
│ └── nwind.xml
└── Resources
│ ├── 068.png
│ ├── frst.png
│ ├── lst.png
│ ├── nxt.png
│ └── prr.png
├── FastReport.OpenSource.Winforms.sln
└── FastReport.OpenSource.Winforms
├── Extensions.cs
├── FRPreview.Designer.cs
├── FRPreview.cs
├── FRPreview.resx
├── FRPrintPreviewControl.Designer.cs
├── FRPrintPreviewControl.cs
├── FRPrintPreviewControl.resx
├── FRPrintPreviewDialog.Designer.cs
├── FRPrintPreviewDialog.cs
├── FRPrintPreviewDialog.resx
├── FastReport.OpenSource.Winforms.csproj
├── Resources
├── print_16.png
├── print_help_16.png
├── print_preview.bmp
├── print_setup_16.png
└── window_print.bmp
├── ZoomMode.cs
├── print_preview.bmp
└── window_print.bmp
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Rafael Teno Dias
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FastReport.OpenSource.Winforms
2 | Métodos de extensão para impressão direta e preview para o FastReport.OpenSource para Winforms .NET Core/.NET.
3 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/FastReport.OpenSource.Winforms.Demo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {B98F7D90-37F1-4BC8-A7E2-48922FB67452}
8 | WinExe
9 | WinFormsOpenSource
10 | WinFormsOpenSource
11 | v4.6.1
12 | 512
13 | true
14 | true
15 | publish\
16 | true
17 | Disk
18 | false
19 | Foreground
20 | 7
21 | Days
22 | false
23 | false
24 | true
25 | 0
26 | 1.0.0.%2a
27 | false
28 | false
29 | true
30 |
31 |
32 |
33 |
34 | AnyCPU
35 | true
36 | full
37 | false
38 | bin\Debug\
39 | DEBUG;TRACE
40 | prompt
41 | 4
42 |
43 |
44 | AnyCPU
45 | pdbonly
46 | true
47 | bin\Release\
48 | TRACE
49 | prompt
50 | 4
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | Form
71 |
72 |
73 | Form1.cs
74 |
75 |
76 |
77 |
78 | Form1.cs
79 |
80 |
81 | ResXFileCodeGenerator
82 | Resources.Designer.cs
83 | Designer
84 |
85 |
86 | True
87 | Resources.resx
88 | True
89 |
90 |
91 | SettingsSingleFileGenerator
92 | Settings.Designer.cs
93 |
94 |
95 | True
96 | Settings.settings
97 | True
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | Microsoft .NET Framework 4.6.1 %28x86 and x64%29
129 | true
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | false
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 | 2020.3.4
143 |
144 |
145 | 2020.4.0
146 |
147 |
148 |
149 |
150 | {72d2953c-ec73-483f-adc3-aeba2c29f05e}
151 | WindowsFormsApp1
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | using FastReport.OpenSource.Winforms;
2 |
3 | namespace WinFormsOpenSource
4 | {
5 | partial class Form1
6 | {
7 | ///
8 | /// Required designer variable.
9 | ///
10 | private System.ComponentModel.IContainer components = null;
11 |
12 | ///
13 | /// Clean up any resources being used.
14 | ///
15 | /// true if managed resources should be disposed; otherwise, false.
16 | protected override void Dispose(bool disposing)
17 | {
18 | if (disposing && (components != null))
19 | {
20 | components.Dispose();
21 | }
22 | base.Dispose(disposing);
23 | }
24 |
25 | #region Windows Form Designer generated code
26 |
27 | ///
28 | /// Required method for Designer support - do not modify
29 | /// the contents of this method with the code editor.
30 | ///
31 | private void InitializeComponent()
32 | {
33 | this.ReportsList = new System.Windows.Forms.ListBox();
34 | this.frPrintPreviewControl1 = new FastReport.OpenSource.Winforms.FRPrintPreviewControl();
35 | this.SuspendLayout();
36 | //
37 | // ReportsList
38 | //
39 | this.ReportsList.Dock = System.Windows.Forms.DockStyle.Left;
40 | this.ReportsList.FormattingEnabled = true;
41 | this.ReportsList.Location = new System.Drawing.Point(0, 0);
42 | this.ReportsList.Name = "ReportsList";
43 | this.ReportsList.Size = new System.Drawing.Size(190, 476);
44 | this.ReportsList.TabIndex = 3;
45 | this.ReportsList.SelectedIndexChanged += new System.EventHandler(this.ReportsList_SelectedIndexChanged);
46 | //
47 | // frPrintPreviewControl1
48 | //
49 | this.frPrintPreviewControl1.Dock = System.Windows.Forms.DockStyle.Fill;
50 | this.frPrintPreviewControl1.Document = null;
51 | this.frPrintPreviewControl1.Location = new System.Drawing.Point(190, 0);
52 | this.frPrintPreviewControl1.Name = "frPrintPreviewControl1";
53 | this.frPrintPreviewControl1.ShowToolbar = true;
54 | this.frPrintPreviewControl1.Size = new System.Drawing.Size(509, 476);
55 | this.frPrintPreviewControl1.TabIndex = 4;
56 | //
57 | // Form1
58 | //
59 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
60 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
61 | this.ClientSize = new System.Drawing.Size(699, 476);
62 | this.Controls.Add(this.frPrintPreviewControl1);
63 | this.Controls.Add(this.ReportsList);
64 | this.Name = "Form1";
65 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
66 | this.Text = "Report viewer";
67 | this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
68 | this.ResumeLayout(false);
69 |
70 | }
71 |
72 | #endregion
73 | private System.Windows.Forms.ListBox ReportsList;
74 | private FRPrintPreviewControl frPrintPreviewControl1;
75 | }
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Drawing;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Windows.Forms;
8 | using FastReport;
9 | using FastReport.OpenSource.Winforms;
10 | using FastReport.Utils;
11 |
12 | namespace WinFormsOpenSource
13 | {
14 | public partial class Form1 : Form
15 | {
16 | public string ReportsPath = Config.ApplicationFolder + @"..\..\Reports\";
17 |
18 | public Form1()
19 | {
20 | InitializeComponent();
21 | LoadReportList();
22 | }
23 |
24 | public Report Report { get; set; } = new Report();
25 |
26 | public void LoadReportList()
27 | {
28 | var filesname = Directory.GetFiles(ReportsPath, "*.frx").ToList();
29 |
30 | foreach (var file in filesname)
31 | {
32 | ReportsList.Items.Add(Path.GetFileNameWithoutExtension(file));
33 | }
34 | }
35 |
36 | private void ReportsList_SelectedIndexChanged(object sender, EventArgs e)
37 | {
38 | if (ReportsList.SelectedItem == null) return;
39 | Report.Load(ReportsPath + ReportsList.SelectedItem.ToString() + ".frx"); //Загружаем шаблон отчета
40 | DataSet data = new DataSet(); //Создаем источник данных
41 | data.ReadXml(ReportsPath + "nwind.xml"); //Загружаем в источник данных базу
42 | Report.RegisterData(data, "NorthWind"); //Регистрируем источник данных в отчете
43 | Report.Prepare(); //Выполняем предварительное построение отчета
44 | Report.Preview(frPrintPreviewControl1);
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace WinFormsOpenSource
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("WinFormsOpenSource")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WinFormsOpenSource")]
13 | [assembly: AssemblyCopyright("Copyright © 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b98f7d90-37f1-4bc8-a7e2-48922fb67452")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WinFormsOpenSource.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinFormsOpenSource.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap _068 {
67 | get {
68 | object obj = ResourceManager.GetObject("068", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Bitmap.
75 | ///
76 | internal static System.Drawing.Bitmap frst {
77 | get {
78 | object obj = ResourceManager.GetObject("frst", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 |
83 | ///
84 | /// Looks up a localized resource of type System.Drawing.Bitmap.
85 | ///
86 | internal static System.Drawing.Bitmap lst {
87 | get {
88 | object obj = ResourceManager.GetObject("lst", resourceCulture);
89 | return ((System.Drawing.Bitmap)(obj));
90 | }
91 | }
92 |
93 | ///
94 | /// Looks up a localized resource of type System.Drawing.Bitmap.
95 | ///
96 | internal static System.Drawing.Bitmap nxt {
97 | get {
98 | object obj = ResourceManager.GetObject("nxt", resourceCulture);
99 | return ((System.Drawing.Bitmap)(obj));
100 | }
101 | }
102 |
103 | ///
104 | /// Looks up a localized resource of type System.Drawing.Bitmap.
105 | ///
106 | internal static System.Drawing.Bitmap prr {
107 | get {
108 | object obj = ResourceManager.GetObject("prr", resourceCulture);
109 | return ((System.Drawing.Bitmap)(obj));
110 | }
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\068.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\frst.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
128 | ..\Resources\lst.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
131 | ..\Resources\nxt.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
132 |
133 |
134 | ..\Resources\prr.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
135 |
136 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WinFormsOpenSource.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Reports/CheckBox.frx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Reports/Image.frx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Reports/Lines and Shapes.frx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Reports/Master-Detail.frx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Reports/Matrix.frx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Reports/Pharmacode.frx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Reports/Polygon.frx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Resources/068.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms.Demo/Resources/068.png
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Resources/frst.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms.Demo/Resources/frst.png
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Resources/lst.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms.Demo/Resources/lst.png
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Resources/nxt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms.Demo/Resources/nxt.png
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.Demo/Resources/prr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms.Demo/Resources/prr.png
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30114.105
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastReport.OpenSource.Winforms", "FastReport.OpenSource.Winforms\FastReport.OpenSource.Winforms.csproj", "{72D2953C-EC73-483F-ADC3-AEBA2C29F05E}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastReport.OpenSource.Winforms.Demo", "FastReport.OpenSource.Winforms.Demo\FastReport.OpenSource.Winforms.Demo.csproj", "{B98F7D90-37F1-4BC8-A7E2-48922FB67452}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {0F4EEBEE-2B8D-4AB0-BDE7-11EB587A55DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {0F4EEBEE-2B8D-4AB0-BDE7-11EB587A55DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {0F4EEBEE-2B8D-4AB0-BDE7-11EB587A55DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {0F4EEBEE-2B8D-4AB0-BDE7-11EB587A55DD}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {B98F7D90-37F1-4BC8-A7E2-48922FB67452}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {B98F7D90-37F1-4BC8-A7E2-48922FB67452}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {B98F7D90-37F1-4BC8-A7E2-48922FB67452}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {B98F7D90-37F1-4BC8-A7E2-48922FB67452}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {72D2953C-EC73-483F-ADC3-AEBA2C29F05E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {72D2953C-EC73-483F-ADC3-AEBA2C29F05E}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {72D2953C-EC73-483F-ADC3-AEBA2C29F05E}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {72D2953C-EC73-483F-ADC3-AEBA2C29F05E}.Release|Any CPU.Build.0 = Release|Any CPU
28 | EndGlobalSection
29 | GlobalSection(SolutionProperties) = preSolution
30 | HideSolutionNode = FALSE
31 | EndGlobalSection
32 | GlobalSection(ExtensibilityGlobals) = postSolution
33 | SolutionGuid = {A911D402-3872-4AB7-9A8E-030761A8427D}
34 | EndGlobalSection
35 | EndGlobal
36 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 | using System.Drawing.Printing;
3 | using System.IO;
4 | using System.Windows.Forms;
5 | using FastReport.Export;
6 | using FastReport.Export.Image;
7 | using FastReport.Utils;
8 |
9 | namespace FastReport.OpenSource.Winforms
10 | {
11 | public static class Extensions
12 | {
13 | #region Fields
14 |
15 | private const float scaleFactor = 300 / 96f;
16 |
17 | #endregion Fields
18 |
19 | #region Methods
20 |
21 | public static void PrintWithDialog(this Report report)
22 | {
23 | using (var dlg = new PrintDialog())
24 | {
25 | dlg.AllowSomePages = true;
26 | dlg.AllowSelection = true;
27 | dlg.UseEXDialog = true;
28 |
29 | if (dlg.ShowDialog() != DialogResult.OK) return;
30 |
31 | report.Print(dlg.PrinterSettings);
32 | }
33 | }
34 |
35 | public static void Print(this Report report, PrinterSettings settings = null)
36 | {
37 | var doc = report.PrepareDoc(settings);
38 | if (doc == null) return;
39 |
40 | doc.Print();
41 | doc.Dispose();
42 | }
43 |
44 | public static void Preview(this Report report, FRPrintPreviewControl preview, PrinterSettings settings = null)
45 | {
46 | var doc = report.PrepareDoc(settings);
47 | if (doc == null) return;
48 |
49 | preview.Document = doc;
50 | }
51 |
52 | public static void Preview(this Report report, PrinterSettings settings = null)
53 | {
54 | var doc = report.PrepareDoc(settings);
55 | if (doc == null) return;
56 |
57 | using (var preview = new FRPrintPreviewDialog() { Document = doc })
58 | preview.ShowDialog();
59 | doc.Dispose();
60 | }
61 |
62 | private static PrintDocument PrepareDoc(this Report report, PrinterSettings settings = null)
63 | {
64 | if (report.PreparedPages.Count < 1)
65 | {
66 | report.Prepare();
67 | if (report.PreparedPages.Count < 1) return null;
68 | }
69 |
70 | var page = 0;
71 | var exp = new ImageExport { ImageFormat = ImageExportFormat.Png, Resolution = 600 };
72 |
73 | var doc = new PrintDocument { DocumentName = report.Name };
74 | if (settings != null)
75 | doc.PrinterSettings = settings;
76 |
77 | // Ajustando o tamanho da pagina
78 | doc.QueryPageSettings += (sender, args) =>
79 | {
80 | var rPage = report.PreparedPages.GetPage(page);
81 | args.PageSettings.Landscape = rPage.Landscape;
82 | args.PageSettings.Margins = new Margins((int)(scaleFactor * rPage.LeftMargin * Units.HundrethsOfInch),
83 | (int)(scaleFactor * rPage.RightMargin * Units.HundrethsOfInch),
84 | (int)(scaleFactor * rPage.TopMargin * Units.HundrethsOfInch),
85 | (int)(scaleFactor * rPage.BottomMargin * Units.HundrethsOfInch));
86 |
87 | args.PageSettings.PaperSize = new PaperSize("Custom", (int)(ExportUtils.GetPageWidth(rPage) * scaleFactor * Units.HundrethsOfInch),
88 | (int)(ExportUtils.GetPageHeight(rPage) * scaleFactor * Units.HundrethsOfInch));
89 | };
90 |
91 | doc.PrintPage += (sender, args) =>
92 | {
93 | using (var ms = new MemoryStream())
94 | {
95 | exp.PageRange = PageRange.PageNumbers;
96 | exp.PageNumbers = $"{page + 1}";
97 | exp.Export(report, ms);
98 |
99 | args.Graphics.DrawImage(Image.FromStream(ms), args.PageBounds);
100 | }
101 |
102 | page++;
103 |
104 | args.HasMorePages = page < report.PreparedPages.Count;
105 | };
106 |
107 | doc.EndPrint += (sender, args) => page = 0;
108 | doc.Disposed += (sender, args) => exp?.Dispose();
109 |
110 | return doc;
111 | }
112 |
113 | #endregion Methods
114 | }
115 | }
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/FRPreview.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FastReport.OpenSource.Winforms
2 | {
3 | partial class FRPreview
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.SuspendLayout();
32 | //
33 | // FRPreview
34 | //
35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
37 | this.Name = "FRPreview";
38 | this.Size = new System.Drawing.Size(243, 139);
39 | this.ResumeLayout(false);
40 |
41 | }
42 |
43 | #endregion
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/FRPreview.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Drawing.Imaging;
6 | using System.Drawing.Printing;
7 | using System.Windows.Forms;
8 |
9 | namespace FastReport.OpenSource.Winforms
10 | {
11 | [ToolboxItem(false)]
12 | internal partial class FRPreview : UserControl
13 | {
14 | #region Fields
15 |
16 | private PrintDocument doc;
17 | private ZoomMode zoomMode;
18 | private double zoom;
19 | private int startPage;
20 | private Brush backBrush;
21 | private Point ptLast;
22 | private PointF himm2Pix = new PointF(-1, -1);
23 | private bool cancel;
24 | private const int MARGIN = 4;
25 | private bool Inicializando;
26 | private readonly List pageImages;
27 |
28 | #endregion Fields
29 |
30 | #region Constructors
31 |
32 | public FRPreview()
33 | {
34 | Inicializando = true;
35 | pageImages = new List();
36 | BackColor = SystemColors.AppWorkspace;
37 | zoomMode = ZoomMode.FullPage;
38 | startPage = 0;
39 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
40 | InitializeComponent();
41 | Inicializando = false;
42 | }
43 |
44 | #endregion Constructors
45 |
46 | #region Propriedades
47 |
48 | ///
49 | /// Gets or sets the being previewed.
50 | ///
51 | public PrintDocument Document
52 | {
53 | get => doc;
54 | set
55 | {
56 | if (value == doc)
57 | return;
58 |
59 | doc = value;
60 | RefreshPreview();
61 | }
62 | }
63 |
64 | ///
65 | /// Gets a value that indicates whether the is being rendered.
66 | ///
67 | [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
68 | public bool IsRendering { get; private set; }
69 |
70 | ///
71 | /// Gets or sets how the zoom should be adjusted when the control is resized.
72 | ///
73 | [DefaultValue(ZoomMode.FullPage)]
74 | public ZoomMode ZoomMode
75 | {
76 | get => zoomMode;
77 | set
78 | {
79 | if (value == zoomMode)
80 | return;
81 |
82 | zoomMode = value;
83 | UpdateScrollBars();
84 | OnZoomModeChanged();
85 | }
86 | }
87 |
88 | ///
89 | /// Gets or sets a custom zoom factor used when the property
90 | /// is set to Custom.
91 | ///
92 | [Browsable(false),
93 | DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
94 | public double Zoom
95 | {
96 | get => zoom;
97 | set
98 | {
99 | if (Equals(value, zoom) &&
100 | ZoomMode == ZoomMode.Custom)
101 | return;
102 |
103 | ZoomMode = ZoomMode.Custom;
104 | zoom = value;
105 | UpdateScrollBars();
106 | OnZoomModeChanged();
107 | }
108 | }
109 |
110 | ///
111 | /// Gets or sets the first page being previewed.
112 | ///
113 | ///
114 | /// There may be one or two pages visible depending on the setting of the
115 | /// property.
116 | ///
117 | [Browsable(false),
118 | DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
119 | public int StartPage
120 | {
121 | get => startPage;
122 | set
123 | {
124 | // validate new setting
125 | if (value > PageCount - 1)
126 | value = PageCount - 1;
127 |
128 | if (value < 0)
129 | value = 0;
130 |
131 | // apply new setting
132 | if (value == startPage)
133 | return;
134 |
135 | startPage = value;
136 | UpdateScrollBars();
137 | OnStartPageChanged();
138 | }
139 | }
140 |
141 | ///
142 | /// Gets the number of pages available for preview.
143 | ///
144 | ///
145 | /// This number increases as the document is rendered into the control.
146 | ///
147 | [Browsable(false),
148 | DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
149 | public int PageCount => pageImages.Count;
150 |
151 | ///
152 | /// Gets or sets the control's background color.
153 | ///
154 | [DefaultValue(typeof(Color), "AppWorkspace")]
155 | public sealed override Color BackColor
156 | {
157 | get => base.BackColor;
158 | set
159 | {
160 | base.BackColor = value;
161 | backBrush = new SolidBrush(value);
162 | }
163 | }
164 |
165 | #endregion Propriedades
166 |
167 | #region Methods
168 |
169 | ///
170 | /// Prints the current document honoring the selected page range.
171 | ///
172 | public void Print(bool showPrintDialog = false)
173 | {
174 | PrinterSettings ps;
175 | if (showPrintDialog)
176 | {
177 | using (var dlg = new PrintDialog())
178 | {
179 | // configure dialog
180 | dlg.AllowSomePages = true;
181 | dlg.AllowSelection = true;
182 | dlg.UseEXDialog = true;
183 | dlg.Document = doc;
184 |
185 | // show allowed page range
186 | ps = dlg.PrinterSettings;
187 | ps.MinimumPage = ps.FromPage = 1;
188 | ps.MaximumPage = ps.ToPage = PageCount;
189 |
190 | // show dialog
191 | if (dlg.ShowDialog(this) == DialogResult.Cancel)
192 | return;
193 | }
194 | }
195 | else
196 | {
197 | ps = new PrinterSettings();
198 | ps.MinimumPage = ps.FromPage = 1;
199 | ps.MaximumPage = ps.ToPage = PageCount;
200 | }
201 |
202 | var page = (PageSettings)doc.DefaultPageSettings.Clone();
203 | doc.PrinterSettings = ps;
204 | doc.DefaultPageSettings = page;
205 |
206 | var first = ps.MinimumPage - 1;
207 | var last = ps.MaximumPage - 1;
208 | switch (ps.PrintRange)
209 | {
210 | case PrintRange.AllPages:
211 | Document.Print();
212 | return;
213 |
214 | case PrintRange.CurrentPage:
215 | first = last = StartPage;
216 | break;
217 |
218 | case PrintRange.Selection:
219 | first = last = StartPage;
220 | if (ZoomMode == ZoomMode.TwoPages)
221 | {
222 | last = Math.Min(first + 1, PageCount - 1);
223 | }
224 | break;
225 |
226 | case PrintRange.SomePages:
227 | first = ps.FromPage - 1;
228 | last = ps.ToPage - 1;
229 | break;
230 | }
231 |
232 | // print using helper class
233 | var dp = new DocumentPrinter(this, first, last);
234 | dp.Print();
235 | }
236 |
237 | ///
238 | /// Regenerates the preview to reflect changes in the document layout.
239 | ///
240 | public void RefreshPreview()
241 | {
242 | // render into PrintController
243 | if (doc != null)
244 | {
245 | // prepare to render preview document
246 | pageImages.Clear();
247 | var savePc = doc.PrintController;
248 |
249 | // render preview document
250 | try
251 | {
252 | cancel = false;
253 | IsRendering = true;
254 | doc.PrintController = new PreviewPrintController();
255 | doc.PrintPage += _doc_PrintPage;
256 | doc.EndPrint += _doc_EndPrint;
257 | doc.Print();
258 | }
259 | finally
260 | {
261 | cancel = false;
262 | IsRendering = false;
263 | doc.PrintPage -= _doc_PrintPage;
264 | doc.EndPrint -= _doc_EndPrint;
265 | doc.PrintController = savePc;
266 | }
267 | }
268 |
269 | // update
270 | OnPageCountChanged();
271 | UpdatePreview();
272 | UpdateScrollBars();
273 | }
274 |
275 | ///
276 | /// Stops rendering the .
277 | ///
278 | public void Cancel()
279 | {
280 | cancel = true;
281 | }
282 |
283 | #endregion Methods
284 |
285 | #region Events
286 |
287 | ///
288 | /// Occurs when the value of the property changes.
289 | ///
290 | public event EventHandler StartPageChanged;
291 |
292 | ///
293 | /// Raises the event.
294 | ///
295 | private void OnStartPageChanged()
296 | {
297 | if (StartPageChanged == null) return;
298 | if (!(StartPageChanged.Target is ISynchronizeInvoke synchronizeInvoke))
299 | StartPageChanged.DynamicInvoke(this, EventArgs.Empty);
300 | else
301 | synchronizeInvoke.Invoke(StartPageChanged, new object[] { this, EventArgs.Empty });
302 | }
303 |
304 | ///
305 | /// Occurs when the value of the property changes.
306 | ///
307 | public event EventHandler PageCountChanged;
308 |
309 | ///
310 | /// Raises the event.
311 | ///
312 | private void OnPageCountChanged()
313 | {
314 | if (PageCountChanged == null) return;
315 | if (!(PageCountChanged.Target is ISynchronizeInvoke synchronizeInvoke))
316 | PageCountChanged.DynamicInvoke(this, EventArgs.Empty);
317 | else
318 | synchronizeInvoke.Invoke(PageCountChanged, new object[] { this, EventArgs.Empty });
319 | }
320 |
321 | ///
322 | /// Occurs when the value of the property changes.
323 | ///
324 | public event EventHandler ZoomModeChanged;
325 |
326 | ///
327 | /// Raises the event.
328 | ///
329 | private void OnZoomModeChanged()
330 | {
331 | if (ZoomModeChanged == null) return;
332 | if (!(ZoomModeChanged.Target is ISynchronizeInvoke synchronizeInvoke))
333 | ZoomModeChanged.DynamicInvoke(this, EventArgs.Empty);
334 | else
335 | synchronizeInvoke.Invoke(ZoomModeChanged, new object[] { this, EventArgs.Empty });
336 | }
337 |
338 | #endregion Events
339 |
340 | #region Overrides
341 |
342 | protected override void OnPaintBackground(PaintEventArgs e)
343 | {
344 | // we're painting it all, so don't call base class
345 | //base.OnPaintBackground(e);
346 | }
347 |
348 | protected override void OnPaint(PaintEventArgs e)
349 | {
350 | var img = GetImage(StartPage);
351 | if (img != null)
352 | {
353 | var rc = GetImageRectangle(img);
354 | if (rc.Width > 2 && rc.Height > 2)
355 | {
356 | // adjust for scrollbars
357 | rc.Offset(AutoScrollPosition);
358 |
359 | // render single page
360 | if (zoomMode != ZoomMode.TwoPages)
361 | {
362 | RenderPage(e.Graphics, img, rc);
363 | }
364 | else // render two pages
365 | {
366 | // render first page
367 | rc.Width = (rc.Width - MARGIN) / 2;
368 | RenderPage(e.Graphics, img, rc);
369 |
370 | // render second page
371 | img = GetImage(StartPage + 1);
372 | if (img != null)
373 | {
374 | // update bounds in case orientation changed
375 | rc = GetImageRectangle(img);
376 | rc.Width = (rc.Width - MARGIN) / 2;
377 |
378 | // render second page
379 | rc.Offset(rc.Width + MARGIN, 0);
380 | RenderPage(e.Graphics, img, rc);
381 | }
382 | }
383 | }
384 | }
385 |
386 | // paint background
387 | e.Graphics.FillRectangle(backBrush, ClientRectangle);
388 | }
389 |
390 | protected override void OnSizeChanged(EventArgs e)
391 | {
392 | UpdateScrollBars();
393 | base.OnSizeChanged(e);
394 | }
395 |
396 | // pan by dragging preview pane
397 | protected override void OnMouseDown(MouseEventArgs e)
398 | {
399 | base.OnMouseDown(e);
400 | if (e.Button != MouseButtons.Left ||
401 | AutoScrollMinSize == Size.Empty)
402 | return;
403 |
404 | Cursor = Cursors.NoMove2D;
405 | ptLast = new Point(e.X, e.Y);
406 | }
407 |
408 | protected override void OnMouseUp(MouseEventArgs e)
409 | {
410 | base.OnMouseUp(e);
411 | if (e.Button == MouseButtons.Left && Cursor == Cursors.NoMove2D)
412 | Cursor = Cursors.Default;
413 | }
414 |
415 | protected override void OnMouseMove(MouseEventArgs e)
416 | {
417 | base.OnMouseMove(e);
418 | if (Cursor != Cursors.NoMove2D)
419 | return;
420 |
421 | var dx = e.X - ptLast.X;
422 | var dy = e.Y - ptLast.Y;
423 | if (dx == 0 && dy == 0)
424 | return;
425 |
426 | var pt = AutoScrollPosition;
427 | AutoScrollPosition = new Point(-(pt.X + dx), -(pt.Y + dy));
428 | ptLast = new Point(e.X, e.Y);
429 | }
430 |
431 | // zoom in/out using control+wheel
432 | protected override void OnMouseWheel(MouseEventArgs e)
433 | {
434 | if ((ModifierKeys & Keys.Control) != 0)
435 | {
436 | // calculate event position in document percentage units
437 | var asp = AutoScrollPosition;
438 | var sms = AutoScrollMinSize;
439 | var ptMouse = e.Location;
440 | var ptDoc = new PointF(
441 | sms.Width > 0 ? (ptMouse.X - asp.X) / (float)sms.Width : 0,
442 | sms.Height > 0 ? (ptMouse.Y - asp.Y) / (float)sms.Height : 0
443 | );
444 |
445 | // update the zoom
446 | var valor = Zoom * (e.Delta > 0 ? 1.1 : 0.9);
447 | Zoom = Math.Min(5, Math.Max(.1, valor));
448 |
449 | // restore position in document percentage units
450 | sms = AutoScrollMinSize;
451 | AutoScrollPosition = new Point(
452 | (int)(ptDoc.X * sms.Width - ptMouse.X),
453 | (int)(ptDoc.Y * sms.Height - ptMouse.Y));
454 | }
455 | else
456 | {
457 | // allow base class to scroll only if not zooming
458 | base.OnMouseWheel(e);
459 | }
460 | }
461 |
462 | // keyboard support
463 | protected override bool IsInputKey(Keys keyData)
464 | {
465 | switch (keyData)
466 | {
467 | case Keys.Left:
468 | case Keys.Up:
469 | case Keys.Right:
470 | case Keys.Down:
471 | case Keys.PageUp:
472 | case Keys.PageDown:
473 | case Keys.Home:
474 | case Keys.End:
475 | return true;
476 | }
477 | return base.IsInputKey(keyData);
478 | }
479 |
480 | protected override void OnKeyDown(KeyEventArgs e)
481 | {
482 | base.OnKeyDown(e);
483 | if (e.Handled)
484 | return;
485 |
486 | switch (e.KeyCode)
487 | {
488 | // arrow keys scroll or browse, depending on ZoomMode
489 | case Keys.Left:
490 | case Keys.Up:
491 | case Keys.Right:
492 | case Keys.Down:
493 |
494 | // browse
495 | if (ZoomMode == ZoomMode.FullPage || ZoomMode == ZoomMode.TwoPages)
496 | {
497 | switch (e.KeyCode)
498 | {
499 | case Keys.Left:
500 | case Keys.Up:
501 | StartPage--;
502 | break;
503 |
504 | case Keys.Right:
505 | case Keys.Down:
506 | StartPage++;
507 | break;
508 | }
509 | break;
510 | }
511 |
512 | // scroll
513 | var pt = AutoScrollPosition;
514 | switch (e.KeyCode)
515 | {
516 | case Keys.Left: pt.X += 20; break;
517 | case Keys.Right: pt.X -= 20; break;
518 | case Keys.Up: pt.Y += 20; break;
519 | case Keys.Down: pt.Y -= 20; break;
520 | }
521 | AutoScrollPosition = new Point(-pt.X, -pt.Y);
522 | break;
523 |
524 | // page up/down browse pages
525 | case Keys.PageUp:
526 | StartPage--;
527 | break;
528 |
529 | case Keys.PageDown:
530 | StartPage++;
531 | break;
532 |
533 | // home/end
534 | case Keys.Home:
535 | AutoScrollPosition = Point.Empty;
536 | StartPage = 0;
537 | break;
538 |
539 | case Keys.End:
540 | AutoScrollPosition = Point.Empty;
541 | StartPage = PageCount - 1;
542 | break;
543 |
544 | default:
545 | return;
546 | }
547 |
548 | // if we got here, the event was handled
549 | e.Handled = true;
550 | }
551 |
552 | #endregion Overrides
553 |
554 | #region Implementation
555 |
556 | private void _doc_PrintPage(object sender, PrintPageEventArgs e)
557 | {
558 | SyncPageImages(false);
559 | if (cancel)
560 | {
561 | e.Cancel = true;
562 | }
563 | }
564 |
565 | private void _doc_EndPrint(object sender, PrintEventArgs e)
566 | {
567 | SyncPageImages(true);
568 | }
569 |
570 | private void SyncPageImages(bool lastPageReady)
571 | {
572 | var pv = (PreviewPrintController)doc.PrintController;
573 | if (pv == null) return;
574 |
575 | var pageInfo = pv.GetPreviewPageInfo();
576 | var count = lastPageReady ? pageInfo.Length : pageInfo.Length - 1;
577 | for (var i = pageImages.Count; i < count; i++)
578 | {
579 | var img = pageInfo[i].Image;
580 | pageImages.Add(img);
581 |
582 | OnPageCountChanged();
583 |
584 | if (StartPage < 0) StartPage = 0;
585 | if (i == StartPage || i == StartPage + 1)
586 | {
587 | Refresh();
588 | }
589 | Application.DoEvents();
590 | }
591 | }
592 |
593 | private Image GetImage(int page)
594 | {
595 | return page > -1 && page < PageCount ? pageImages[page] : null;
596 | }
597 |
598 | private Rectangle GetImageRectangle(Image img)
599 | {
600 | // start with regular image rectangle
601 | var sz = GetImageSizeInPixels(img);
602 | var rc = new Rectangle(0, 0, sz.Width, sz.Height);
603 |
604 | // calculate zoom
605 | var rcCli = this.ClientRectangle;
606 | switch (zoomMode)
607 | {
608 | case ZoomMode.ActualSize:
609 | zoom = 1;
610 | break;
611 |
612 | case ZoomMode.TwoPages:
613 | rc.Width *= 2; // << two pages side-by-side
614 | goto case ZoomMode.FullPage;
615 |
616 | case ZoomMode.FullPage:
617 | var zoomX = (rc.Width > 0) ? rcCli.Width / (double)rc.Width : 0;
618 | var zoomY = (rc.Height > 0) ? rcCli.Height / (double)rc.Height : 0;
619 | zoom = Math.Min(zoomX, zoomY);
620 | break;
621 |
622 | case ZoomMode.PageWidth:
623 | zoom = (rc.Width > 0) ? rcCli.Width / (double)rc.Width : 0;
624 | break;
625 | }
626 |
627 | // apply zoom factor
628 | rc.Width = (int)(rc.Width * zoom);
629 | rc.Height = (int)(rc.Height * zoom);
630 |
631 | // center image
632 | var dx = (rcCli.Width - rc.Width) / 2;
633 | if (dx > 0) rc.X += dx;
634 | var dy = (rcCli.Height - rc.Height) / 2;
635 | if (dy > 0) rc.Y += dy;
636 |
637 | // add some extra space
638 | rc.Inflate(-MARGIN, -MARGIN);
639 | if (zoomMode == ZoomMode.TwoPages)
640 | {
641 | rc.Inflate(-MARGIN / 2, 0);
642 | }
643 |
644 | // done
645 | return rc;
646 | }
647 |
648 | private Size GetImageSizeInPixels(Image img)
649 | {
650 | // get image size
651 | var szf = img.PhysicalDimension;
652 |
653 | // if it is a metafile, convert to pixels
654 | if (img is Metafile)
655 | {
656 | // get screen resolution
657 | if (himm2Pix.X < 0)
658 | {
659 | using (var g = CreateGraphics())
660 | {
661 | himm2Pix.X = g.DpiX / 2540f;
662 | himm2Pix.Y = g.DpiY / 2540f;
663 | }
664 | }
665 |
666 | // convert himetric to pixels
667 | szf.Width *= himm2Pix.X;
668 | szf.Height *= himm2Pix.Y;
669 | }
670 |
671 | // done
672 | return Size.Truncate(szf);
673 | }
674 |
675 | private static void RenderPage(Graphics g, Image img, Rectangle rc)
676 | {
677 | // draw the page
678 | rc.Offset(1, 1);
679 | g.DrawRectangle(Pens.Black, rc);
680 | rc.Offset(-1, -1);
681 | g.FillRectangle(Brushes.White, rc);
682 | g.DrawImage(img, rc);
683 | g.DrawRectangle(Pens.Black, rc);
684 |
685 | // exclude cliprect to paint background later
686 | rc.Width++;
687 | rc.Height++;
688 | g.ExcludeClip(rc);
689 | rc.Offset(1, 1);
690 | g.ExcludeClip(rc);
691 | }
692 |
693 | private void UpdateScrollBars()
694 | {
695 | // get image rectangle to adjust scroll size
696 | var rc = Rectangle.Empty;
697 | var img = GetImage(StartPage);
698 | if (img != null)
699 | {
700 | rc = GetImageRectangle(img);
701 | }
702 |
703 | // calculate new scroll size
704 | var scrollSize = new Size(0, 0);
705 | switch (zoomMode)
706 | {
707 | case ZoomMode.PageWidth:
708 | scrollSize = new Size(0, rc.Height + 2 * MARGIN);
709 | break;
710 |
711 | case ZoomMode.ActualSize:
712 | case ZoomMode.Custom:
713 | scrollSize = new Size(rc.Width + 2 * MARGIN, rc.Height + 2 * MARGIN);
714 | break;
715 | }
716 |
717 | // apply if needed
718 | if (scrollSize != AutoScrollMinSize)
719 | AutoScrollMinSize = scrollSize;
720 |
721 | // ready to update
722 | UpdatePreview();
723 | }
724 |
725 | private void UpdatePreview()
726 | {
727 | // validate current page
728 | if (startPage < 0) startPage = 0;
729 | if (startPage > PageCount - 1) startPage = PageCount - 1;
730 |
731 | // repaint
732 | Invalidate();
733 | }
734 |
735 | #endregion Implementation
736 |
737 | #region Nested Class
738 |
739 | // helper class that prints the selected page range in a PrintDocument.
740 | private class DocumentPrinter : PrintDocument
741 | {
742 | private readonly int first;
743 | private readonly int last;
744 | private int index;
745 | private readonly List imgList;
746 |
747 | public DocumentPrinter(FRPreview preview, int first, int last)
748 | {
749 | // save page range and image list
750 | this.first = first;
751 | this.last = last;
752 | imgList = preview.pageImages;
753 |
754 | // copy page and printer settings from original document
755 | DefaultPageSettings = preview.Document.DefaultPageSettings;
756 | PrinterSettings = preview.Document.PrinterSettings;
757 | }
758 |
759 | protected override void OnBeginPrint(PrintEventArgs e)
760 | {
761 | // start from the first page
762 | index = first;
763 | }
764 |
765 | protected override void OnPrintPage(PrintPageEventArgs e)
766 | {
767 | // render the current page and increment the index
768 | e.Graphics.PageUnit = GraphicsUnit.Display;
769 | e.Graphics.DrawImage(imgList[index++], e.PageBounds);
770 |
771 | // stop when we reach the last page in the range
772 | e.HasMorePages = index <= last;
773 | }
774 | }
775 |
776 | #endregion Nested Class
777 | }
778 | }
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/FRPreview.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/FRPrintPreviewControl.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FastReport.OpenSource.Winforms
2 | {
3 | partial class FRPrintPreviewControl
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FRPrintPreviewControl));
32 | this._toolStrip = new System.Windows.Forms.ToolStrip();
33 | this.btnQuickPrint = new System.Windows.Forms.ToolStripButton();
34 | this.btnPrint = new System.Windows.Forms.ToolStripButton();
35 | this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
36 | this._btnZoom = new System.Windows.Forms.ToolStripSplitButton();
37 | this._itemActualSize = new System.Windows.Forms.ToolStripMenuItem();
38 | this._itemFullPage = new System.Windows.Forms.ToolStripMenuItem();
39 | this._itemPageWidth = new System.Windows.Forms.ToolStripMenuItem();
40 | this._itemTwoPages = new System.Windows.Forms.ToolStripMenuItem();
41 | this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
42 | this._item500 = new System.Windows.Forms.ToolStripMenuItem();
43 | this._item200 = new System.Windows.Forms.ToolStripMenuItem();
44 | this._item150 = new System.Windows.Forms.ToolStripMenuItem();
45 | this._item100 = new System.Windows.Forms.ToolStripMenuItem();
46 | this._item75 = new System.Windows.Forms.ToolStripMenuItem();
47 | this._item50 = new System.Windows.Forms.ToolStripMenuItem();
48 | this._item25 = new System.Windows.Forms.ToolStripMenuItem();
49 | this._item10 = new System.Windows.Forms.ToolStripMenuItem();
50 | this.btnFirst = new System.Windows.Forms.ToolStripButton();
51 | this._btnPrev = new System.Windows.Forms.ToolStripButton();
52 | this.txtStartPage = new System.Windows.Forms.ToolStripTextBox();
53 | this.lblPageCount = new System.Windows.Forms.ToolStripLabel();
54 | this._btnNext = new System.Windows.Forms.ToolStripButton();
55 | this._btnLast = new System.Windows.Forms.ToolStripButton();
56 | this._separator = new System.Windows.Forms.ToolStripSeparator();
57 | this.btnCancel = new System.Windows.Forms.ToolStripButton();
58 | this.preview = new FRPreview();
59 | this._toolStrip.SuspendLayout();
60 | this.SuspendLayout();
61 | //
62 | // _toolStrip
63 | //
64 | this._toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
65 | this._toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
66 | this.btnQuickPrint,
67 | this.btnPrint,
68 | this.toolStripSeparator2,
69 | this._btnZoom,
70 | this.btnFirst,
71 | this._btnPrev,
72 | this.txtStartPage,
73 | this.lblPageCount,
74 | this._btnNext,
75 | this._btnLast,
76 | this._separator,
77 | this.btnCancel});
78 | this._toolStrip.Location = new System.Drawing.Point(0, 0);
79 | this._toolStrip.Name = "_toolStrip";
80 | this._toolStrip.Size = new System.Drawing.Size(437, 25);
81 | this._toolStrip.TabIndex = 1;
82 | this._toolStrip.Text = "toolStrip1";
83 | //
84 | // btnQuickPrint
85 | //
86 | this.btnQuickPrint.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
87 | this.btnQuickPrint.Image = ((System.Drawing.Image)(resources.GetObject("btnQuickPrint.Image")));
88 | this.btnQuickPrint.ImageTransparentColor = System.Drawing.Color.Magenta;
89 | this.btnQuickPrint.Name = "btnQuickPrint";
90 | this.btnQuickPrint.Size = new System.Drawing.Size(23, 22);
91 | this.btnQuickPrint.Text = "Impressão Rapida";
92 | this.btnQuickPrint.Click += new System.EventHandler(this.btnQuickPrint_Click);
93 | //
94 | // btnPrint
95 | //
96 | this.btnPrint.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
97 | this.btnPrint.Image = ((System.Drawing.Image)(resources.GetObject("btnPrint.Image")));
98 | this.btnPrint.ImageTransparentColor = System.Drawing.Color.Magenta;
99 | this.btnPrint.Name = "btnPrint";
100 | this.btnPrint.Size = new System.Drawing.Size(23, 22);
101 | this.btnPrint.Text = "Imprimir";
102 | this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
103 | //
104 | // toolStripSeparator2
105 | //
106 | this.toolStripSeparator2.Name = "toolStripSeparator2";
107 | this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
108 | //
109 | // _btnZoom
110 | //
111 | this._btnZoom.AutoToolTip = false;
112 | this._btnZoom.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
113 | this._itemActualSize,
114 | this._itemFullPage,
115 | this._itemPageWidth,
116 | this._itemTwoPages,
117 | this.toolStripMenuItem1,
118 | this._item500,
119 | this._item200,
120 | this._item150,
121 | this._item100,
122 | this._item75,
123 | this._item50,
124 | this._item25,
125 | this._item10});
126 | this._btnZoom.Image = ((System.Drawing.Image)(resources.GetObject("_btnZoom.Image")));
127 | this._btnZoom.ImageTransparentColor = System.Drawing.Color.Magenta;
128 | this._btnZoom.Name = "_btnZoom";
129 | this._btnZoom.Size = new System.Drawing.Size(71, 22);
130 | this._btnZoom.Text = "&Zoom";
131 | this._btnZoom.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.btnZoom_DropDownItemClicked);
132 | //
133 | // _itemActualSize
134 | //
135 | this._itemActualSize.Image = ((System.Drawing.Image)(resources.GetObject("_itemActualSize.Image")));
136 | this._itemActualSize.Name = "_itemActualSize";
137 | this._itemActualSize.Size = new System.Drawing.Size(180, 22);
138 | this._itemActualSize.Text = "Actual Size";
139 | //
140 | // _itemFullPage
141 | //
142 | this._itemFullPage.Image = ((System.Drawing.Image)(resources.GetObject("_itemFullPage.Image")));
143 | this._itemFullPage.Name = "_itemFullPage";
144 | this._itemFullPage.Size = new System.Drawing.Size(180, 22);
145 | this._itemFullPage.Text = "Full Page";
146 | //
147 | // _itemPageWidth
148 | //
149 | this._itemPageWidth.Image = ((System.Drawing.Image)(resources.GetObject("_itemPageWidth.Image")));
150 | this._itemPageWidth.Name = "_itemPageWidth";
151 | this._itemPageWidth.Size = new System.Drawing.Size(180, 22);
152 | this._itemPageWidth.Text = "Page Width";
153 | //
154 | // _itemTwoPages
155 | //
156 | this._itemTwoPages.Image = ((System.Drawing.Image)(resources.GetObject("_itemTwoPages.Image")));
157 | this._itemTwoPages.Name = "_itemTwoPages";
158 | this._itemTwoPages.Size = new System.Drawing.Size(180, 22);
159 | this._itemTwoPages.Text = "Two Pages";
160 | //
161 | // toolStripMenuItem1
162 | //
163 | this.toolStripMenuItem1.Name = "toolStripMenuItem1";
164 | this.toolStripMenuItem1.Size = new System.Drawing.Size(177, 6);
165 | //
166 | // _item500
167 | //
168 | this._item500.Name = "_item500";
169 | this._item500.Size = new System.Drawing.Size(180, 22);
170 | this._item500.Text = "500%";
171 | //
172 | // _item200
173 | //
174 | this._item200.Name = "_item200";
175 | this._item200.Size = new System.Drawing.Size(180, 22);
176 | this._item200.Text = "200%";
177 | //
178 | // _item150
179 | //
180 | this._item150.Name = "_item150";
181 | this._item150.Size = new System.Drawing.Size(180, 22);
182 | this._item150.Text = "150%";
183 | //
184 | // _item100
185 | //
186 | this._item100.Name = "_item100";
187 | this._item100.Size = new System.Drawing.Size(180, 22);
188 | this._item100.Text = "100%";
189 | //
190 | // _item75
191 | //
192 | this._item75.Name = "_item75";
193 | this._item75.Size = new System.Drawing.Size(180, 22);
194 | this._item75.Text = "75%";
195 | //
196 | // _item50
197 | //
198 | this._item50.Name = "_item50";
199 | this._item50.Size = new System.Drawing.Size(180, 22);
200 | this._item50.Text = "50%";
201 | //
202 | // _item25
203 | //
204 | this._item25.Name = "_item25";
205 | this._item25.Size = new System.Drawing.Size(180, 22);
206 | this._item25.Text = "25%";
207 | //
208 | // _item10
209 | //
210 | this._item10.Name = "_item10";
211 | this._item10.Size = new System.Drawing.Size(180, 22);
212 | this._item10.Text = "10%";
213 | //
214 | // btnFirst
215 | //
216 | this.btnFirst.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
217 | this.btnFirst.Image = ((System.Drawing.Image)(resources.GetObject("btnFirst.Image")));
218 | this.btnFirst.ImageTransparentColor = System.Drawing.Color.Red;
219 | this.btnFirst.Name = "btnFirst";
220 | this.btnFirst.Size = new System.Drawing.Size(23, 22);
221 | this.btnFirst.Text = "Primeira Pagina";
222 | this.btnFirst.Click += new System.EventHandler(this.btnFirst_Click);
223 | //
224 | // _btnPrev
225 | //
226 | this._btnPrev.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
227 | this._btnPrev.Image = ((System.Drawing.Image)(resources.GetObject("_btnPrev.Image")));
228 | this._btnPrev.ImageTransparentColor = System.Drawing.Color.Red;
229 | this._btnPrev.Name = "_btnPrev";
230 | this._btnPrev.Size = new System.Drawing.Size(23, 22);
231 | this._btnPrev.Text = "Pagina Anterior";
232 | this._btnPrev.Click += new System.EventHandler(this.btnPrev_Click);
233 | //
234 | // txtStartPage
235 | //
236 | this.txtStartPage.AutoSize = false;
237 | this.txtStartPage.Font = new System.Drawing.Font("Segoe UI", 9F);
238 | this.txtStartPage.Name = "txtStartPage";
239 | this.txtStartPage.Size = new System.Drawing.Size(32, 23);
240 | this.txtStartPage.TextBoxTextAlign = System.Windows.Forms.HorizontalAlignment.Center;
241 | this.txtStartPage.Enter += new System.EventHandler(this.txtStartPage_Enter);
242 | this.txtStartPage.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtStartPage_KeyPress);
243 | this.txtStartPage.Validating += new System.ComponentModel.CancelEventHandler(this.txtStartPage_Validating);
244 | //
245 | // lblPageCount
246 | //
247 | this.lblPageCount.Name = "lblPageCount";
248 | this.lblPageCount.Size = new System.Drawing.Size(10, 22);
249 | this.lblPageCount.Text = " ";
250 | //
251 | // _btnNext
252 | //
253 | this._btnNext.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
254 | this._btnNext.Image = ((System.Drawing.Image)(resources.GetObject("_btnNext.Image")));
255 | this._btnNext.ImageTransparentColor = System.Drawing.Color.Red;
256 | this._btnNext.Name = "_btnNext";
257 | this._btnNext.Size = new System.Drawing.Size(23, 22);
258 | this._btnNext.Text = "Proxima Pagina";
259 | this._btnNext.Click += new System.EventHandler(this.btnNext_Click);
260 | //
261 | // _btnLast
262 | //
263 | this._btnLast.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
264 | this._btnLast.Image = ((System.Drawing.Image)(resources.GetObject("_btnLast.Image")));
265 | this._btnLast.ImageTransparentColor = System.Drawing.Color.Red;
266 | this._btnLast.Name = "_btnLast";
267 | this._btnLast.Size = new System.Drawing.Size(23, 22);
268 | this._btnLast.Text = "Ultima Pagina";
269 | this._btnLast.Click += new System.EventHandler(this.btnLast_Click);
270 | //
271 | // _separator
272 | //
273 | this._separator.Name = "_separator";
274 | this._separator.Size = new System.Drawing.Size(6, 25);
275 | this._separator.Visible = false;
276 | //
277 | // btnCancel
278 | //
279 | this.btnCancel.AutoToolTip = false;
280 | this.btnCancel.Image = ((System.Drawing.Image)(resources.GetObject("btnCancel.Image")));
281 | this.btnCancel.ImageTransparentColor = System.Drawing.Color.Magenta;
282 | this.btnCancel.Name = "btnCancel";
283 | this.btnCancel.Size = new System.Drawing.Size(73, 22);
284 | this.btnCancel.Text = "Cancelar";
285 | this.btnCancel.ToolTipText = "Cancelar";
286 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
287 | //
288 | // preview
289 | //
290 | this.preview.Dock = System.Windows.Forms.DockStyle.Fill;
291 | this.preview.Document = null;
292 | this.preview.Location = new System.Drawing.Point(0, 25);
293 | this.preview.Name = "preview";
294 | this.preview.Size = new System.Drawing.Size(437, 281);
295 | this.preview.TabIndex = 0;
296 | this.preview.StartPageChanged += new System.EventHandler(this.preview_StartPageChanged);
297 | this.preview.PageCountChanged += new System.EventHandler(this.preview_PageCountChanged);
298 | this.preview.ZoomModeChanged += new System.EventHandler(this.preview_ZoomModeChanged);
299 | //
300 | // FRPrintPreviewControl
301 | //
302 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
303 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
304 | this.Controls.Add(this.preview);
305 | this.Controls.Add(this._toolStrip);
306 | this.Name = "FRPrintPreviewControl";
307 | this.Size = new System.Drawing.Size(437, 306);
308 | this._toolStrip.ResumeLayout(false);
309 | this._toolStrip.PerformLayout();
310 | this.ResumeLayout(false);
311 | this.PerformLayout();
312 |
313 | }
314 |
315 | #endregion
316 |
317 | private FRPreview preview;
318 | private System.Windows.Forms.ToolStrip _toolStrip;
319 | private System.Windows.Forms.ToolStripButton btnQuickPrint;
320 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
321 | private System.Windows.Forms.ToolStripSplitButton _btnZoom;
322 | private System.Windows.Forms.ToolStripMenuItem _itemActualSize;
323 | private System.Windows.Forms.ToolStripMenuItem _itemFullPage;
324 | private System.Windows.Forms.ToolStripMenuItem _itemPageWidth;
325 | private System.Windows.Forms.ToolStripMenuItem _itemTwoPages;
326 | private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
327 | private System.Windows.Forms.ToolStripMenuItem _item500;
328 | private System.Windows.Forms.ToolStripMenuItem _item200;
329 | private System.Windows.Forms.ToolStripMenuItem _item150;
330 | private System.Windows.Forms.ToolStripMenuItem _item100;
331 | private System.Windows.Forms.ToolStripMenuItem _item75;
332 | private System.Windows.Forms.ToolStripMenuItem _item50;
333 | private System.Windows.Forms.ToolStripMenuItem _item25;
334 | private System.Windows.Forms.ToolStripMenuItem _item10;
335 | private System.Windows.Forms.ToolStripButton btnFirst;
336 | private System.Windows.Forms.ToolStripButton _btnPrev;
337 | private System.Windows.Forms.ToolStripTextBox txtStartPage;
338 | private System.Windows.Forms.ToolStripLabel lblPageCount;
339 | private System.Windows.Forms.ToolStripButton _btnNext;
340 | private System.Windows.Forms.ToolStripButton _btnLast;
341 | private System.Windows.Forms.ToolStripSeparator _separator;
342 | private System.Windows.Forms.ToolStripButton btnCancel;
343 | private System.Windows.Forms.ToolStripButton btnPrint;
344 | }
345 | }
346 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/FRPrintPreviewControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Drawing.Printing;
6 | using System.Windows.Forms;
7 |
8 | namespace FastReport.OpenSource.Winforms
9 | {
10 | [ToolboxBitmap(typeof(FRPrintPreviewDialog), @"FastReport.OpenSource.Winforms.Print.print_preview.bmp"),
11 | DesignerCategory(@"FastReport.OpenSource.Winforms"), DesignTimeVisible(true), ToolboxItem(true)]
12 | public partial class FRPrintPreviewControl : UserControl
13 | {
14 | #region Events
15 |
16 | public event EventHandler StartPageChanged;
17 |
18 | public event EventHandler PageCountChanged;
19 |
20 | public event EventHandler ZoomModeChanged;
21 |
22 | private void preview_PageCountChanged(object sender, EventArgs e)
23 | {
24 | Update();
25 | Application.DoEvents();
26 | if (lblPageCount != null)
27 | lblPageCount.Text = $@" de {preview.PageCount}";
28 |
29 | if (PageCountChanged == null) return;
30 | if (!(PageCountChanged.Target is ISynchronizeInvoke synchronizeInvoke))
31 | PageCountChanged.DynamicInvoke(this, EventArgs.Empty);
32 | else
33 | synchronizeInvoke.Invoke(PageCountChanged, new object[] { this, EventArgs.Empty });
34 | }
35 |
36 | private void preview_ZoomModeChanged(object sender, EventArgs e)
37 | {
38 | if (ZoomModeChanged == null) return;
39 | if (!(ZoomModeChanged.Target is ISynchronizeInvoke synchronizeInvoke))
40 | ZoomModeChanged.DynamicInvoke(this, EventArgs.Empty);
41 | else
42 | synchronizeInvoke.Invoke(ZoomModeChanged, new object[] { this, EventArgs.Empty });
43 | }
44 |
45 | private void preview_StartPageChanged(object sender, EventArgs e)
46 | {
47 | var page = preview.StartPage + 1;
48 | if (txtStartPage != null)
49 | txtStartPage.Text = page.ToString();
50 |
51 | if (StartPageChanged == null) return;
52 | if (!(StartPageChanged.Target is ISynchronizeInvoke synchronizeInvoke))
53 | StartPageChanged.DynamicInvoke(this, EventArgs.Empty);
54 | else
55 | synchronizeInvoke.Invoke(StartPageChanged, new object[] { this, EventArgs.Empty });
56 | }
57 |
58 | #endregion Events
59 |
60 | #region Fields
61 |
62 | private PrintDocument doc;
63 |
64 | #endregion Fields
65 |
66 | #region Constructors
67 |
68 | public FRPrintPreviewControl()
69 | {
70 | InitializeComponent();
71 | }
72 |
73 | #endregion Constructors
74 |
75 | #region Propriedades
76 |
77 | ///
78 | /// Gets or sets the being previewed.
79 | ///
80 | public PrintDocument Document
81 | {
82 | get => doc;
83 | set
84 | {
85 | // unhook event handlers
86 | if (doc != null)
87 | {
88 | doc.BeginPrint -= doc_BeginPrint;
89 | doc.EndPrint -= doc_EndPrint;
90 | }
91 |
92 | // save the value
93 | doc = value;
94 |
95 | // hook up event handlers
96 | if (doc != null)
97 | {
98 | doc.BeginPrint += doc_BeginPrint;
99 | doc.EndPrint += doc_EndPrint;
100 | }
101 |
102 | if (txtStartPage != null)
103 | txtStartPage.Text = "1";
104 |
105 | // don't assign document to preview until this form becomes visible
106 | preview.Document = Document;
107 | }
108 | }
109 |
110 | ///
111 | /// Gets a value that indicates whether the is being rendered.
112 | ///
113 | [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
114 | public bool IsRendering => preview.IsRendering;
115 |
116 | ///
117 | /// Gets or sets how the zoom should be adjusted when the control is resized.
118 | ///
119 | [DefaultValue(ZoomMode.FullPage)]
120 | public ZoomMode ZoomMode
121 | {
122 | get => preview.ZoomMode;
123 | set => preview.ZoomMode = value;
124 | }
125 |
126 | ///
127 | /// Gets or sets a custom zoom factor used when the property
128 | /// is set to Custom.
129 | ///
130 | [Browsable(false),
131 | DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
132 | public double Zoom
133 | {
134 | get => preview.Zoom;
135 | set => preview.Zoom = value;
136 | }
137 |
138 | ///
139 | /// Gets or sets the first page being previewed.
140 | ///
141 | ///
142 | /// There may be one or two pages visible depending on the setting of the
143 | /// property.
144 | ///
145 | [Browsable(false),
146 | DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
147 | public int StartPage
148 | {
149 | get => preview.StartPage;
150 | set => preview.StartPage = value;
151 | }
152 |
153 | ///
154 | /// Gets the number of pages available for preview.
155 | ///
156 | ///
157 | /// This number increases as the document is rendered into the control.
158 | ///
159 | [Browsable(false),
160 | DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
161 | public int PageCount => preview.PageCount;
162 |
163 | ///
164 | /// Gets or sets the control's background color.
165 | ///
166 | [DefaultValue(typeof(Color), "AppWorkspace")]
167 | public sealed override Color BackColor
168 | {
169 | get => preview.BackColor;
170 | set => preview.BackColor = value;
171 | }
172 |
173 | public bool ShowToolbar
174 | {
175 | get => _toolStrip.Visible;
176 | set => _toolStrip.Visible = value;
177 | }
178 |
179 | #endregion Propriedades
180 |
181 | #region Methods
182 |
183 | ///
184 | /// Prints the current document honoring the selected page range.
185 | ///
186 | public void Print(bool showPrintDialog = false)
187 | {
188 | preview.Print(showPrintDialog);
189 | }
190 |
191 | ///
192 | /// Regenerates the preview to reflect changes in the document layout.
193 | ///
194 | public void RefreshPreview()
195 | {
196 | preview.RefreshPreview();
197 | }
198 |
199 | ///
200 | /// Stops rendering the .
201 | ///
202 | public void Cancel()
203 | {
204 | preview.Cancel();
205 | }
206 |
207 | public void PrimeiraPagina()
208 | {
209 | preview.StartPage = 0;
210 | }
211 |
212 | public void PaginaAnterior()
213 | {
214 | preview.StartPage--;
215 | }
216 |
217 | public void ProximaPagina()
218 | {
219 | preview.StartPage++;
220 | }
221 |
222 | public void UltimaPagina()
223 | {
224 | preview.StartPage = preview.PageCount - 1;
225 | }
226 |
227 | public void IrParaPagina(int page)
228 | {
229 | preview.StartPage = page - 1;
230 | }
231 |
232 | #endregion Methods
233 |
234 | #region Toolbar
235 |
236 | #region Main Commands
237 |
238 | private void btnQuickPrint_Click(object sender, EventArgs e)
239 | {
240 | preview.Print();
241 | }
242 |
243 | private void btnPrint_Click(object sender, EventArgs e)
244 | {
245 | preview.Print(true);
246 | }
247 |
248 | #endregion Main Commands
249 |
250 | #region Zoom
251 |
252 | private void btnZoom_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
253 | {
254 | if (e.ClickedItem == _itemActualSize)
255 | {
256 | preview.ZoomMode = ZoomMode.ActualSize;
257 | }
258 | else if (e.ClickedItem == _itemFullPage)
259 | {
260 | preview.ZoomMode = ZoomMode.FullPage;
261 | }
262 | else if (e.ClickedItem == _itemPageWidth)
263 | {
264 | preview.ZoomMode = ZoomMode.PageWidth;
265 | }
266 | else if (e.ClickedItem == _itemTwoPages)
267 | {
268 | preview.ZoomMode = ZoomMode.TwoPages;
269 | }
270 | if (e.ClickedItem == _item10)
271 | {
272 | preview.Zoom = .1;
273 | }
274 | else if (e.ClickedItem == _item100)
275 | {
276 | preview.Zoom = 1;
277 | }
278 | else if (e.ClickedItem == _item150)
279 | {
280 | preview.Zoom = 1.5;
281 | }
282 | else if (e.ClickedItem == _item200)
283 | {
284 | preview.Zoom = 2;
285 | }
286 | else if (e.ClickedItem == _item25)
287 | {
288 | preview.Zoom = .25;
289 | }
290 | else if (e.ClickedItem == _item50)
291 | {
292 | preview.Zoom = .5;
293 | }
294 | else if (e.ClickedItem == _item500)
295 | {
296 | preview.Zoom = 5;
297 | }
298 | else if (e.ClickedItem == _item75)
299 | {
300 | preview.Zoom = .75;
301 | }
302 | }
303 |
304 | #endregion Zoom
305 |
306 | #region Page Navigation
307 |
308 | private void btnFirst_Click(object sender, EventArgs e)
309 | {
310 | PrimeiraPagina();
311 | }
312 |
313 | private void btnPrev_Click(object sender, EventArgs e)
314 | {
315 | PaginaAnterior();
316 | }
317 |
318 | private void btnNext_Click(object sender, EventArgs e)
319 | {
320 | ProximaPagina();
321 | }
322 |
323 | private void btnLast_Click(object sender, EventArgs e)
324 | {
325 | UltimaPagina();
326 | }
327 |
328 | private void txtStartPage_Enter(object sender, EventArgs e)
329 | {
330 | txtStartPage.SelectAll();
331 | }
332 |
333 | private void txtStartPage_Validating(object sender, CancelEventArgs e)
334 | {
335 | CommitPageNumber();
336 | }
337 |
338 | private void txtStartPage_KeyPress(object sender, KeyPressEventArgs e)
339 | {
340 | var c = e.KeyChar;
341 | if (c == (char)13)
342 | {
343 | CommitPageNumber();
344 | e.Handled = true;
345 | }
346 | else if (c > ' ' && !char.IsDigit(c))
347 | {
348 | e.Handled = true;
349 | }
350 | }
351 |
352 | private void CommitPageNumber()
353 | {
354 | int page;
355 | if (int.TryParse(txtStartPage.Text, out page))
356 | {
357 | IrParaPagina(page);
358 | }
359 | }
360 |
361 | #endregion Page Navigation
362 |
363 | #region Job Control
364 |
365 | private void btnCancel_Click(object sender, EventArgs e)
366 | {
367 | if (preview.IsRendering)
368 | {
369 | preview.Cancel();
370 | }
371 | else
372 | {
373 | ParentForm?.Close();
374 | }
375 | }
376 |
377 | private void doc_BeginPrint(object sender, PrintEventArgs e)
378 | {
379 | btnCancel.Text = @"&Cancelar";
380 | btnCancel.ToolTipText = @"&Cancelar";
381 | btnQuickPrint.Enabled = false;
382 | btnPrint.Enabled = false;
383 | }
384 |
385 | private void doc_EndPrint(object sender, PrintEventArgs e)
386 | {
387 | btnCancel.Text = @"&Fechar";
388 | btnCancel.ToolTipText = @"&Fechar";
389 | btnQuickPrint.Enabled = true;
390 | btnPrint.Enabled = true;
391 | }
392 |
393 | #endregion Job Control
394 |
395 | #endregion Toolbar
396 | }
397 | }
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/FRPrintPreviewControl.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
124 |
125 |
126 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
127 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJ8SURBVDhPhdPtS1NRHAfwYwazFwkGvROsF0L/QGFGLHxR
128 | 9geMnJOBq01LDQsyUXzI5SjU8upshtYVpQfNyrSVobmkTZ2u+TgzE2dqBtvcdO7Bea1vZ6so4Wo/+HDh
129 | nt/3d7iHc8m/1dzaPtH6XIudPGpp0wII+x35WwzzSvCw+Rm86z+25fF/B9v4mEtMTBTQyNYhLMtGNDQ1
130 | w+3d2NaqJ4B7bCNH26NEIlF4KMgw1dkq1c21qqoaxGmMOKwZ3FG8ZgC0H0qlarW8/FYWqaiocVgmp2B3
131 | LOOo2oDCaR/yp/gVfPLhWI0Bc3PzGBu3oLKSWSEaTR3X06OD2WzG8dvvoJrxIdfkxtWhrYLvSj/7IGR6
132 | YbcvY3FxCbW19SDV1RrO6VzBxsYmhGVdyDRYIdfN8MrQW5FQ3g2/fx0ulxtqdS1ISYmKsztcCAQ4nK1/
133 | D2GpdkeK+/pQr9O5CuX1GyDZl65ws9Z52GzL8Hh8dHoA/vVt0LW1NS9mzKP0HBaQk5MHkn4+i7NMTmPW
134 | uoC5L1//a7hbh77wcBg7u5B18TJIqkzOmT6MYsIyjSetbTh56jSEJxJ4BddYtgkm/QDMw+NQpGWASCQy
135 | 20ttJ4yDZpRVVIJR1+GF9i2vO3cbQt/dPzCE9o7XSJGmOok09Zw0KVliEydLoUjPhLazBwvfnLy6dAbI
136 | 6a5nkiRBttjYQ4rgZQyLiYmJoM8osUT6oFc/iCWbG8H/4o+Wpx1wuPzoM45ALE55Q3sPUPupvVSowiIj
137 | I/fl5hez/UNjWPFs8jKNfIRMpuggZE80zeymdoXStILTotMuZMrziku9hddU4FNQVOw7EhdfJBAIDv7K
138 | EPIT8d6lv/OwafMAAAAASUVORK5CYII=
139 |
140 |
141 |
142 |
143 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
144 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAMASURBVDhPdZJbTJJxGMZxtdltd915a3VVmzM7zFYtbUvL
145 | HOZhYR5yVGbWKp1mJgpZHqEMSxtNylOWZqA2UzzmmTxhBOoHHhPEED9B/LSnD3RZU5/tt3fvf8/7XLz/
146 | l/GvSsoqB8vKpdiOotIKKQCHdfv/4vOrHAtLPmBx6feWkJZViAqKKU9PT0favjlEJBLtei0ugWlxeUvm
147 | SSteiQoo2rqbyWTuWJuixec/jebxHi8IBDk4JOyAi7BzWw4L20F7kZzMm09Pz7xhD8jIyJlVDCmhnzXA
148 | 7VkrHqjMiFduJuGHGUdyWqHRjKF/QIHsbL7RHiAU5lH19TLI5XIcy2oAb9iM2G4TYro2sPVctRnu/Ebo
149 | 9QZMTEwhNzcf9gAOh0fpZ3/BaqUQlt8Md650E1W94+gh9BiemQdFrWLOSCI5JXUtIPrWXWqUGINOZwBJ
150 | mmGxWGFZ2oCiVvD5K4Fr3C/wYL8Hm/MZ1U1qNLe0QyaT7WSwr96gFEMqjBLj0Ggn/0JopzBvInE7XYZD
151 | 4RL4pw7hsoCAH28QrqGViOJKMGu0pDFCQq9Q3T19GFSo8K6sAqc9zsD9+Am8KSxBZl41XMMkiHyphdm6
152 | gmXqNxQaE91r4BJSicJqRQsjKChUJ5HWoKNTjrSMbPCf5eGjtA7TP/W4FCfBuRQ1vo2Y0KOaQ5L4O32I
153 | ALeYgDdHicC4qmkGKySc5R8YpAsIZCGCHQlpTT3Gp+ewZF2GG6sIXimj8OYROJ8kp99W0T5EB6cN4Cxn
154 | GG7BRaRtjw5OTk676Lo7IIj1trGlE1M6E9QjGvjd+YhjN9twMrYfzMQWKLVG+CY04WRMH45GtcLv3qcZ
155 | W4BNDrbzjI1/KGrr6oeRXMGCmcK7WhX2+xXDJbwWdd2TsNBfXds1ae/3M4vworRXuj6/pixB7oVM/nOS
156 | BlkCIZRqAiH3JXD2EWOfrxgRKV/s1dmnAMFxNePaKRN7fXRr7d17wKmiuvH+o9yqAa9r5YaDF8VLXtcr
157 | DIlZkoYr0U9OMRiMPX8AWa+ISblHK1gAAAAASUVORK5CYII=
158 |
159 |
160 |
161 |
162 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
163 | JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAABJ0AAASdAHeZh94AAABO0lE
164 | QVQ4T8WTvU6EQBSFeaLVByCGSrcwBio3FiwJ0VgpBYmlNNS7Bb0kJBs7h9hsB6UFxZRSSUUs5w2uc4Zh
165 | YbMWqIUnOZnL/Hzzcy/Gn/VSfFisbIiVfPCWU9qblZ2fO6+lVynjy4eVpQBysaBfaHbqNhrAddd0CSHo
166 | eO7RHqBt211b1/VB3LcQANYi0AB5zyzLyDRNNRiGISVJohaP4zzPVYyWy1t7QTQA0Ok4DlVVpYzdAB3H
167 | MABxHJMXMQqidQfAS0NjAISJ4xigoijUZpdXLtm3+gRIEQQAJmFCDxrHEEDwZvNK1vnNPsD3fdXi3t/F
168 | eIfhBNdk2ToLKI6fCpnbpRGV1XzqkYnCwx8A+Lug8q2R5p3lLvhmsCz1dAsPJT6bu0IB7h+f7JOLOwHi
169 | VGPx0dmy+xf+WYbxBSXMcQBcleBHAAAAAElFTkSuQmCC
170 |
171 |
172 |
173 |
174 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
175 | JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAABJ0AAASdAHeZh94AAACi0lE
176 | QVQ4T6VSv1MTURC+f0jCj9oZrBLGAu10RghQ2ckMhZ2hs0KSNFolBxZCAblgAZlxuHexAArzLsERcIbc
177 | e2dhGkKCzqijuc/dPf8D38zO2/djv/3223V41dUlar5BXVl4wSVZhLofy3nPt+muvqCmuqg0Q5RqbRRe
178 | 7SIN9j/DDw1s7wYmHsJG36HtFXTUR+t8SGbRPjdQYYSmNjjUEYKjiIA17j8ug7JbCh4g6l0hsgPsBjE8
179 | FeOtCiljB/V9Dddro7LtY31bITjpQh1ZrG36mJ5fTQGi3hCxHaLd7VNwCF4j/JGdHCSph0x2Ec1jg72j
180 | GEU3wPSDZThcrzU3lP0KoRlQvadIkgTBcUxULTHS8A60gExl85J9N7AouT4mZ58wAwboQ1MwA2zstyRb
181 | wqnFGYk/+AGM5xZQp/pZ9BcbDDCXMuBAba9FtJqUMII6juCfxHKuH3SE1fhMXjTijhSrCpME6HikAQOw
182 | sdpVEo35cl4RgI3c4c8EY7m8tJTbWd58j7GZeQKg/ofmGqdnBp1PMapeWgIr79Y1Km9CEYzwicEc+L/X
183 | MChVAmKQ5xIu0bpggBitsy7cPUV0GeK3sPhGtZvBCJ2vwASJKEN28FFEzNxdhLOjjFDX5xFU28Ld8oXy
184 | mqvoU4DVlwEKJR9tQ22cWaCOfCChtbyN55bgvN7vyLSFF7FMW3FLYfArge1T5htA9xIqEQQwki5UGyHc
185 | hpaymJHD7ZBR1Qxg6GGHxFrEZHZJMmZyj+QjB2do54SVRksA+M5ZeV6VkS1vvhNa3J4iga67h+mZ/PJG
186 | U+7lTMZjvPS0nIrI685CAbcfPsPE7Aqm7i3jFmXn+ti418LkHws2vpvIUgv/fznOX1rx4Mqi9Qj5AAAA
187 | AElFTkSuQmCC
188 |
189 |
190 |
191 |
192 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
193 | JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAABJ0AAASdAHeZh94AAABT0lE
194 | QVQ4T8WTIVMDMRCF+4sKv4CJgiomsqqNPAXnqCOyrvcPiMQRWUdkZSSOk8hI3PJekuvBwTAMCDLzzfSS
195 | 3fd2s+nsz+vh8Vn50IsPcWQfxQ34ULgvdGDnfFzf7FQWQHKSX6z5+aqvArFulWU7N7LtpLVgY8U0tkaI
196 | pJTkdGFkFHgV6V9EXPi+GNMlYb0UUMu2CqDPEJNoCzbxg7sd3FtgWtFbxvUSocK9o4BqQk5Wy656TRYq
197 | TIDJqvFirM+tZQHedHxiSS4LFHcwdUfJyricHA5RNO6kCGBEaAltQH1aQXXmOXtnMs0iYrV5J8DDgdG9
198 | K+5NcdfaHGPCAWb4LgJ4GPkAUyBfOXM/8rz+5uSOY+TLGpJJnj3c24m7QsIQw4v/JMDeWBovKAMXfnuC
199 | p+72ZHzi88UqZYHr2zt9dnmVqPhTmHxysS7/hX9es9kbvfRVU3JRt9UAAAAASUVORK5CYII=
200 |
201 |
202 |
203 |
204 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
205 | JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAABJ0AAASdAHeZh94AAACyklE
206 | QVQ4T6VSTU8TURTtL+LDHyHIQsC4xRYWxrigwMKAm7a4QExKO0hSMLEzhU03TqfECCTKfJBIibGdqQvA
207 | BGamxlhNoC0uJCpzPG8a/QO+5Oa9mfvOfeeecyNiLRVMLMs6kvIuUrKJ+dxLzK9qSOVUJNY0JLObmM6U
208 | MSP2BRUzjxVMMUJwWjGhGTbcb2343gUa3jmqDNtrwz5qofbxFM6RB91x8brO3fawe+CiRMxEQkbkkWLA
209 | b7bhNltouBf/wM5hB7UjH/bhCQzbhVVrwGDsVT5jt+JD4sPRJAskePC+dMKfJb0GeaeODc1EOqfBPm7w
210 | dQIrLlnWoOwwX9IhranI/i2QWtPhu2fQLBsIwPUTuArQNxhD9diF6fhhiyIXBL+Zv2JuAtmCjjup52SQ
211 | K4W9q0YV6rYDueigcxmgdyAaUtadE6hmt0DnEmgxrl0fhxA++kC0QJWrjTPIWw7aP4DvjE4b6B3qFrBq
212 | HgqvHJj7LlS20G4BfTeioQaxuQwiSdolRMuX67TSxEU7QKPJS2zBoOLGvo+CVkOrA5yzsNe8Qs8QW8iz
213 | wGyWBaQX+MACclmHy0s+we+8X+gfioWWCQFlzYDbCqAU3+PpqoWegbFQxJH4EiIzHBDh93rRoBvgGShb
214 | p+yTLRAsqOeLJj59BaqHAZ3yQ32yhTcYjUuITEql0Kr0qhr21s9k78A4egajBJ+g/NZH5pmKfgon2hJ5
215 | sQsXbsWpwfRiiX57nDjSFZQ5NGalAfPAg8ZdM3xs6pwDk7HlY32rjvx2DVnZwPAUGcQXNjhtYtII5qha
216 | NieP1IV4JeO0C2QRbZs7gfmdKtZFAWowPEUG8UUlnDLhq7AmLe9huWBBkq3wFXFR/Bd5QXuF6kuKjskn
217 | mxi+RxfEGksqmEgpiCXy9LaA6Fwe0dkljD/MhjRH+ZJ47ea0FH6P3M/g9t2VLvj/ViTyBy4u0pwU8oSq
218 | AAAAAElFTkSuQmCC
219 |
220 |
221 |
222 |
223 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
224 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAF2SURBVDhPjZMhc8JAEIX5KfwD8gvayAomwYFhDte6xIG7
225 | uKaKk7ieRK5Enqw8iYysPIl73U0vpEAY+mbeTGay39u922TUSb9vx7relmzStQlaazEVWpfFWo9j2bAY
226 | TgVkwR8bhBAQToGfPeyeUGw4aK3TWH6p2Jmcc7jRCRwE0MGhKApi304iY0vnawnYOgDNN2B2FupNlRHr
227 | Jd1l7L+6gNmeX9PBQ70qF7FeWhs+Mld1uuoslgDnA5bLZYhYL7ntc8BV519YLjOAvprhAF4Tee/vw2zH
228 | AZYc1HzgCLyiUlYlcAd2Y0tngWX8qjZQKq8i1ks+kmJTtN/AGYxdBSS22RGyeeZMvcLnh5pFtBfvN1W8
229 | Z2NsO6qcV2z3DlVlkC9y8q5COFrQ7k4Ir2islCrZJJc1XUyDgFn25GyVoDmkCI1pfTdkSCqfzFazBFT3
230 | IY03sGaFWPJYXYitU5BJMEsTbHU+/G/cUxvyMkaaJMifJ/8b/7FGox9dBs7xxrfhlwAAAABJRU5ErkJg
231 | gg==
232 |
233 |
234 |
235 |
236 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
237 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACeSURBVDhPrZGLEYAgDEPZiZ3YiZ3cCZPSaoWq5yd3ObUk
238 | D9T0q0pZWim16eOpmNPbXVKu3RXW8STLTBtlDO4AWxlmXsddGSfIXIAjANelaI4AiRB4BBzKmpG8lwzU
239 | HuDLtm4baaQrAmzvO5TpEJBrOwB4DQHIxScYAJQHW/kaAHsA5dfMjwCiAfIcQH0GQPwe9nd0tIuQiRwo
240 | LL9TSivZcjER1IJlpAAAAABJRU5ErkJggg==
241 |
242 |
243 |
244 |
245 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
246 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABxSURBVDhPvZGLCcAgDESzU3bKTtnJnWwSolhB8Sr04EDU
247 | 9/BDv0Sk1BziES01KopLOmxlVMB27ABbEcELtnFrLu8zwuRQ9kjQ7zvBxwJdCbRiV2ADRhgSeGJzgp8E
248 | kUmCCzzXAou/R/udnMJzBe9D9ACHF6qJFTcrxgAAAABJRU5ErkJggg==
249 |
250 |
251 |
252 |
253 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
254 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAB3SURBVDhPtZLRDYAwCES7U3diJ3bqTsgR0GhjAkQvuaQf
255 | vldBxy8hWuLHeohY1hJhbkqmCgCTdnYkEARsrY4DQYAGR7MJwQl6029yu/XR1Nd5FbDYbvyx92wCBdHa
256 | CAY1YOQSeCswsgmqwaan/sotOJLa9jcZ4wDShaZay4OXjgAAAABJRU5ErkJggg==
257 |
258 |
259 |
260 |
261 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
262 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACsSURBVDhPrZLRDcMgDETZiZ3YiQU6TMUo+egGru/AkZMa
263 | KqqedEpk7h4EJf1NpTQZr1MhE+ZKqdKaSK1zCNbaIfJ4viRrfoy7MECgqPMEgvUzEwGsTAfH9BuEACuy
264 | bHYCgKezjJcBzuKwDwIQzanLrjfbrf8GqMLvRmYPoEXYBwmgr3OKA5bs+RnqgHjNAYbvAdUeINASgJvO
265 | +ivPytASANltr9R/4++5DaX0BhMILpazUwN4AAAAAElFTkSuQmCC
266 |
267 |
268 |
269 |
270 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
271 | YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEjSURBVDhPzZK9TsMwFIXv2AEpGRClCBGPTK03kCqwx0wo
272 | WylSoSMbjGy8Ut8gfgP8CHkDPKNKh2snlmh+oDBxJEtOpO87Vzeh/xc8qLS59gYLJZprNwwLvK7ckMTD
273 | H/dXFWZJV+IhvKxRn67Ew1jNHQoJnBPeM+qVCDwXLCiwfbqx/jm8v1MywLmEEwGWAegLQxJrDdzyeWRo
274 | oXSAtfgZjmGJDhI/7nzicJlGeHiB7WCpCuQCkAxPyL2d7NEcg4tMbPOpjc1eYI/JluM9JoDKUuQ8Njej
275 | abaHVFUsYon7VrID86dCs7CSJYYlLICpJToAXwOVpLg+MzU8cgzv/Ae+2RyRYQE2o4FJMKPUnVLVhmP8
276 | JJsDqsrkFwttxzeXAwV/CNEnc2Ctuurre4oAAAAASUVORK5CYII=
277 |
278 |
279 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/FRPrintPreviewDialog.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FastReport.OpenSource.Winforms
2 | {
3 | partial class FRPrintPreviewDialog
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.preview = new FRPrintPreviewControl();
32 | this.SuspendLayout();
33 | //
34 | // preview
35 | //
36 | this.preview.Dock = System.Windows.Forms.DockStyle.Fill;
37 | this.preview.Document = null;
38 | this.preview.Location = new System.Drawing.Point(0, 0);
39 | this.preview.Name = "preview";
40 | this.preview.ShowToolbar = true;
41 | this.preview.Size = new System.Drawing.Size(565, 364);
42 | this.preview.TabIndex = 0;
43 | //
44 | // FRPrintPreviewDialog
45 | //
46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
48 | this.ClientSize = new System.Drawing.Size(565, 364);
49 | this.Controls.Add(this.preview);
50 | this.Name = "FRPrintPreviewDialog";
51 | this.Text = "G2iPrintPreviewDialog";
52 | this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
53 | this.ResumeLayout(false);
54 |
55 | }
56 |
57 | #endregion
58 |
59 | private FRPrintPreviewControl preview;
60 | }
61 | }
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/FRPrintPreviewDialog.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Drawing.Printing;
6 | using System.Windows.Forms;
7 |
8 | namespace FastReport.OpenSource.Winforms
9 | {
10 | [ToolboxBitmap(typeof(FRPrintPreviewDialog), @"FastReport.OpenSource.Winforms.Print.window_print.bmp"),
11 | DesignerCategory(@"FastReport.OpenSource.Winforms"), DesignTimeVisible(true), ToolboxItem(true),
12 | Designer("System.ComponentModel.Design.ComponentDesigner"),
13 | ToolboxItemFilter("System.Windows.Forms.Control.TopLevel")]
14 | public partial class FRPrintPreviewDialog : Form
15 | {
16 | #region Constructors
17 |
18 | public FRPrintPreviewDialog()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | #endregion Constructors
24 |
25 | #region Propriedades
26 |
27 | ///
28 | /// Gets or sets the being previewed.
29 | ///
30 | public PrintDocument Document { get; set; }
31 |
32 | ///
33 | /// Gets a value that indicates whether the is being rendered.
34 | ///
35 | [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
36 | public bool IsRendering => preview.IsRendering;
37 |
38 | ///
39 | /// Gets or sets how the zoom should be adjusted when the control is resized.
40 | ///
41 | [DefaultValue(ZoomMode.FullPage)]
42 | public ZoomMode ZoomMode
43 | {
44 | get => preview.ZoomMode;
45 | set => preview.ZoomMode = value;
46 | }
47 |
48 | ///
49 | /// Gets or sets a custom zoom factor used when the property
50 | /// is set to Custom.
51 | ///
52 | [Browsable(false),
53 | DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
54 | public double Zoom
55 | {
56 | get => preview.Zoom;
57 | set => preview.Zoom = value;
58 | }
59 |
60 | ///
61 | /// Gets or sets the first page being previewed.
62 | ///
63 | ///
64 | /// There may be one or two pages visible depending on the setting of the
65 | /// property.
66 | ///
67 | [Browsable(false),
68 | DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
69 | public int StartPage
70 | {
71 | get => preview.StartPage;
72 | set => preview.StartPage = value;
73 | }
74 |
75 | ///
76 | /// Gets the number of pages available for preview.
77 | ///
78 | ///
79 | /// This number increases as the document is rendered into the control.
80 | ///
81 | [Browsable(false),
82 | DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
83 | public int PageCount => preview.PageCount;
84 |
85 | ///
86 | /// Gets or sets the control's background color.
87 | ///
88 | [DefaultValue(typeof(Color), "AppWorkspace")]
89 | public sealed override Color BackColor
90 | {
91 | get => preview.BackColor;
92 | set => preview.BackColor = value;
93 | }
94 |
95 | #endregion Propriedades
96 |
97 | #region Overloads
98 |
99 | ///
100 | /// Creates the handle for the form. If a derived class overrides this function, it must call the base implementation.
101 | ///
102 | ///
103 | protected override void CreateHandle()
104 | {
105 | // We want to check printer settings before we push the modal message loop,
106 | // so the user has a chance to catch the exception instead of letting go to
107 | // the windows forms exception dialog.
108 | if (Document != null && !Document.PrinterSettings.IsValid)
109 | throw new InvalidPrinterException(Document.PrinterSettings);
110 |
111 | base.CreateHandle();
112 | }
113 |
114 | ///
115 | /// Overridden to assign document to preview control only after the
116 | /// initial activation.
117 | ///
118 | /// that contains the event data.
119 | protected override void OnShown(EventArgs e)
120 | {
121 | base.OnShown(e);
122 | preview.Document = Document;
123 | }
124 |
125 | ///
126 | /// Overridden to cancel any ongoing previews when closing form.
127 | ///
128 | /// that contains the event data.
129 | protected override void OnFormClosing(FormClosingEventArgs e)
130 | {
131 | base.OnFormClosing(e);
132 | if (preview.IsRendering && !e.Cancel)
133 | {
134 | preview.Cancel();
135 | }
136 | }
137 |
138 | #endregion Overloads
139 | }
140 | }
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/FRPrintPreviewDialog.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/FastReport.OpenSource.Winforms.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Library
5 | net4;netcoreapp3.1
6 | true
7 | FastReport.OpenSource.Winforms
8 | FastReport.OpenSource.Winforms
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/Resources/print_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms/Resources/print_16.png
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/Resources/print_help_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms/Resources/print_help_16.png
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/Resources/print_preview.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms/Resources/print_preview.bmp
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/Resources/print_setup_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms/Resources/print_setup_16.png
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/Resources/window_print.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms/Resources/window_print.bmp
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/ZoomMode.cs:
--------------------------------------------------------------------------------
1 | namespace FastReport.OpenSource.Winforms
2 | {
3 | public enum ZoomMode
4 | {
5 | ///
6 | /// Show the preview in actual size.
7 | ///
8 | ActualSize,
9 |
10 | ///
11 | /// Show a full page.
12 | ///
13 | FullPage,
14 |
15 | ///
16 | /// Show a full page width.
17 | ///
18 | PageWidth,
19 |
20 | ///
21 | /// Show two full pages.
22 | ///
23 | TwoPages,
24 |
25 | ///
26 | /// Use the zoom factor specified by the property.
27 | ///
28 | Custom
29 | }
30 | }
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/print_preview.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms/print_preview.bmp
--------------------------------------------------------------------------------
/src/FastReport.OpenSource.Winforms/window_print.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rftd/FastReport.OpenSource.Winforms/ba2b4d6cc8e909b970def9990cd668252326d360/src/FastReport.OpenSource.Winforms/window_print.bmp
--------------------------------------------------------------------------------