/// <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)); }
/// <summary> /// Initializes a <see cref="DeviceContext2D">Direct2D device context</see> according to the specified settings. /// The base class retains ownership of the context and will dispose of it when appropriate. /// </summary> /// <param name="settings">The settings.</param> /// <returns>The initialized device context.</returns> protected void InitializeDevice(DeviceSettings2D settings) { var result = new DeviceContext2D(_form.Handle, settings); //userInterfaceRenderer = new UserInterfaceRenderer9( result.Device, settings.Width, settings.Height ); apiContext = result; Context2D = result; }
public void InitializeDevice() { DeviceSettings2D settings = new DeviceSettings2D { Width = ClientSize.Width, Height = ClientSize.Height }; var result = new DeviceContext2D(Handle, settings); apiContext = result; Context2D = result; }
/// <summary> /// Initializes a new instance of the <see cref="DeviceContext2D"/> class. /// </summary> /// <param name="handle">The window handle to associate with the device.</param> /// <param name="settings">The settings used to configure the device.</param> public DeviceContext2D(IntPtr handle, DeviceSettings2D settings) { if (handle == IntPtr.Zero) throw new ArgumentException("Value must be a valid window handle.", "handle"); if (settings == null) throw new ArgumentNullException("settings"); this.settings = settings; factory = new Factory(); RenderTarget = new WindowRenderTarget(factory, new WindowRenderTargetProperties { Handle = handle, PixelSize = new Size(settings.Width, settings.Height) }); }
/// <summary> /// Initializes a new instance of the <see cref="DeviceContext2D"/> class. /// </summary> /// <param name="handle">The window handle to associate with the device.</param> /// <param name="settings">The settings used to configure the device.</param> public DeviceContext2D(IntPtr handle, DeviceSettings2D settings) { if (handle == IntPtr.Zero) { throw new ArgumentException("Value must be a valid window handle.", "handle"); } if (settings == null) { throw new ArgumentNullException("settings"); } this.settings = settings; factory = new Factory(); RenderTarget = new WindowRenderTarget(factory, new WindowRenderTargetProperties { Handle = handle, PixelSize = new Size(settings.Width, settings.Height) }); }
/// <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(); }
/// <summary> /// Initializes a <see cref="DeviceContext2D">Direct2D device context</see> according to the specified settings. /// The base class retains ownership of the context and will dispose of it when appropriate. /// </summary> /// <param name="settings">The settings.</param> /// <returns>The initialized device context.</returns> protected void InitializeDevice( DeviceSettings2D settings ) { var result = new DeviceContext2D( _form.Handle, settings ); //userInterfaceRenderer = new UserInterfaceRenderer9( result.Device, settings.Width, settings.Height ); apiContext = result; Context2D = result; }