Browse Source

时间流逝效果

liuyuqi-dellpc 11 months ago
parent
commit
396bb4cfc5
2 changed files with 110 additions and 4 deletions
  1. 50 4
      DayOf1440/MainForm.Designer.cs
  2. 60 0
      DayOf1440/MainForm.cs

+ 50 - 4
DayOf1440/MainForm.Designer.cs

@@ -38,6 +38,10 @@ namespace DayOf1440
             this.pictureBox1 = new System.Windows.Forms.PictureBox();
             this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
             this.cms_life = new System.Windows.Forms.ToolStripMenuItem();
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
             this.panelNum.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
@@ -117,10 +121,46 @@ namespace DayOf1440
             // cms_life
             // 
             this.cms_life.Name = "cms_life";
-            this.cms_life.Size = new System.Drawing.Size(180, 22);
+            this.cms_life.Size = new System.Drawing.Size(139, 22);
             this.cms_life.Text = "人生进度条";
             this.cms_life.Click += new System.EventHandler(this.cms_life_Click);
             // 
+            // label1
+            // 
+            this.label1.BackColor = System.Drawing.Color.Red;
+            this.label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.label1.Location = new System.Drawing.Point(0, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(100, 23);
+            this.label1.TabIndex = 1;
+            // 
+            // label2
+            // 
+            this.label2.BackColor = System.Drawing.Color.Red;
+            this.label2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.label2.Location = new System.Drawing.Point(1343, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(23, 100);
+            this.label2.TabIndex = 2;
+            // 
+            // label3
+            // 
+            this.label3.BackColor = System.Drawing.Color.Red;
+            this.label3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.label3.Location = new System.Drawing.Point(0, 745);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(100, 23);
+            this.label3.TabIndex = 3;
+            // 
+            // label4
+            // 
+            this.label4.BackColor = System.Drawing.Color.Red;
+            this.label4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+            this.label4.Location = new System.Drawing.Point(0, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(23, 100);
+            this.label4.TabIndex = 4;
+            // 
             // MainForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -129,11 +169,14 @@ namespace DayOf1440
             this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
             this.ClientSize = new System.Drawing.Size(1366, 768);
             this.ContextMenuStrip = this.contextMenuStrip1;
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.label1);
             this.Controls.Add(this.panelNum);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
             this.Name = "MainForm";
             this.Text = "Form1";
-            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
             this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
             this.Load += new System.EventHandler(this.MainForm_Load);
             this.DoubleClick += new System.EventHandler(this.MainForm_DoubleClick);
@@ -148,8 +191,6 @@ namespace DayOf1440
         }
 
         #endregion
-
-        private System.Windows.Forms.Timer timer1;
         private System.Windows.Forms.Panel panelNum;
         private System.Windows.Forms.PictureBox pictureBox4;
         private System.Windows.Forms.PictureBox pictureBox3;
@@ -157,6 +198,11 @@ namespace DayOf1440
         private System.Windows.Forms.PictureBox pictureBox1;
         private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
         private System.Windows.Forms.ToolStripMenuItem cms_life;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Timer timer1;
     }
 }
 

+ 60 - 0
DayOf1440/MainForm.cs

@@ -15,6 +15,7 @@ namespace DayOf1440
     public partial class MainForm : BaseForm
     {   
         Bitmap[] charNum=new Bitmap[10];
+        
         public MainForm()
         {
             InitializeComponent();
@@ -26,6 +27,7 @@ namespace DayOf1440
             setPanelToCenter();
             // 让屏幕常亮
             SystemSleep.PreventForCurrentThread();
+            initCircleStyle();
             timer1.Start();
         }
 
@@ -37,6 +39,64 @@ namespace DayOf1440
         private void timer1_Tick(object sender, EventArgs e)
         {
             updateTime();
+            circleStyle();
+        }
+
+        //
+        private int[] getScreenSize(){
+            // 获取屏幕大小
+            int width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
+            int height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
+            int[] res = { width, height };
+            return res;
+        }
+
+        private void initCircleStyle(){
+            int[] size = getScreenSize();
+            label1.Width = size[0];
+            label2.Height = size[1];
+            label3.Width = size[0];
+            label4.Height= size[1];
+        }
+
+        /// 边框倒计时效果
+        private void circleStyle(){
+            int[] size = getScreenSize();
+            int second = DateTime.Now.Second;
+            if(second==0){
+                label1.Location = new Point(0,0);
+                label2.Location = new Point(size[0]-23,0);
+                label3.Location = new Point(0,size[1]-23);
+                label4.Location = new Point(0,0);
+            }else if(second<10){
+                label1.Location = new Point(0,0);
+                label2.Location = new Point(size[0]-23,0);
+                label3.Location = new Point(0,size[1]-23);
+
+                label4.Location = new Point(0, size[1]/10*second);
+            }else if(second<30){
+                label1.Location = new Point(0,0);
+                label2.Location = new Point(size[0]-23,0);
+
+                label3.Location = new Point(size[0]/20*(second-10),label3.Location.Y);
+
+                label4.Location = new Point(0, size[1]/10*second);
+            }else if (second<40)
+            {
+                label1.Location = new Point(0,0);
+
+                label2.Location = new Point(label2.Location.X, -size[1]/10*(second-30));
+
+                label3.Location = new Point(size[0]/20*(second-10),label3.Location.Y);
+                label4.Location = new Point(0, size[1]/10*second);
+            }else
+            {
+                label1.Location = new Point(-size[0]/20*(second-40),label1.Location.Y);
+
+                label2.Location = new Point(label2.Location.X, -size[1]/10*(second-30));
+                label3.Location = new Point(size[0]/20*(second-10),label3.Location.Y);
+                label4.Location = new Point(0, size[1]/10*second);
+            }
         }
 
         private void updateTime()