Example #1
0
        private void RebuildUI(ScheduleDisplayOption option)
        {
            // unload the last control
            Control last = tblSchedule.GetControlFromPosition(1, 5);

            if (last != null)
            {
                tblSchedule.Controls.Remove(last);
                last.Dispose();
            }

            if (option == null)
            {
                return;
            }

            // load the custom control for specifics of this schedule type if necessary
            if (option.ControlType != null)
            {
                Control extra = null;
                try
                {
                    extra = option.CreateControl();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "There was a problem creating the requested schedule controls.\n\n" + ex.Message, "Create Schedule", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                extra.Dock = DockStyle.Fill;
                tblSchedule.Controls.Add(extra, 1, 5);
                ((IScheduleView)extra).CurrentSchedule = CurrentSchedule;
            }
        }
Example #2
0
        public void SetOptions(IEnumerable <ScheduleDisplayOption> options)
        {
            if (options == null)
            {
                return;
            }

            bsTypes.DataSource = options;

            IEnumerator <ScheduleDisplayOption> enumerator = options.GetEnumerator();
            ScheduleDisplayOption toSet = null;

            for (int i = 0; enumerator.MoveNext(); i++)
            {
                if (i == 0)
                {
                    toSet = enumerator.Current;
                }

                if (CurrentSchedule != null && enumerator.Current.ScheduleType == CurrentSchedule.GetType())
                {
                    toSet = enumerator.Current;
                    break;
                }
            }

            if (CurrentSchedule == null)
            {
                CreateSchedule(toSet);
            }
            else
            {
                _typeComboCanCreate  = false;
                cboType.SelectedItem = toSet;
                _typeComboCanCreate  = true;

                RebuildUI(toSet);
            }
        }
Example #3
0
        private void CreateSchedule(ScheduleDisplayOption option)
        {
            //DateTime? existingStartDate = null;
            //if (CurrentSchedule != null)
            //    existingStartDate = CurrentSchedule.StartDate;

            //try
            //{
            //    CurrentSchedule = option.CreateSchedule();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(this, "There was a problem creating the requested schedule.\n\n" + ex.Message, "Create Schedule", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return;
            //}

            //if (existingStartDate.HasValue)
            //    CurrentSchedule.StartDate = existingStartDate.Value;

            //if (!NoEndDateAllowed)
            //    CurrentSchedule.EndDate = dtpEndDate.Value;

            //RebuildUI(option);
        }
        private void RebuildUI(ScheduleDisplayOption option)
        {
            // unload the last control
            Control last = tblSchedule.GetControlFromPosition(1, 5);
            if (last != null)
            {
                tblSchedule.Controls.Remove(last);
                last.Dispose();
            }

            if (option == null)
                return;

            // load the custom control for specifics of this schedule type if necessary
            if (option.ControlType != null)
            {
                Control extra = null;
                try
                {
                    extra = option.CreateControl();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "There was a problem creating the requested schedule controls.\n\n" + ex.Message, "Create Schedule", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                extra.Dock = DockStyle.Fill;
                tblSchedule.Controls.Add(extra, 1, 5);
                ((IScheduleView)extra).CurrentSchedule = CurrentSchedule;
            }
        }
        private void CreateSchedule(ScheduleDisplayOption option)
        {
            //DateTime? existingStartDate = null;
            //if (CurrentSchedule != null)
            //    existingStartDate = CurrentSchedule.StartDate;

            //try
            //{
            //    CurrentSchedule = option.CreateSchedule();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(this, "There was a problem creating the requested schedule.\n\n" + ex.Message, "Create Schedule", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return;
            //}

            //if (existingStartDate.HasValue)
            //    CurrentSchedule.StartDate = existingStartDate.Value;

            //if (!NoEndDateAllowed)
            //    CurrentSchedule.EndDate = dtpEndDate.Value;

            //RebuildUI(option);
        }