C# STUDY

简介:
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 WindowsFormsApplication3
{

    public partial class Form1 : Form
    {
        public delegate void TimerHandler();
        public event TimerHandler m_TimerEvent;
        public int m_offset;

        private System.Timers.Timer m_timer;
        private List<System.Drawing.Point> m_orinLocation;
        private List<System.Windows.Forms.Button> m_Buttons;
        public Form1()
        {
            InitializeComponent();
            m_timer = new System.Timers.Timer(50);
            m_timer.Elapsed += new System.Timers.ElapsedEventHandler(theout);
            m_timer.Enabled = true;
            m_orinLocation = new List<System.Drawing.Point>();
            m_Buttons = new List<System.Windows.Forms.Button>();
            m_orinLocation.Add(button1.Location);
            m_orinLocation.Add(button2.Location);
            m_orinLocation.Add(button3.Location);
            m_orinLocation.Add(button4.Location);
            m_orinLocation.Add(button5.Location);
            m_orinLocation.Add(button6.Location);
            m_orinLocation.Add(button7.Location);
            m_orinLocation.Add(button8.Location);
            m_orinLocation.Add(button9.Location);
            m_Buttons.Add(button1);
            m_Buttons.Add(button2);
            m_Buttons.Add(button3);
            m_Buttons.Add(button4);
            m_Buttons.Add(button5);
            m_Buttons.Add(button6);
            m_Buttons.Add(button7);
            m_Buttons.Add(button8);
            m_Buttons.Add(button9);
            m_offset = 0;
            m_TimerEvent += process;
        }

        public void process()
        {
            m_timer.Enabled = false;
            int itemHeight = this.button1.Height;

            System.Console.WriteLine("Process m_offset{0}, mod{1}", m_offset, m_offset % itemHeight);
            m_offset += itemHeight / 2;
            if (m_offset >= itemHeight)
            {
                m_offset = 0;
                for (int i = 0; i < 9; ++i)
                {
                    m_Buttons[i].Location = new System.Drawing.Point(m_orinLocation[i].X, m_orinLocation[i].Y);
                }
            }
            else
            {
                for (int i = 0; i < 9; ++i)
                {
                    m_Buttons[i].Location = new System.Drawing.Point(m_orinLocation[i].X, m_orinLocation[i].Y - m_offset);
                }
              
            }

           m_timer.Enabled = true; 
        }

        public void theout(object source, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                if (m_TimerEvent != null)
                    this.Invoke(m_TimerEvent);
            }
            catch(System.Exception err)
            {
                Console.WriteLine("{0}",err.Message);
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {

        }

        protected override void OnClosing(CancelEventArgs e)
        {
            m_timer.Stop();
            m_timer.Close();
            m_TimerEvent = null;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

        }

    }

}



本文转自莫水千流博客园博客,原文链接:http://www.cnblogs.com/zhoug2020/p/5875950.html,如需转载请自行联系原作者

相关文章
|
机器学习/深度学习 算法框架/工具
什么是ablation study(消融实验)?
什么是ablation study(消融实验)?
什么是ablation study(消融实验)?
|
6月前
|
测试技术 Shell Android开发
随机测试 Monkey Test
随机测试 Monkey Test
170 0
|
6月前
|
编译器 C语言 C++
lesson05-C++模板
lesson05-C++模板
39 0
Learn R package together--(2)
介绍俩个小众但实用的包wherepackage、rPlotter
82 0
|
人工智能
Learn R package together--(3)
论文中作图经常会有合并图排版需求,一般会放入PPT中或AI手动调节,若是在R中出图前直接调好岂不是更美滋滋,So本次就介绍几种关于合并图形的包cowplot、gridExtra、ggpubr、patchwork
73 0
Learn R package together--(1)
ggrepel包 此包可解决标签重合问题
75 0