void GetDpiHandler(out float dpix, out float dpiy)
{
- dpix = (int)DisplayInformation.GetForCurrentView().LogicalDpi;
- dpiy = (int)DisplayInformation.GetForCurrentView().LogicalDpi;
+ dpix = DisplayInformation.GetForCurrentView().LogicalDpi;
+ dpiy = DisplayInformation.GetForCurrentView().LogicalDpi;
}
public bool Resize(Windows.UI.Xaml.Shapes.Rectangle rect, double width, double height)
D2D.DeviceContext D2DContext;
D2D.Bitmap1 Bitmap;
Size Size;
+ float dpi;
- public D2DPrintPreviewRender(string fontName, double fontSize, Size size)
+ public D2DPrintPreviewRender(string fontName, double fontSize, Size size,float dpi)
: base()
{
this.Size = size;
+ this.dpi = dpi;
base.ConstructRender = this.ConstructRenderHandler;
base.ConstrctedResource = this.ConstructedResourceHandler;
new void GetDpi(out float dpix, out float dpiy)
{
- dpix = (int)DisplayInformation.GetForCurrentView().LogicalDpi;
- dpiy = (int)DisplayInformation.GetForCurrentView().LogicalDpi;
+ dpix = this.dpi;
+ dpiy = this.dpi;
}
public override void BeginDraw()
public void EndDraw(IPrintPreviewDxgiPackageTarget target,uint page)
{
base.EndDraw();
- float dpix, dpiy;
- this.GetDpi(out dpix, out dpiy);
-
- target.DrawPage(page, this.Surface.NativePointer, (float)dpix, (float)dpiy);
+ target.DrawPage(page, this.Surface.NativePointer, this.dpi, this.dpi);
}
public void SetScale(float scale)
D2D.RenderTarget ConstructRenderHandler(D2D.Factory1 factory, D2D.RenderTargetProperties prop, double width, double height)
{
- float dpix, dpiy;
- this.GetDpi(out dpix, out dpiy);
-
D3D11.Texture2DDescription desc = new D3D11.Texture2DDescription();
- desc.Width = (int)(width * dpix / 96);
- desc.Height = (int)(height * dpix / 96);
+ desc.Width = (int)(width * this.dpi / 96);
+ desc.Height = (int)(height * this.dpi / 96);
desc.Format = DXGI.Format.B8G8R8A8_UNorm;
desc.BindFlags = D3D11.BindFlags.RenderTarget | D3D11.BindFlags.ShaderResource;
desc.ArraySize = 1;
this.D2DContext = new D2D.DeviceContext(this.D2DDevice, D2D.DeviceContextOptions.None);
- this.D2DContext.DotsPerInch = new Size2F(dpix, dpix);
+ this.D2DContext.DotsPerInch = new Size2F(this.dpi, this.dpi);
D2D.BitmapProperties1 bmpProp = new D2D.BitmapProperties1();
bmpProp.BitmapOptions = D2D.BitmapOptions.Target | D2D.BitmapOptions.CannotDraw;
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.\r
*/\r
using System;\r
+using Windows.Graphics.Display;\r
using Windows.Graphics.Printing;\r
using System.Runtime.InteropServices;\r
using Windows.UI;\r
int lineBreakCharCount, tabCount;\r
bool drawLineNumber, urlMark;\r
IHilighter hilighter;\r
+ float displayDpi;\r
public PrintableViewFactory(FooTextBox textbox)\r
{\r
this.foreground = textbox.Foreground;\r
this.drawLineNumber = textbox.DrawLineNumber;\r
this.urlMark = textbox.MarkURL;\r
this.hilighter = textbox.Hilighter;\r
+ this.displayDpi = DisplayInformation.GetForCurrentView().LogicalDpi;\r
}\r
public D2DRenderBase CreateRender(PrintPageDescription pagedesc, IPrintDocumentPackageTarget docPackageTarget)\r
{\r
{\r
D2DPrintPreviewRender render;\r
Size size = new Size(pagedesc.ImageableRect.Width, pagedesc.ImageableRect.Height);\r
- render = new D2DPrintPreviewRender(this.fontName, this.fontSize, size);\r
+ render = new D2DPrintPreviewRender(this.fontName, this.fontSize, size, this.displayDpi);\r
render.Foreground = this.foreground;\r
render.Comment = this.comment;\r
render.Keyword1 = this.keyword1;\r