自定义类创建数组的赋值;并回复:窗体图片时间

news2024/9/23 21:31:20

缘由https://bbs.csdn.net/topics/392551630

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;

namespace 解答专用窗体
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        ImageList 图标集 = new ImageList();
        private void Form1_Load(object sender, EventArgs e)
        {
            int 循环 = 0; ArrayList aa = new ArrayList();
            while (循环 < 10) 图标集.Images.Add(Image.FromFile(@System.Environment.CurrentDirectory + "\\数字" + 循环++.ToString() + ".png"));
            PictureBox xin = new PictureBox();
            图标集.ImageSize = new Size(xin.Width * 1, xin.Height * 1);
            foreach (char kj in "123456")
            {
                xin = new PictureBox();
                xin.Name = kj.ToString();
                xin.Image = 图标集.Images[0];
                xin.Parent = this;
                xin.Location = new Point(xin.Width * int.Parse(kj.ToString()), 2);
            }
            this.DoubleClick += new EventHandler(this_DoubleClick);
        }
        private void this_DoubleClick(object sender, EventArgs e)
        {
            Control.ControlCollection 图控件 = this.Controls;
            //foreach (Control 图 in 图控件) if (图 is PictureBox) ((PictureBox)图).Image = 图标集.Images[int.Parse(图.Name)];
            this.BeginInvoke(new Action(() =>
            {
                while (true)
                {
                    System.Threading.Thread.SpinWait(999); Application.DoEvents();
                    DateTime shijian = DateTime.Now;
                    Image[] sutu = { 
                    图标集.Images[shijian.Hour / 10],   图标集.Images[shijian.Hour % 10], 
                    图标集.Images[shijian.Minute / 10], 图标集.Images[shijian.Minute % 10],
                    图标集.Images[shijian.Second / 10], 图标集.Images[shijian.Second % 10]};
                    foreach (Control 图 in 图控件) if (图 is PictureBox)
                        {
                            PictureBox tu = ((PictureBox)图);
                            if ("123456".Contains(tu.Name)) tu.Image = sutu[int.Parse(tu.Name) - 1];
                        }
                }
            }));
        }
    }
}

