/// <summary>
 /// 下一张壁纸
 /// </summary>
 private void NextWallpaper()
 {
     try
     {
         timerW.Stop();
         LogHelper.WriteLog("更换壁纸", EnumLogLevel.Info);
         ImgInfo imgInfo = imgHelper.GetNextImage();
         if (UserDataManage.IsDislike(imgInfo.Id))
         {
             imgInfo = imgHelper.GetNextImage();
         }
         string imgFullName = System.IO.Path.Combine(ConfigManage.Base.CachePath, imgInfo.GetFileName());
         if (!File.Exists(imgFullName))
         {
             // 判断下载目录中是否存在
             imgFullName = System.IO.Path.Combine(ConfigManage.Base.DownPath, imgInfo.GetFileName());
             if (!File.Exists(imgFullName))
             {
                 WebHelper.DownImage(imgInfo.url, imgFullName);
             }
         }
         if (File.Exists(imgFullName))
         {
             Common.WinApi.SetWallpaper(imgFullName);
             UserDataManage.AddRecord(RecordType.AutoWallpaper, imgInfo);
             ConfigManage.Wallpaper.ReplaceLastTime = DateTime.Now;
             ConfigManage.Save();
         }
         timerW.Start();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #2
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     try
     {
         this.Hide();
         timerP.Stop();
         timerP.Dispose();
         timerP = null;
         timerL.Stop();
         timerL.Dispose();
         ConfigManage.Save();
     }
     catch { }
 }
Exemple #3
0
        private void window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            #region 基本
            ConfigManage.Base.AutoOn         = cbox_basic_AutoOn.IsChecked.Value;
            ConfigManage.Base.Cache          = cbox_basic_Cache.IsChecked.Value;
            ConfigManage.Base.AutoClearCache = cbox_basic_AutoClearCache.IsChecked.Value;
            ConfigManage.Base.DownPath       = tbox_basic_DownPath.Text;
            ConfigManage.Base.CachePath      = tbox_basic_CachePath.Text;
            #endregion 基本

            #region 壁纸
            ConfigManage.Wallpaper.AutoReplace  = cbox_wallpaper_AutoReplace.IsChecked.Value;
            ConfigManage.Wallpaper.TimeInterval = nbox_wallpaper_Interval.Value;
            // 壁纸类型
            List <string> typeList = new List <string>();
            foreach (Tag tag in cbox_wallpaper_SelectedTypes.Children)
            {
                if (tag.IsSelected)
                {
                    typeList.Add(tag.Tag.ToString());
                }
            }
            ConfigManage.Wallpaper.SelectedTypes = string.Join(",", typeList);
            // 清除壁纸无效进度信息
            for (int i = 0; i < ConfigManage.Wallpaper.TypeIndexs.Count; i++)
            {
                var item = ConfigManage.Wallpaper.TypeIndexs.ElementAt(i);
                if (!typeList.Contains(item.Key.ToString()))
                {
                    ConfigManage.Wallpaper.TypeIndexs.Remove(item.Key);
                    i--;
                }
            }
            // 添加缺失的进度信息
            for (int i = 0; i < typeList.Count; i++)
            {
                string key = typeList[i];
                if (!ConfigManage.Wallpaper.TypeIndexs.ContainsKey(key))
                {
                    ConfigManage.Wallpaper.TypeIndexs.Add(key, -1);
                }
            }
            typeList.Clear();
            #endregion

            #region 屏保
            ConfigManage.Screen.Open            = cbox_screen_AutoReplace.IsChecked.Value;
            ConfigManage.Screen.OpenInterval    = nbox_screen_OpenInterval.Value;
            ConfigManage.Screen.ReplaceInterval = nbox_screen_ReplaceInterval.Value;
            // 壁纸类型
            foreach (Tag tag in cbox_screen_SelectedTypes.Children)
            {
                if (tag.IsSelected)
                {
                    typeList.Add(tag.Tag.ToString());
                }
            }
            ConfigManage.Screen.SelectedTypes = string.Join(",", typeList);
            // 清除壁纸无效进度信息
            for (int i = 0; i < ConfigManage.Screen.TypeIndexs.Count; i++)
            {
                var item = ConfigManage.Screen.TypeIndexs.ElementAt(i);
                if (!typeList.Contains(item.Key.ToString()))
                {
                    ConfigManage.Screen.TypeIndexs.Remove(item.Key);
                    i--;
                }
            }
            // 添加缺失的进度信息
            for (int i = 0; i < typeList.Count; i++)
            {
                string key = typeList[i];
                if (!ConfigManage.Screen.TypeIndexs.ContainsKey(key))
                {
                    ConfigManage.Screen.TypeIndexs.Add(key, -1);
                }
            }
            typeList.Clear();
            #endregion
            //引发事件
            ChangeConfigEvent?.Invoke();
            ConfigManage.Save();
        }