Ejemplo n.º 1
0
 /// <summary>
 /// 用窗口句柄初始化
 /// </summary>
 /// <param name="hwnd">绘制窗口句柄</param>
 public DirectXEngine(Control ctrl)
 {
     _ctrl       = ctrl;
     _cancelTask = new CancellationTokenSource();
     InitHwndRenderTarget();
     _bmp = new DXBitmap(hwndRenderTarget);
 }
Ejemplo n.º 2
0
 public void ChangeBitmap(Stream s)
 {
     lock (_lockObj)
     {
         _preBmp  = _bmp;                              //当前图片变成前一张图片
         _bmp     = new DXBitmap(hwndRenderTarget, s); //新图片赋值给当前图片
         _opacity = 1f;                                //
     }
 }
Ejemplo n.º 3
0
 public void ChangeBitmap(string imageFileName)
 {
     if (string.IsNullOrWhiteSpace(imageFileName))
     {
         throw new ArgumentException(imageFileName);
     }
     if (!File.Exists(imageFileName))
     {
         throw new FileNotFoundException(imageFileName);
     }
     lock (_lockObj)
     {
         _preBmp  = _bmp;                                          //当前图片变成前一张图片
         _bmp     = new DXBitmap(hwndRenderTarget, imageFileName); //新图片赋值给当前图片
         _opacity = 1f;                                            //
     }
 }
Ejemplo n.º 4
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.

                    if (hwndRenderTarget != null)
                    {
                        hwndRenderTarget.Dispose();
                        hwndRenderTarget = null;
                    }
                    if (_preBmp != null)
                    {
                        _preBmp.Dispose();
                        _preBmp = null;
                    }

                    if (_bmp != null)
                    {
                        _bmp.Dispose();
                        _bmp = null;
                    }
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.

                // Note disposing has been done.
                disposed = true;
            }
        }