zoukankan      html  css  js  c++  java
  • 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);

            }

        }
    }

  • 相关阅读:
    C#0004--打开和保存文本文件
    C#0003--如何使用树状视图控件
    C#0002--信息提示框的使用
    C#0001--如何使用错误提醒控件
    使用C#创建简单的联系人备忘录
    SharePoint站点图片轮转器imageRotator
    优秀的代码的设计和组织架构
    思考:为什么每一种开发语言的语法都是不一样的呢(语法设置的不一样的出发点是基于什么考虑)?如果设置成一样有什么不可行的吗?
    分析一个突发问题的思考方法
    思考:架构师的前瞻性能力
  • 原文地址:https://www.cnblogs.com/zhoug2020/p/5875950.html
Copyright © 2011-2022 走看看