97 lines
3.0 KiB
C#
97 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Drawing;
|
|
using iTextSharp.text.pdf;
|
|
using iTextSharp.text;
|
|
using VEPROMS.CSLA.Library;
|
|
|
|
|
|
namespace Volian.Print.Library
|
|
{
|
|
public partial class vlnBox : vlnPrintObject
|
|
{
|
|
private int _LineType; /* how to represent?? */
|
|
private System.Drawing.Color _Color;
|
|
public System.Drawing.Color Color
|
|
{
|
|
get { return _Color; }
|
|
set { _Color = value; }
|
|
}
|
|
private Box _MyBox;
|
|
|
|
public Box MyBox
|
|
{
|
|
get { return _MyBox; }
|
|
set { _MyBox = value; }
|
|
}
|
|
// the following two fields are used if 'boxed' step, thus
|
|
// no 'Box' was defined in format file.
|
|
public string DefBox = null;
|
|
public float DefEnd = 0;
|
|
public vlnBox()
|
|
{
|
|
}
|
|
public vlnBox(vlnParagraph paragraph)
|
|
{
|
|
}
|
|
public const string BoxThin = "\x2510.\x2500.\x250c.\x2502. . .\x2518.\x2514. .\x2500. . ";
|
|
const string BoxThick = "\x2584.\x2584.\x2584.\x2588. . .\x2580.\x2580. .\x2580. . ";
|
|
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
{
|
|
cb.SaveState();
|
|
VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
|
|
PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer;
|
|
if (textLayer != null) cb.BeginLayer(textLayer);
|
|
MyContentByte = cb;
|
|
//Console.WriteLine("'{0}','{1}'", CharToAsc(MyBox.BoxStyle), MyParent.MyItemInfo.ShortPath);
|
|
float top = CalculateYOffset(yPageStart, yTopMargin) - (7*MyPageHelper.YMultiplier);
|
|
float bottom = top - (Height * MyPageHelper.YMultiplier);
|
|
float leftmargin = (float)MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin + 3;
|
|
float left = (float)(MyBox.Start == null ? MyParent.MyItemInfo.MyDocStyle.Layout.LeftMargin : leftmargin + MyBox.Start);
|
|
float right = leftmargin + (float)(MyBox.End ?? DefEnd);
|
|
iTextSharp.text.Color boxColor = new iTextSharp.text.Color(PrintOverride.OverrideBoxColor(System.Drawing.Color.Black));
|
|
cb.SetColorStroke(boxColor);
|
|
if (DefBox != null)
|
|
{
|
|
cb.SetLineWidth(.6F);
|
|
cb.Rectangle(left, bottom, right - left, Height * MyPageHelper.YMultiplier);
|
|
}
|
|
else
|
|
{
|
|
float lineThickness = 0;
|
|
switch (MyBox.BoxStyle)
|
|
{
|
|
case BoxThin:
|
|
lineThickness = .6F;
|
|
break;
|
|
case BoxThick:
|
|
lineThickness = 6;
|
|
break;
|
|
default:
|
|
// For other than OHLP/HLP. For those not matching the HLP Boxes
|
|
throw new Exception("Missing vlnBox handler");
|
|
}
|
|
const float llxOffset = 3;
|
|
cb.SetLineWidth(lineThickness);
|
|
cb.Rectangle(left + llxOffset, bottom + (lineThickness / 2), right - left - llxOffset, (Height - lineThickness) * MyPageHelper.YMultiplier);
|
|
}
|
|
cb.Stroke();
|
|
if (textLayer != null) cb.EndLayer();
|
|
cb.RestoreState();
|
|
return yPageStart;
|
|
}
|
|
|
|
private string CharToAsc(string p)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (char c in p)
|
|
{
|
|
if (c >= ' ' && c < 127) sb.Append(c);
|
|
else sb.Append(string.Format("\\x{0:x}", (int)c));
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|