コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();

            TasksList = new ObservableCollection <Task>();

            Shown = IsShown.no;
            foreach (var task in TasksList)
            {
                if (task.EndingDate == DateTime.Now.AddDays(1).ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks is going to meet a deadline tomorrow!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline tomorrow",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        Shown = IsShown.yes;
                    }
                }
                else if (task.EndingDate == DateTime.Now.AddHours(1).ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks is going to meet a deadline in one hour!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline in one hour",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        Shown = IsShown.yes;
                    }
                }
                else if (task.EndingDate == DateTime.Now.AddHours(12).ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks is going to meet a deadline in 12 hours!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline in one hour",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        Shown = IsShown.yes;
                    }
                }
                else if (task.EndingDate == DateTime.Now.AddHours(6).ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks is going to meet a deadline in 6 hours!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline in one hour",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        Shown = IsShown.yes;
                    }
                }
                else if (task.EndingDate == DateTime.Now.ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks have met a deadline!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline in one hour",
                                        MessageBoxButton.OK, MessageBoxImage.Warning);
                        Shown = IsShown.yes;
                    }
                }
            }
            Shown = IsShown.no;

            TimeCounter          = new System.Timers.Timer(60000);
            TimeCounter.Elapsed += TimeCounter_Elapsed;
            TimeCounter.Start();

            OnPropertyChanged(nameof(TasksList));
        }
コード例 #2
0
        private void TimeCounter_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            foreach (var task in TasksList)
            {
                if (task.EndingDate == DateTime.Now.AddDays(1).ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks is going to meet a deadline tomorrow!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline tomorrow",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        Shown = IsShown.yes;
                    }
                }
                else if (task.EndingDate == DateTime.Now.AddHours(1).ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks is going to meet a deadline in 1 hour!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline in one hour",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        Shown = IsShown.yes;
                    }
                }
                else if (task.EndingDate == DateTime.Now.AddHours(12).ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks is going to meet a deadline in 12 hours!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline in one hour",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        Shown = IsShown.yes;
                    }
                }
                else if (task.EndingDate == DateTime.Now.AddHours(6).ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks is going to meet a deadline in 6 hours!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline in 6 hours",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        Shown = IsShown.yes;
                    }
                }
                else if (task.EndingDate == DateTime.Now.ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks have met a deadline!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline now",
                                        MessageBoxButton.OK, MessageBoxImage.Warning);
                        Shown = IsShown.yes;
                    }
                }
                else if (task.EndingDate == DateTime.Now.AddDays(2).ToString("dd-MM-yyyy HH:mm"))
                {
                    if (Shown == IsShown.no)
                    {
                        MessageBox.Show("One of your tasks is going to meet a deadline in 2 days!" +
                                        "\nCheck tasklist for further information.",
                                        "Announcement - deadline in 2 days",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        Shown = IsShown.yes;
                    }
                }
            }

            Shown = IsShown.no;
        }