예제 #1
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            List <DailyReminder> NewListOfReminders = new List <DailyReminder>();

            foreach (Grid elemet in ListOfRemindersGrids)
            {
                DailyReminder DailyReminder = new DailyReminder();
                DailyReminder.Name      = ((TextBox)LogicalTreeHelper.FindLogicalNode(elemet, textboxName)).Text;
                DailyReminder.Monday    = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[0])).IsChecked ?? false;
                DailyReminder.Tuesday   = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[1])).IsChecked ?? false;
                DailyReminder.Wednesday = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[2])).IsChecked ?? false;
                DailyReminder.Thursday  = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[3])).IsChecked ?? false;
                DailyReminder.Friday    = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[4])).IsChecked ?? false;
                DailyReminder.Saturday  = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[5])).IsChecked ?? false;
                DailyReminder.Sunday    = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[6])).IsChecked ?? false;
                ComboBoxItem comboBoxItem = (ComboBoxItem)((ComboBox)LogicalTreeHelper.FindLogicalNode(elemet, "type")).SelectedItem;
                Enum.TryParse(comboBoxItem.Content.ToString(), out ReminderType type);
                DailyReminder.type = type;
                NewListOfReminders.Add(DailyReminder);
            }
            var events = CreateEvents(NewListOfReminders, this.OldListOfReminders);

            foreach (Event actualEvent in events)
            {
                model.CommitEvent(actualEvent);
            }
            model.SaveModel();
            this.Close();
        }
예제 #2
0
 public Boolean isDateRequired(DateTime date, DailyReminder dailyReminder)
 {
     if (date.DayOfWeek == DayOfWeek.Monday && dailyReminder.Monday)
     {
         return(true);
     }
     if (date.DayOfWeek == DayOfWeek.Tuesday && dailyReminder.Tuesday)
     {
         return(true);
     }
     if (date.DayOfWeek == DayOfWeek.Wednesday && dailyReminder.Wednesday)
     {
         return(true);
     }
     if (date.DayOfWeek == DayOfWeek.Thursday && dailyReminder.Thursday)
     {
         return(true);
     }
     if (date.DayOfWeek == DayOfWeek.Friday && dailyReminder.Friday)
     {
         return(true);
     }
     if (date.DayOfWeek == DayOfWeek.Saturday && dailyReminder.Saturday)
     {
         return(true);
     }
     if (date.DayOfWeek == DayOfWeek.Sunday && dailyReminder.Sunday)
     {
         return(true);
     }
     return(false);
 }
        public Grid createElementList(DailyReminder reminder)
        {
            Grid            grid    = new Grid();
            SolidColorBrush myBrush = new SolidColorBrush(Colors.Red);

            myBrush.Opacity          = 0.1;
            grid.Background          = myBrush;
            grid.HorizontalAlignment = HorizontalAlignment.Stretch;
            grid.VerticalAlignment   = VerticalAlignment.Top;

            grid.Height = 60;

            TextBox textbox = new TextBox();

            textbox.Width = 180;
            textbox.HorizontalAlignment = HorizontalAlignment.Left;
            grid.Children.Add(textbox);
            textbox.Name = textboxName;
            textbox.Text = reminder.Name;
            Boolean[] days = new Boolean[7] {
                reminder.Monday, reminder.Tuesday, reminder.Wednesday, reminder.Thursday, reminder.Friday, reminder.Saturday, reminder.Sunday
            };
            for (int i = 0; i < 7; i++)
            {
                CheckBox checkBox = new CheckBox();
                checkBox.IsChecked           = days[i];
                checkBox.Name                = daysName[i];
                checkBox.Margin              = new Thickness((i * 100) + 220, 24, 10, 0);
                checkBox.HorizontalAlignment = HorizontalAlignment.Left;
                grid.Children.Add(checkBox);
            }

            return(grid);
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            List <DailyReminder> NewListOfReminders = new List <DailyReminder>();

            foreach (Grid elemet in ListOfRemindersGrids)
            {
                DailyReminder DailyReminder = new DailyReminder();
                DailyReminder.Name      = ((TextBox)LogicalTreeHelper.FindLogicalNode(elemet, textboxName)).Text;
                DailyReminder.Monday    = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[0])).IsChecked ?? false;
                DailyReminder.Tuesday   = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[1])).IsChecked ?? false;
                DailyReminder.Wednesday = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[2])).IsChecked ?? false;
                DailyReminder.Thursday  = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[3])).IsChecked ?? false;
                DailyReminder.Friday    = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[4])).IsChecked ?? false;
                DailyReminder.Saturday  = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[5])).IsChecked ?? false;
                DailyReminder.Sunday    = ((CheckBox)LogicalTreeHelper.FindLogicalNode(elemet, daysName[6])).IsChecked ?? false;
                NewListOfReminders.Add(DailyReminder);
            }
            var addEvents = CreateAddDailyReminderEvents(NewListOfReminders, this.OldListOfReminders);

            foreach (AddDailyReminderEvent addEvent in addEvents)
            {
                model.CommitEvent(addEvent);
            }
            model.SaveModel();
            this.Close();
        }