从整图中获取单个数字区域图

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace C井解答专用窗体
{
    public partial class C井解答专用窗体 : Form
    {
        public C井解答专用窗体()
        {
            InitializeComponent();
        }
        int 循环 = 0;
        int[][] 图0坐标 = new int[][] { new int[] { 180, 200 }, new int[] { 10, 0 }, new int[] { 175, 0 }, new int[] { 175 * 2 - 20, 0 }, new int[] { 175 * 3 - 25, 0 }, new int[] { 175 * 4 - 25, 0 }, new int[] { 0, 230 }, new int[] { 175 + 10, 230 }, new int[] { 175 * 2 + 10, 230 }, new int[] { 175 * 3 + 10, 230 }, new int[] { 175 * 4 - 5, 230 } },
                图1坐标 = new int[][] { new int[] { 150, 200 }, new int[] { 10, 5 }, new int[] { 130, 5 }, new int[] { 130 * 2, 5 }, new int[] { 130 * 3 - 10, 5 }, new int[] { 130 * 4 - 10, 5 }, new int[] { 10, 195 }, new int[] { 130, 195 }, new int[] { 130 * 2 - 10, 195 }, new int[] { 130 * 3 - 10, 195 }, new int[] { 130 * 4 - 15, 195 } },
                图4坐标 = new int[][] { new int[] { 180, 270 }, new int[] { 185 * 4 + 25, 275 }, new int[] { 10, 5 }, new int[] { 185 + 5, 5 }, new int[] { 185 * 2 + 5, 5 }, new int[] { 185 * 3 + 10, 5 }, new int[] { 185 * 4 + 10, 5 }, new int[] { 25, 275 }, new int[] { 185 + 15, 275 }, new int[] { 185 * 2 + 10, 275 }, new int[] { 185 * 3 + 25, 275 } },
                图5坐标 = new int[][] { new int[] { 140, 185 }, new int[] { 150 * 4, 220 }, new int[] { 0, 10 }, new int[] { 140, 10 }, new int[] { 150 * 2, 10 }, new int[] { 150 * 3 - 10, 10 }, new int[] { 150 * 4, 10 }, new int[] { 0, 220 }, new int[] { 150 - 15, 220 }, new int[] { 150 * 2, 220 }, new int[] { 150 * 3 - 5, 220 } },
                图2坐标 = new int[][] { new int[] { 170, 170 }, new int[] { 5, 5 }, new int[] { 170 + 5, 5 }, new int[] { 170 * 2 + 5, 5 }, new int[] { 170 * 3 + 10, 5 }, new int[] { 170 * 4 + 10, 5 }, new int[] { 5, 210 }, new int[] { 170 + 5, 210 }, new int[] { 170 * 2 + 5, 210 }, new int[] { 170 * 3 + 5, 210 }, new int[] { 170 * 4 + 5, 210 } },
                图3坐标 = new int[][] { new int[] { 220, 240 }, new int[] { 5, 5 }, new int[] { 210, 5 }, new int[] { 210 * 2 - 20, 5 }, new int[] { 210 * 3 - 30, 5 }, new int[] { 210 * 4 - 50, 5 }, new int[] { 0, 270 }, new int[] { 210, 270 }, new int[] { 210 * 2 - 20, 270 }, new int[] { 210 * 3 - 40, 270 }, new int[] { 210 * 4 - 50, 270 } };
        private void C井解答专用窗体_Load(object sender, EventArgs e)
        {
            //System.Collections.ArrayList aarrayList = new System.Collections.ArrayList();
            PictureBox xin = new PictureBox();
            foreach (char kj in "12345678ABCDEFGH")
            {
                xin = new PictureBox();
                xin.Name = kj.ToString();
                xin.Size = new System.Drawing.Size(50, 100);
                if ("12345678".Contains(kj))
                {
                    xin.Image = 选图区域(@System.Environment.CurrentDirectory + "\\ICO\\数字3.jpg", 图3坐标[++循环][0], 图3坐标[循环][1], 图3坐标[0][0], 图3坐标[0][1], xin.Width, xin.Height);
                    xin.Location = new Point(xin.Width * (int.Parse(kj.ToString())) + 5 * int.Parse(kj.ToString()), 5);
                }
                if ("ABCDEFGH".Contains(kj))
                {
                    xin.Image = 选图区域(@System.Environment.CurrentDirectory + "\\ICO\\数字2.jpg", 图2坐标[++循环 - 8][0], 图2坐标[循环 - 8][1], 图2坐标[0][0], 图2坐标[0][1], xin.Width, xin.Height);
                    xin.Location = new Point((xin.Width * (循环 - 8)) + 5 * (循环 - 8), xin.Height + 15);
                }
                xin.Parent = this;
            }
            this.DoubleClick += new EventHandler(窗体双击);
        }
        static System.Drawing.Bitmap 选图区域(string 图片路径, int 原图X, int 原图Y, int 原图宽, int 原图高, int 区域宽, int 区域高)
        {//参考https://www.cnblogs.com/zhangruifeng/p/5986463.html
            System.Drawing.Image 原图 = System.Drawing.Image.FromFile(图片路径);
            System.Drawing.Bitmap 图区 = new System.Drawing.Bitmap(区域宽, 区域高);
            System.Drawing.Graphics 新图 = System.Drawing.Graphics.FromImage(图区);
            System.Drawing.Rectangle 目标位置 = new System.Drawing.Rectangle(new System.Drawing.Point(0, 0), new System.Drawing.Size(区域宽, 区域高));
            System.Drawing.Rectangle 原图位置 = new System.Drawing.Rectangle(new System.Drawing.Point(原图X, 原图Y), new System.Drawing.Size(原图宽, 原图高));
            新图.DrawImage(原图, 目标位置, 原图位置, System.Drawing.GraphicsUnit.Pixel);
            return 图区;
        }
        private void 窗体双击(object sender, EventArgs e)
        {
            Control.ControlCollection 图控件 = this.Controls;
            this.BeginInvoke(new Action(() =>
            {
                while (true)
                {
                    Task.Delay(999); Application.DoEvents();
                    DateTime shijian = DateTime.Now; 循环 = 6;
                    int[] sutu = { shijian.Hour / 10, shijian.Hour % 10, shijian.Minute / 10, shijian.Minute % 10, shijian.Second / 10, shijian.Second % 10, Array.IndexOf("Sunday Monday Tuesday Wednesday Thursday Friday Saturday ".Split(' '), shijian.DayOfWeek.ToString()), shijian.Year / 1000, shijian.Year / 100 % 10, shijian.Year / 10 % 10, shijian.Year % 10, shijian.Month / 10 % 10, shijian.Month % 10, shijian.Day / 10 % 10, shijian.Day % 10 };
                    foreach (Control 图 in 图控件) if (图 is PictureBox)
                        {
                            PictureBox tu = ((PictureBox)图);
                            if ("12".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\ICO\\数字0.jpg", 图0坐标[sutu[int.Parse(tu.Name) - 1] + 1][0], 图0坐标[sutu[int.Parse(tu.Name) - 1] + 1][1], 图0坐标[0][0], 图0坐标[0][1], tu.Width, tu.Height);
                            if ("34".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\ICO\\数字5.jpg", 图5坐标[sutu[int.Parse(tu.Name) - 1] + 1][0], 图5坐标[sutu[int.Parse(tu.Name) - 1] + 1][1], 图5坐标[0][0], 图5坐标[0][1], tu.Width, tu.Height);
                            if ("56".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\ICO\\数字4.jpg", 图4坐标[sutu[int.Parse(tu.Name) - 1] + 1][0], 图4坐标[sutu[int.Parse(tu.Name) - 1] + 1][1], 图4坐标[0][0], 图4坐标[0][1], tu.Width, tu.Height);
                            if ("7".Contains(tu.Name)) tu.Image = new Bitmap(tu.Width, tu.Height );
                            if ("8".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\ICO\\数字0.jpg", 图0坐标[sutu[int.Parse(tu.Name) - 2] + 1][0], 图0坐标[sutu[int.Parse(tu.Name) - 2] + 1][1], 图0坐标[0][0], 图0坐标[0][1], tu.Width, tu.Height);
                            if ("ABCDGH".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\ICO\\数字2.jpg", 图2坐标[sutu[++循环] + 1][0], 图2坐标[sutu[循环] + 1][1], 图2坐标[0][0], 图2坐标[0][1], tu.Width, tu.Height);
                            if ("EF".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\ICO\\数字3.jpg", 图3坐标[sutu[++循环] + 1][0], 图3坐标[sutu[循环] + 1][1], 图3坐标[0][0], 图3坐标[0][1], tu.Width, tu.Height);
                        }
                }
            }));
        }

    }
}

超级丑修改一下显示时间、星期、年月日

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 微佛诞提示日历时间
{
    public partial class 微佛诞提示日历时间 : Form
    {
        private class 佛诞
        { 
            public string 名称 { get; set; } 
            public int 日期 { get; set; }
            public 佛诞(string 称号, int 诞日)
            { 名称 = 称号; 日期 = 诞日; }
        }
        佛诞[] 佛诞组 = new 佛诞[] { new 佛诞("那摩阿弥陀佛!圣诞", 1117), new 佛诞("那摩地藏王菩萨!圣诞", 729), new 佛诞("那摩地藏王菩萨!圣诞", 730)
            , new 佛诞("那摩释迦牟尼佛!圣诞", 48), new 佛诞("那摩释迦牟尼佛!出家", 28), new 佛诞("那摩释迦牟尼佛!成道", 128), new 佛诞("那摩释迦牟尼佛!涅槃", 215)
            , new 佛诞("那摩观世音菩萨!圣诞", 219), new 佛诞("那摩观世音菩萨!出家", 919), new 佛诞("那摩观世音菩萨!成道", 619), new 佛诞("那摩大势至菩萨!圣诞", 713)
        , new 佛诞("那摩普贤菩萨!圣诞", 221), new 佛诞("那摩文殊师利菩萨!圣诞", 44), new 佛诞("那摩禅宗达摩祖师!圣诞", 105), new 佛诞("那摩慧能禅宗六祖!圣诞", 29), new 佛诞("那摩慧能禅宗六祖!圆寂", 83)
        , new 佛诞("那摩华严菩萨!圣诞", 1229), new 佛诞("那摩药师佛!圣诞", 930), new 佛诞("那摩燃灯古佛!圣诞", 822), new 佛诞("那摩定光佛!圣诞", 16), new 佛诞("那摩弥勒菩萨!圣诞;春节", 11)
        , new 佛诞("那摩福德土地正神!圣诞", 22), new 佛诞("那摩准提菩萨!圣诞", 316), new 佛诞("那摩药王菩萨!圣诞", 428), new 佛诞("那摩伽蓝菩萨!圣诞", 518)
        , new 佛诞("那摩韦驮菩萨!圣诞", 63), new 佛诞("那摩第五殿阎罗天子!圣诞", 18), new 佛诞("那摩帝释天尊!圣诞", 19), new 佛诞("那摩妈祖升仙!重阳节", 729)
        , new 佛诞("那摩妈祖!圣诞", 323), new 佛诞("那摩文昌帝君!圣诞", 23), new 佛诞("那摩第四殿五官王!圣诞", 218), new 佛诞("那摩第六殿卞城王!圣诞", 38)
        , new 佛诞("那摩中岳大帝;后土娘娘!圣诞", 319), new 佛诞("那摩子孙娘娘!圣诞", 320), new 佛诞("那摩第七殿泰山王!圣诞", 327), new 佛诞("那摩地藏王菩萨!圣诞", 729)
        , new 佛诞("佛欢喜日!盂兰盆节", 715), new 佛诞("元宵节!", 115), new 佛诞("端午节", 55), new 佛诞("七夕情人节", 77), new 佛诞("中秋节", 815), new 佛诞("中秋节", 815)
        , new 佛诞("腊八节", 128), new 佛诞("小年", 1223), new 佛诞("除夕", 1230), new 佛诞("道教中元节", 715)};
        //System.Collections.ArrayList 佛菩萨圣诞 = new System.Collections.ArrayList();

        public 微佛诞提示日历时间()
        {
            InitializeComponent();
        }
        ToolTip 控件说明 = new ToolTip();
        NotifyIcon 托盘 = new NotifyIcon();
        System.Timers.Timer 定时 = new System.Timers.Timer(1000);
        System.Globalization.ChineseLunisolarCalendar 微软农历 = new System.Globalization.ChineseLunisolarCalendar();
        int 循环 = 0, 天 = 0, 月 = 0, 年 = 0; int[] 提醒组 = { };
        int[][] 图0坐标 = new int[][] { new int[] { 180, 200 }, new int[] { 10, 0 }, new int[] { 175, 0 }, new int[] { 175 * 2 - 20, 0 }, new int[] { 175 * 3 - 25, 0 }, new int[] { 175 * 4 - 25, 0 }, new int[] { 0, 230 }, new int[] { 175 + 10, 230 }, new int[] { 175 * 2 + 10, 230 }, new int[] { 175 * 3 + 10, 230 }, new int[] { 175 * 4 - 5, 230 } },
                图1坐标 = new int[][] { new int[] { 150, 200 }, new int[] { 10, 5 }, new int[] { 130, 5 }, new int[] { 130 * 2, 5 }, new int[] { 130 * 3 - 10, 5 }, new int[] { 130 * 4 - 10, 5 }, new int[] { 10, 195 }, new int[] { 130, 195 }, new int[] { 130 * 2 - 10, 195 }, new int[] { 130 * 3 - 10, 195 }, new int[] { 130 * 4 - 15, 195 } },
                图4坐标 = new int[][] { new int[] { 180, 270 }, new int[] { 185 * 4 + 25, 275 }, new int[] { 10, 5 }, new int[] { 185 + 5, 5 }, new int[] { 185 * 2 + 5, 5 }, new int[] { 185 * 3 + 10, 5 }, new int[] { 185 * 4 + 10, 5 }, new int[] { 25, 275 }, new int[] { 185 + 15, 275 }, new int[] { 185 * 2 + 10, 275 }, new int[] { 185 * 3 + 25, 275 } },
                图5坐标 = new int[][] { new int[] { 140, 185 }, new int[] { 150 * 4, 220 }, new int[] { 0, 10 }, new int[] { 140, 10 }, new int[] { 150 * 2, 10 }, new int[] { 150 * 3 - 10, 10 }, new int[] { 150 * 4, 10 }, new int[] { 0, 220 }, new int[] { 150 - 15, 220 }, new int[] { 150 * 2, 220 }, new int[] { 150 * 3 - 5, 220 } },
                图2坐标 = new int[][] { new int[] { 170, 170 }, new int[] { 5, 5 }, new int[] { 170 + 5, 5 }, new int[] { 170 * 2 + 5, 5 }, new int[] { 170 * 3 + 10, 5 }, new int[] { 170 * 4 + 10, 5 }, new int[] { 5, 210 }, new int[] { 170 + 5, 210 }, new int[] { 170 * 2 + 5, 210 }, new int[] { 170 * 3 + 5, 210 }, new int[] { 170 * 4 + 5, 210 } },
                图3坐标 = new int[][] { new int[] { 220, 240 }, new int[] { 5, 5 }, new int[] { 210, 5 }, new int[] { 210 * 2 - 20, 5 }, new int[] { 210 * 3 - 30, 5 }, new int[] { 210 * 4 - 50, 5 }, new int[] { 0, 270 }, new int[] { 210, 270 }, new int[] { 210 * 2 - 20, 270 }, new int[] { 210 * 3 - 40, 270 }, new int[] { 210 * 4 - 50, 270 } };
        //ComboBox 下拉框 = new ComboBox();
        //ListBox 项列表 = new ListBox();
        //TextBox 姓名 = new TextBox(), 电话 = new TextBox();
        //Button 添加 = new Button(), 删除 = new Button();
        private void 微佛诞提示日历时间_Load(object sender, EventArgs e)
        {

            //删除.Parent = 添加.Parent = 电话.Parent = 姓名.Parent = 项列表.Parent = this;
            //删除.Anchor = 添加.Anchor = 电话.Anchor = 姓名.Anchor = 项列表.Anchor = (AnchorStyles.Top | AnchorStyles.Left);
            //项列表.Location = new Point(2, 2);
            //电话.Location = new Point(2, 项列表.Bottom + 5);
            //姓名.Location = new Point(电话.Right + 5, 项列表.Bottom + 5);
            //添加.Location = new Point(2, 电话.Bottom + 5);
            //删除.Location = new Point(添加.Right + 5, 电话.Bottom + 5);
            //电话.Text = "电话"; 姓名.Text = "姓名"; 项列表.Items.Add("项列表"); 添加.Text = "添加"; 删除.Text = "删除";
            //删除.Click += new EventHandler(删除数据);
            //添加.Click += new EventHandler(添加数据);

            //截取桌面图片();
            //下拉框.Parent = this;
            //foreach (string kj in "1 2 3 4 5 6 7 8 9 10 11 12".Split(' ')) 下拉框.Items.Add(kj+"月");
            //下拉框.SelectedIndex = DateTime.Now.Month - 1;
            
            PictureBox xin = new PictureBox();
            foreach (char kj in "12345678ABCDEFGH")
            {
                xin = new PictureBox();
                xin.Name = kj.ToString();
                xin.Size = new System.Drawing.Size(50, 100);
                if ("12345678".Contains(kj))
                {
                    xin.Image = 选图区域(@System.Environment.CurrentDirectory + "\\数字\\数字3.jpg", 图3坐标[++循环][0], 图3坐标[循环][1], 图3坐标[0][0], 图3坐标[0][1], xin.Width, xin.Height);
                    xin.Location = new Point(xin.Width * (int.Parse(kj.ToString()) - 1) + 5 * int.Parse(kj.ToString()), 5);
                }
                if ("ABCDEFGH".Contains(kj))
                {
                    xin.Image = 选图区域(@System.Environment.CurrentDirectory + "\\数字\\数字2.jpg", 图2坐标[++循环 - 8][0], 图2坐标[循环 - 8][1], 图2坐标[0][0], 图2坐标[0][1], xin.Width, xin.Height);
                    xin.Location = new Point((xin.Right * (循环 - 9)) + 5 * (循环 - 8), xin.Bottom  + 15);
                }
                xin.Parent = this;
            }
            this.AllowDrop = true; //this.Opacity = .9;
            this.DoubleClick += new EventHandler(窗体双击);
            this.Resize += new EventHandler(窗体大小);
            this.FormClosed += new FormClosedEventHandler(关闭后);
            this.DragDrop += new DragEventHandler(窗体拖放);
            this.DragEnter += new DragEventHandler(拖入窗体);
            //MessageBox.Show("空 格 直接使用现有函数处理".Replace(" ", ""));
            月历加载(/*初始*/); 开机启动();
            定时.AutoReset = true; 定时.Enabled = true;
            定时.Elapsed += new System.Timers.ElapsedEventHandler(定时触发);
            托盘.Visible = true; 托盘.Click += new EventHandler(点击托盘);
            托盘.Icon = this.Icon = new Icon(@System.Environment.CurrentDirectory + "\\佛像\\八卦.ico");
            托盘.BalloonTipTitle = 托盘.Text = "微佛诞图片提示日月历时间,从这里开始!";
            Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(用户登录);
            //Microsoft.Win32.SystemEvents.SessionSwitch -= new Microsoft.Win32.SessionSwitchEventHandler(用户登录);
            //var 用户 = System.Security.Principal.WindowsIdentity.GetCurrent(false);
            //var dsa = 用户;//参考https://bbs.csdn.net/topics/391906081

        }
        //private void 删除数据(object sender, EventArgs e)
        //{
        //    //if (项列表.GetSelected(项列表.SelectedIndex)) 项列表.Items.RemoveAt(项列表.SelectedIndex);
        //    foreach (object aa in 项列表.Items)
        //        if (aa.ToString().Contains(电话.Text)) { 项列表.Items.Remove(aa); break; }
        //    var dd = 项列表.Items.IndexOf(电话.Text + ":" + 姓名.Text);
        //    if (dd>=0)
        //    {
        //        项列表.Items.Remove(项列表.Items[dd]);
        //        //MessageBox.Show("记录删除成功!", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
        //    }
        //    else
        //        MessageBox.Show("用户不存在!", "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //}
        //private void 添加数据(object sender, EventArgs e)
        //{
        //    if (项列表.Items.IndexOf(电话.Text + ":" + 姓名.Text) < 0)
        //        项列表.Items.Add(电话.Text + ":" + 姓名.Text);
        //    else
        //        MessageBox.Show("用户名已存在!", "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //}
        private void 关闭后(object sender, FormClosedEventArgs e)
        {
            托盘.Visible = false;
        }
        private void 点击托盘(object sender, EventArgs e)
        {
            this.ShowInTaskbar = !this.ShowInTaskbar;
            this.WindowState = this.ShowInTaskbar ? FormWindowState.Normal : FormWindowState.Minimized;
        }
        private void 用户登录(object sender, Microsoft.Win32.SessionSwitchEventArgs e)
        {
            switch (e.Reason)
            {
                case Microsoft.Win32.SessionSwitchReason.SessionLogon:
                case Microsoft.Win32.SessionSwitchReason.SessionUnlock:
                    月历加载(/*屏保*/);
                    break;
                case Microsoft.Win32.SessionSwitchReason.SessionLock:
                case Microsoft.Win32.SessionSwitchReason.SessionLogoff:
                   this.WindowState = FormWindowState.Minimized;
                    break;
            }
        }
        private void 窗体双击(object sender, EventArgs e)
        {
            //if (this.Tag != null)
            //    using (System.IO.FileStream 流 = new System.IO.FileStream(@System.Environment.CurrentDirectory + "\\屏幕\\屏幕" + DateTime.Now.ToShortDateString().Replace("/", "") + DateTime.Now.ToLongTimeString().Replace(":", "") + ".ICO", System.IO.FileMode.Create, System.IO.FileAccess.Write))
            //    { 无损转换Image为Icon((Bitmap)this.Tag).Save(流); MessageBox.Show(流.Name,"友情提示,图标已经成功生成并保存如下:"); }//C# Image转Icon
        }
        private void 窗体大小(object sender, EventArgs e)
        {/*0还原1最小2最大*/
            if (Convert.ToUInt16(this.WindowState) == 0) { this.BackgroundImage = null; 月历加载(/*还原*/); }
            if (Convert.ToUInt16(this.WindowState) == 1) this.ShowInTaskbar = false;
            if (Convert.ToUInt16(this.WindowState) == 2 && this.Tag != null) 图片适应((Image)this.Tag);
        }
        private void 拖入窗体(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Copy;
            //this.BackgroundImage = new Bitmap(new Bitmap(((string[])e.Data.GetData(DataFormats.FileDrop, true))[0]), this.Width, this.Height);
        }
        private void 窗体拖放(object sender, DragEventArgs e)
        {
            图片适应(new Bitmap(((string[])e.Data.GetData(DataFormats.FileDrop, true))[0]));
        }
        [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
        extern static bool DestroyIcon(IntPtr 处理);//参考https://docs.microsoft.com/zh-cn/dotnet/api/system.drawing.icon.fromhandle?redirectedfrom=MSDN&view=netframework-4.7.2#System_Drawing_Icon_FromHandle_System_IntPtr_
        private void 定时触发(object sender, System.Timers.ElapsedEventArgs e)
        {
            //if (Clipboard.ContainsImage())
            //    this.BackgroundImage = Clipboard.GetImage();
            显示图片();
            try
            {
                this.BeginInvoke(new Action(() =>
                {
                    using (Bitmap 旋 = this.Icon.ToBitmap())
                    {
                        旋.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        using (Icon 转 = Icon.FromHandle(旋.GetHicon(/*发生一般性GDI错误*/)))
                        { 托盘.Icon = this.Icon = (Icon)转.Clone(); DestroyIcon(转.Handle); }
                    }
                }));
            }
            catch (Exception)
            {  }
        }
        bool 判断文件存在(string 路径文件名) { return new System.IO.FileInfo(路径文件名).Exists; }
        void 月历加载()
        {
            天 = 微软农历.GetDayOfMonth(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day));
            月 = 微软农历.GetMonth(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day));
            年 = 微软农历.GetSexagenaryYear(DateTime.Now); 提醒组 = new int[] { };
            foreach (char 查 in "123456") 提醒组 = 提醒组.Concat(new int[] { int.Parse(微软农历.GetMonth(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(int.Parse(查.ToString()))).ToString() + 微软农历.GetDayOfMonth(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(int.Parse(查.ToString()))).ToString()) }).ToArray();
            this.Text = "月历:" + " 甲乙丙丁戊己庚辛壬癸"[微软农历.GetCelestialStem(年)]
                            + " 鼠牛虎兔龙蛇马羊猴鸡狗猪"[微软农历.GetTerrestrialBranch(年)] + "年"
                            + " 正二三四五六七八九十冬腊"[月] + (天 > 10 ? "月" : "月初") + " 十廿仨"[天 / 10] + " 一二三四五六七八九"[天 % 10];
        }
        void 显示图片()
        {
            Control.ControlCollection 控件集 = this.Controls;
            this.BeginInvoke(new Action(() =>
            {
                DateTime shijian = DateTime.Now; 循环 = 6; string ts = "";
                if (shijian.Hour + shijian.Minute + shijian.Second == 0) 月历加载(/*0点*/);
                int[] sutu = { shijian.Hour / 10, shijian.Hour % 10, shijian.Minute / 10, shijian.Minute % 10, shijian.Second / 10, shijian.Second % 10, Array.IndexOf("Sunday Monday Tuesday Wednesday Thursday Friday Saturday ".Split(' '), shijian.DayOfWeek.ToString()), shijian.Year / 1000, shijian.Year / 100 % 10, shijian.Year / 10 % 10, shijian.Year % 10, shijian.Month / 10 % 10, shijian.Month % 10, shijian.Day / 10 % 10, shijian.Day % 10 };
                foreach (Control 图 in 控件集) if (图 is PictureBox)
                    {
                        PictureBox tu = ((PictureBox)图);
                        if ("12".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\数字\\数字0.jpg", 图0坐标[sutu[int.Parse(tu.Name) - 1] + 1][0], 图0坐标[sutu[int.Parse(tu.Name) - 1] + 1][1], 图0坐标[0][0], 图0坐标[0][1], tu.Width, tu.Height);
                        if ("34".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\数字\\数字5.jpg", 图5坐标[sutu[int.Parse(tu.Name) - 1] + 1][0], 图5坐标[sutu[int.Parse(tu.Name) - 1] + 1][1], 图5坐标[0][0], 图5坐标[0][1], tu.Width, tu.Height);
                        if ("56".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\数字\\数字4.jpg", 图4坐标[sutu[int.Parse(tu.Name) - 1] + 1][0], 图4坐标[sutu[int.Parse(tu.Name) - 1] + 1][1], 图4坐标[0][0], 图4坐标[0][1], tu.Width, tu.Height);
                        if ("7".Contains(tu.Name))
                        {
                            佛诞[] 圣号 = 佛诞组.Where(查 => 查.日期 == int.Parse(月.ToString() + 天.ToString()) || 提醒组.Contains(查.日期)).OrderBy(排 => 提醒组.ToList().IndexOf(排.日期)).ToArray();
                            tu.Image = new Bitmap(new Bitmap((((圣号.Length > 0) ? 判断文件存在(@System.Environment.CurrentDirectory + "\\佛像\\" + 圣号[0].名称.Split('!')[0] + ".jpg") : false) ? @System.Environment.CurrentDirectory + "\\佛像\\" + 圣号[0].名称.Split('!')[0] + ".jpg" : @System.Environment.CurrentDirectory + "\\佛像\\那摩韦驮菩萨.jpg")), tu.Width, tu.Height);
                            if (圣号.Length > 0 && 判断文件存在(@System.Environment.CurrentDirectory + "\\佛像\\" + 圣号[0].名称.Split('!')[0] + ".jpg"))
                                this.Tag = new Bitmap(@System.Environment.CurrentDirectory + "\\佛像\\" + 圣号[0].名称.Split('!')[0] + ".jpg");// else this.Tag = null;
                            foreach (var 圣 in 圣号) ts += 圣.名称 + (提醒组.ToList().IndexOf(圣.日期) + 1) + "天;";
                            if (圣号.Length > 0)
                            {
                                int 预 = 提醒组.ToList().IndexOf(圣号[0].日期) + 1;
                                控件说明.SetToolTip(tu, ts.Replace("0", "今"));
                                if (shijian.Second % (2 + 预) == 0 && !this.Text.Contains("(提醒!)" + 预.ToString("0天").Replace("0", "今"))) this.Text += "(提醒!)" + 预.ToString("0天").Replace("0", "今"); else this.Text = this.Text.Replace("(提醒!)" + 预.ToString("0天").Replace("0", "今"), "");
                            }
                            else if (this.Tag == null) this.Tag = new Bitmap(@System.Environment.CurrentDirectory + "\\佛像\\韦驮菩萨.jpg");
                        }
                        if ("8".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\数字\\数字0.jpg", 图0坐标[sutu[int.Parse(tu.Name) - 2] + 1][0], 图0坐标[sutu[int.Parse(tu.Name) - 2] + 1][1], 图0坐标[0][0], 图0坐标[0][1], tu.Width, tu.Height);
                        if ("ABCDGH".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\数字\\数字2.jpg", 图2坐标[sutu[++循环] + 1][0], 图2坐标[sutu[循环] + 1][1], 图2坐标[0][0], 图2坐标[0][1], tu.Width, tu.Height);
                        if ("EF".Contains(tu.Name)) tu.Image = 选图区域(@System.Environment.CurrentDirectory + "\\数字\\数字3.jpg", 图3坐标[sutu[++循环] + 1][0], 图3坐标[sutu[循环] + 1][1], 图3坐标[0][0], 图3坐标[0][1], tu.Width, tu.Height);
                    }
            }));
        }
        void 开机启动()
        {//选择 COM 选项卡并选择 Windows Script Host Object Model 
            string 程序名 = Application.ExecutablePath,
            名称 = 程序名.Substring(程序名.LastIndexOf("\\") + 1);
            名称 = 名称.Remove(名称.LastIndexOf("."));
            if (!System.IO.File.Exists(程序名)) return;
            string 快捷文件 = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + 名称 + ".lnk";
            if (System.IO.File.Exists(快捷文件))
            {
                //if (MessageBox.Show("确定要删除 [" + 名称 + "] 开机启动吗?", "删除确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                //    System.IO.File.Delete(快捷文件);
            }
            else
            {
                if (MessageBox.Show("确定要创建 [" + 名称 + "] 开机启动吗?", "创建确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    IWshRuntimeLibrary.WshShell 外壳 = new IWshRuntimeLibrary.WshShell();
                    IWshRuntimeLibrary.IWshShortcut 快捷键 = (IWshRuntimeLibrary.IWshShortcut)外壳.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + 名称 + ".lnk");
                    快捷键.TargetPath = 程序名;
                    快捷键.WorkingDirectory = System.Environment.CurrentDirectory;
                    快捷键.WindowStyle = 1;
                    快捷键.Description = 名称;
                    快捷键.IconLocation = 程序名;
                    快捷键.Save();
                }
                MessageBox.Show("[" + 名称 + "] 开机启动,设置完成!");
            }
        }
        void 图片适应(Image 原图)
        {
            double 比率 = 1; int 标题高 = 28;
            if (原图.Height > this.Height) 比率 = (double)(this.Height - 标题高) / (double)原图.Height;
            if (原图.Width > this.Width) 比率 = (double)(this.Width) / 原图.Width;
            if (原图.Height > this.Height && 原图.Width > this.Width)
                比率 = ((double)(this.Height - 标题高) / (double)原图.Height) > ((double)(this.Width) / 原图.Width) ? (double)(this.Width) / 原图.Width : ((double)(this.Height - 标题高) / (double)原图.Height);
            this.Tag = this.BackgroundImage = 高质缩略图(原图, (int)(原图.Width * 比率), (int)(原图.Height * 比率), new Bitmap(this.Width, this.Height - 标题高));
        }
        static System.Drawing.Bitmap 选图区域(string 图片路径, int 原图X, int 原图Y, int 原图宽, int 原图高, int 区域宽, int 区域高)
        {//参考https://www.cnblogs.com/zhangruifeng/p/5986463.html
            System.Drawing.Bitmap 图区 = new System.Drawing.Bitmap(区域宽, 区域高);
            try
            {
                System.Drawing.Image 原图 = System.Drawing.Image.FromFile(图片路径);
                System.Drawing.Graphics 新图 = System.Drawing.Graphics.FromImage(图区);
                System.Drawing.Rectangle 目标位置 = new System.Drawing.Rectangle(new System.Drawing.Point(0, 0), new System.Drawing.Size(区域宽, 区域高));
                System.Drawing.Rectangle 原图位置 = new System.Drawing.Rectangle(new System.Drawing.Point(原图X, 原图Y), new System.Drawing.Size(原图宽, 原图高));
                新图.DrawImage(原图, 目标位置, 原图位置, System.Drawing.GraphicsUnit.Pixel);
                //.Save(@System.Environment.CurrentDirectory + "\\屏幕\\屏幕" + DateTime.Now.ToShortDateString().Replace("/", "") + DateTime.Now.ToLongTimeString().Replace(":", "") + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            }
            catch { }
            finally { }
            return 图区;
        }


    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/710748.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Nacos 配置更新的工作流程

首先&#xff0c;Nacos 是采用长轮训的方式向 Nacos Server 端发起配置更新查询的功能。所谓长轮训&#xff0c;&#xff08;如图&#xff09;就是客户端发起一次轮训请求到服务端&#xff0c;当服务端配置没有任何变更的时候&#xff0c;这个连接一直打开。 直到服务端有配置或…

微分方程应用——笔记整理

首先&#xff0c;根据正常思路走&#xff0c;化简得到式子&#xff1a; 不难发现&#xff0c;设 后面得出该方程的通解&#xff1a; 这里要注意什么等于这个通解 --- z 又因为该曲线过点 所以可以求出c为3 该题虽然简单&#xff0c;但是要注意几个问题&#xff0c;该定…

轻松生成高质量用例的API接口工具

1、前言 随着自动化测试技术的普及&#xff0c;已经有很多公司或项目&#xff0c;多多少少都会进行自动化测试。 目前本部门的自动化测试以接口自动化为主&#xff0c;接口用例采用 Excel 进行维护&#xff0c;按照既定的接口用例编写规则&#xff0c;对于功能测试人员来说只…

vue使用img标签:src属性动态引入资源路径的方法

vue版本号&#xff1a;3.2.13 vue中<img src"" />标签静态引入图片资源 <template><!-- <router-view/> --><!-- 静态引入图片资源 --><img src"./assets/logo.png" alt""> </template><style la…

微软MFC技术中消息的定义

我是荔园微风&#xff0c;作为一名在IT界整整25年的老兵&#xff0c;今天来聊聊MFC技术中消息的定义。 本贴子首先介绍MFC消息的基本概念&#xff0c;理解消息的定义是学习使用MFC的基础。了解消息的驱动机制后&#xff0c;才能彻底明白MFC的运行机制。 首先来看什么是消息。…

VS code搭建JavaScript环境调用XHR实现post和get简单流程

一、下载NodeJS 下载node&#xff0c;最好到node官 https://nodejs.org/en/ 下载一个LTS&#xff08;Long Term Surport&#xff09;长期支持版本。 输入命令node -v 就可以看到node的版本了如果node安装包集成了npm(node package manage)&#xff0c;那我们输入命令npm -v 也…

11 S整数小波分解图像(matlab程序)

1.简述 学习目标&#xff1a; 非标准小波分解&#xff08;用S整数变换&#xff09; 小波分解过程&#xff1a;读取加入噪声后的图片后&#xff0c;数据即是高度*宽度个数据点。对此矩阵数据要做二维离散小波分解&#xff0c;二维小波变换和一维小波变换的区别从原理上来说就是…

stable diffusion webui 下载和使用civitai中的模型

1.网址 C站网址为&#xff1a;https://civitai.com/。注&#xff1a;这里需要科学上网 2.下载模型 1.选择想要的模型&#xff0c;点击【Download】按钮&#xff0c;这里演示【Deliberate】模型的下载和使用 2.将下载的模型&#xff0c;存放到【/models/Stable-diffusion】目…

基于圆弧搜索和最小似然圆估计的圆查找算法

在这里提出一种算法&#xff0c;其实是将两篇papers的想法的结合。没有什么创新点&#xff0c;只是做一下算法原理的记录&#xff0c;防止后面重新看代码的时候一头雾水。 算法的目的在于查找特定半径范围的圆&#xff0c;而不致力于查找所有的圆&#xff0c;当然它也支持查找所…

04约瑟夫环

约瑟夫问题 设编号为1&#xff0c;2&#xff0c;3……n的n个人围坐成一圈&#xff0c;约定编号为k(1<k<n)的人从1开始报数&#xff0c;数到m的那个人出列&#xff0c;它的下一位又从1开始报数&#xff0c;数到m的那个人又出列&#xff0c;以此类推&#xff0c;直到所有人…

新手简单看懂Servlet里面的web.xml配置

背景&#xff1a; ecplisetomcatservlet 我们在学习servlet时候&#xff0c;因为前面基础没学好&#xff0c;导致servlet看不懂&#xff0c;比如笔者当时就是servlet的web.xml看不懂&#xff0c;如果我们能先看懂web.xml&#xff0c;知道前端访问哪个接口&#xff0c;调用哪个…

一个VBA的概率的模型(草稿)(未完成)

现在 可以让概率变化一般的抽奖&#xff0c;都是 概率稳定的&#xff0c;好处是稳定&#xff0c;没啥好处坏处是&#xff0c;不同的人次数差距很大&#xff0c;无法形成稳定的预期 概率0.1 变成概率0.1&#xff0c;如果失败就增加概率 这个增加概率可以是&#xff0c;已经失…

Flutter学习四:Flutter开发基础(五)资源管理

目录 0 引言 1 资源管理 1.1 指定 assets 1.2 Asset 变体&#xff08;variant&#xff09; 1.3 加载 assets 1.3.1 加载文本 1.3.2 加载图片 1.3.2.1 声明分辨率相关的图片 1.3.2.2 加载图片 1.3.3 依赖包中的资源图片 1.3.4 打包包中的 assets 1.3.5 特定平台 as…

B062-组件 路由 属性扩展 webpack Vue-cli

目录 一&#xff1a;组件1.何为组件2.组件的定义方式全局组件局部组件 3.组件的注意事项4.template的定义方式5.组件获取数据的方式 二&#xff1a;路由1.什么是路由&#xff1f;2.路由的使用步骤 三&#xff1a;Vue属性扩展1.计算属性 computed和监听属性 watch3.钩子函数 mou…

【Redis 三种模式----主从复制、哨兵以及集群】

目录 一、主从复制1.1、主从复制的概念1.2、主从复制的作用1.3、主从复制流程1.4、搭建Redis 主从复制1、环境准备2、安装Redis3、修改 Redis 配置文件&#xff08;Master节点操作&#xff09;4、修改 Redis 配置文件&#xff08;Slave节点操作&#xff09;5、验证主从效果 二、…

[牛客周赛复盘] 牛客周赛 Round 1 20230702

[牛客周赛复盘] 牛客周赛 Round 1 20230702 总结游游画U1. 题目描述2. 思路分析3. 代码实现 游游的数组染色1. 题目描述2. 思路分析3. 代码实现 游游的交换字符1. 题目描述2. 思路分析3. 代码实现 游游的9的倍数1. 题目描述2. 思路分析3. 代码实现 六、参考链接 总结 牛客第一…

时序预测 | MATLAB实现BO-NARX和BO-LSTM贝叶斯优化神经网络股票价格预测比较

时序预测 | MATLAB实现BO-NARX贝叶斯优化非线性自回归外生模型和BO-LSTM贝叶斯优化长短期记忆神经网络股票价格预测比较 目录 时序预测 | MATLAB实现BO-NARX贝叶斯优化非线性自回归外生模型和BO-LSTM贝叶斯优化长短期记忆神经网络股票价格预测比较效果一览基本介绍研究过程程序…

《分布式中间件技术实战:Java版》学习笔记(二):RabbitMQ死信队列/延迟队列实现商品扣库存

一.关于RabbitMQ 1.RabbitMQ交换机类型 (1).FanoutExchange&#xff1a;广播交换机。消息发送到交换机后&#xff0c;会广播到所有队列&#xff0c;不需要经过路由。 (2).DirectExchange&#xff1a;直通交换机。生产者发送消息到交换机(Exchange)&#xff0c;再经过路由(Ro…

自然语言处理从入门到应用——预训练模型总览:预训练模型的拓展

分类目录&#xff1a;《自然语言处理从入门到应用》总目录 相关文章&#xff1a; 预训练模型总览&#xff1a;从宏观视角了解预训练模型 预训练模型总览&#xff1a;词嵌入的两大范式 预训练模型总览&#xff1a;两大任务类型 预训练模型总览&#xff1a;预训练模型的拓展 …

Fully-Convolutional Siamese Networks for Object Tracking(SiamFC)

Fully-Convolutional Siamese Networks for Object Tracking&#xff08;SiamFC&#xff0c;ECCV2016&#xff09; 全卷积网络的优势在于&#xff0c;可以将一个更大的搜索图像作为输入提供给网络&#xff0c;它将在单个评估中计算所有平移后的子窗口的相似度&#xff0c;而不…