트레이 아이콘을 만들고 , 무언가 알림이 있을때 풍선메시지를 만들어 본다.
먼저 간단히 아이콘을 만들어 리소스에 넣어 본다.
* [프로젝트 속성] - 리소스 - 리소스추가 - 아이콘 추가
를 하면 기본 아이콘이 생성된다.
이를
Properties.Resources.Icon1;
로 접근 할수 있다.
사용법은 아래와 같다.
private System.Windows.Forms.NotifyIcon trayIcon; protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); //make up tray icon trayIcon = new System.Windows.Forms.NotifyIcon(); trayIcon.BalloonTipText = "this app has been minimised"; trayIcon.BalloonTipTitle = "BalloonTipTitle"; trayIcon.Text = "Text"; trayIcon.Icon = Properties.Resources.Icon1; trayIcon.Click += m_notifyIcon_Click; //make up test timer. DispatcherTimer timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 2); timer.Tick += timer_Tick; timer.Start(); } private int c = 0; void timer_Tick(object sender, EventArgs e) { //if you want alert something , use this method. and change Text trayIcon.ShowBalloonTip(1000); trayIcon.BalloonTipTitle = "count " + c; trayIcon.BalloonTipText = "alert test"; ++c; } void m_notifyIcon_Click(object sender, EventArgs e) { Show(); //restore window state WindowState = System.Windows.WindowState.Normal; } private void Window_IsVisibleChanged_1(object sender, DependencyPropertyChangedEventArgs e) { // when window is unvisible , change visible option tray icon . if (IsVisible == false) trayIcon.Visible = true; } private void Window_StateChanged_1(object sender, EventArgs e) { if (WindowState == System.Windows.WindowState.Minimized) { Hide(); trayIcon.ShowBalloonTip(2000); } } protected override void OnClosing(CancelEventArgs e) { base.OnClosed(e); //when user click The [Close button] , this app will not work window close command. //instead , this app window change to minimized state. WindowState = System.Windows.WindowState.Minimized; e.Cancel = true; } |
'C#' 카테고리의 다른 글
[Surface - WPF] Surface 에서의 에니메이션 활용 (ArtefactAnimator) (5) | 2013.01.22 |
---|---|
[.NET] 어셈블리 하나로 합치기 (ilmerge 사용안함) (6) | 2013.01.16 |
[WPF] 트레이 아이콘 만들고 사용하기 (6) | 2013.01.16 |
[WPF] 윈도우 닫기 명령 무시하기 (6) | 2013.01.16 |
[asmx] 쿠키 이용하기 , (사용자 인증) (7) | 2013.01.15 |
[SQL2012] DB 생성부터 사용자 만들기 그리고 SQL 접속하기 (4) | 2013.01.14 |
행복을 졸겨야 할 시간은 지금이다. 행복을 즐겨야 할 장소는 여기다.
아름다운 여자가 해바라기하는 걸 좋아해요
아름다운 여자가 해바라기하는 걸 좋아해요
태양이 바다에 미광을 비추면,나는 너를 생각한다.
다른 남자 부르면서 울거면 나한테 이쁘지나 말던지
버마Your ISP shut your services down even if you are running opt-in email lists because of some complaints from some users that forget they were opted in? Then our overseas BP (bullet proof) web hosting services are your choice. We will help you on getting a stable web hosting and make money with ease.
Your ISP shut your services down even if you are running opt-in email lists because of some com어리