internal override void AttachScheduler(C1Scheduler owner)
 {
     base.AttachScheduler(owner);
     _start = owner.Start;
     _end   = owner.End;
     RefreshView();
 }
Exemple #2
0
        /// <summary>
        /// Generates single page image using specified size and clipping options.
        /// </summary>
        /// <param name="printSchedule">The <see cref="C1Scheduler"/> control to print.</param>
        /// <param name="contentWidth">The content width.</param>
        /// <param name="contentHeight">The content height.</param>
        /// <param name="clipHScrollBar">True to clip horizontal scrollbar area.</param>
        /// <param name="clipVScrollBar">True to clip vertical scrollbar area.</param>
        private void GeneratePage(C1Scheduler printSchedule, double contentWidth, double contentHeight, bool clipHScrollBar, bool clipVScrollBar)
        {
            // Measure control with specified size.
            printSchedule.Measure(new Size(contentWidth, contentHeight));
            // Update content size if it was undefined according to the control's desired size.
            if (double.IsPositiveInfinity(contentWidth))
            {
                contentWidth = Math.Max(printSchedule.DesiredSize.Width, ContentSize.Width);
            }
            if (double.IsPositiveInfinity(contentHeight))
            {
                contentHeight = Math.Max(printSchedule.DesiredSize.Height, ContentSize.Height);
            }
            // Set up clip to exclude scrollbars.
            printSchedule.Clip = new RectangleGeometry(new Rect(0, 0, contentWidth, contentHeight));
            // Enlarge size, so that scrollbars go out of printable area.
            if (clipVScrollBar)
            {
                contentWidth += SystemParameters.VerticalScrollBarWidth;
            }
            if (clipHScrollBar)
            {
                contentHeight += SystemParameters.HorizontalScrollBarHeight;
            }
            // Perform layout according to the desired page size.
            Size contentSize = new Size(contentWidth, contentHeight);

            printSchedule.Measure(contentSize);
            printSchedule.Arrange(new Rect(contentSize));
            // In some C1Scheduler views not all bindings got updated during Arrange call, so force the whole visual tree update.
            printSchedule.InvalidateVisualTree();
            printSchedule.UpdateLayout();
            // Generate page image.
            _pages.Add(GetImageFromElement(printSchedule));
        }
Exemple #3
0
 internal virtual void AttachScheduler(C1Scheduler scheduler)
 {
     scheduler.AppointmentAdded   += _schedule_AppointmentAdded;
     scheduler.AppointmentDeleted += _schedule_AppointmentDeleted;
     scheduler.AppointmentChanged += _schedule_AppointmentChanged;
     scheduler.Loaded             += _schedule_Loaded;
 }
 internal override void DetachScheduler(C1Scheduler owner)
 {
     base.DetachScheduler(owner);
     if (_days != null)
     {
         _days.Dispose();
         _days = null;
     }
 }
Exemple #5
0
 /// <summary>
 /// Initializes a ne instance of the <see cref="PrintInfo"/> class.
 /// </summary>
 /// <param name="schedule"></param>
 public PrintInfo(C1Scheduler schedule)
 {
     HidePrivateAppointments = false;
     _schedule = schedule;
     PrintDocument = new C1PrintDocument();
     PrintStyles = new PrintStyleCollection();
     PrintStyles.LoadDefaults();
     PrintDocument.DocumentStarting += new EventHandler(_printDoc_DocumentStarting);
 }
Exemple #6
0
 /// <summary>
 /// Initializes a ne instance of the <see cref="PrintInfo"/> class.
 /// </summary>
 /// <param name="schedule"></param>
 public PrintInfo(C1Scheduler schedule)
 {
     HidePrivateAppointments = false;
     _schedule     = schedule;
     PrintDocument = new C1PrintDocument();
     PrintStyles   = new PrintStyleCollection();
     PrintStyles.LoadDefaults();
     PrintDocument.DocumentStarting += new EventHandler(_printDoc_DocumentStarting);
 }
