Beispiel #1
0
        private void SetWallpaper(int imageId)
        {
            string imageFilename = ThemeManager.currentTheme.imageFilename.Replace("*", imageId.ToString());
            string imagePath     = Path.Combine(Directory.GetCurrentDirectory(), "themes",
                                                ThemeManager.currentTheme.themeId, imageFilename);

            if (imagePath == lastImagePath)
            {
                return;
            }

            WallpaperApi.EnableTransitions();
            UwpDesktop.GetHelper().SetWallpaper(imageFilename);

            if (Environment.OSVersion.Version.Build >= 21337)
            {
                if (!virtualDesktopInit.IsCompleted)
                {
                    virtualDesktopInit.Wait();
                }

                foreach (VirtualDesktop desktop in VirtualDesktop.GetDesktops())
                {
                    if (desktop.Id != VirtualDesktop.Current.Id)
                    {
                        desktop.WallpaperPath = imagePath;
                    }
                }
            }

            lastImagePath = imagePath;
        }
Beispiel #2
0
        public AppContext()
        {
            EnforceSingleInstance();

            JsonConfig.LoadConfig();
            InitializeComponent();

            _startupManager = UwpDesktop.GetStartupManager(notifyIcon.ContextMenu.MenuItems[6]);
            _wcsService     = new WallpaperChangeScheduler();

            if (!Directory.Exists("images"))
            {
                DownloadImages();
            }
            else if (JsonConfig.settings.location == null)
            {
                UpdateLocation();
            }
            else
            {
                _wcsService.RunScheduler();
            }

            UpdateChecker.Initialize(notifyIcon);
        }
        public static void Initialize()
        {
            if (!UwpDesktop.IsRunningAsUwp())
            {
                JsonConfig.settings.useWindowsLocation = false;
            }
            else if (JsonConfig.settings.useWindowsLocation && !UwpLocation.HasAccess())
            {
                JsonConfig.settings.useWindowsLocation = false;
                JsonConfig.settings.latitude           = null;
                JsonConfig.settings.longitude          = null;
            }

            if (JsonConfig.settings.latitude != null && JsonConfig.settings.longitude != null)
            {
                isReady = true;
                AppContext.RunInBackground();
            }
            else
            {
                ChangeLocation();

                if (JsonConfig.firstRun)
                {
                    AppContext.ShowPopup(_("Welcome! Please enter your location so the app can " +
                                           "determine sunrise and sunset times."));
                }
            }
        }
        public static List <ToolStripItem> GetMenuItems()
        {
            RegistryKey themeKey = Registry.CurrentUser.OpenSubKey(registryThemeLocation);

            if (UwpDesktop.IsRunningAsUwp() || themeKey == null)
            {
                JsonConfig.settings.changeSystemTheme = false;
                JsonConfig.settings.changeAppTheme    = false;

                return(new List <ToolStripItem>());
            }

            themeKey.Close();

            automaticSystemThemeItem = new ToolStripMenuItem(
                Localization.GetTranslation("Change Windows 10 &system theme automatically"),
                null, OnSystemThemeItemClick);
            automaticSystemThemeItem.Checked = JsonConfig.settings.changeSystemTheme;

            automaticAppThemeItem = new ToolStripMenuItem(
                Localization.GetTranslation("Change Windows 10 &app theme automatically"),
                null, OnAppThemeItemClick);
            automaticAppThemeItem.Checked = JsonConfig.settings.changeAppTheme;

            return(new List <ToolStripItem>()
            {
                new ToolStripSeparator(),
                automaticSystemThemeItem,
                automaticAppThemeItem
            });
        }
 public static void SyncVirtualDesktops(string imagePath)
 {
     if (UwpDesktop.IsVirtualDesktopSupported())
     {
         VirtualDesktopApi.SetWallpaper(imagePath);
     }
 }
