Esempio n. 1
0
        public void Initialize(Presenter presenter)
        {
            // https://msdn.microsoft.com/en-us/library/windows/desktop/mt186590(v=vs.85).aspx
            Presenter  = presenter;
            Device3D11 = Device3D11.CreateFromDirect3D12(
                Device.NativeDevice,
                DeviceCreationFlags.BgraSupport,// | DeviceCreationFlags.Debug,
                null,
                null,
                presenter.NativeCommandQueue);

            DeviceContext3D = Device3D11.ImmediateContext;
            Device3D        = Device3D11.QueryInterface <Device3D>();

            // create d2d/directwrite
            using (var factory = new Factory(FactoryType.SingleThreaded))
            {
                Factory = factory.QueryInterface <Factory1>();
            }


            RoundedRectangleGeometry = new RoundedRectangleGeometry(
                Factory,
                new RoundedRectangle()
            {
                RadiusX = 32,
                RadiusY = 32,
                Rect    = new RectangleF(128, 128, 500 - 128 * 2, 500 - 128 * 2)
            });


            // direct write
            FactoryDW      = new FactoryDW(SharpDX.DirectWrite.FactoryType.Shared);
            FontLoader     = new ResourceFontLoader(FactoryDW, @"Fonts");
            FontCollection = new FontCollection(FactoryDW, FontLoader, FontLoader.Key);

            TextFormat = new TextFormat(
                FactoryDW,
                "Material-Design-Iconic-Font",
                FontCollection,
                SharpDX.DirectWrite.FontWeight.Normal,
                FontStyle.Normal,
                FontStretch.Normal,
                30);
            TextFormat.TextAlignment      = TextAlignment.Leading;
            TextFormat.ParagraphAlignment = ParagraphAlignment.Near;

            DeviceContextOptions deviceOptions = DeviceContextOptions.None;

            using (var deviceGI = Device3D.QueryInterface <DeviceGI>())
            {
                Device2D      = new Device(Factory, deviceGI);
                DeviceContext = new DeviceContext(Device2D, deviceOptions);
            }

            DesktopDpi = Factory.DesktopDpi;
            InitializePresentable(Device);
        }