Skip to content

Commit 0115389

Browse files
JosipJosip
Josip
authored and
Josip
committed
Fixed problem with wrongly applying /CropBox on page orientation (/Rotate) other than Portrait. Added debug (StdOut and StdErr) output in the Ghostscript.NET.Viewer.
1 parent 93776b5 commit 0115389

16 files changed

+1294
-37
lines changed

Ghostscript.NET.VS2015.VC.db

4 MB
Binary file not shown.

Ghostscript.NET.Viewer/FDebug.Designer.cs

+67
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Ghostscript.NET.Viewer/FDebug.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Windows.Forms;
9+
10+
namespace Ghostscript.NET.Viewer
11+
{
12+
public partial class FDebug : Form
13+
{
14+
public FDebug()
15+
{
16+
InitializeComponent();
17+
}
18+
}
19+
}

Ghostscript.NET.Viewer/FDebug.resx

+970
Large diffs are not rendered by default.

Ghostscript.NET.Viewer/FMain.Designer.cs

+43-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Ghostscript.NET.Viewer/FMain.cs

+45-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public partial class FMain : Form
4242
{
4343
private GhostscriptViewer _viewer;
4444
private GhostscriptVersionInfo _gsVersion = GhostscriptVersionInfo.GetLastInstalledVersion();
45+
private StringBuilder _stdOut = new StringBuilder();
46+
private StringBuilder _stdErr = new StringBuilder();
47+
private bool _supressPageNumberChangeEvent = false;
4548

4649
public FMain()
4750
{
@@ -53,6 +56,7 @@ public FMain()
5356
pbPage.Height = 100;
5457

5558
_viewer = new GhostscriptViewer();
59+
_viewer.AttachStdIO(new GhostscriptStdIOHandler(_stdOut, _stdErr));
5660

5761
_viewer.DisplaySize += new GhostscriptViewerViewEventHandler(_viewer_DisplaySize);
5862
_viewer.DisplayUpdate += new GhostscriptViewerViewEventHandler(_viewer_DisplayUpdate);
@@ -75,7 +79,10 @@ void _viewer_DisplayPage(object sender, GhostscriptViewerViewEventArgs e)
7579
pbPage.Invalidate();
7680
pbPage.Update();
7781

82+
_supressPageNumberChangeEvent = true;
7883
tbPageNumber.Text = _viewer.CurrentPageNumber.ToString();
84+
_supressPageNumberChangeEvent = false;
85+
7986
tbTotalPages.Text = " / " + _viewer.LastPageNumber.ToString();
8087
}
8188

@@ -98,6 +105,8 @@ private void mnuFileOpen_Click(object sender, EventArgs e)
98105
{
99106
mnuFileClose_Click(this, null);
100107

108+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> OPEN");
109+
101110
_viewer.Open(ofd.FileName, _gsVersion, false);
102111

103112
this.Text = System.IO.Path.GetFileName(ofd.FileName) + " - " + Program.NAME;
@@ -107,6 +116,10 @@ private void mnuFileOpen_Click(object sender, EventArgs e)
107116
private void mnuFileClose_Click(object sender, EventArgs e)
108117
{
109118
_viewer.Close();
119+
120+
_stdOut.Clear();
121+
_stdErr.Clear();
122+
110123
pbPage.Image = null;
111124
this.Text = Program.NAME;
112125
tbPageNumber.Text = string.Empty;
@@ -121,31 +134,39 @@ private void mnuFileExit_Click(object sender, EventArgs e)
121134

122135
private void tbPageFirst_Click(object sender, EventArgs e)
123136
{
137+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW FIRST PAGE");
124138
_viewer.ShowFirstPage();
125139
}
126140

127141
private void tbPagePrevious_Click(object sender, EventArgs e)
128142
{
143+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW PREVIOUS PAGE");
129144
_viewer.ShowPreviousPage();
130145
}
131146

132147
private void tbPageNext_Click(object sender, EventArgs e)
133148
{
149+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW NEXT PAGE");
134150
_viewer.ShowNextPage();
135151
}
136152

137153
private void tbPageLast_Click(object sender, EventArgs e)
138154
{
155+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW LAST PAGE");
139156
_viewer.ShowLastPage();
140157
}
141158

142159
private void tbPageNumber_TextChanged(object sender, EventArgs e)
143160
{
144161
try
145162
{
146-
if (tbPageNumber.Text.Length > 0)
163+
if (!_supressPageNumberChangeEvent)
147164
{
148-
_viewer.ShowPage(int.Parse(tbPageNumber.Text));
165+
if (tbPageNumber.Text.Length > 0)
166+
{
167+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW PAGE " + tbPageNumber.Text);
168+
_viewer.ShowPage(int.Parse(tbPageNumber.Text));
169+
}
149170
}
150171
}
151172
catch { }
@@ -158,32 +179,54 @@ private void mnuAbout_Click(object sender, EventArgs e)
158179

159180
private void mnuNext_Click(object sender, EventArgs e)
160181
{
182+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW NEXT PAGE");
161183
_viewer.ShowNextPage();
162184
}
163185

164186
private void mnuPrev_Click(object sender, EventArgs e)
165187
{
188+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW PREVIOUS PAGE");
166189
_viewer.ShowPreviousPage();
167190
}
168191

169192
private void mnuFirst_Click(object sender, EventArgs e)
170193
{
194+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW LAST PAGE");
171195
_viewer.ShowFirstPage();
172196
}
173197

174198
private void mnuLast_Click(object sender, EventArgs e)
175199
{
200+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW LAST PAGE");
176201
_viewer.ShowLastPage();
177202
}
178203

179204
private void tpZoomIn_Click(object sender, EventArgs e)
180205
{
206+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> ZOOM IN");
181207
_viewer.ZoomIn();
182208
}
183209

184210
private void tpZoomOut_Click(object sender, EventArgs e)
185211
{
212+
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> ZOOM OUT");
186213
_viewer.ZoomOut();
187214
}
215+
216+
private void tbDebug_Click(object sender, EventArgs e)
217+
{
218+
219+
FDebug debug = new FDebug();
220+
debug.txtDebug.AppendText("StdOut:\r\n");
221+
debug.txtDebug.AppendText("---------------------------------------------------------------------------\r\n");
222+
debug.txtDebug.AppendText(_stdOut.ToString() + "\r\n");
223+
debug.txtDebug.AppendText("===========================================================================\r\n");
224+
debug.txtDebug.AppendText("StdErr:\r\n");
225+
debug.txtDebug.AppendText("---------------------------------------------------------------------------\r\n");
226+
debug.txtDebug.AppendText(_stdErr.ToString() + "\r\n");
227+
debug.txtDebug.AppendText("===========================================================================\r\n");
228+
debug.ShowDialog(this);
229+
debug.Dispose();
230+
}
188231
}
189232
}

0 commit comments

Comments
 (0)