Beispiel #6
0
        public FormWrapper()
        {
            Application.ApplicationExit += new EventHandler(OnApplicationExit);
            EnforceSingleInstance();
            SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(OnPowerModeChanged);

            JsonConfig.LoadConfig();
            _wcsService = new WallpaperChangeScheduler();

            InitializeComponent();
            _startupManager = UwpDesktop.GetStartupManager(notifyIcon.ContextMenu.MenuItems[6]);

            if (!Directory.Exists("images"))
            {
                DownloadImages();
            }
            else if (JsonConfig.firstRun)
            {
                UpdateLocation();
            }
            else
            {
                _wcsService.StartScheduler();
            }
        }
        public static List <ToolStripItem> GetMenuItems()
        {
            if (UwpDesktop.IsRunningAsUwp())
            {
                return(new List <ToolStripItem>());
            }

            int jpegImportQuality = (int)(GetValue(registryDesktopPath, "JPEGImportQuality") ?? 0);

            isJpegCompressionTweaked = jpegImportQuality == 100;

            jpegCompressionItem = new ToolStripMenuItem(
                _("Disable Windows 10 &JPEG wallpaper compression"), null,
                OnJpegCompressionItemClick);
            jpegCompressionItem.Checked = isJpegCompressionTweaked;

            int startupDelay = (int)(GetValue(registrySerializePath, "StartupDelayInMSec") ?? 1);

            isStartupDelayTweaked = startupDelay == 0;

            startupDelayItem = new ToolStripMenuItem(
                _("Disable Windows 10 &program startup delay"), null,
                OnStartupDelayItemClick);
            startupDelayItem.Checked = isStartupDelayTweaked;

            return(new List <ToolStripItem>()
            {
                new ToolStripSeparator(),
                jpegCompressionItem,
                startupDelayItem
            });
        }
        public static void CheckManual()
        {
            string currentVersion = GetCurrentVersion();
            string latestVersion  = GetLatestVersion();

            if (latestVersion == null)
            {
                MessageDialog.ShowWarning(_("WinDynamicDesktop could not connect to the Internet to check for " +
                                            "updates."), _("Error"));
            }
            else if (IsUpdateAvailable(currentVersion, latestVersion))
            {
                DialogResult result = MessageDialog.ShowQuestion(string.Format(_("There is a newer version of " +
                                                                                 "WinDynamicDesktop available. Do you want to download the update now?\n\nCurrent Version: {0}\n" +
                                                                                 "Latest Version: {1}"), currentVersion, latestVersion), _("Update Available"));

                if (result == DialogResult.Yes)
                {
                    UwpDesktop.GetHelper().OpenUpdateLink();
                }
            }
            else
            {
                MessageDialog.ShowInfo(_("You already have the latest version of WinDynamicDesktop installed."),
                                       _("Up To Date"));
            }
        }
 private static void OnBalloonTipClicked(object sender, EventArgs e)
 {
     if (AppContext.notifyIcon.BalloonTipTitle == _("Update Available"))
     {
         UwpDesktop.GetHelper().OpenUpdateLink();
     }
 }
        private void SetWallpaper(int imageId1, int imageId2, double percent)
        {
            string imageFilename1 = ThemeManager.currentTheme.imageFilename.Replace("*", imageId1.ToString());
            string imageFilename2 = ThemeManager.currentTheme.imageFilename.Replace("*", imageId2.ToString());

            string folder     = Path.Combine(Directory.GetCurrentDirectory(), "themes", ThemeManager.currentTheme.themeId);
            string imagePath1 = Path.Combine(folder, imageFilename1);
            string imagePath2 = Path.Combine(folder, imageFilename2);
            string outputPath = Path.Combine(folder, "current.jpg");

            Task.Run(() =>
            {
                var sw = new System.Diagnostics.Stopwatch();

                sw.Restart();
                using (var image1 = new ImageMagick.MagickImage(imagePath1))
                    using (var image2 = new ImageMagick.MagickImage(imagePath2))
                    {
                        image1.Quality = 98;
                        image1.Composite(image2, ImageMagick.CompositeOperator.Blend, Math.Round(percent * 100).ToString());
                        image1.Write(outputPath);
                    }
                sw.Stop();
                Console.WriteLine($"NEW: {sw.ElapsedMilliseconds}");

                GC.Collect();

                WallpaperApi.EnableTransitions();
                UwpDesktop.GetHelper().SetWallpaper("current.jpg");
            });

            lastImagePath = outputPath;
        }
        public static void CheckManual()
        {
            string currentVersion = GetCurrentVersion();
            string latestVersion  = GetLatestVersion();

            if (latestVersion == null)
            {
                DarkMessageBox.ShowWarning("WinDynamicDesktop could not connect to the Internet " +
                                           "to check for updates.", "Error");
            }
            else if (IsUpdateAvailable(currentVersion, latestVersion))
            {
                DialogResult result = DarkMessageBox.ShowInformation("There is a newer version " +
                                                                     "of WinDynamicDesktop available. Do you want to download the update now?\n\n" +
                                                                     "Current Version: " + currentVersion + "\nLatest Version: " + latestVersion,
                                                                     "Update Available", DarkDialogButton.YesNo);

                if (result == DialogResult.Yes)
                {
                    UwpDesktop.GetHelper().OpenUpdateLink();
                }
            }
            else
            {
                DarkMessageBox.ShowInformation("You already have the latest version of " +
                                               "WinDynamicDesktop installed.", "Up To Date");
            }
        }
        public void DownloadImages()
        {
            if (!UwpDesktop.IsRunningAsUwp())
            {
                string imagesZipUri = JsonConfig.imageSettings.imagesZipUri;

                if (imagesZipUri == null)
                {
                    MessageBox.Show("Images folder not found. The program will quit now.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    Environment.Exit(0);
                }

                downloadDialog             = new ProgressDialog();
                downloadDialog.FormClosed += OnDownloadDialogClosed;
                downloadDialog.Show();

                using (WebClient client = new WebClient())
                {
                    client.DownloadProgressChanged += downloadDialog.OnDownloadProgressChanged;
                    client.DownloadFileCompleted   += downloadDialog.OnDownloadFileCompleted;
                    client.DownloadFileAsync(new Uri(imagesZipUri), "images.zip");
                }
            }
            else
            {
                ThemeDialog dialog = new ThemeDialog();
                dialog.FormClosed += OnDownloadDialogClosed;
                dialog.Show();
            }
        }
Beispiel #13
0
        private string GetRtfText()
        {
            string versionStr = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            versionStr  = versionStr.Remove(versionStr.Length - 2);
            versionStr += UwpDesktop.IsRunningAsUwp() ? " (UWP)" : string.Empty;

            string copyrightLine = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(
                                        Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute), false)).Copyright;

            string donateRateLine = string.Format(_("If you like the app, please consider {0} or {1} :)"),
                                                  GetRtfLink(donateLink, _("donating")), GetRtfLink(rateLink, _("rating it")));

            return(@"{\rtf1\pc\fs5\par" +
                   @"\sb72\qc\fs30\b WinDynamicDesktop " + versionStr + @"\b0\par" +
                   @"\fs20 " + _("Port of macOS Mojave Dynamic Desktop feature to Windows 10") + @"\par " +
                   copyrightLine + @"\par " +
                   GetRtfLink(websiteLink) + @"\par " +
                   donateRateLine + @"\par" +
                   @"\par" +
                   @"\b " + _("Thanks to:") + @"\b0\par " +
                   _("Apple for the Mojave wallpapers") + @"\par " +
                   _("Contributors and translators on GitHub") + @"\par " +
                   _("LocationIQ for their free geocoding API") + @"\par " +
                   _("Roundicons from flaticon.com for the icon (licensed by CC 3.0 BY)") + @"\par" +
                   @"\par }");
        }
        public static List <ToolStripItem> GetMenuItems()
        {
            RegistryKey themeKey = Registry.CurrentUser.OpenSubKey(registryThemeLocation);

            if (!UwpDesktop.IsRunningAsUwp() && (themeKey != null))
            {
                themeKey.Close();

                menuItem = new ToolStripMenuItem(
                    Localization.GetTranslation("&Change Windows 10 theme color"),
                    null, OnThemeItemClick);
                menuItem.Checked = JsonConfig.settings.changeSystemTheme;

                return(new List <ToolStripItem>()
                {
                    menuItem
                });
            }
            else
            {
                JsonConfig.settings.changeSystemTheme = false;

                return(new List <ToolStripItem>());
            }
        }
