This is a migrated thread and some comments may be shown as answers.

Printing with paging support

6 Answers 89 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
alang
Top achievements
Rank 1
alang asked on 16 Jan 2018, 08:18 AM

Hello Telerik team,

I have written the following "Feature Request": ScheduleView: Provide methods to print its content with full paging Support.

At the moment I'm trying to print the "WeekView" (seven days) on two pages. On the first page the first four days and on the second the rest. To realize this I use a hidden RadScheduleView (name: printScheduleView). My plan is to create an image for each page. Currently I am using the PrintVisual method, but later I would like to use the PrintDocument method (public abstract DocumentPage GetPage(int pageNumber)).

Before the PrintVisual method is called, printScheduleView must be rendered correctly, which currently only works with a timer. printScheduleView.UpdateLayout method could not solve the problem. Even a dirty DoEvents (UIElement.UpdateLayout Method) didn't solve the problem completely.

The sample project on my OneDrive account shows the bad behavior.

Can you please help me find a good solution?

Regards,
Marco

6 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 18 Jan 2018, 04:58 PM
Hello Marco,

Thanks for the extensive information. I will check it a bit later and will get back in this forum tomorrow.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Martin Ivanov
Telerik team
answered on 19 Jan 2018, 02:26 PM
Hello Marco,

The RadScheduleView control needs some time to get rendered. This is why when you call PrintVisual() method, the picture is wrong. The rendering of the control is not yet completed and only some of its parts are rendered as expected. To resolve this, you can move the Measure(), Arrange() and UpdateLayout() methods after all settings of the scheduleview and then call the PrintVisual() method in a Dispatcher action with a low priority. This will delay the opening of the file dialog that freezes the UI and gives the control some additional time to be rendered. Here is an example in code:
private void btnPrint_Click(object sender, RoutedEventArgs e)
{
    _printDlg = new PrintDialog();
    if (_printDlg.ShowDialog() == true)
    {
        PrintCapabilities capabilities = _printDlg.PrintQueue.GetPrintCapabilities(_printDlg.PrintTicket);
        double printWidht = capabilities.PageImageableArea.ExtentWidth - 50;
        double printHeight = capabilities.PageImageableArea.ExtentHeight - 50;
        Size size = new Size(printWidht, printHeight);
         
        this.printScheduleView.MinTimeRulerExtent = printHeight - 70;
        this.printScheduleView.MaxTimeRulerExtent = printHeight - 70;
        this.printScheduleView.ViewDefinitions[0].VisibleDays = 4;
        MainViewModel viewModel = (MainViewModel)this.DataContext;
        this.printScheduleView.AppointmentsSource = new List<Appointment>(viewModel.Appointments);
        this.printScheduleView.Measure(size);
        this.printScheduleView.Arrange(new Rect(size));               
        this.printScheduleView.UpdateLayout();
         
        Dispatcher.BeginInvoke(new Action(() => {
            _printDlg.PrintVisual(this.GetImageFromElement(this.printScheduleView), "Test Print");
        }), (DispatcherPriority)5);
    }
}
As for the feature request, we will review it and update its status according to the decision taken.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
alang
Top achievements
Rank 1
answered on 22 Jan 2018, 10:28 AM

Hello Martin,

I have adapted my sample project on my OneDrive with your solution. Unfortunately, even with BeginInvoke the control doesn't get enough time for rendering. The described problem is visible in the PDF files on my OneDrive, [ViewDefinitionName]First.pdf for the first and [ViewDefinitionName]Second.pdf for the second attempt.

Regards,
Marco

0
Kalin
Telerik team
answered on 25 Jan 2018, 10:12 AM
Hello Marco,

I check the project and I'm looking for a solution - will get back you as soon as possible.

Thanks for understanding.

Regards,
Kalin
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
alang
Top achievements
Rank 1
answered on 30 Jan 2018, 04:24 PM
My start post is now two weeks ago. Have you found a solution?
0
Accepted
Kalin
Telerik team
answered on 31 Jan 2018, 04:14 PM
Hello Marco,

Sorry for the delay. The reason for the incorrect images is the transition animation played right after the AppointmentsSource is changed and the ActiveViewDefinition is changed. Removing the transition should resolve this, however with the current implementation the only to do so would be to modify the ControlTemplate - you would need to find the TransitionControl with x:Name "PART_TransitionControl" and set the Transition property to null.

I have modified the project in order to demonstrate the exact approach - hope this will work for you.

Regards,
Kalin
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ScheduleView
Asked by
alang
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
alang
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or