/* * private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) * { * if (m_d3dInterop == null) * { * m_d3dInterop = new Direct3DInterop(); * * * // Задание границ окна в аппаратно-независимых пикселях (DIP) * m_d3dInterop.WindowBounds = new Windows.Foundation.Size( * (float)DrawingSurface.ActualWidth, * (float)DrawingSurface.ActualHeight * ); * * // Задание собственного разрешения в пикселях * m_d3dInterop.NativeResolution = new Windows.Foundation.Size( * (float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), * (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) * ); * * // Задание для разрешения отрисовки значения полного собственного разрешения * m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; * * // Присоединение собственного компонента к DrawingSurface * DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider()); * DrawingSurface.SetManipulationHandler(m_d3dInterop); * } * } */ private void DrawingSurfaceBackground_Loaded() { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateBackgroundContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); m_d3dInterop.WindowOrientation = DisplayOrientations.Portrait; } }