Beispiel #15
0
        private void InitializeComponent()
        {
            Application.ApplicationExit += new EventHandler(OnApplicationExit);

            notifyIcon = new NotifyIcon
            {
                Visible = !JsonConfig.settings.hideTrayIcon,
                Icon    = Properties.Resources.AppIcon,
                Text    = "WinDynamicDesktop",
            };

            notifyIcon.ContextMenu = new ContextMenu(new MenuItem[]
            {
                new MenuItem("WinDynamicDesktop"),
                new MenuItem("-"),
                new MenuItem("&Update Location...", OnLocationItemClick),
                new MenuItem("&Refresh Wallpaper", OnRefreshItemClick),
                new MenuItem("-"),
                new MenuItem("&Dark Mode", OnDarkModeClick),
                new MenuItem("&Start on Boot", OnStartOnBootClick),
                new MenuItem("-"),
                new MenuItem("&About", OnAboutItemClick),
                new MenuItem("-"),
                new MenuItem("E&xit", OnExitItemClick)
            });

            notifyIcon.ContextMenu.MenuItems[0].Enabled = false;
            notifyIcon.ContextMenu.MenuItems[5].Checked = JsonConfig.settings.darkMode;

            if (!UwpDesktop.IsRunningAsUwp())
            {
                UpdateChecker.Initialize(notifyIcon);
            }
        }
        private void SetWallpaper(int imageId)
        {
            string imageFilename = ThemeManager.currentTheme.imageFilename.Replace("*", imageId.ToString());

            UwpDesktop.GetHelper().SetWallpaper(imageFilename);

            lastImageId = imageId;
        }
        public static ContextMenu GetMenu()
        {
            List <MenuItem> menuItems = GetMenuItems();

            UwpDesktop.GetHelper().CheckStartOnBoot();

            return(new ContextMenu(menuItems.ToArray()));
        }
        static void Main()
        {
            Environment.CurrentDirectory = UwpDesktop.GetHelper().GetCurrentDirectory();
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new AppContext());
        }
