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);
}
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
2013-09-16 Morton Code