using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; using System.Drawing; namespace NotifyWindow { class StartNotifyWindow { Form nForm = new Form(); Label notiLabel; Thread t1; public StartNotifyWindow() { initLable("Notification Test"); initNotifyForm(); } public StartNotifyWindow(string msg) { initLable(msg); initNotifyForm(); } private void initLable(string a_text) { notiLabel = new Label(); notiLabel.Text = a_text; notiLabel.Font = new Font("Arial", 15); notiLabel.Font = new Font(notiLabel.Font, FontStyle.Bold); //notiLabel.Font.Bold = true; notiLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; notiLabel.Location = new System.Drawing.Point(50, 10); notiLabel.Size = new System.Drawing.Size(300, 80); nForm.Controls.Add(notiLabel); } private void initNotifyForm() { nForm.TopMost = true; nForm.FormBorderStyle = FormBorderStyle.FixedToolWindow; nForm.ControlBox = false; nForm.StartPosition = FormStartPosition.CenterScreen; nForm.ClientSize = new System.Drawing.Size(400, 100); nForm.Opacity = 0; nForm.BackColor = Color.Snow; nForm.Visible = true; nForm.ShowInTaskbar = false; } private void nForm_MouseClick(object sender, EventArgs e) { /* 이벤트가 필요할 경우 사용 */ } public void showNotifyWindow() { startThread(); } private void stopThread() { t1.Abort(); } private void startThread() { t1 = new Thread(new ThreadStart(StartNotify)); t1.Start(); } private void StartNotify() { /* 이벤트가 필요할 경우 사용 */ //nForm.MouseClick += nForm_MouseClick; //notiLabel.MouseClick += nForm_MouseClick; // fade-in while (nForm.Opacity < 1) { nForm.Opacity += .01; nForm.Refresh(); //sleep System.Threading.Thread.Sleep(10); } // remain for 1.5 sec System.Threading.Thread.Sleep(1500); // fade-out while (nForm.Opacity != 0) { nForm.Opacity -= .01; nForm.Refresh(); //sleep System.Threading.Thread.Sleep(15); } nForm.Visible = false; // when finished Notify, abort the thread. stopThread(); // and dispose nForm nForm.Dispose(); } } }
C# Notify Windows
C# Notify Windows test code.
트레이아이콘과는 다른 notify window
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기
안녕하세요 :)