Exemplo n.º 1
0
        private void Handler()
        {
            bool dayChecked = false;
            bool timePicked = false;

            //Loop through class times
            for (int i = 0; i < spClassTimesViewer.Children.Count; i++)
            {
                ClassTime time = spClassTimesViewer.Children[i] as ClassTime;

                WrapPanel panel    = time.FindName("wpDays") as WrapPanel;
                Grid      timeGrid = time.FindName("TimeGrid") as Grid;

                //Loop through checkboxes
                for (int j = 0; j < panel.Children.Count; j++)
                {
                    if (panel.Children[i] is CheckBox)
                    {
                        CheckBox check = panel.Children[j] as CheckBox;
                        if (check.IsChecked == true)
                        {
                            dayChecked = true;
                        }
                    }
                }

                //Loop through time pickers
                for (int j = 0; j < timeGrid.Children.Count; j++)
                {
                    if (timeGrid.Children[j] is TimePicker)
                    {
                        TimePicker picker = timeGrid.Children[j] as TimePicker;
                        timePicked = picker.SelectedTime != null;
                    }
                }
            }

            if (dayChecked && timePicked && txtClassName.Text != "")
            {
                btnSaveClass.IsEnabled = true;
            }
            else
            {
                btnSaveClass.IsEnabled = false;
            }
        }
Exemplo n.º 2
0
        public EditClassWindow(Class _class)
        {
            InitializeComponent();

            this._class       = _class;
            txtClassName.Text = _class.ClassName;

            for (int i = 0; i < _class.ClassTimes.Length; i++)
            {
                if (_class.ClassTimes[i][0] == null || _class.ClassTimes[i][1] == null)
                {
                    continue;
                }
                ClassTime time = ClassTimeExist(_class.ClassTimes[i][0]) ?? new ClassTime();

                time.tpStartTime.SelectedTime = _class.ClassTimes[i][0];
                time.tpEndTime.SelectedTime   = _class.ClassTimes[i][1];

                //Loop through class times
                WrapPanel wrap = time.FindName("wpDays") as WrapPanel;
                foreach (CheckBox check in wrap.Children)
                {
                    if (check.Content.ToString() == ((DayOfWeek)i).ToString())
                    {
                        check.IsChecked = true;
                    }
                }

                time.ClassTimeChanged += Handler;
                _classTimes.Add(time);
                if (!spClassTimesViewer.Children.Contains(time))
                {
                    spClassTimesViewer.Children.Add(time);
                }
            }
        }