Preparation to switch to ITextSharp library

Corrected logic to process window size/movement adjustments
This commit is contained in:
Rich 2009-02-06 15:52:27 +00:00
parent 1503b3f9cc
commit 1731dbe43b
3 changed files with 68 additions and 56 deletions

View File

@ -91,8 +91,8 @@ namespace VG
public void UpdatePageInfo(Page pa) public void UpdatePageInfo(Page pa)
{ {
pg.LeftMargin=pa.LeftMargin; pg.LeftMargin=pa.LeftMargin;
pg.portrait=pg.portrait; pg.portrait=pa.portrait; // RHM 20081003 - This had been pg.portrait=pg.portrait
pg.VertOffset=pg.VertOffset; pg.VertOffset=pa.VertOffset; // RHM 20081003 - This had been pg.VertOffset=pg.VertOffset
} }
public string AddRTFBUI(string origStr, string bold, string underline, string italics) public string AddRTFBUI(string origStr, string bold, string underline, string italics)
@ -134,14 +134,14 @@ namespace VG
pg = ipg; pg = ipg;
} }
public void ToPdf(C1PdfDocument c1pdf) public void ToPdf(C1PdfDocument pdf)
{ {
float startx = pg.portrait ? (cx + pg.LeftMargin): (pg.VertOffset + cy); float startx = pg.portrait ? (cx + pg.LeftMargin): (pg.VertOffset + cy);
float starty = pg.portrait ? (cy + pg.VertOffset): (pg.LeftMargin - cx); float starty = pg.portrait ? (cy + pg.VertOffset): (pg.LeftMargin - cx);
float endx = pg.portrait ? (dx + pg.LeftMargin): (pg.VertOffset + dy); float endx = pg.portrait ? (dx + pg.LeftMargin): (pg.VertOffset + dy);
float endy = pg.portrait ? (dy + pg.VertOffset): (pg.LeftMargin - dx); float endy = pg.portrait ? (dy + pg.VertOffset): (pg.LeftMargin - dx);
Pen pn = new Pen(Brushes.Black,ToPoints(lnwid)); Pen pn = new Pen(Brushes.Black,ToPoints(lnwid));
c1pdf.DrawLine(pn, ToPoints(startx), ToPoints(starty), ToPoints(endx), ToPoints(endy)); pdf.DrawLine(pn, ToPoints(startx), ToPoints(starty), ToPoints(endx), ToPoints(endy));
} }
} }
@ -169,7 +169,7 @@ namespace VG
pg = ipg; pg = ipg;
} }
public void ToPdf(C1PdfDocument c1pdf) public void ToPdf(C1PdfDocument pdf)
{ {
Pen pn = new Pen(Brushes.Black,ToPoints(lnwid)); Pen pn = new Pen(Brushes.Black,ToPoints(lnwid));
@ -178,7 +178,7 @@ namespace VG
float endx = pg.portrait ? dx: dy; float endx = pg.portrait ? dx: dy;
float endy = pg.portrait ? dy: dx; float endy = pg.portrait ? dy: dx;
RectangleF rc = new RectangleF(ToPoints(startx), ToPoints(starty), ToPoints(endx), ToPoints(endy)); RectangleF rc = new RectangleF(ToPoints(startx), ToPoints(starty), ToPoints(endx), ToPoints(endy));
c1pdf.DrawRectangle(pn,rc); pdf.DrawRectangle(pn,rc);
} }
} }
@ -206,7 +206,7 @@ namespace VG
pg = ipg; pg = ipg;
} }
public void ToPdf(C1PdfDocument c1pdf) public void ToPdf(C1PdfDocument pdf)
{ {
Pen pn = new Pen(Brushes.Black,lnwid); Pen pn = new Pen(Brushes.Black,lnwid);
Bitmap bm = new Bitmap(FileName); Bitmap bm = new Bitmap(FileName);
@ -215,7 +215,7 @@ namespace VG
rc.Width = ToPoints((bm.Width*Scale)*4.8f); rc.Width = ToPoints((bm.Width*Scale)*4.8f);
rc.X = ToPoints(pg.LeftMargin+cx); rc.X = ToPoints(pg.LeftMargin+cx);
rc.Y = ToPoints(pg.VertOffset+cy); rc.Y = ToPoints(pg.VertOffset+cy);
c1pdf.DrawImage(bm, rc, ContentAlignment.MiddleCenter, ImageSizeModeEnum.Scale); pdf.DrawImage(bm, rc, ContentAlignment.MiddleCenter, ImageSizeModeEnum.Scale);
} }
} }
@ -242,10 +242,10 @@ namespace VG
pg = ipg; pg = ipg;
} }
public void ToPdf(C1PdfDocument c1pdf) public void ToPdf(C1PdfDocument pdf)
{ {
Pen pn = new Pen(Brushes.Black,ToPoints(lnwid)); Pen pn = new Pen(Brushes.Black,ToPoints(lnwid));
c1pdf.DrawEllipse(pn,ToPoints(pg.LeftMargin+cx), ToPoints(pg.VertOffset+cy), ToPoints(dx), ToPoints(dy)); pdf.DrawEllipse(pn,ToPoints(pg.LeftMargin+cx), ToPoints(pg.VertOffset+cy), ToPoints(dx), ToPoints(dy));
} }
} }
@ -290,18 +290,18 @@ namespace VG
pg = ipg; pg = ipg;
} }
public void ToPdf(C1PdfDocument c1pdf) public void ToPdf(C1PdfDocument pdf)
{ {
Font myfont = new Font(FontName,FontSize); Font myfont = new Font(FontName,FontSize);
RectangleF rc = new RectangleF(); RectangleF rc = new RectangleF();
// the returned value from c1 pdf code is already in points, // the returned value from c1 pdf code is already in points,
// so need to convert the size. // so need to convert the size.
rc.Size = c1pdf.MeasureStringRtf(Text,myfont,500); // TODO: 500 or pagewidth, or what rc.Size = pdf.MeasureStringRtf(Text,myfont,500); // TODO: 500 or pagewidth, or what
rc.X = ToPoints(pg.LeftMargin+cx); rc.X = ToPoints(pg.LeftMargin+cx);
rc.Y = ToPoints(pg.VertOffset+cy)-FontSize; rc.Y = ToPoints(pg.VertOffset+cy)-FontSize;
// add bold, underline & italics for entire object. // add bold, underline & italics for entire object.
string rtfout = AddRTFBUI(Text,Bold,Underline,Italics); string rtfout = AddRTFBUI(Text,Bold,Underline,Italics);
c1pdf.DrawStringRtf(rtfout,myfont,Brushes.Black,rc); pdf.DrawStringRtf(rtfout,myfont,Brushes.Black,rc);
} }
} }
public class VG_Arc : VG public class VG_Arc : VG
@ -339,7 +339,7 @@ public class VG_Arc : VG
// pg = ipg; // pg = ipg;
// } // }
public void ToPdf(C1PdfDocument c1pdf) public void ToPdf(C1PdfDocument pdf)
{ {
// Pen pn = new Pen(Brushes.Black,ToPoints(lnwid)); // Pen pn = new Pen(Brushes.Black,ToPoints(lnwid));
#if DEBUG #if DEBUG
@ -357,7 +357,7 @@ public class VG_Arc : VG
// c1pdf.DrawRectangle(pn,rc); //debug // c1pdf.DrawRectangle(pn,rc); //debug
// c1pdf.DrawArc(new Pen(Color.Black,ToPoints(lnwid)),new RectangleF(stX,stY,rWid,rHgt),startAngle,sweepAngle); // c1pdf.DrawArc(new Pen(Color.Black,ToPoints(lnwid)),new RectangleF(stX,stY,rWid,rHgt),startAngle,sweepAngle);
c1pdf.DrawArc(pn,rc,startAngle,sweepAngle); pdf.DrawArc(pn,rc,startAngle,sweepAngle);
// c1pdf.DrawArc(new Pen(Color.Black, 4),rc,startAngle,sweepAngle); // c1pdf.DrawArc(new Pen(Color.Black, 4),rc,startAngle,sweepAngle);
} }
} }