Beispiel #19
0
        static void Main()
        {
            Environment.CurrentDirectory = UwpDesktop.GetCurrentDirectory();
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(
                OnUnhandledException);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormWrapper());
        }
        public static void Initialize()
        {
            if (UwpDesktop.IsRunningAsUwp())
            {
                return;
            }

            AppContext.notifyIcon.BalloonTipClicked += OnBalloonTipClicked;

            TryCheckAuto();
        }
Beispiel #21
0
        public static ContextMenuStrip GetMenu()
        {
            List <ToolStripItem> menuItems = GetMenuItems();

            UwpDesktop.GetHelper().CheckStartOnBoot();

            ContextMenuStrip menuStrip = new ContextMenuStrip();

            menuStrip.Items.AddRange(menuItems.ToArray());

            return(menuStrip);
        }
Beispiel #22
0
        public static ContextMenuStrip GetMenu()
        {
            List <ToolStripItem> menuItems = GetMenuItems();

            UwpDesktop.GetHelper().CheckStartOnBoot();

            ContextMenuStrip menuStrip = new ContextMenuStrip();

            menuStrip.Items.AddRange(menuItems.ToArray());
            IntPtr handle = menuStrip.Handle;  // Handle needed for BeginInvoke to work

            return(menuStrip);
        }
