private async void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            if (comboBox1.SelectedIndex != -1)
            {
                Note note = new Note();
                note.RoomID     = int.Parse((comboBox1.SelectedItem as ComboBoxItem).Name);
                note.RoomName   = (comboBox1.SelectedItem as ComboBoxItem).Content.ToString();
                note.TextOfNote = textBox.Text;
                note.TimeOfNote = datePicker.Date.ToString("dd-MM-yyyy") + " " + timePicker.Time.ToString(@"hh\:mm");
                databaseHelper.InsertNote(note);

                TextBlock text = new TextBlock()
                {
                    FontSize = App.FontSize,
                    Text     = $"{note.TextOfNote}\nW dniu: {note.TimeOfNote.Insert(10, " o godzinie ")}\nMiejsce: {note.RoomName}\n",
                    Name     = "item" + note.ID
                };
                text.Tapped += Text_Tapped;
                if (ContentRoot.Children[0] is TextBlock)
                {
                    if ((ContentRoot.Children[0] as TextBlock).Name == "item0")
                    {
                        ContentRoot.Children.RemoveAt(0);
                    }
                }
                ContentRoot.Children.Insert(0, text);

                DateTime date = DateTime.ParseExact(note.TimeOfNote, @"dd-MM-yyyy HH\:mm", CultureInfo.InvariantCulture);
                if (date >= DateTime.Now)
                {
                    notifications.AddNotification(note);
                }
                GridAddNote.Visibility = Visibility.Collapsed;
            }
            else
            {
                MessageDialog message = new MessageDialog("Nie wybrano sali");
                await message.ShowAsync();
            }
        }
示例#2
0
 private void Show_Click(object sender, EventArgs e)
 {
     notifications.AddNotification(databaseHelper.FindNoteByID(1));
 }