예제 #1
0
        private void AddButton(object sender, RoutedEventArgs e)
        {
            ReminderElement r = new ReminderElement();

            DateTime date;

            if (!DateTime.TryParse(dataPicker.Text, out date) || textBoxContent.Text.Length != 0)
            {
                r.time = date.Date.ToString().Substring(0, 10) + " " + comboBoxSelectHours.Text + ":" + comboBoxSelectMinutes.Text + ":" + comboBoxSelectSecunds.Text;

                FileWithReminders      f  = new FileWithReminders();
                List <ReminderElement> lr = f.readRemindersFromFile();

                if (lr.Count != 0)
                {
                    r.id = lr[lr.Count() - 1].id + 1;
                }
                else
                {
                    r.id = 0;
                }

                r.content = textBoxContent.Text;

                lr.Add(r);
                f.saveRemindersToFile(lr);

                this.Close();
            }
            else
            {
                MessageBox.Show("Dane są niepoprawne lub nie zostały wprowadzone.", "Błąd");
            }
        }
        private void initInputFields()
        {
            ObservableCollection <string> listNrHours = new ObservableCollection <string>();

            for (int i = 0; i < 24; i++)
            {
                listNrHours.Add(i > 9 ? i.ToString() : "0" + i.ToString());
            }
            comboBoxSelectHours.ItemsSource = listNrHours;

            ObservableCollection <string> listNrMinutes = new ObservableCollection <string>();

            for (int i = 0; i < 60; i++)
            {
                listNrMinutes.Add(i > 9 ? i.ToString() : "0" + i.ToString());
            }
            comboBoxSelectMinutes.ItemsSource = listNrMinutes;
            comboBoxSelectSecunds.ItemsSource = listNrMinutes;

            FileWithReminders f = new FileWithReminders();
            ReminderElement   r = f.getReminder(id);

            DateTime date;

            if (DateTime.TryParse(r.time, out date))
            {
                comboBoxSelectHours.SelectedIndex   = int.Parse(date.Hour.ToString());
                comboBoxSelectMinutes.SelectedIndex = int.Parse(date.Minute.ToString());
                comboBoxSelectSecunds.SelectedIndex = int.Parse(date.Second.ToString());

                dataPicker.SelectedDate = date.Date;
            }

            textBoxContent.Text = r.content;
        }
예제 #3
0
        public void RefreshListReminders()
        {
            FileWithReminders f = new FileWithReminders();

            listReminderElement = f.readRemindersFromFile();
            if (listReminderElement.Count != 0)
            {
                showListRemainders(listReminderElement);
            }
        }
예제 #4
0
        private void Timer()
        {
            FileWithReminders      f = new FileWithReminders();
            List <ReminderElement> lr;

            DispatcherTimer timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
            {
                textBlockTimer.Text = DateTime.Now.ToString();
            }, Dispatcher);
        }
예제 #5
0
        private void ReminderTrigger()
        {
            FileWithReminders      f = new FileWithReminders();
            List <ReminderElement> lr;

            DispatcherTimer timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
            {
                lr = f.readRemindersFromFile();
                foreach (ReminderElement r in lr)
                {
                    if (DateTime.Now.ToString() == r.time)
                    {
                        ReminderWindow rw = new ReminderWindow(r.content);
                        rw.Show();
                    }
                }
            }, Dispatcher);
        }
예제 #6
0
        private void deleteReminder_Clicked(object sender, RoutedEventArgs e)
        {
            Button cmd = (Button)sender;

            if (cmd.DataContext is ReminderElement)
            {
                ReminderElement  deleteme = (ReminderElement)cmd.DataContext;
                MessageBoxResult result   = MessageBox.Show("Czy napewno chcesz usunąć przypomnienie?\nO treści: " + deleteme.content + "\nZaplanowanym na: " + deleteme.time, "Usuń", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

                if (result == MessageBoxResult.Yes)
                {
                    collectionReminders.Remove(deleteme);

                    FileWithReminders f = new FileWithReminders();
                    f.deleteReminder(deleteme.id);
                }
            }
        }