private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (desptopWallpaper != null)
     {
         desptopWallpaper.Close();
         desptopWallpaper = null;
     }
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            Process[] processes = Process.GetProcessesByName("MDesptopWallpaper");
            if (processes.Length > 1)
            {
                foreach (Process process in processes)
                {
                    if (process.Id != Process.GetCurrentProcess().Id)
                    {
                        process.Kill();
                    }
                }
            }
            if (args.Length > 0)
            {
                MDesptopWallpaper.App app = new MDesptopWallpaper.App();
                MainWindow.Init();
                int ScreenId = 0;
                if (args.Length > 0)
                {
                    ScreenId = int.Parse(args[0]);
                }

                if (ScreenId >= Screen.AllScreens.Length)
                {
                    ScreenId = 0;
                }
                Screen screen = Screen.AllScreens[ScreenId];

                DesptopWallpaper desptopWallpaper = new DesptopWallpaper();

                string path = @"C:\Windows\Web\Wallpaper\Theme1";
                if (args.Length > 1 && Directory.Exists(args[1]))
                {
                    path = args[1];
                }

                desptopWallpaper.ImagePath = path;
                desptopWallpaper.Show();
                MainWindow.SetParent(new WindowInteropHelper(desptopWallpaper).Handle, MainWindow.programIntPtr);
                desptopWallpaper.Left   = screen.Bounds.Left;
                desptopWallpaper.Top    = screen.Bounds.Top;
                desptopWallpaper.Width  = screen.Bounds.Width;
                desptopWallpaper.Height = screen.Bounds.Height;

                app.Run();
            }
            else
            {
                MDesptopWallpaper.App app = new MDesptopWallpaper.App();
                app.InitializeComponent();
                app.Run();
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Screen screen = displayselect.SelectedItem as Screen;

            if (desptopWallpaper == null && screen != null)
            {
                Init();
                desptopWallpaper           = new DesptopWallpaper();
                desptopWallpaper.ImagePath = pathselect.Text;
                desptopWallpaper.Show();
                SetParent(new WindowInteropHelper(desptopWallpaper).Handle, programIntPtr);
                desptopWallpaper.Left   = screen.Bounds.Left;
                desptopWallpaper.Top    = screen.Bounds.Top;
                desptopWallpaper.Width  = screen.Bounds.Width;
                desptopWallpaper.Height = screen.Bounds.Height;
            }
        }