1. design class
2. main_function class
3. function class(timer)
ex :
1. timer
using System;
using System.Timers;
namespace Timer1
{
internal class B_Timer
{
Timer tm2;
int ss = 0; int mm = 0; int hh = 0;
string var = "- - - - - -";
public void Init(int interval)
{
tm2 = new Timer();
tm2.Interval = interval;
tm2.Elapsed += OnTimedEvent;
}
private void OnTimedEvent(Object source, ElapsedEventArgs e)
{
ss++;
if(ss == 60)
{
ss = 0;
mm++;
if(mm == 60)
{
mm = 0;
hh++;
{
if(hh == 24)
{
ss = 0; mm = 0; hh = 0;
}
}
}
}
var = hh + "시 " + mm + "분 " + ss + "초";
}
public void Start()
{
tm2.Start();
}
public void Stop()
{
tm2.Stop();
}
public void Reset()
{
ss = 0; mm = 0; hh = 0;
tm2.Stop();
//tm2.Dispose();
}
public String result()
{
return var;
}
}
}
2. function
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 Timer1
{
public partial class Form1 : Form
{
B_Timer bt = new B_Timer();
public Form1()
{
bt.Init(1000);
InitializeComponent();
}
private void timer_btn_Click(object sender, EventArgs e)
{
if (timer_btn.Text == "S T A R T")
{
timer_btn.Text = "S T O P";
A_timer.Start();
bt.Start();
} else
{
timer_btn.Text = "S T A R T";
A_timer.Stop();
bt.Reset();
}
}
private void timer1_Tick(object sender, EventArgs e)
{
timer_la.Text = bt.result();
}
}
}
인정하기 싫은데;;; C# 생각 보다 좋다....
근데, 빌게이츠가 싫다.
그래서 나중에 기회 되면 다시 자바로 넘어가야겠다.
그건 그렇고.... 대학교 4학년 동안 구구단 배운 거 말고 뭘 배웠는지 기억이 나질 않는다;;
나도 전자과나 갔어야 하는데;;
'소프트웨어 (과거) > 자바 GUI & C# 등...' 카테고리의 다른 글
53. 개인 커스텀 에디터, C# vs JAVA Spring ??? 고찰 (0) | 2022.08.26 |
---|---|
51. 자바 마우스 우측 버튼 클릭 (0) | 2022.05.24 |
50. 단일 패널 인쇄 자바 (0) | 2022.05.13 |
49. printjob 예제 15 (0) | 2022.05.13 |
48. [JAVA] 자바 메모장 실행 및 텍스트 파일 열기 (실행시키기) (0) | 2022.05.09 |