示例#1
0
        public virtual Task Clean()
        {
            return(Task.Run(() =>
            {
                lastParameter = null;
                Initlize();
                //W32.SetParent(cacheMainHandle, cacheParent);

                if (process != null)
                {
                    try
                    {
                        process.Kill();
                    }
                    catch (Exception)
                    {
                    }
                    process = null;
                }

                if (!string.IsNullOrEmpty(_defaultBG))
                {
                    ImgWallpaper.SetBG(_defaultBG);
                    _defaultBG = null;
                }


                //var resul = W32.RedrawWindow(workerw, IntPtr.Zero, IntPtr.Zero, RedrawWindowFlags.Invalidate);
                //var temp = W32.GetParent(workerw);
                //W32.SendMessage(temp, 0x000F, 0, IntPtr.Zero);
                //W32.SendMessage(workerw, 0x000F, 0, IntPtr.Zero);
                //W32.SendMessage(workerw, W32.WM_CHANGEUISTATE, 2, IntPtr.Zero);
                //W32.SendMessage(workerw, W32.WM_UPDATEUISTATE, 2, IntPtr.Zero);
            }));
        }
示例#2
0
        public virtual async Task Show(WallpapaerParameter model)
        {
            if (model == null || model.Equals(lastParameter))
            {
                return;
            }

            lastParameter = model;

            bool isOk = await Task.Run(() => Initlize());

            if (!isOk)
            {
                return;
            }

            KillOldProcess();

            _defaultBG = await ImgWallpaper.GetCurrentBG();


            bool isInt = int.TryParse(model.Dir, out int Pid);

            if (isInt)
            {
                process = Process.GetProcessById(Pid);
            }
            else
            {
                string name = Path.GetFileNameWithoutExtension(model.Dir);
                foreach (Process exe in Process.GetProcessesByName(name))
                {
                    try
                    {
                        if (exe.MainModule.FileName == model.Dir)
                        {
                            process = exe;
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                if (process == null)
                {
                    var tempDir = model.Dir;
                    if (model.Dir.StartsWith("\\Wallpapers\\"))
                    {
                        tempDir = Services.AppService.ApptEntryDir + model.Dir;
                    }

                    ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(tempDir, model.EnterPoint));
                    startInfo.WindowStyle = ProcessWindowStyle.Maximized;
                    double x = Screen.AllScreens[0].Bounds.Width;
                    double y = Screen.AllScreens[0].Bounds.Height;
                    startInfo.Arguments = $"{model.Args} -popupwindow -screen-height {y} -screen-width {x}";
                    //startInfo.Arguments = $" -popupwindow -screen-width {y1}";
                    process = Process.Start(startInfo);

                    //NativeWindowHandler windowHandler = new NativeWindowHandler();
                    //windowHandler.MaximizeWindow(process.Handle.ToInt32());

                    //process = Process.Start(path);
                }
            }
            cacheMainHandle = await TryGetMainWindowHandle(process);

            cacheParent = W32.GetParent(cacheMainHandle);
            W32.SetParent(cacheMainHandle, workerw);
        }