Beispiel #23
0
 public static void Initialize()
 {
     if (!UwpDesktop.IsUwpSupported())
     {
         JsonConfig.settings.useWindowsLocation = false;
     }
     else if (JsonConfig.settings.useWindowsLocation && !UwpLocation.HasAccess())
     {
         JsonConfig.settings.useWindowsLocation = false;
         JsonConfig.settings.latitude           = null;
         JsonConfig.settings.longitude          = null;
     }
 }
Beispiel #24
0
        private void InputDialog_Load(object sender, EventArgs e)
        {
            if (JsonConfig.settings.location != null)
            {
                inputBox.Text = JsonConfig.settings.location;
            }

            locationCheckBox.Checked = JsonConfig.settings.useWindowsLocation;
            locationCheckBox.Enabled = UwpDesktop.IsRunningAsUwp();

            UpdateGuiState();
            locationCheckBox.CheckedChanged += locationCheckBox_CheckedChanged;
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            string localFolder = UwpDesktop.GetHelper().GetLocalFolder();

            Application.ThreadException += (sender, e) => ErrorHandler.LogError(localFolder, e.Exception);
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
                                                          ErrorHandler.LogError(localFolder, e.ExceptionObject as Exception);

            Directory.SetCurrentDirectory(FindCwd(localFolder));

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new AppContext(args));
        }
Beispiel #26
0
        private void SetWallpaper(int imageId)
        {
            string imageFilename = ThemeManager.currentTheme.imageFilename.Replace("*", imageId.ToString());
            string imagePath     = Path.Combine(Directory.GetCurrentDirectory(), "themes",
                                                ThemeManager.currentTheme.themeId, imageFilename);

            if (imagePath == lastImagePath)
            {
                return;
            }

            UwpDesktop.GetHelper().SetWallpaper(imagePath);
            lastImagePath = imagePath;
        }
        private void InputDialog_Load(object sender, EventArgs e)
        {
            if (JsonConfig.settings.location != null)
            {
                inputBox.Text = JsonConfig.settings.location;
            }
            else
            {
                okButton.Enabled = false;
            }

            locationCheckBox.Checked = JsonConfig.settings.useWindowsLocation;
            locationCheckBox.Enabled = UwpDesktop.IsRunningAsUwp();
        }
        private void AboutDialog_Load(object sender, EventArgs e)
        {
            iconBox.Image = (new Icon(Properties.Resources.AppIcon, 64, 64)).ToBitmap();

            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            nameLabel.Text += " " + version.Remove(version.Length - 2);

            if (UwpDesktop.IsRunningAsUwp())
            {
                nameLabel.Text += " (UWP)";
            }

            creditsBox.Text = GetCreditsText();
        }
        private void AboutDialog_Load(object sender, EventArgs e)
        {
            iconBox.Image = (new Icon(Properties.Resources.AppIcon, 64, 64)).ToBitmap();

            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            nameLabel.Text += " " + version;

            if (!UwpDesktop.IsRunningAsUwp())
            {
                donateButton.Visible = true;
            }

            creditsBox.Text = GetCreditsText();
        }
Beispiel #30
0
        private void SetWallpaper(int imageId)
        {
            string imageFilename = ThemeManager.currentTheme.imageFilename.Replace("*",
                                                                                   imageId.ToString());
            string imagePath = Path.Combine(Directory.GetCurrentDirectory(), "themes",
                                            ThemeManager.currentTheme.themeName, imageFilename);

            WallpaperApi.SetWallpaper(imagePath);

            if (UwpDesktop.IsRunningAsUwp() && JsonConfig.settings.changeLockScreen)
            {
                UwpHelper.SetLockScreenImage(imagePath);
            }

            lastImageId = imageId;
        }