Esempio n. 1
0
        /// <summary>
        /// In a derived class, implements logic to initialize the sample.
        /// </summary>
        protected override void OnInitialize()
        {
            DeviceSettings2D settings = new DeviceSettings2D {
                Width  = WindowWidth,
                Height = WindowHeight
            };

            InitializeDevice(settings);
            geometry = new PathGeometry(Context2D.RenderTarget.Factory);
            using (GeometrySink sink = geometry.Open()) {
                PointF p0 = new PointF(0.50f * WindowWidth, 0.25f * WindowHeight);
                PointF p1 = new PointF(0.75f * WindowWidth, 0.75f * WindowHeight);
                PointF p2 = new PointF(0.25f * WindowWidth, 0.75f * WindowHeight);

                sink.BeginFigure(p0, FigureBegin.Filled);
                sink.AddLine(p1);
                sink.AddLine(p2);
                sink.EndFigure(FigureEnd.Closed);

                // Note that Close() and Dispose() are not equivalent like they are for
                // some other IDisposable() objects.
                sink.Close();
            }

            brush = new SolidColorBrush(Context2D.RenderTarget, new Color4(0.93f, 0.40f, 0.08f));
        }
Esempio n. 2
0
        public void InitializeDevice()
        {
            DeviceSettings2D settings = new DeviceSettings2D
            {
                Width  = ClientSize.Width,
                Height = ClientSize.Height
            };
            var result = new DeviceContext2D(Handle, settings);

            apiContext = result;
            Context2D  = result;
        }
Esempio n. 3
0
        /// <summary>
        /// In a derived class, implements logic to initialize the sample.
        /// </summary>
        protected override void OnInitialize()
        {
            DeviceSettings2D settings = new DeviceSettings2D
            {
                Width  = WindowWidth,
                Height = WindowHeight
            };

            InitializeDevice(settings);
            _writeFactory                  = new SlimDX.DirectWrite.Factory(SlimDX.DirectWrite.FactoryType.Shared);
            _textFormat                    = _writeFactory.CreateTextFormat("Gabriola", FontWeight.Regular, FontStyle.Normal, FontStretch.Normal, 72.0f, "en-us");
            _textFormat.TextAlignment      = TextAlignment.Center;
            _textFormat.ParagraphAlignment = ParagraphAlignment.Center;
            using (Graphics graphics = Graphics.FromHwnd(_mainForm.Handle))
            {
                _dpiY = graphics.DpiY / 96.0f;
                _dpiX = graphics.DpiX / 96.0f;
            }

            InitializeSimpleText();
            InitializeMultiformattedText();
        }