.NET 學習

.NET 學習生活感想... 万事成蹉跎..... 贵在坚持 及时整理自己做过和学过的东西

博客园 首页 新随笔 联系 订阅 管理

 

http://www.devexpress.com/Support/Center/e/E1041.aspx

 

using System;
using System.Windows.Forms;
using DevExpress.ExpressApp;
using DevExpress.XtraBars.Alerter;
using DevExpress.ExpressApp.Utils;

namespace WinSolution.Module {
    
public class ShowAlertControlMainWindowController : WindowController {
        
private AlertControl alertControlCore;
        
private Timer alertTimerCore;
        
public ShowAlertControlMainWindowController() {
            TargetWindowType 
= WindowType.Main;
        }
        
protected override void OnActivated() {
            
base.OnActivated();
            InitAlertControlCore();
            InitAlertTimerCore();
        }
        
protected virtual void InitAlertControlCore() {
            alertControlCore 
= new AlertControl();
        }
        
protected virtual void InitAlertTimerCore() {
            alertTimerCore 
= new Timer();
            alertTimerCore.Tick 
+= alertTimerCore_Tick;
            alertTimerCore.Interval 
= 2000;
            alertTimerCore.Start();
        }
        
private void alertTimerCore_Tick(object sender, EventArgs e) {
            ShowAlertInfo();
        }
        
protected override void OnDeactivating() {
            
if (alertTimerCore != null)
                alertTimerCore.Stop();
            
base.OnDeactivating();
        }
        
protected virtual void ShowAlertInfo() {
            Form mainForm 
= (Form)Application.MainWindow.Template;
            AlertInfo info 
= new AlertInfo("Frohe Weihnachten! (Merry Christmas!)", DateTime.Now.ToString(), ImageLoader.Instance.GetImageInfo("Attention").Image);
            AlertControl.Show(mainForm, info);
        }
        
public AlertControl AlertControl { get { return alertControlCore; } }
        
public Timer AlertTimer { get { return alertTimerCore; } }
    }
}

 

 

posted on 2010-08-23 17:13  Tonyyang  阅读(865)  评论(0编辑  收藏  举报
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/