Exemple #7
0
 internal virtual void DetachScheduler(C1Scheduler scheduler)
 {
     if (scheduler != null)
     {
         scheduler.Loaded             -= _schedule_Loaded;
         scheduler.AppointmentAdded   -= _schedule_AppointmentAdded;
         scheduler.AppointmentDeleted -= _schedule_AppointmentDeleted;
         scheduler.AppointmentChanged -= _schedule_AppointmentChanged;
     }
 }
        internal override void DetachScheduler(C1Scheduler owner)
        {
            this.ItemsSource = null;
            if (_table != null)
            {
                _table.RowChanged -= Table_RowChanged;
                _table             = null;
            }

            base.DetachScheduler(owner);
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_isLoaded)
            {
                _pattern = DataContext as RecurrencePattern;

                if (!System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
                {
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(Window));
                }
                else
                {
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(C1Window));
                }
                if (_parentWindow != null)
                {
                    _appointment = _parentWindow.Tag as Appointment;
                    if (_appointment != null && _appointment.ParentCollection != null)
                    {
                        Scheduler = ((C1ScheduleStorage)_appointment.ParentCollection.ParentStorage.ScheduleStorage).Scheduler;
                    }
                    if (_parentWindow.Resources.Contains("IsOld"))
                    {
                        _isOld = (bool)_parentWindow.Resources["IsOld"];
                    }
                    PART_DialogCustomButton.IsEnabled = _isOld;
                    if (_parentWindow is Window)
                    {
                        ((Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                    }
                    else
                    {
                        ((C1Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                    }
                }
                if (_parentWindow != null)
                {
                    ((INotifyPropertyChanged)_pattern).PropertyChanged += new PropertyChangedEventHandler(EditRecurrenceControl_PropertyChanged);
                    InitializeEnums();
                }
                startTime.Focus();
                endTime.DateTime        = _pattern.EndTime;
                duration.Value          = _pattern.Duration;
                patternEndDate.DateTime = _pattern.PatternEndDate;

                UpdateRecurrenceType();
                UpdateDayOfWeekMaskControls();
                UpdateRangeControls();
                _isLoaded = true;
            }
        }
Exemple #10
0
        private void OnSchedulerChanged(DependencyPropertyChangedEventArgs e)
        {
            C1Scheduler oldSch = e.OldValue as C1Scheduler;

            if (oldSch != null)
            {
                ((INotifyCollectionChanged)oldSch.ActiveReminders).CollectionChanged -= new NotifyCollectionChangedEventHandler(ShowRemindersControl_CollectionChanged);
            }
            if (Scheduler != null)
            {
                ((INotifyCollectionChanged)Scheduler.ActiveReminders).CollectionChanged += new NotifyCollectionChangedEventHandler(ShowRemindersControl_CollectionChanged);
            }
            UpdateTitle();
        }
Exemple #11
0
 private void root_Loaded(object sender, RoutedEventArgs e)
 {
     if (!_isLoaded)
     {
         if (!System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
         {
             _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(Window));
         }
         else
         {
             _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(C1Window));
         }
         if (_parentWindow != null)
         {
             if (Scheduler == null)
             {
                 Scheduler = _parentWindow.DataContext as C1Scheduler;
             }
             if (_parentWindow is Window)
             {
                 ((Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
             }
             else
             {
                 ((C1Window)_parentWindow).Closed             += new EventHandler(_parentWindow_Closed);
                 ((C1Window)_parentWindow).WindowStateChanged += new EventHandler <PropertyChangedEventArgs <C1WindowState> >(_parentWindow_WindowStateChanged);
             }
         }
         UpdateTitle();
         remList.SelectionChanged += new SelectionChangedEventHandler(remList_SelectionChanged);
         UpdateTimer(1);
         remList.Focus();
         _isLoaded = true;
     }
     ShowRemindersControl_CollectionChanged(null, null);
 }
 internal override void AttachScheduler(C1Scheduler owner)
 {
     base.AttachScheduler(owner);
     _days = new DayCollection(owner.CalendarHelper.Info);
     RefreshView();
 }
        // Use this method to set all tags at document starting.
        // Note: start and end parameters are just default values.
        // If document contains StartDate and EndDate tags,
        // actual start and end values go from the tags.
        internal void SetupTags(C1PrintDocument printDoc, AppointmentCollection appointmentCollection,
                                List <Appointment> appointmentList, DateTime start, DateTime end, bool hidePrivateAppointments, CalendarInfo calendarInfo)
        {
            Tag           tag  = null;
            TagCollection Tags = printDoc.Tags;

            if (Tags.IndexOfName("Appointment") >= 0)
            {
                tag = Tags["Appointment"];
                if (tag != null && tag.Type == typeof(Appointment) &&
                    appointmentList != null && appointmentList.Count > 0)
                {
                    tag.Value = appointmentList[0];
                }
            }
            if (Tags.IndexOfName("Appointments") >= 0)
            {
                tag = Tags["Appointments"];
                if (tag != null)
                {
                    if (tag.Type == typeof(AppointmentCollection))
                    {
                        tag.Value = appointmentCollection;
                    }
                    else if (tag.Type == typeof(IList <Appointment>))
                    {
                        if ((Context & PrintContextType.Appointment) != 0 &&
                            appointmentList != null)
                        {
                            appointmentList.Sort(AppointmentComparer.Default);
                            tag.Value = appointmentList;
                        }
                        else
                        {
                            Tag tag1 = null;
                            if (Tags.IndexOfName("StartDate") >= 0)
                            {
                                tag1 = Tags["StartDate"];
                                if (tag1 != null && tag1.Type == typeof(DateTime))
                                {
                                    start = (DateTime)tag1.Value;
                                }
                            }
                            if (Tags.IndexOfName("EndDate") >= 0)
                            {
                                tag1 = Tags["EndDate"];
                                if (tag1 != null && tag1.Type == typeof(DateTime))
                                {
                                    end = (DateTime)tag1.Value;
                                }
                            }
                            C1Scheduler scheduler = ((C1ScheduleStorage)appointmentCollection.ParentStorage.ScheduleStorage).Scheduler;
                            // get appointments for the currently selected SchedulerGroupItem if any,
                            // or all appointments otherwise.
                            AppointmentList list = appointmentCollection.GetOccurrences(
                                scheduler.SelectedGroupItem == null ? null : scheduler.SelectedGroupItem.Owner,
                                scheduler.GroupBy, start, end.AddDays(1), !hidePrivateAppointments);
                            list.Sort();
                            tag.Value = list;
                        }
                    }
                }
            }
            if (Tags.IndexOfName("CalendarInfo") >= 0)
            {
                tag = Tags["CalendarInfo"];
                if (tag != null && tag.Type == typeof(CalendarInfo))
                {
                    tag.Value = calendarInfo;
                }
            }
            if (Tags.IndexOfName("HidePrivateAppointments") >= 0)
            {
                tag = Tags["HidePrivateAppointments"];
                if (tag != null && tag.Type == typeof(bool))
                {
                    tag.Value = hidePrivateAppointments;
                }
            }
            // update string tags
            foreach (Tag t in Tags)
            {
                if (t.Type == typeof(string))
                {
                    string key = t.Name.ToLower();
                    switch (key)
                    {
                    case "start":
                        key = "startTime";
                        break;

                    case "end":
                        key = "endTime";
                        break;

                    case "showtimeas":
                        key = "showTimeAs";
                        break;

                    case "contacts":
                        key = "contactsButton";
                        break;

                    case "resources":
                        key = "resourcesButton";
                        break;

                    case "categories":
                        key = "categoriesButton";
                        break;
                    }
                    if (!string.IsNullOrEmpty(key))
                    {
                        // try find localized value from the Scheduler resources
                        string str = C1.WPF.Localization.C1Localizer.GetString("EditAppointment", key, (string)t.Value).Trim();
                        if (!string.IsNullOrEmpty(str))
                        {
                            while (str.EndsWith("."))
                            {
                                str = str.Substring(0, str.Length - 1);
                            }
                            if (!str.EndsWith(":"))
                            {
                                str += ":";
                            }
                            t.Value = str;
                        }
                    }
                }
            }
        }
Exemple #14
0
        private void EditAppointmentControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_isLoaded)
            {
                _appointment = DataContext as Appointment;

                _defaultStart    = _appointment.AllDayEvent ? TimeSpan.FromHours(8) : _appointment.Start.TimeOfDay;
                _defaultDuration = _appointment.AllDayEvent ? TimeSpan.FromMinutes(30) : _appointment.Duration;
                if (!System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
                {
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(Window));
                }
                else
                {
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(C1Window));
                }
                if (_parentWindow != null)
                {
                    Binding bnd = new Binding("Header");
                    bnd.Source = this;
                    if (_parentWindow is Window)
                    {
                        _parentWindow.SetBinding(Window.TitleProperty, bnd);
                    }
                    else
                    {
                        _parentWindow.SetBinding(C1Window.HeaderProperty, bnd);
                    }

                    if (_parentWindow is Window)
                    {
                        ((Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                    }
                    else
                    {
                        ((C1Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                    }
                }
                if (_appointment != null)
                {
                    ((System.ComponentModel.INotifyPropertyChanged)_appointment).PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(appointment_PropertyChanged);
                    if (_appointment.ParentCollection != null)
                    {
                        _scheduler = ((C1ScheduleStorage)_appointment.ParentCollection.ParentStorage.ScheduleStorage).Scheduler;

                        AppointmentBOList _os = (AppointmentBOList)_scheduler.DataStorage.AppointmentStorage.List;
                        var _list             = _os.Where(w => w.Id.Equals(_appointment.Key[0])).ToList();

                        foreach (AppointmentBusinessObject _item in _list)
                        {
                            _hidid.Text = _item.BOProperty1.ToString();
                        }

                        if (_appointment.AllDayEvent)
                        {
                            _defaultStart    = _scheduler.CalendarHelper.StartDayTime;
                            _defaultDuration = _scheduler.CalendarHelper.Info.TimeScale;
                        }
                    }
                    UpdateWindowHeader();
                    UpdateRecurrenceState();
                    UpdateCollections();
                    UpdateEndCalendar();
                    if (_appointment.AllDayEvent)
                    {
                        startCalendar.EditMode = endCalendar.EditMode = C1DateTimePickerEditMode.Date;
                    }
                    else
                    {
                        startCalendar.EditMode = endCalendar.EditMode = C1DateTimePickerEditMode.DateTime;
                    }
                    UpdateEditingControls();
                }
                if (_parentWindow != null && _appointment != null)
                {
                    _isLoaded = true;
                }
            }
            subject.Focus();
        }
        private void EditAppointmentControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_isLoaded)
            {
                _appointment = DataContext as Appointment;
                _defaultStart = _appointment.AllDayEvent ? TimeSpan.FromHours(8) : _appointment.Start.TimeOfDay;
                _defaultDuration = _appointment.AllDayEvent ? TimeSpan.FromMinutes(30) : _appointment.Duration;
                if (!System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
                {
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(Window));
                }
                else
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(C1Window));
                if (_parentWindow != null)
                {
                    Binding bnd = new Binding("Header");
                    bnd.Source = this;
                    if (_parentWindow is Window)
                    {
                        _parentWindow.SetBinding(Window.TitleProperty, bnd);
                    }
                    else
                    {
                        _parentWindow.SetBinding(C1Window.HeaderProperty, bnd);
                    }

                    if (_parentWindow is Window)
                    {
                        ((Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                    }
                    else
                        ((C1Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                }
                if (_appointment != null)
                {
                    ((System.ComponentModel.INotifyPropertyChanged)_appointment).PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(appointment_PropertyChanged);
                    if (_appointment.ParentCollection != null)
                    {
                        _scheduler = _appointment.ParentCollection.ParentStorage.ScheduleStorage.Scheduler;
                        if (_appointment.AllDayEvent)
                        {
                            _defaultStart = _scheduler.CalendarHelper.StartDayTime;
                            _defaultDuration = _scheduler.CalendarHelper.Info.TimeScale;
                        }
                    }
                    UpdateWindowHeader();
                    UpdateRecurrenceState();
                    UpdateCollections();
                    UpdateEndCalendar();
                    if (_appointment.AllDayEvent)
                    {
                        startCalendar.EditMode = endCalendar.EditMode = C1DateTimePickerEditMode.Date;
                    }
                    else
                    {
                        startCalendar.EditMode = endCalendar.EditMode = C1DateTimePickerEditMode.DateTime;
                    }
                    UpdateEditingControls();
                }
                if (_parentWindow != null && _appointment != null)
                {
                    _isLoaded = true;
                }
            }
            subject.Focus();
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_isLoaded)
            {
                _pattern = DataContext as RecurrencePattern;

                if (!System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
                {
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(Window));
                }
                else
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(C1Window));
                if (_parentWindow != null)
                {
                    _appointment = _parentWindow.Tag as Appointment;
                    if (_appointment != null && _appointment.ParentCollection != null)
                    {
                        Scheduler = _appointment.ParentCollection.ParentStorage.ScheduleStorage.Scheduler;
                    }
                    if (_parentWindow.Resources.Contains("IsOld"))
                    {
                        _isOld = (bool)_parentWindow.Resources["IsOld"];
                    }
                    PART_DialogCustomButton.IsEnabled = _isOld;
                    if (_parentWindow is Window)
                    {
                        ((Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                    }
                    else
                        ((C1Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                }
                if (_parentWindow != null)
                {
                    ((INotifyPropertyChanged)_pattern).PropertyChanged += new PropertyChangedEventHandler(EditRecurrenceControl_PropertyChanged);
                    InitializeEnums();
                }
                startTime.Focus();
                endTime.DateTime = _pattern.EndTime;
                duration.Value = _pattern.Duration;
                patternEndDate.DateTime = _pattern.PatternEndDate;

                UpdateRecurrenceType();
                UpdateDayOfWeekMaskControls();
                UpdateRangeControls();
                _isLoaded = true;
            }
        }
 private void root_Loaded(object sender, RoutedEventArgs e)
 {
     if (!_isLoaded)
     {
         if (!System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
         {
             _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(Window));
         }
         else
             _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(C1Window));
         if (_parentWindow != null)
         {
             if (Scheduler == null)
             {
                 Scheduler = _parentWindow.DataContext as C1Scheduler;
             }
             if (_parentWindow is Window)
             {
                 ((Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
             }
             else
             {
                 ((C1Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                 ((C1Window)_parentWindow).WindowStateChanged += new EventHandler<PropertyChangedEventArgs<C1WindowState>>(_parentWindow_WindowStateChanged);
             }
         }
         UpdateTitle();
         remList.SelectionChanged += new SelectionChangedEventHandler(remList_SelectionChanged);
         UpdateTimer(1);
         remList.Focus();
         _isLoaded = true;
     }
     ShowRemindersControl_CollectionChanged(null, null);
 }
Exemple #18
0
        List <FrameworkElement> _pages = new List <FrameworkElement>(); // list of pages to print
        #endregion

        #region ** ctor
        /// <summary>
        /// Initializes a new instance of the <see cref="C1SchedulerPaginator"/> class.
        /// </summary>
        /// <param name="schedule">The <see cref="C1Scheduler"/> control to print.</param>
        /// <param name="printSchedule">The hidden <see cref="C1Scheduler"/> control included into visual tree which can be used to create print pages.</param>
        /// <param name="pageSize">The page size to use.</param>
        /// <param name="margin">The page margins.</param>
        /// <param name="resolutionX">The horizontal printer resolution.</param>
        /// <param name="resolutionY">The vertical printer resolution.</param>
        public C1SchedulerPaginator(C1Scheduler schedule, C1Scheduler printSchedule, Size pageSize, Thickness margin, int resolutionX, int resolutionY)
        {
            PrintResolutionX = resolutionX;
            PrintResolutionY = resolutionY;
            // calculate page parameters
            PageSize        = pageSize;
            ContentSize     = new Size(PageSize.Width - margin.Left - margin.Right, PageSize.Height - margin.Top - margin.Bottom);
            ContentLocation = new Point(margin.Left, margin.Top);

            // copy required settings from the C1Scheduler control into the hidden instance used for printing
            SetupPrintScheduler(schedule, printSchedule);

            // generate print pages for current view
            switch (printSchedule.ViewType)
            {
            case ViewType.Month:
            case ViewType.Custom:
                // print current view as a single page, fit in page
                // Notes:
                // - if you use grouping, you might consider printing one group on page;
                // - if you need to print arbitrary date range, you should split on pages
                //   by setting printSchedule.VisibleDates property and then using printSchedule.IncrementStartTimeLarge() for moving further;
                // - if every day has a lot of appointments, you can split on pages to only print 2 or 3 weeks on page.
                GeneratePage(printSchedule, ContentSize.Width, ContentSize.Height, false, true);     // only clip vertical scrollbar
                break;

            case ViewType.TimeLine:
                // print current view with paging, day-by-day
                DateTime endDate = schedule.VisibleDates[schedule.VisibleDates.Count - 1];
                VisualIntervalCollection dayIntervals = printSchedule.VisibleGroupItems[0].VisualIntervals;
                if (dayIntervals.Count > 16)
                {
                    // time line might not fit in page, so split 1 day to some pages
                    DateTime start  = dayIntervals[0].StartTime;
                    DateTime end    = dayIntervals[dayIntervals.Count - 1].EndTime;
                    DateTime middle = start.Add(TimeSpan.FromMilliseconds((end - start).TotalMilliseconds / 2));
                    while (printSchedule.VisibleDates[0] <= endDate)
                    {
                        // first half of day
                        printSchedule.BeginUpdate();
                        printSchedule.CalendarHelper.StartDayTime = start.TimeOfDay;
                        printSchedule.CalendarHelper.EndDayTime   = middle.TimeOfDay;
                        printSchedule.EndUpdate();
                        GeneratePage(printSchedule, double.PositiveInfinity, ContentSize.Height, true, !string.IsNullOrEmpty(printSchedule.GroupBy));     // always clip horizontal scrollbar, clip vertical scrollbar if grouping is enabled
                        // second half of day
                        printSchedule.BeginUpdate();
                        printSchedule.CalendarHelper.StartDayTime = middle.TimeOfDay;
                        printSchedule.CalendarHelper.EndDayTime   = end.TimeOfDay;
                        printSchedule.EndUpdate();
                        GeneratePage(printSchedule, double.PositiveInfinity, ContentSize.Height, true, !string.IsNullOrEmpty(printSchedule.GroupBy));     // always clip horizontal scrollbar, clip vertical scrollbar if grouping is enabled
                        if (printSchedule.VisibleDates[0] == printSchedule.End.Date)
                        {
                            // if we reached C1Scheduler.End date, IncrementStartTimeLarge won't change VisibleDates.
                            // So break here to avoid endless loop
                            break;
                        }
                        // move to next day
                        printSchedule.IncrementStartTimeLarge();
                    }
                }
                else
                {
                    // 1 day - 1 page
                    while (printSchedule.VisibleDates[0] <= endDate)
                    {
                        GeneratePage(printSchedule, double.PositiveInfinity, ContentSize.Height, true, !string.IsNullOrEmpty(printSchedule.GroupBy));     // always clip horizontal scrollbar, clip vertical scrollbar if grouping is enabled
                        if (printSchedule.VisibleDates[0] == printSchedule.End.Date)
                        {
                            // if we reached C1Scheduler.End date, IncrementStartTimeLarge won't change VisibleDates.
                            // So break here to avoid endless loop
                            break;
                        }
                        // move to next day
                        printSchedule.IncrementStartTimeLarge();
                    }
                }
                break;

            default:
                // Day, Working week, Week views.
                // If ShowWorkTimeOnly is true, in most cases the whole view will fit into page well enough, so don't break on pages.
                // Print current view with scaling for page height
                GeneratePage(printSchedule, ContentSize.Width, double.PositiveInfinity, false, true);     // clip vertical scrollbar
                break;
            }

            // done; release resources
            printSchedule.Clip = null;
            printSchedule.BeginUpdate();
            printSchedule.DataStorage.AppointmentStorage.Appointments.Clear();
            printSchedule.EndUpdate();
        }
Exemple #19
0
        /// <summary>
        /// Copies settings from the source to target control.
        /// </summary>
        /// <param name="source">The <see cref="C1Scheduler"/> control to copy settings from.</param>
        /// <param name="target">The hidden <see cref="C1Scheduler"/> control used for printing.</param>
        private void SetupPrintScheduler(C1Scheduler source, C1Scheduler target)
        {
            // call BeginUpdate to supress events and layout during initialization
            target.BeginUpdate();
            // copy theme information
            target.Theme = source.Theme;
            // you can use customized theme with simpler appearance and better print contrast
            // To do so:
            // - copy default xaml into custom ResourceDictionary;
            // - edit xaml according your needs (for example, use the same appearance for all time slots, more contrast colors, etc.);
            // - set target.Theme to your ResourceDictionary.

            // copy start and end dates
            target.Start = source.Start;
            target.End   = source.End;

            // copy view information
            target.Style            = source.Style;
            target.ViewType         = source.ViewType;
            target.CurrentTimeBrush = null;
            // copy time scale information
            target.VisualIntervalScale = source.VisualIntervalScale;
            if (source.VisualIntervalScale.TotalMinutes < 20 && source.ViewType != ViewType.TimeLine)
            {
                // limit number of intervals in day view
                target.VisualIntervalScale = TimeSpan.FromMinutes(20);
            }
            // copy calendar parameters
            target.CalendarHelper.WeekStart    = source.CalendarHelper.WeekStart;
            target.CalendarHelper.StartDayTime = source.CalendarHelper.StartDayTime;
            target.CalendarHelper.EndDayTime   = source.CalendarHelper.EndDayTime;
            // if you use custom working days, holidays or weekend exceptions, copy them as well

            // grouping
            target.GroupBy       = source.GroupBy;
            target.GroupPageSize = source.GroupPageSize;

            // hide free time
            target.ShowWorkTimeOnly = true;

            // copied the most of settings, call EndUpdate to allow layout
            target.EndUpdate();

            // load appointments
            using (MemoryStream stream = new MemoryStream())
            {
                // exporty appointments from the displayed Scheduler
                source.DataStorage.Export(stream, FileFormatEnum.XML);
                stream.Position = 0;
                // import appointments into hidden Scheduler
                target.DataStorage.Import(stream, FileFormatEnum.XML);
            }
            if (!string.IsNullOrEmpty(target.GroupBy))
            {
                // copy visible groups
                target.VisibleGroupItems.BeginUpdate();
                target.VisibleGroupItems.Clear();
                foreach (SchedulerGroupItem group in source.VisibleGroupItems)
                {
                    target.VisibleGroupItems.Add(target.GroupItems[source.GroupItems.IndexOf(group)]);
                }
                target.VisibleGroupItems.EndUpdate();
            }
            // set the same visible dates
            target.VisibleDates.BeginUpdate();
            target.VisibleDates.Clear();
            if (target.ViewType == ViewType.TimeLine)
            {
                // only single day fits into page, so print day-by-day
                target.VisibleDates.Add(source.VisibleDates[0]);
            }
            else
            {
                foreach (DateTime day in source.VisibleDates)
                {
                    target.VisibleDates.Add(day);
                }
            }
            target.VisibleDates.EndUpdate();
        }