B2019-069 – Consider the monitor’s scaling factor when generating an X/Y Plot, B2019-090 – Reset the Word sections printed text color to black after printing with overlay (compare)
This commit is contained in:
parent
cba19044d8
commit
ef3d04b4aa
@ -13,6 +13,7 @@ using LBWordLibrary;
|
|||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using Volian.Base.Library;
|
using Volian.Base.Library;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
@ -725,6 +726,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
MSWordToPDF.OverrideColor = overrideColor;
|
MSWordToPDF.OverrideColor = overrideColor;
|
||||||
PdfInfo myPdf = PdfInfo.Get(sect,DocReplace!=null);
|
PdfInfo myPdf = PdfInfo.Get(sect,DocReplace!=null);
|
||||||
|
MSWordToPDF.OverrideColor = Color.Black; // B2019-090 reset to black text (when a Complete RO Report was created after printing procedure, X/Y Plot was in red text)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// B2018-071 Save list of DocIDs for invalid document so that error log messages are not repeated
|
// B2018-071 Save list of DocIDs for invalid document so that error log messages are not repeated
|
||||||
@ -1525,6 +1527,26 @@ namespace VEPROMS.CSLA.Library
|
|||||||
string fileName = VlnSettings.TemporaryFolder + @"\Doc_" + sect.MyContent.MyEntry.DocID.ToString()+".Pdf"; // +" " + (sect.DisplayNumber == "" ? sect.DisplayText : sect.DisplayNumber);
|
string fileName = VlnSettings.TemporaryFolder + @"\Doc_" + sect.MyContent.MyEntry.DocID.ToString()+".Pdf"; // +" " + (sect.DisplayNumber == "" ? sect.DisplayText : sect.DisplayNumber);
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
[DllImport("User32.dll")]
|
||||||
|
static extern IntPtr GetDC(IntPtr hwnd);
|
||||||
|
[DllImport("User32.dll")]
|
||||||
|
static extern int ReleaseDC(IntPtr hwnd, IntPtr dc);
|
||||||
|
[DllImport("gdi32.dll")]
|
||||||
|
static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
|
||||||
|
public enum DeviceCap
|
||||||
|
{
|
||||||
|
VERTRES = 10,
|
||||||
|
DESKTOPVERTRES = 117
|
||||||
|
}
|
||||||
|
// B2019-069 needed to get the monitor's scaling factor - used in generating RO X/Y plot
|
||||||
|
private static float ScalingFactor()
|
||||||
|
{
|
||||||
|
IntPtr desktop = GetDC(IntPtr.Zero);
|
||||||
|
int LogicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.VERTRES);
|
||||||
|
int PhysicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES);
|
||||||
|
ReleaseDC(IntPtr.Zero, desktop);
|
||||||
|
return (float)PhysicalScreenHeight / (float)LogicalScreenHeight; // a value of 1.50 represents monitor scaling set to 150%
|
||||||
|
}
|
||||||
public static RectangleF CreatePlot(string pngFile, string xyPlot, float resolution, System.Windows.Forms.Form myForm)
|
public static RectangleF CreatePlot(string pngFile, string xyPlot, float resolution, System.Windows.Forms.Form myForm)
|
||||||
{
|
{
|
||||||
RectangleF retval = new RectangleF(0, 0, 0, 0);
|
RectangleF retval = new RectangleF(0, 0, 0, 0);
|
||||||
@ -1532,37 +1554,41 @@ namespace VEPROMS.CSLA.Library
|
|||||||
System.Windows.Forms.Form frm = myForm;
|
System.Windows.Forms.Form frm = myForm;
|
||||||
Graphics grfx = frm.CreateGraphics();
|
Graphics grfx = frm.CreateGraphics();
|
||||||
string emfFile = pngFile.Replace(".png", ".emf");
|
string emfFile = pngFile.Replace(".png", ".emf");
|
||||||
Metafile mf = new Metafile(emfFile, grfx.GetHdc());
|
using (Metafile mf = new Metafile(emfFile, grfx.GetHdc()))
|
||||||
grfx.Dispose();
|
{
|
||||||
grfx = Graphics.FromImage(mf);
|
grfx.Dispose();
|
||||||
float dpi = grfx.DpiX;
|
grfx = Graphics.FromImage(mf);
|
||||||
//grfx.ScaleTransform(resolution / grfx.DpiX, (resolution +1F) / grfx.DpiY);
|
float dpi = grfx.DpiX;
|
||||||
grfx.ScaleTransform(resolution / grfx.DpiX, resolution / grfx.DpiY);
|
float sf = ScalingFactor(); // B2019-069 get monitor scaling factor
|
||||||
grfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
//grfx.ScaleTransform(resolution / grfx.DpiX, (resolution +1F) / grfx.DpiY);
|
||||||
grfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
grfx.ScaleTransform(sf * resolution / grfx.DpiX, sf * resolution / grfx.DpiY); // B2019-069 multiply the monitor's scaling factor
|
||||||
grfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
grfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||||
grfx.Clear(MSWordToPDF.DebugStatus==1 ? System.Drawing.Color.Transparent : System.Drawing.Color.White);
|
grfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||||
//grfx.Clear(System.Drawing.Color.SlateGray);
|
grfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
||||||
XYPlots.XYPlot.BlackColor = MSWordToPDF.OverrideColor == Color.Red ? Color.Red : Color.Black;
|
grfx.Clear(MSWordToPDF.DebugStatus == 1 ? System.Drawing.Color.Transparent : System.Drawing.Color.White);
|
||||||
XYPlots.XYPlot myPlot = new XYPlots.XYPlot(xyPlot);
|
//grfx.Clear(System.Drawing.Color.SlateGray);
|
||||||
myPlot.SetMargins(0, 0, 0, 0);
|
XYPlots.XYPlot.BlackColor = MSWordToPDF.OverrideColor == Color.Red ? Color.Red : Color.Black;
|
||||||
VG.IVGOutput vgOut = new VG.VGOut_Graphics(grfx);
|
XYPlots.XYPlot myPlot = new XYPlots.XYPlot(xyPlot);
|
||||||
vgOut.DebugStatus = MSWordToPDF.DebugStatus;
|
myPlot.SetMargins(0, 0, 0, 0);
|
||||||
myPlot.Process(vgOut);
|
VG.IVGOutput vgOut = new VG.VGOut_Graphics(grfx);
|
||||||
GC.Collect(); // memory garbage collection (Regex bug)
|
vgOut.DebugStatus = MSWordToPDF.DebugStatus;
|
||||||
grfx.Dispose();
|
myPlot.Process(vgOut);
|
||||||
GraphicsUnit gu = new GraphicsUnit();
|
GC.Collect(); // memory garbage collection (Regex bug)
|
||||||
retval = mf.GetBounds(ref gu);
|
grfx.Dispose();
|
||||||
retval.Width *= dpi / resolution;
|
GraphicsUnit gu = new GraphicsUnit();
|
||||||
retval.Height *= dpi / resolution;
|
retval = mf.GetBounds(ref gu);
|
||||||
retval.X *= dpi / resolution;
|
retval.Width *= dpi / resolution;
|
||||||
retval.Y *= dpi / resolution;
|
retval.Height *= dpi / resolution;
|
||||||
//retval.X = myPlot.Width-retval.Width;
|
retval.X *= dpi / resolution;
|
||||||
//AddInfo("{0},{1},{2},{3},{4},{5}", myPlot.Width, myPlot.Height, retval.Width, retval.Height,retval.X,retval.Y);
|
retval.Y *= dpi / resolution;
|
||||||
//Console.Write("{0},{1},{2},{3}", myPlot.Width, myPlot.Height, retval.Width, retval.Height);
|
//retval.X = myPlot.Width-retval.Width;
|
||||||
mf.Save(pngFile, ImageFormat.Png);
|
//AddInfo("{0},{1},{2},{3},{4},{5}", myPlot.Width, myPlot.Height, retval.Width, retval.Height,retval.X,retval.Y);
|
||||||
//Console.WriteLine("'pngfile','{0}'", pngFile);
|
//Console.Write("{0},{1},{2},{3}", myPlot.Width, myPlot.Height, retval.Width, retval.Height);
|
||||||
mf.Dispose();
|
//mf.Save(pngFile, ImageFormat.Png);
|
||||||
|
//Console.WriteLine("'pngfile','{0}'", pngFile);
|
||||||
|
}
|
||||||
|
using(Metafile mf2 = new Metafile(emfFile))
|
||||||
|
mf2.Save(pngFile, ImageFormat.Png);
|
||||||
FileInfo myFile = new System.IO.FileInfo(emfFile);
|
FileInfo myFile = new System.IO.FileInfo(emfFile);
|
||||||
myFile.Delete();
|
myFile.Delete();
|
||||||
return retval;
|
return retval;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user