Skip to content

Commit

Permalink
Fixed problem with wrongly applying /CropBox on page orientation (/Ro…
Browse files Browse the repository at this point in the history
…tate) other than Portrait. Added debug (StdOut and StdErr) output in the Ghostscript.NET.Viewer.
  • Loading branch information
Josip authored and Josip committed Dec 14, 2016
1 parent 93776b5 commit 0115389
Show file tree
Hide file tree
Showing 16 changed files with 1,294 additions and 37 deletions.
Binary file added Ghostscript.NET.VS2015.VC.db
Binary file not shown.
67 changes: 67 additions & 0 deletions Ghostscript.NET.Viewer/FDebug.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Ghostscript.NET.Viewer/FDebug.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Ghostscript.NET.Viewer
{
public partial class FDebug : Form
{
public FDebug()
{
InitializeComponent();
}
}
}
970 changes: 970 additions & 0 deletions Ghostscript.NET.Viewer/FDebug.resx

Large diffs are not rendered by default.

59 changes: 43 additions & 16 deletions Ghostscript.NET.Viewer/FMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 45 additions & 2 deletions Ghostscript.NET.Viewer/FMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public partial class FMain : Form
{
private GhostscriptViewer _viewer;
private GhostscriptVersionInfo _gsVersion = GhostscriptVersionInfo.GetLastInstalledVersion();
private StringBuilder _stdOut = new StringBuilder();
private StringBuilder _stdErr = new StringBuilder();
private bool _supressPageNumberChangeEvent = false;

public FMain()
{
Expand All @@ -53,6 +56,7 @@ public FMain()
pbPage.Height = 100;

_viewer = new GhostscriptViewer();
_viewer.AttachStdIO(new GhostscriptStdIOHandler(_stdOut, _stdErr));

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

_supressPageNumberChangeEvent = true;
tbPageNumber.Text = _viewer.CurrentPageNumber.ToString();
_supressPageNumberChangeEvent = false;

tbTotalPages.Text = " / " + _viewer.LastPageNumber.ToString();
}

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

_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> OPEN");

_viewer.Open(ofd.FileName, _gsVersion, false);

this.Text = System.IO.Path.GetFileName(ofd.FileName) + " - " + Program.NAME;
Expand All @@ -107,6 +116,10 @@ private void mnuFileOpen_Click(object sender, EventArgs e)
private void mnuFileClose_Click(object sender, EventArgs e)
{
_viewer.Close();

_stdOut.Clear();
_stdErr.Clear();

pbPage.Image = null;
this.Text = Program.NAME;
tbPageNumber.Text = string.Empty;
Expand All @@ -121,31 +134,39 @@ private void mnuFileExit_Click(object sender, EventArgs e)

private void tbPageFirst_Click(object sender, EventArgs e)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW FIRST PAGE");
_viewer.ShowFirstPage();
}

private void tbPagePrevious_Click(object sender, EventArgs e)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW PREVIOUS PAGE");
_viewer.ShowPreviousPage();
}

private void tbPageNext_Click(object sender, EventArgs e)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW NEXT PAGE");
_viewer.ShowNextPage();
}

private void tbPageLast_Click(object sender, EventArgs e)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW LAST PAGE");
_viewer.ShowLastPage();
}

private void tbPageNumber_TextChanged(object sender, EventArgs e)
{
try
{
if (tbPageNumber.Text.Length > 0)
if (!_supressPageNumberChangeEvent)
{
_viewer.ShowPage(int.Parse(tbPageNumber.Text));
if (tbPageNumber.Text.Length > 0)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW PAGE " + tbPageNumber.Text);
_viewer.ShowPage(int.Parse(tbPageNumber.Text));
}
}
}
catch { }
Expand All @@ -158,32 +179,54 @@ private void mnuAbout_Click(object sender, EventArgs e)

private void mnuNext_Click(object sender, EventArgs e)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW NEXT PAGE");
_viewer.ShowNextPage();
}

private void mnuPrev_Click(object sender, EventArgs e)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW PREVIOUS PAGE");
_viewer.ShowPreviousPage();
}

private void mnuFirst_Click(object sender, EventArgs e)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW LAST PAGE");
_viewer.ShowFirstPage();
}

private void mnuLast_Click(object sender, EventArgs e)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> SHOW LAST PAGE");
_viewer.ShowLastPage();
}

private void tpZoomIn_Click(object sender, EventArgs e)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> ZOOM IN");
_viewer.ZoomIn();
}

private void tpZoomOut_Click(object sender, EventArgs e)
{
_stdOut.AppendLine("@GSNET_VIEWER -> COMMAND -> ZOOM OUT");
_viewer.ZoomOut();
}

private void tbDebug_Click(object sender, EventArgs e)
{

FDebug debug = new FDebug();
debug.txtDebug.AppendText("StdOut:\r\n");
debug.txtDebug.AppendText("---------------------------------------------------------------------------\r\n");
debug.txtDebug.AppendText(_stdOut.ToString() + "\r\n");
debug.txtDebug.AppendText("===========================================================================\r\n");
debug.txtDebug.AppendText("StdErr:\r\n");
debug.txtDebug.AppendText("---------------------------------------------------------------------------\r\n");
debug.txtDebug.AppendText(_stdErr.ToString() + "\r\n");
debug.txtDebug.AppendText("===========================================================================\r\n");
debug.ShowDialog(this);
debug.Dispose();
}
}
}
Loading

0 comments on commit 0115389

Please sign in to comment.