public void Initialize(Window window) { Vector dpi = DisplayResolution.GetDpi(window); float dpiX = (float)dpi.X; float dpiY = (float)dpi.Y; _renderer = _engine.CreateRenderer(dpiX, dpiY, this); _renderer.AddListener(new RendererListener(this)); backgroundLayer.Renderer = _renderer; modelLayer.Renderer = _renderer; captureLayer.Renderer = _renderer; temporaryLayer.Renderer = _renderer; _editor = _engine.CreateEditor(Renderer); _editor.SetViewSize((int)Math.Round(captureLayer.ActualWidth), (int)Math.Round(captureLayer.ActualHeight)); _editor.SetFontMetricsProvider(new FontMetricsProvider(dpiX, dpiY)); _editor.AddListener(new EditorListener(this)); smartGuide.Editor = _editor; var tempFolder = _engine.Configuration.GetString("content-package.temp-folder"); _loader = new ImageLoader(_editor, tempFolder); backgroundLayer.ImageLoader = _loader; modelLayer.ImageLoader = _loader; captureLayer.ImageLoader = _loader; temporaryLayer.ImageLoader = _loader; float verticalMarginPX = 60; float horizontalMarginPX = 40; float verticalMarginMM = 25.4f * verticalMarginPX / dpiY; float horizontalMarginMM = 25.4f * horizontalMarginPX / dpiX; _engine.Configuration.SetNumber("text.margin.top", verticalMarginMM); _engine.Configuration.SetNumber("text.margin.left", horizontalMarginMM); _engine.Configuration.SetNumber("text.margin.right", horizontalMarginMM); _engine.Configuration.SetNumber("math.margin.top", verticalMarginMM); _engine.Configuration.SetNumber("math.margin.bottom", verticalMarginMM); _engine.Configuration.SetNumber("math.margin.left", horizontalMarginMM); _engine.Configuration.SetNumber("math.margin.right", horizontalMarginMM); }
private void Initialize() { var info = DisplayInformation.GetForCurrentView(); _dpiX = info.RawDpiX; var dpiY = info.RawDpiY; if (info.RawPixelsPerViewPixel > 0.0) { _pixelDensity = (float)info.RawPixelsPerViewPixel; } else if (info.ResolutionScale != ResolutionScale.Invalid) { _pixelDensity = (float)info.ResolutionScale / 100.0f; } if (_pixelDensity > 0.0f) { _dpiX /= _pixelDensity; dpiY /= _pixelDensity; } // RawDpi properties can return 0 when the monitor does not provide physical dimensions and when the user is // in a clone or duplicate multiple -monitor setup. if (_dpiX == 0 || dpiY == 0) { _dpiX = dpiY = 96; } _renderer = _engine.CreateRenderer(_dpiX, dpiY, this); _renderer.AddListener(new RendererListener(this)); _modelLayer = new Layer(modelCanvas, this, LayerType.MODEL, _renderer); _captureLayer = new Layer(captureCanvas, this, LayerType.CAPTURE, _renderer); _editor = _engine.CreateEditor(_renderer); _editor.SetViewSize((int)ActualWidth, (int)ActualHeight); _editor.SetFontMetricsProvider(new FontMetricsProvider(_dpiX, dpiY)); _editor.AddListener(new EditorListener(this)); smartGuide.Editor = _editor; var tempFolder = _engine.Configuration.GetString("content-package.temp-folder"); _loader = new ImageLoader(_editor, tempFolder); _modelLayer.ImageLoader = _loader; _captureLayer.ImageLoader = _loader; float verticalMarginPX = 60; float horizontalMarginPX = 40; var verticalMarginMM = 25.4f * verticalMarginPX / dpiY; var horizontalMarginMM = 25.4f * horizontalMarginPX / _dpiX; _engine.Configuration.SetNumber("text.margin.top", verticalMarginMM); _engine.Configuration.SetNumber("text.margin.left", horizontalMarginMM); _engine.Configuration.SetNumber("text.margin.right", horizontalMarginMM); _engine.Configuration.SetNumber("math.margin.top", verticalMarginMM); _engine.Configuration.SetNumber("math.margin.bottom", verticalMarginMM); _engine.Configuration.SetNumber("math.margin.left", horizontalMarginMM); _engine.Configuration.SetNumber("math.margin.right", horizontalMarginMM); }