public static void TryCheckAuto(bool forceIfEnabled = false) { if (UwpDesktop.IsRunningAsUwp() || JsonConfig.settings.disableAutoUpdate) { return; } if (JsonConfig.settings.lastUpdateCheck != null && !forceIfEnabled) { DateTime lastUpdateCheck = DateTime.Parse(JsonConfig.settings.lastUpdateCheck); TimeSpan timeDiff = new TimeSpan(DateTime.Now.Ticks - lastUpdateCheck.Ticks); if (timeDiff.Days < 7) { return; } } Task.Run(() => CheckAuto()); }
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()) { notifyIcon.ContextMenu.MenuItems.Add(8, new MenuItem("&Check for Updates Now", OnUpdateItemClick)); notifyIcon.ContextMenu.MenuItems.Add(9, new MenuItem("C&heck Automatically Once a Week", OnAutoUpdateItemClick)); notifyIcon.ContextMenu.MenuItems[9].Checked = !JsonConfig.settings.disableAutoUpdate; notifyIcon.ContextMenu.MenuItems.Add(10, new MenuItem("-")); notifyIcon.BalloonTipClicked += OnBalloonTipClicked; } }
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.SetWallpaper(imagePath); if (UwpDesktop.IsRunningAsUwp() && JsonConfig.settings.changeLockScreen) { UwpHelper.SetLockScreenImage(imageFilename); } lastImagePath = imagePath; }
private static List <MenuItem> GetMenuItems() { List <MenuItem> items = new List <MenuItem>(); themeItem = new MenuItem("&Select Theme...", OnThemeItemClick); MenuItem optionsItem = new MenuItem("&Options"); optionsItem.MenuItems.AddRange(GetOptionsMenuItems().ToArray()); items.AddRange(new List <MenuItem>() { new MenuItem("WinDynamicDesktop"), new MenuItem("-"), themeItem, new MenuItem("&Update Location...", OnLocationItemClick) }); items[0].Enabled = false; items.AddRange(new List <MenuItem>() { new MenuItem("&Refresh Wallpaper", OnRefreshItemClick), new MenuItem("-"), optionsItem, new MenuItem("-") }); if (!UwpDesktop.IsRunningAsUwp()) { items.Add(new MenuItem("&Check for Updates", OnUpdateItemClick)); } items.AddRange(new List <MenuItem>() { new MenuItem("&About", OnAboutItemClick), new MenuItem("-"), new MenuItem("E&xit", OnExitItemClick) }); return(items); }
private void InputDialog_Load(object sender, EventArgs e) { if (JsonConfig.settings.location != null) { locationBox.Text = JsonConfig.settings.location; } radioButton2.Enabled = UwpDesktop.IsRunningAsUwp(); hasLocationPermission = UwpLocation.HasAccess(); if (JsonConfig.settings.sunriseTime != null && JsonConfig.settings.sunsetTime != null) { sunriseTimePicker.Value = DateTime.Parse(JsonConfig.settings.sunriseTime); sunsetTimePicker.Value = DateTime.Parse(JsonConfig.settings.sunsetTime); } else { sunriseTimePicker.Value = DateTime.Today.AddHours(6); sunsetTimePicker.Value = DateTime.Today.AddHours(18); } sunriseTimePicker.MinDate = sunriseTimePicker.Value.Date; sunriseTimePicker.MaxDate = sunsetTimePicker.Value.Date.AddHours(24); if (JsonConfig.settings.sunriseSunsetDuration > 0) { sunriseSunsetDurationBox.Value = JsonConfig.settings.sunriseSunsetDuration; } if (JsonConfig.settings.useWindowsLocation) { radioButton2.Checked = true; } else if (JsonConfig.settings.dontUseLocation) { radioButton3.Checked = true; } UpdateGuiState(); }
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; } else { ChangeLocation(); } }
public static void SetWallpaper(string imagePath) { EnableTransitions(); ThreadStart threadStarter = () => { IActiveDesktop _activeDesktop = ActiveDesktopWrapper.GetActiveDesktop(); _activeDesktop.SetWallpaper(imagePath, 0); _activeDesktop.ApplyChanges(AD_Apply.ALL | AD_Apply.FORCE); Marshal.ReleaseComObject(_activeDesktop); }; Thread thread = new Thread(threadStarter); thread.SetApartmentState(ApartmentState.STA); // Set the thread to STA (required!) thread.Start(); thread.Join(2000); if (UwpDesktop.IsRunningAsUwp()) // Ensure wallpaper registry setting gets updated { UpdateRegistrySettings(imagePath); } }
public static void TryCheckAuto() { if (UwpDesktop.IsRunningAsUwp() || JsonConfig.settings.disableAutoUpdate) { return; } if (JsonConfig.settings.lastUpdateCheck != null) { DateTime lastUpdateCheck = DateTime.Parse(JsonConfig.settings.lastUpdateCheck); int dayDiff = (new TimeSpan(DateTime.Now.Ticks - lastUpdateCheck.Ticks)).Days; if (dayDiff < 7) { return; } } CheckAuto(); JsonConfig.settings.lastUpdateCheck = DateTime.Now.ToString("yyyy-MM-dd"); JsonConfig.SaveConfig(); }
public static List <ToolStripItem> GetMenuItems() { RegistryKey desktopKey = Registry.CurrentUser.OpenSubKey(registryCompressionLocation); if (UwpDesktop.IsRunningAsUwp() || desktopKey == null) { return(new List <ToolStripItem>()); } isWallpaperCompressionTweaked = (int)desktopKey.GetValue("JPEGImportQuality", 0) == 100; desktopKey.Close(); compressionTweakItem = new ToolStripMenuItem( _("Disable Windows 10 &JPEG wallpaper compression"), null, OnWallpaperCompressionItemClick); compressionTweakItem.Checked = isWallpaperCompressionTweaked; return(new List <ToolStripItem>() { new ToolStripSeparator(), compressionTweakItem }); }
private void OnDownloadDialogClosed(object sender, EventArgs e) { downloadDialog = null; if (Directory.Exists("images")) { TryStartScheduler(); } else if (!UwpDesktop.IsRunningAsUwp()) { DialogResult result = MessageBox.Show("Failed to download images. Click Retry to " + "try again or Cancel to exit the program.", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (result == DialogResult.Retry) { DownloadImages(); } else { Environment.Exit(0); } } }