Exemplo n.º 1
0
        private void EditSchedulePanel_Load(object sender, EventArgs e)
        {
            _inPanelLoad = true;

            try
            {
                MainForm.SetMenuMode(MainMenuMode.SaveCancel);

                if (_schedule.ScheduleType == ScheduleType.Recording)
                {
                    SetGeneralGroupBoxHeight(_standardGeneralHeight);
                }
                else
                {
                    SetGeneralGroupBoxHeight(_standardGeneralHeight - _generalHeightNoCommandsDelta);
                }

                _model = new EditScheduleModel();
                _controller = new EditScheduleController(_model);
                _controller.Initialize(_schedule, _forceManualSchedule, "All Channels", "Default");

                if (_schedule.ScheduleType == ScheduleType.Recording)
                {
                    _formatsBindingSource.DataSource = _model.RecordingFormats;
                    _formatsBindingSource.ResetBindings(false);
                    _fileFormatComboBox.SelectedValue = _schedule.RecordingFileFormatId.HasValue ? _schedule.RecordingFileFormatId.Value : Guid.Empty;
                }

                _titleRuleTypeComboBox.SelectedIndex = TitleRuleTypeIndex.Equals;
                _subTitleRuleTypeComboBox.SelectedIndex = TitleRuleTypeIndex.Equals;
                _episodeNumberRuleTypeComboBox.SelectedIndex = TitleRuleTypeIndex.Equals;

                _manualScheduleGroupBox.Visible = _model.IsManual;
                _rulesTableLayoutPanel.Visible = !_model.IsManual;

                _schedulePriorityControl.SchedulePriority = _model.Schedule.SchedulePriority;

                _preRecDateTimePicker.MaxDate = _timePickerReferenceDate.AddSeconds(_allowedTimeFrame);
                _preRecDateTimePicker.MinDate = _timePickerReferenceDate;
                _postRecDateTimePicker.MaxDate = _timePickerReferenceDate.AddSeconds(_allowedTimeFrame);
                _postRecDateTimePicker.MinDate = _timePickerReferenceDate;

                if (_model.Schedule.PreRecordSeconds.HasValue)
                {
                    _preRecDateTimePicker.Value = _preRecDateTimePicker.MinDate.AddSeconds(Math.Min(_model.Schedule.PreRecordSeconds.Value, _allowedTimeFrame));
                    _preRecDateTimePicker.Checked = true;
                }
                else
                {
                    Utility.SetDateTimePickerValue(MainForm, _preRecDateTimePicker, ConfigurationKey.Scheduler.PreRecordsSeconds);
                    _preRecDateTimePicker.Checked = false;
                }

                if (_model.Schedule.PostRecordSeconds.HasValue)
                {
                    _postRecDateTimePicker.Value = _preRecDateTimePicker.MinDate.AddSeconds(Math.Min(_model.Schedule.PostRecordSeconds.Value, _allowedTimeFrame));
                    _postRecDateTimePicker.Checked = true;
                }
                else
                {
                    Utility.SetDateTimePickerValue(MainForm, _postRecDateTimePicker, ConfigurationKey.Scheduler.PostRecordsSeconds);
                    _postRecDateTimePicker.Checked = false;
                }

                UpdateKeepMethodControl();
                UpdateProcesingCommandsControl();

                if (_model.IsManual)
                {
                    _manualChannelGroupComboBox.DataSource = _model.ChannelGroups;
                    _manualChannelGroupComboBox.DisplayMember = "GroupName";
                    _manualChannelGroupComboBox.ValueMember = "ChannelGroupId";

                    _manualDatePicker.Value = DateTime.Today;
                    _manualTimePicker.Value = DateTime.Now;
                    _manualDurationDateTimePicker.Value = DateTime.Today.AddHours(1);
                }
                else
                {
                    _channelGroupCombobox.DataSource = _model.ChannelGroups;
                    _channelGroupCombobox.DisplayMember = "GroupName";
                    _channelGroupCombobox.ValueMember = "ChannelGroupId";

                    _aroundDateTimePicker.Value = DateTime.Today.AddHours(12);

                    foreach (string category in _model.Categories)
                    {
                        _categoryComboBox.Items.Add(category);
                    }

                    _betweenFromDateTimePicker.Value = DateTime.Today;
                    _betweenToDateTimePicker.Value = DateTime.Today.Add(new TimeSpan(23, 59, 0));
                }

                ShowRulesInUI();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            _inPanelLoad = false;

            string name = _model.Schedule.Name;
            _upcomingProgramsControl.ScheduleType = _model.Schedule.ScheduleType;
            RefreshUpcoming();
            _nameTextBox.Text = name;
        }
 public EditScheduleController(EditScheduleModel model)
 {
     _model = model;
 }