Beispiel #1
0
        private void OnTimedEvent(object sender, ElapsedEventArgs e)
        {
            timer.Enabled = false;

            var unHandledLetter = Program.Service.GetUnhandledLetter();

            if (unHandledLetter.NoticeCount != lastUnHandledLetter.NoticeCount)
            {
                lbNotice.Text = String.Format("通知({0})", unHandledLetter.NoticeCount.ToString());
            }
            if (unHandledLetter.MessageCount != lastUnHandledLetter.MessageCount)
            {
                lbMessage.Text = String.Format("私信({0})", unHandledLetter.MessageCount.ToString());
            }
            if (unHandledLetter.ReminderCount != lastUnHandledLetter.ReminderCount)
            {
                lbReminder.Text = String.Format("提醒({0})", unHandledLetter.ReminderCount.ToString());
            }

            //todo: 需要考虑小于的情况
            if (unHandledLetter.NoticeCount > lastUnHandledLetter.NoticeCount)
            {
                var infoForm = new InformationForm(String.Format("您有{0}条未处理的通知。",
                                                                 (unHandledLetter.NoticeCount).ToString()),
                                                   Program.Service.NoticeLink);
                new Thread(() =>
                {
                    Application.Run(infoForm);
                }).Start();
            }
            if (unHandledLetter.MessageCount > lastUnHandledLetter.MessageCount)
            {
                var infoForm = new InformationForm(String.Format("您有{0}条未处理的私信。",
                                                                 (unHandledLetter.MessageCount).ToString()),
                                                   Program.Service.MessageLink);
                new Thread(() =>
                {
                    Application.Run(infoForm);
                }).Start();
            }
            if (unHandledLetter.ReminderCount > lastUnHandledLetter.ReminderCount)
            {
                var infoForm = new InformationForm(String.Format("您有{0}条到期提醒。",
                                                                 (unHandledLetter.ReminderCount).ToString()),
                                                   Program.Service.ReminderLink);
                new Thread(() =>
                {
                    Application.Run(infoForm);
                }).Start();
            }

            lastUnHandledLetter = unHandledLetter;

            timer.Enabled = true;
        }
Beispiel #2
0
        public MainForm()
        {
            InitializeComponent();

            CheckForIllegalCrossThreadCalls = false;

            lastUnHandledLetter = new UnHandledLetter
            {
                NoticeCount   = 0,
                MessageCount  = 0,
                ReminderCount = 0
            };

            if (Program.Service.CurrentUser != null)
            {
                labelName.Text = Program.Service.CurrentUser.TrueName;
            }

            timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
            timer.Start();
        }