View File

@ -1161,6 +1161,15 @@ namespace Volian.Controls.Library
ExpandChildren(_MyRNOStepItems); ExpandChildren(_MyRNOStepItems);
ExpandChildren(_MyAfterStepItems); ExpandChildren(_MyAfterStepItems);
} }
private string MyPath
{
get
{
if(MyItemInfo.MyContent.Type >= 20000)
return MyItemInfo.Path.Substring(MyItemInfo.ActiveSection.Path.Length);
return "";
}
}
/// <summary> /// <summary>
/// Adjust the Location of all items below the current item. /// Adjust the Location of all items below the current item.
/// </summary> /// </summary>
@ -1261,8 +1270,7 @@ namespace Volian.Controls.Library
get get
{ {
StepItem tmp = this; StepItem tmp = this;
// If this item appears before it's parent, and it doesn't have anything below it, return the parent if (tmp.MyNextStepItem == null && FirstSiblingStepItem._MyChildRelation == ChildRelation.Before && tmp._MyAfterStepItems == null)
if (tmp.MyNextStepItem == null && FirstSiblingStepItem._MyChildRelation == ChildRelation.Before)
return UpOneStepItem; return UpOneStepItem;
if (Expanded && tmp._MyAfterStepItems != null)// check to see if there is a _After if (Expanded && tmp._MyAfterStepItems != null)// check to see if there is a _After
return tmp._MyAfterStepItems[0].TopMostStepItem;// if there is go that way return tmp._MyAfterStepItems[0].TopMostStepItem;// if there is go that way
@ -1273,6 +1281,8 @@ namespace Volian.Controls.Library
return null; return null;
if (tmp.MyExpandingStatus == ExpandingStatus.Expanding || tmp.Moving) // Parent Expanding or Moving - Wait if (tmp.MyExpandingStatus == ExpandingStatus.Expanding || tmp.Moving) // Parent Expanding or Moving - Wait
return null; return null;
if (tmp.MyNextStepItem == null && tmp.FirstSiblingStepItem._MyChildRelation == ChildRelation.Before)
return tmp.UpOneStepItem;
StepItem btm = tmp.BottomMostStepItem; StepItem btm = tmp.BottomMostStepItem;
if (this != btm) if (this != btm)
{ {

View File

@ -14,21 +14,47 @@ namespace XYPlots
/// </summary> /// </summary>
public class XYPlot public class XYPlot
{ {
// private int ConvertToTwips = 1440; #region OldStuff
private double ConvertToTwips = 4.8; #if OldStuff
static long HP3_HPGL_COMPENSATEX = 1016L; /* OK, so you don't believe it */ static long HP3_HPGL_COMPENSATEX = 1016L; /* OK, so you don't believe it */
static long HP3_HPGL_COMPENSATEY = 1016L;/* OK, so you don't believe it */ static long HP3_HPGL_COMPENSATEY = 1016L;/* OK, so you don't believe it */
private long DotsToPlotterUnitsX(int x)
{
long retval;
retval = (long)((1.0 * x * HP_FudgeX) / 300.0 + .5);
return (retval);
}
private long DotsToPlotterUnitsY(int y)
{
long retval;
retval = (long)((1.0 * y * HP_FudgeY) / 300.0 + .5);
return (retval);
}
private long HP_FudgeX = HP3_HPGL_COMPENSATEX;
private long HP_FudgeY = HP3_HPGL_COMPENSATEY;
static long PRINTAPLOT_COMPENSATE = 1020L;/* but these resolve differently*/ static long PRINTAPLOT_COMPENSATE = 1020L;/* but these resolve differently*/
static int MAX_XY_STACK = 8; /* this is max of CIE cursor/font stack */ static int DASH = 2;
private void Graphics(int flag)
{
// if(graph_GraphicsStr[flag])
// fprintf(stdprn,"%s",graph_GraphicsStr[flag]);
}
private string GoodOldStringX;
private string GoodOldStringY;
#endif
#endregion
// private int ConvertToTwips = 1440;
private double ConvertToTwips = 4.8;
static int MAX_XY_STACK = 8; /* this is max of CIE cursor/font stack */
static int DPI = 1440; //300; static int DPI = 1440; //300;
static int CWIDEDOTS = 120; //25; static int CWIDEDOTS = 120; //25;
static int CHIGHDOTS = 240; //50; static int CHIGHDOTS = 240; //50;
static int STRAIGHT = 0; static int STRAIGHT = 0;
static int CURVE = 1; static int CURVE = 1;
static int DASH = 2;
static int X = 0; static int X = 0;
static int Y = 1; static int Y = 1;
@ -50,11 +76,7 @@ namespace XYPlots
private int[] SavedY; private int[] SavedY;
private int stack; private int stack;
private int HPGLMode; private int HPGLMode;
private long HP_FudgeX = HP3_HPGL_COMPENSATEX;
private long HP_FudgeY = HP3_HPGL_COMPENSATEY;
private string GoodOldStringX;
private string GoodOldStringY;
public int LinesUsed; public int LinesUsed;
@ -1448,12 +1470,6 @@ namespace XYPlots
return; return;
} }
private void Graphics(int flag)
{
// if(graph_GraphicsStr[flag])
// fprintf(stdprn,"%s",graph_GraphicsStr[flag]);
}
private void SetPenDiameter(int pd) private void SetPenDiameter(int pd)
{ {
if ((pd * ConvertToTwips) != CurPenWidth) if ((pd * ConvertToTwips) != CurPenWidth)
@ -1522,20 +1538,6 @@ namespace XYPlots
ptr = string.Format("+{0}",i.ToString()); ptr = string.Format("+{0}",i.ToString());
} }
private long DotsToPlotterUnitsX(int x)
{
long retval;
retval = (long)((1.0*x*HP_FudgeX) / 300.0 + .5);
return( retval );
}
private long DotsToPlotterUnitsY(int y)
{
long retval;
retval = (long)((1.0*y*HP_FudgeY) / 300.0 + .5);
return( retval );
}
private void MoveRelative(int x, int y) private void MoveRelative(int x, int y)
{ {
long xl,yl; long xl,yl;
@ -2210,8 +2212,8 @@ namespace XYPlots
FixBuffIfNeeded(); FixBuffIfNeeded();
GetScaleInfo(); GetScaleInfo();
C1.C1Pdf.C1PdfDocument c1pdf = new C1.C1Pdf.C1PdfDocument(); C1.C1Pdf.C1PdfDocument pdf = new C1.C1Pdf.C1PdfDocument();
c1pdf.FontType = C1.C1Pdf.FontTypeEnum.Embedded; // embed fonts pdf.FontType = C1.C1Pdf.FontTypeEnum.Embedded; // embed fonts
VG.Page pg = new Page(true,(float)(1440),(float)(1440)); VG.Page pg = new Page(true,(float)(1440),(float)(1440));
@ -2271,13 +2273,13 @@ namespace XYPlots
} }
PrevCommand = Command; PrevCommand = Command;
} }
Graphics(1); //Graphics(1);
GenerateGrid(pg,c1pdf); GenerateGrid(pg,pdf);
DoAxisTitles(pg,c1pdf); DoAxisTitles(pg,pdf);
DoBoxes(pg,c1pdf); DoBoxes(pg,pdf);
DrawLines(pg,c1pdf); DrawLines(pg,pdf);
Graphics(0); //Graphics(0);
c1pdf.Save(_ThePDFFile); pdf.Save(_ThePDFFile);
//c1pdf.Save(PdfFileName); //c1pdf.Save(PdfFileName);
FreeBoxList(); FreeBoxList();
FreeLineList(); FreeLineList();