public virtual void Initialize(DeviceManager deviceManager)
 {
     sceneColorBrush = new SolidColorBrush(deviceManager.ContextDirect2D, Color.Blue);
     textFormat = new TextFormat(deviceManager.FactoryDirectWrite, "Calibri", 20) { TextAlignment = TextAlignment.Leading, ParagraphAlignment = ParagraphAlignment.Center };
     clock = Stopwatch.StartNew();
     deviceManager.ContextDirect2D.TextAntialiasMode = TextAntialiasMode.Grayscale;
 }
Esempio n. 2
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            pointers = new List<PointerData>();
            // Get the Screen size
            var bounds = Window.Current.Bounds;
            double height = bounds.Height;
            double width = bounds.Width;
            Debug.WriteLine("Screen width:" + width + "  Screen height" + height);
            _Rect.Width = width;
            _Rect.Height = height;

            int pixelWidth = (int)(_Rect.Width * DisplayProperties.LogicalDpi / 96.0);
            int pixelHeight = (int)(_Rect.Height * DisplayProperties.LogicalDpi / 96.0);

            #region sharpDX Initialization

            // Use Rectangle that makes sharpDX to draw
            d2dBrush = new ImageBrush();
            _Rect.Fill = d2dBrush;

            // Safely dispose any previous instance
            // Creates a new DeviceManager (Direct3D, Direct2D, DirectWrite, WIC)
            deviceManager = new DeviceManager();

            // New CubeRenderer
            shapeRenderer = new ShapeRenderer(pointers);
            fpsRenderer = new FpsRenderer();

            d2dTarget = new SurfaceImageSourceTarget(pixelWidth, pixelHeight);
            d2dBrush.ImageSource = d2dTarget.ImageSource;

            // Add Initializer to device manager
            deviceManager.OnInitialize += d2dTarget.Initialize;
            deviceManager.OnInitialize += shapeRenderer.Initialize;
            deviceManager.OnInitialize += fpsRenderer.Initialize;

            // Render the cube within the CoreWindow
            d2dTarget.OnRender += shapeRenderer.Render;
            d2dTarget.OnRender += fpsRenderer.Render;

            // Initialize the device manager and all registered deviceManager.OnInitialize
            deviceManager.Initialize(DisplayProperties.LogicalDpi);

            // Setup rendering callback
            CompositionTarget.Rendering += CompositionTarget_Rendering;

            // Callback on DpiChanged
            DisplayProperties.LogicalDpiChanged += DisplayProperties_LogicalDpiChanged;

            #endregion
        }
        public virtual void Initialize(DeviceManager deviceManager)
        {
            TouchCapabilities = new Windows.Devices.Input.TouchCapabilities();

            // Initialize a TextFormat
            textFormat = new TextFormat(deviceManager.FactoryDirectWrite, "Calibri", 20) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center };
            textFormat2 = new TextFormat(deviceManager.FactoryDirectWrite, "Calibri", 20) { TextAlignment = TextAlignment.Leading, ParagraphAlignment = ParagraphAlignment.Center };

            sceneColorBrush = new SolidColorBrush(deviceManager.ContextDirect2D, Color.Tomato);

            strokeProperties = new StrokeStyleProperties();
            strokeProperties.StartCap = CapStyle.Round;
            strokeProperties.EndCap = CapStyle.Round;
            strokeProperties.LineJoin = LineJoin.Round;

            strokeStyle = new StrokeStyle(deviceManager.FactoryDirect2D, strokeProperties);
        }
 /// <inveritdoc/>
 public override void Initialize(DeviceManager deviceManager)
 {
     base.Initialize(deviceManager);
     surfaceImageSourceNative.Device = ToDispose(DeviceManager.DeviceDirect3D.QueryInterface<SharpDX.DXGI.Device>());
 }
Esempio n. 5
0
 private void devices_OnDpiChanged(DeviceManager obj)
 {
     if (OnSizeChanged != null)
         OnSizeChanged(this);
 }
Esempio n. 6
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        /// <param name="deviceManager">The device manager</param>
        public virtual void Initialize(DeviceManager deviceManager)
        {
            this.DeviceManager = deviceManager;

            // If the DPI is changed, we need to perform a OnSizeChanged event
            deviceManager.OnDpiChanged -= devices_OnDpiChanged;
            deviceManager.OnDpiChanged += devices_OnDpiChanged;
        }