zoukankan      html  css  js  c++  java
  • 小创意之-设置电脑壁纸

    小创意— 设置电脑壁纸

    看着面黄肌肉的电脑壁纸,默默打卡了百度,搜索美丽的壁纸。看着风格古怪,分辨率里五五六六的图片。默默的流了几滴汗。于是单生了一个念头,为什么不抓去合适的图片自动设置成电脑壁纸呢?于是便用C#写了一个小程序。

    寻找合适的代码图片下载到本地

    提供几个常见的图片网址

    https://unsplash.it/1600/900?random(国外的随机图片)

    https://uploadbeta.com/api/pictures/random/?key=BingEverydayWallpaperPicture(必应每日图片)

    https://uploadbeta.com/api/pictures/random(随机图片)

    通过C#下载图片和预览图片

    
                 // 图片下载下来 保存到本地
                string url = "https://uploadbeta.com/api/pictures/random/";
                 System.Net.WebClient mywebclient = new System.Net.WebClient();
                 mywebclient.DownloadFile(url, filePath);
                // this.pictureBox1.Load(filePath);
                // 把图片预览在C#的 pictureBox控件
                FileStream pFileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                pictureBox1.Image = Image.FromStream(pFileStream);
                pFileStream.Close();
                pFileStream.Dispose();
    

    调用win的库 设置为壁纸

     /// <summary>
            ///  图片设置为背景图片
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button2_Click(object sender, EventArgs e)
            {       
                MessageBox.Show(filePath);
                SystemParametersInfo(20,1,filePath,1);
            }
    
            [DllImport("user32.dll",EntryPoint= "SystemParametersInfo")]
            public static extern int SystemParametersInfo(
                int uAction,
                int uParam,
                string lpvParam,
                int fuWinIni
                );
        }
    

    最后样式

    窗体设置样式

    image-20200514225248365

    运行效果

    image-20200514225305663 image-20200514225440199

    具体的代码在github连接里面

    小创意— 设置电脑壁纸

    看着面黄肌肉的电脑壁纸,默默打卡了百度,搜索美丽的壁纸。看着风格古怪,分辨率里五五六六的图片。默默的流了几滴汗。于是单生了一个念头,为什么不抓去合适的图片自动设置成电脑壁纸呢?于是便用C#写了一个小程序。

    寻找合适的代码图片下载到本地

    提供几个常见的图片网址

    https://unsplash.it/1600/900?random(国外的随机图片)

    https://uploadbeta.com/api/pictures/random/?key=BingEverydayWallpaperPicture(必应每日图片)

    https://uploadbeta.com/api/pictures/random(随机图片)

    通过C#下载图片和预览图片

    
                 // 图片下载下来 保存到本地
                string url = "https://uploadbeta.com/api/pictures/random/";
                 System.Net.WebClient mywebclient = new System.Net.WebClient();
                 mywebclient.DownloadFile(url, filePath);
                // this.pictureBox1.Load(filePath);
                // 把图片预览在C#的 pictureBox控件
                FileStream pFileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                pictureBox1.Image = Image.FromStream(pFileStream);
                pFileStream.Close();
                pFileStream.Dispose();
    

    调用win的库 设置为壁纸

     /// <summary>
            ///  图片设置为背景图片
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void button2_Click(object sender, EventArgs e)
            {       
                MessageBox.Show(filePath);
                SystemParametersInfo(20,1,filePath,1);
            }
    
            [DllImport("user32.dll",EntryPoint= "SystemParametersInfo")]
            public static extern int SystemParametersInfo(
                int uAction,
                int uParam,
                string lpvParam,
                int fuWinIni
                );
        }
    

    最后样式

    窗体设置样式

    image-20200514225248365

    运行效果

    image-20200514225305663 image-20200514225440199

    具体的代码在github连接里面

  • 相关阅读:
    数据类型装换
    变量及数据类型
    27 网络通信协议 udp tcp
    26 socket简单操作
    26 socket简单操作
    14 内置函数 递归 二分法查找
    15 装饰器 开闭原则 代参装饰器 多个装饰器同一函数应用
    12 生成器和生成器函数以及各种推导式
    13 内置函数 匿名函数 eval,exec,compile
    10 函数进阶 动态传参 作用域和名称空间 函数的嵌套 全局变量
  • 原文地址:https://www.cnblogs.com/fangyuandoit/p/13713771.html
Copyright © 2011-2022 走看看