This commit is contained in:
Kathy Ruffing 2011-01-19 16:06:46 +00:00
parent 7c5ebdaecc
commit 8a7e5bcc18

View File

@ -370,22 +370,32 @@ namespace VEPROMS.CSLA.Library
string fileName = GetFileName(sect); string fileName = GetFileName(sect);
FileInfo fi = new FileInfo(fileName); FileInfo fi = new FileInfo(fileName);
FileStream fs = fi.Create(); FileStream fs = fi.Create();
fs.Write(mydoc.DocPdf, 0, mydoc.DocPdf.Length); if (mydoc.DocPdf!=null)fs.Write(mydoc.DocPdf, 0, mydoc.DocPdf.Length);
fs.Close(); fs.Close();
return fileName; return fileName;
} }
public static void UpdateDocPdf(DocumentInfo mydoc, Color overrideColor) public static bool UpdateDocPdf(DocumentInfo mydoc, Color overrideColor)
{ {
if (mydoc.DocPdf == null || overrideColor.ToArgb() != mydoc.DocumentConfig.Printing_Color.ToArgb()) if (mydoc.DocPdf == null || overrideColor.ToArgb() != mydoc.DocumentConfig.Printing_Color.ToArgb())
{ {
MSWordToPDF.OverrideColor = overrideColor; MSWordToPDF.OverrideColor = overrideColor;
SetDocPdf(mydoc); return SetDocPdf(mydoc);
} }
return true;
} }
public static void SetDocPdf(DocumentInfo docInfo) public static bool SetDocPdf(DocumentInfo docInfo)
{ {
string pdfTmp = MSWordToPDF.ToPDFReplaceROs(docInfo); string pdfTmp = null;
try
{
pdfTmp = MSWordToPDF.ToPDFReplaceROs(docInfo);
}
catch (Exception ex)
{
return false;
}
if (pdfTmp == null) return false;
FileInfo pdfFile = new FileInfo(pdfTmp); FileInfo pdfFile = new FileInfo(pdfTmp);
FileStream fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); FileStream fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Byte[] buf = new byte[pdfFile.Length]; Byte[] buf = new byte[pdfFile.Length];
@ -401,6 +411,7 @@ namespace VEPROMS.CSLA.Library
doc.Save(); doc.Save();
} }
docInfo.RefreshConfig(); docInfo.RefreshConfig();
return true;
} }
public static string ToPDFReplaceROs(DocumentInfo doc) public static string ToPDFReplaceROs(DocumentInfo doc)
{ {
@ -493,37 +504,44 @@ namespace VEPROMS.CSLA.Library
} }
else if ((int)type == 4) // X-Y Plot else if ((int)type == 4) // X-Y Plot
{ {
val = val.Replace("`", "\xB0"); try
//AddInfo("\tRO Found {0} = '{1}'", sel.Text, val); {
sel.Text = ""; val = val.Replace("`", "\xB0");
//float width = 72 * Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) / 12.0F; //AddInfo("\tRO Found {0} = '{1}'", sel.Text, val);
//float height = 72 * lines / 6.0F; sel.Text = "";
string pngFile = VlnSettings.TemporaryFolder + @"\XYPlot1.png"; //@"C:\Temp\XYPlot1.png"; //float width = 72 * Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) / 12.0F;
RectangleF plotRect = CreatePlot(pngFile, val, 600F, FormForPlotGraphics); //float height = 72 * lines / 6.0F;
//LBShape shape = myDoc.Shapes.AddPicture(@"C:\Temp\XYPlot.png", 0, 0, sel.Range); string pngFile = VlnSettings.TemporaryFolder + @"\XYPlot1.png"; //@"C:\Temp\XYPlot1.png";
float x = (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage); RectangleF plotRect = CreatePlot(pngFile, val, 600F, FormForPlotGraphics);
float y = (float)sel.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage); //LBShape shape = myDoc.Shapes.AddPicture(@"C:\Temp\XYPlot.png", 0, 0, sel.Range);
//LBInlineShape shape = sel.InlineShapes.AddPicture(pngFile); float x = (float)sel.get_Information(LBWdInformation.wdHorizontalPositionRelativeToPage);
LBRange myRange = sel.Paragraphs.First.Range; float y = (float)sel.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
float yTop = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage); //LBInlineShape shape = sel.InlineShapes.AddPicture(pngFile);
float xAdjust = -29.3F; // TODO: Check this value LBRange myRange = sel.Paragraphs.First.Range;
float yAdjust = 9.1F; // TODO: Check this value float yTop = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage);
LBShape shape = myDoc.Shapes.AddPicture(pngFile, x + xAdjust + plotRect.X, yAdjust + y - yTop + plotRect.Y, sel.Range); float xAdjust = -29.3F; // TODO: Check this value
File.Delete(pngFile); float yAdjust = 9.1F; // TODO: Check this value
//Console.WriteLine(",{0},{1},{2},{3}", x, y - yTop, xAdjust,yAdjust); LBShape shape = myDoc.Shapes.AddPicture(pngFile, x + xAdjust + plotRect.X, yAdjust + y - yTop + plotRect.Y, sel.Range);
shape.LockAspectRatio = LBMsoTriState.msoTrue; File.Delete(pngFile);
//shape.Width = .89F * shape.Width; //Console.WriteLine(",{0},{1},{2},{3}", x, y - yTop, xAdjust,yAdjust);
//shape.Width = float.Parse(tbAdjust.Text) * shape.Width; shape.LockAspectRatio = LBMsoTriState.msoTrue;
shape.Width = plotRect.Width; //shape.Width = .89F * shape.Width;
//shape.Height = .89F * shape.Height; //shape.Width = float.Parse(tbAdjust.Text) * shape.Width;
sel.WholeStory(); shape.Width = plotRect.Width;
// TODO: Do we want to color code ROs //shape.Height = .89F * shape.Height;
//sel.Range.Font.Color = LBWdColor.wdColorRed; sel.WholeStory();
//Console.WriteLine("{0} Shape Width {1} Height {2}", val.Replace("\n", "','"), shape.Width, shape.Height); // TODO: Do we want to color code ROs
//shape.Width = width; //sel.Range.Font.Color = LBWdColor.wdColorRed;
//shape.Height = height; //Console.WriteLine("{0} Shape Width {1} Height {2}", val.Replace("\n", "','"), shape.Width, shape.Height);
//Console.WriteLine("{0} Shape Width {1} Height {2}", val.Replace("\n", "','"), shape.Width, shape.Height); //shape.Width = width;
//imageROTokenReplaced = true; //shape.Height = height;
//Console.WriteLine("{0} Shape Width {1} Height {2}", val.Replace("\n", "','"), shape.Width, shape.Height);
//imageROTokenReplaced = true;
}
catch (Exception ex)
{
return null;
}
} }
else else
{ {