Printing colour or greyscale charts with a zoom function

3 posts, 0 answers
  1. Gustav Mulder
    Gustav Mulder avatar
    5 posts
    Member since:
    Jul 2009

    Posted 04 May 2010 Link to this post

    Requirements

    RadControls version

    2009 Q3

    .NET version

    3.5

    Visual Studio version

    2008 SP1

    programming language

    C#


    PROJECT DESCRIPTION
    The RadChart does not have a print method directly on the control.  We have created a print method that will use a zoom window to ensure that the chart will fit on a standard A4 size page.  This is customizable offcourse.  Firstly we will use the RadChart component to generate a graph, then the printer settings and page settings will be set.  We clone the RadChart and set the size to fit on the page.  If this is not done, the WYSIWYG view of chart will not fit onto the page.  Hence the zoom control.  We then give the user the option to print in color or greyscale as many of our customers have asked for this feature.  This is my first code article, so please excuse if it is not in the correct format etc.

    Here is the code:

    public static void PrintChart(RadChart chart)   
            {  
                try  
                {  
                    PrinterSettings prtSettings = new PrinterSettings();  
                    PageSettings pgSettings = new PageSettings();  
                    pgSettings.Landscape = true;  
                    pgSettings.PaperSize = new PaperSize("A4", 827, 1169);  
     
                    RadChart zoom = (RadChart)chart.Clone();  
                    zoom.Size = new Size(305, 200);  
     
                    switch (MessageBox.Show("Would you like to print the chart in colour?", "Chart Print Options", MessageBoxButtons.YesNoCancel))  
                    {  
                        case DialogResult.Yes:  
                            {  
                                zoom.Printing.PrintChart(prtSettings, pgSettings, ChartPrintOptions.ShowPrinterSelectDialog);  
                                break;  
                            }  
                        case DialogResult.No:  
                            {  
                                ChartOperations.ApplyChartSkin(zoom, types.ChartSkins.GreyScale);  
                                zoom.Printing.PrintChart(prtSettings, pgSettings, ChartPrintOptions.ShowPrinterSelectDialog);  
                                break;  
                            }  
                    }  
                }  
                catch (Exception ex)  
                {  
                    throw new Exception("(PrintChart)" + ex.Message);  
                } 
  2. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 06 May 2010 Link to this post

    Hello Gustav,

    Thank you for posting this. I am sure this will come in handy for a number of users. Your Telerik points have been updated.

    Sincerely,
    Ves
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Kiran
    Kiran avatar
    1 posts
    Member since:
    Jul 2010

    Posted 27 Jul 2010 Link to this post

    k
Back to Top