private void OnRenderModeChange(bool oldValue, bool newValue)
 {
     if (!newValue)
     {
         DesktopTool.UpdateWallpaper();
     }
 }
Exemplo n.º 2
0
        protected void RenderTask()
        {
            try
            {
                Cef.EnableHighDPISupport();

                Application.SetCompatibleTextRenderingDefault(false);

                Cef.Initialize(Settings);

                WallpaperManager.Initalize();

                WallpaperManager.ShowWindow();

                DesktopTool.AppendToWallpaperArea((wallpaperHandle = WallpaperManager.Window.Form.Handle));

                WallpaperManager.Window.FillDisplay();

                Logger.Log("Render task started");

                Application.Run();
            } catch (ThreadAbortException)
            {
                Thread.ResetAbort();
                OnRenderQuit();
                Logger.Log("Render task finished");
            }
        }
        public int Run()
        {
            if (Running)
            {
                return(-1);
            }

            Running = true;

            Graphics graphics = DesktopTool.GetWallpaperGraphics();

            IntPtr hdc   = graphics.GetHdc();
            IntPtr memDc = NativeWin32.CreateCompatibleDC(hdc);

            LastRender = DateTime.Now.Ticks;

            try
            {
                while (Running)
                {
                    if (RenderEnabled.Value && RenderTarget != null && RenderTarget.CanDraw)
                    {
                        RenderTarget.Draw(this, hdc, memDc);
                    }

                    long now = DateTime.Now.Ticks;

                    FPS        = (now - LastRender) / 1000;
                    LastRender = now;

                    if (VSyncEnabled.Value)
                    {
                        System.Threading.Thread.Sleep(1000 / ScreenManager.WallpaperRefreshRate);
                    }
                }
            } catch (Exception e)
            {
                Logger.Error("Wallpaper rendering failed retrying after 1 seconds " + e);

                NativeWin32.DeleteObject(memDc);

                System.Threading.Thread.Sleep(1000);

                if (Running)
                {
                    Run();
                }
            }

            return(0);
        }
Exemplo n.º 4
0
        protected void OnRenderQuit()
        {
            if (WallpaperManager.Initalized)
            {
                Cef.Shutdown();
            }

            WallpaperManager.HideWindow();

            if (wallpaperHandle != IntPtr.Zero)
            {
                DesktopTool.RemoveFromWallpaperArea(wallpaperHandle);
                DesktopTool.UpdateWallpaper();

                wallpaperHandle = IntPtr.Zero;
            }

            Application.Exit();
        }
 public void Dispose()
 {
     Running = false;
     DesktopTool.UpdateWallpaper();
 }