예제 #5
0
        public EditDailyReminderEvent(DailyReminder oldDailyReminder, DailyReminder newDailyReminder) : base()
        {
            EditDailyReminder = new EditDailyReminder();
            EditDailyReminder.oldDailyReminder = oldDailyReminder;
            EditDailyReminder.newDailyReminder = newDailyReminder;

            parameter = EditDailyReminder;
        }
예제 #6
0
        private void AddButton_Copy_Click(object sender, RoutedEventArgs e)
        {
            DailyReminder dailyReminder = new DailyReminder();

            addElements(new List <DailyReminder>()
            {
                dailyReminder
            });
        }
예제 #7
0
 public AddDailyReminderEvent(DailyReminder DailyReminder) : base()
 {
     this.DailyReminder = DailyReminder;
     parameter          = DailyReminder;
 }
예제 #8
0
 public AddDailyReminderEvent() : base()
 {
     DailyReminder = (DailyReminder)parameter;
 }
예제 #9
0
        public Grid createElementList(DailyReminder reminder)
        {
            Grid            grid    = new Grid();
            SolidColorBrush myBrush = new SolidColorBrush(Colors.Red);

            myBrush.Opacity          = 0.1;
            grid.Background          = myBrush;
            grid.HorizontalAlignment = HorizontalAlignment.Stretch;
            grid.VerticalAlignment   = VerticalAlignment.Top;

            grid.Height = 60;
            grid.MouseLeftButtonDown += Grid_MouseLeftButtonDown;
            TextBox textbox = new TextBox();

            textbox.Width = 180;
            textbox.HorizontalAlignment = HorizontalAlignment.Left;
            grid.Children.Add(textbox);
            textbox.Name = textboxName;
            textbox.Text = reminder.Name;
            Boolean[] days = new Boolean[7] {
                reminder.Monday, reminder.Tuesday, reminder.Wednesday, reminder.Thursday, reminder.Friday, reminder.Saturday, reminder.Sunday
            };
            for (int i = 0; i < 7; i++)
            {
                CheckBox checkBox = new CheckBox();
                checkBox.IsChecked           = days[i];
                checkBox.Name                = daysName[i];
                checkBox.Margin              = new Thickness((i * 100) + 220, 24, 10, 0);
                checkBox.HorizontalAlignment = HorizontalAlignment.Left;
                grid.Children.Add(checkBox);
            }

            ComboBox     comboBox     = new ComboBox();
            ComboBoxItem comboBoxItem = new ComboBoxItem();

            comboBoxItem.Content = "INTEGER";
            comboBoxItem.Style   = myResourceDictionary["ComboBoxItemStyle"] as Style;
            ComboBoxItem comboBoxItem2 = new ComboBoxItem();

            comboBoxItem2.Content   = "BOOLEAN";
            comboBoxItem2.Style     = myResourceDictionary["ComboBoxItemStyle"] as Style;
            comboBoxItem.IsSelected = true;

            comboBox.Items.Add(comboBoxItem);
            comboBox.Items.Add(comboBoxItem2);
            comboBox.Margin = new Thickness(870, 0, 10, 0);
            comboBox.HorizontalAlignment = HorizontalAlignment.Left;
            comboBox.Height = 32;
            comboBox.Style  = myResourceDictionary["ComboBoxStyle"] as Style;
            comboBox.Name   = "type";
            grid.Children.Add(comboBox);

            if (reminder.type.Equals(ReminderType.BOOLEAN))
            {
                comboBox.SelectedItem = comboBoxItem2;
            }
            else
            {
                comboBox.SelectedItem = comboBoxItem;
            }

            return(grid);
        }