Exemplo n.º 1
0
        private void Dispose()
        {
            // Unregister handlers
            UnregisterKeyBindings();

            SkinContext.DeviceSceneEnd -= UICapture;
            if (surfaceDestination != null)
            {
                surfaceDestination.Dispose();
                surfaceDestination = null;
            }

            messageQueue.MessageReceived -= OnMessageReceived;

            // Dispose of the AtmoLight Core
            coreObject.ChangeEffect(settings.MPExitEffect);

            coreObject.Dispose();

            // Unregister Log Handler
            Log.OnNewLog             -= new Log.NewLogHandler(OnNewLog);
            Core.OnNewConnectionLost -= new Core.NewConnectionLostHandler(OnNewConnectionLost);
            Core.OnNewVUMeter        -= new Core.NewVUMeterHander(OnNewVUMeter);
            AtmoLight.Configuration.OnOffButton.ButtonsChanged -=
                new Configuration.OnOffButton.ButtonsChangedHandler(ReregisterKeyBindings);
            AtmoLight.Configuration.ProfileButton.ButtonsChanged -=
                new Configuration.ProfileButton.ButtonsChangedHandler(ReregisterKeyBindings);
            SystemEvents.PowerModeChanged -= PowerModeChanged;

            if (settings.MonitorScreensaverState)
            {
                settings.MonitorScreensaverState = false;
            }

            UnregisterSettingsChangedHandler();
        }
Exemplo n.º 2
0
 public override void Dispose()
 {
     if (dx9Device != null)
     {
         dx9Device.Dispose();
     }
     if (dx9ScreenSurface != null)
     {
         dx9ScreenSurface.Dispose();
     }
     if (screenShot != null)
     {
         screenShot.Dispose();
     }
     bmpData = null;
 }
Exemplo n.º 3
0
        private Bitmap GetDX9ScreenShot()
        {
            try
            {
                screenShot       = null;
                screenShot       = new System.Drawing.Bitmap(WIDTH, HEIGHT, pixelFormat);
                dx9ScreenSurface = SharpDX.Direct3D9.Surface.CreateOffscreenPlain(
                    dx9Device,
                    WIDTH,
                    HEIGHT,
                    SharpDX.Direct3D9.Format.A8R8G8B8,
                    Pool.SystemMemory);

                dx9Device.GetFrontBufferData(0, dx9ScreenSurface);

                dx9Map  = dx9ScreenSurface.LockRectangle(LockFlags.None);
                bmpData = screenShot.LockBits(boundsRect,
                                              System.Drawing.Imaging.ImageLockMode.WriteOnly, screenShot.PixelFormat);

                var sourcePtr = dx9Map.DataPointer;
                var destPtr   = bmpData.Scan0;
                for (int y = 0; y < HEIGHT; y++)
                {
                    // Copy a single line
                    Utilities.CopyMemory(destPtr, sourcePtr, ARGB_WIDTH);
                    // Advance pointers
                    sourcePtr = IntPtr.Add(sourcePtr, dx9Map.Pitch);
                    destPtr   = IntPtr.Add(destPtr, bmpData.Stride);
                }

                screenShot.UnlockBits(bmpData);
                dx9ScreenSurface.UnlockRectangle();
                dx9ScreenSurface.Dispose();
                bmpData = null;
                GC.Collect();
                return(screenShot);
            }
            catch (Exception ex)
            {
                LdpLog.Error("GetDX9ScreenShot error.\n" + ex.Message);
                return(screenShot = null);
            }
        }
        private Bitmap GetDX9ScreenShot()
        {
            try
            {
                screenShot = null;
                screenShot = new System.Drawing.Bitmap(WIDTH, HEIGHT, pixelFormat);
                dx9ScreenSurface = SharpDX.Direct3D9.Surface.CreateOffscreenPlain(
                dx9Device,
                WIDTH,
                HEIGHT,
                SharpDX.Direct3D9.Format.A8R8G8B8,
                Pool.SystemMemory);

                dx9Device.GetFrontBufferData(0, dx9ScreenSurface);

                dx9Map = dx9ScreenSurface.LockRectangle(LockFlags.None);
                bmpData = screenShot.LockBits(boundsRect,
                    System.Drawing.Imaging.ImageLockMode.WriteOnly, screenShot.PixelFormat);

                var sourcePtr = dx9Map.DataPointer;
                var destPtr = bmpData.Scan0;
                for (int y = 0; y < HEIGHT; y++)
                {
                    // Copy a single line
                    Utilities.CopyMemory(destPtr, sourcePtr, ARGB_WIDTH);
                    // Advance pointers
                    sourcePtr = IntPtr.Add(sourcePtr, dx9Map.Pitch);
                    destPtr = IntPtr.Add(destPtr, bmpData.Stride);
                }

                screenShot.UnlockBits(bmpData);
                dx9ScreenSurface.UnlockRectangle();
                dx9ScreenSurface.Dispose();
                bmpData = null;
                GC.Collect();
                return screenShot;
            }
            catch (Exception ex)
            {
                LdpLog.Error("GetDX9ScreenShot error.\n" + ex.Message);
                return screenShot = null;
            }
        }