浏览代码

Merge branch 'master' of https://github.com/yuzhengyang/Fork

yuzhengyang 6 年之前
父节点
当前提交
a9d41f7b5c

+ 21 - 1
Azylee.Utils/Azylee.Core/WindowsUtils/APIUtils/WinDrawUtils/WinDrawTool.cs

@@ -1,5 +1,7 @@
-using System;
+using Azylee.Core.DataUtils.StringUtils;
+using System;
 using System.Drawing;
 using System.Drawing;
+using System.IO;
 
 
 namespace Azylee.Core.WindowsUtils.APIUtils.WinDrawUtils
 namespace Azylee.Core.WindowsUtils.APIUtils.WinDrawUtils
 {
 {
@@ -11,6 +13,24 @@ namespace Azylee.Core.WindowsUtils.APIUtils.WinDrawUtils
         /// <summary>
         /// <summary>
         /// 将图片绘制到桌面上
         /// 将图片绘制到桌面上
         /// </summary>
         /// </summary>
+        /// <param name="file"></param>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        public static void Paint(string file, int x, int y, int width, int height)
+        {
+            try
+            {
+                Image image = null;
+                if (Str.Ok(file) && File.Exists(file)) image = Image.FromFile(file);
+                if (image != null) Paint(image, x, y, width, height);
+            }
+            catch { }
+        }
+        /// <summary>
+        /// 将图片绘制到桌面上
+        /// </summary>
         /// <param name="image"></param>
         /// <param name="image"></param>
         /// <param name="x"></param>
         /// <param name="x"></param>
         /// <param name="y"></param>
         /// <param name="y"></param>

+ 11 - 0
Azylee.Utils/Azylee.Jsons/Json.cs

@@ -69,6 +69,17 @@ namespace Azylee.Jsons
                 try { return JsonConvert.DeserializeObject<T>(json); } catch (Exception e) { }
                 try { return JsonConvert.DeserializeObject<T>(json); } catch (Exception e) { }
             }
             }
             return default(T);
             return default(T);
+        }/// <summary>
+         /// 模型 存储到文件
+         /// </summary>
+         /// <typeparam name="T"></typeparam>
+         /// <param name="file"></param>
+         /// <returns></returns>
+        public static bool Object2File<T>(string file, T t)
+        {
+            string s = Object2String(t);
+            bool rs = TxtTool.Create(file, s);
+            return rs;
         }
         }
         /// <summary>
         /// <summary>
         /// 对象 转 字节(JSON中转)
         /// 对象 转 字节(JSON中转)

+ 7 - 1
Azylee.Utils/Azylee.YeahWeb/ExtWebAPI/BingWebAPI/WallpaperUtils/WallpaperModel.cs

@@ -1,4 +1,5 @@
-using System;
+using Azylee.Core.DataUtils.StringUtils;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
@@ -78,6 +79,11 @@ namespace Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils
         /// 
         /// 
         /// </summary>
         /// </summary>
         public List<string> hs { get; set; }
         public List<string> hs { get; set; }
+        public string GetImageUrl()
+        {
+            if (Str.Ok(url)) return "https://cn.bing.com" + url;
+            return "";
+        }
     }
     }
 
 
     public class Tooltips
     public class Tooltips

+ 21 - 1
Azylee.Utils/Azylee.YeahWeb/ExtWebAPI/BingWebAPI/WallpaperUtils/WallpaperTool.cs

@@ -1,4 +1,5 @@
-using Azylee.Jsons;
+using Azylee.Core.DataUtils.CollectionUtils;
+using Azylee.Jsons;
 using Azylee.YeahWeb.HttpUtils;
 using Azylee.YeahWeb.HttpUtils;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
@@ -35,6 +36,25 @@ namespace Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils
         {
         {
             return GetSomeday(1);
             return GetSomeday(1);
         }
         }
+        public static List<ImagesItem> GetLast10Days()
+        {
+            List<ImagesItem> result = new List<ImagesItem>();
+            for (var i = 0; i < 10; i++)
+            {
+                WallpaperModel model = GetSomeday(i);
+                if (model != null && Ls.Ok(model.images))
+                {
+                    foreach (var img in model.images)
+                    {
+                        if (!result.Any(x => x.hsh == img.hsh))
+                        {
+                            result.Add(img);
+                        }
+                    }
+                }
+            }
+            return result;
+        }
         /// <summary>
         /// <summary>
         /// 获取某一天的壁纸(每天8张)
         /// 获取某一天的壁纸(每天8张)
         /// </summary>
         /// </summary>

+ 18 - 1
Azylee.Utils/Tests/Test.ImageToolTest/Form1.cs

@@ -1,5 +1,9 @@
-using Azylee.Core.DrawingUtils.ImageUtils;
+using Azylee.Core.DataUtils.CollectionUtils;
+using Azylee.Core.DataUtils.GuidUtils;
+using Azylee.Core.DrawingUtils.ImageUtils;
+using Azylee.Core.IOUtils.DirUtils;
 using Azylee.Core.WindowsUtils.APIUtils.WallpaperUtils;
 using Azylee.Core.WindowsUtils.APIUtils.WallpaperUtils;
+using Azylee.YeahWeb.HttpUtils;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.ComponentModel;
@@ -21,9 +25,22 @@ namespace Test.ImageToolTest
 
 
         private void Form1_Load(object sender, EventArgs e)
         private void Form1_Load(object sender, EventArgs e)
         {
         {
+            Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils.WallpaperTool.GetLast10Days();
+
+           List<string> file_list = new List<string>();
             var md = Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils.WallpaperTool.GetToday();
             var md = Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils.WallpaperTool.GetToday();
             var md2 = Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils.WallpaperTool.GetYesterday();
             var md2 = Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils.WallpaperTool.GetYesterday();
 
 
+            if (md != null && Ls.Ok(md.images))
+            {
+                foreach (var item in md.images)
+                {
+                    string image_url = item.GetImageUrl();
+                    string file_path = DirTool.Combine(@"F:\imgs", item.hsh + ".jpg");
+                    bool down_result = HttpTool.Download(image_url, file_path);
+                    if (down_result) file_list.Add(file_path);
+                }
+            }
             //string a = WallpaperTool.Get();
             //string a = WallpaperTool.Get();
 
 
             //bool b = WallpaperTool.Set(@"C:\Users\yuzhengyang\Pictures\\cc.jpg");
             //bool b = WallpaperTool.Set(@"C:\Users\yuzhengyang\Pictures\\cc.jpg");