Exemple #1
0
 protected override void OnRender(DrawingContext dc)
 {
     if (ActualHeight > 0 && ActualWidth > 0 && ViewModelBase.ApiHandle != IntPtr.Zero)
     {
         if (_bitmap == null)
         {
             _bitmap = new Bitmap((int)ActualWidth, (int)ActualHeight, PixelFormat.Format24bppRgb);
         }
         if (_bitmap != null && (_bitmap.Height != ActualHeight || _bitmap.Width != ActualWidth))
         {
             _bitmap.Dispose();
             _bitmap = new Bitmap((int)ActualWidth, (int)ActualHeight, PixelFormat.Format24bppRgb);
         }
         using (var g = Graphics.FromImage(_bitmap))
         {
             if (Program.IsRun)
             {
                 DR2API.DR2_Draw(ViewModelBase.ApiHandle, WindowHandle, g.GetHdc(), new RECT(0, 0, (int)ActualWidth, (int)ActualHeight),
                                 ActualWidth == Window.GetWindow(this).ActualWidth ? 1 : 0);
             }
         }
         dc.DrawImage(ToBitmapSource(_bitmap), new Rect(0, 0, ActualWidth, ActualHeight));
         GC.Collect();
     }
 }
Exemple #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            IntPtr hdc = e.Graphics.GetHdc();

            if (Program.IsRun)
            {
                DR2API.DR2_Draw(ViewModelBase.ApiHandle, Handle, hdc, new RECT(0, 0, (int)Width, (int)Height), 0);
            }
            e.Graphics.ReleaseHdc(hdc);
        }