fyiReporting.RdlDesign.RdlDesigner.menuFilePrint_Click C# (CSharp) Method

menuFilePrint_Click() private method

private menuFilePrint_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void menuFilePrint_Click(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;
            if (mc == null)
            {
                return;
            }
            if (printChild != null)			// already printing
            {
                MessageBox.Show(Strings.RdlDesigner_Show_PrintOneFile, Strings.RdlDesigner_Show_RDLDesign);
                return;
            }

            printChild = mc;

            PrintDocument pd = new PrintDocument();
            pd.DocumentName = mc.SourceFile.LocalPath;
            pd.PrinterSettings.FromPage = 1;
            pd.PrinterSettings.ToPage = mc.PageCount;
            pd.PrinterSettings.MaximumPage = mc.PageCount;
            pd.PrinterSettings.MinimumPage = 1;
            pd.DefaultPageSettings.Landscape = mc.PageWidth > mc.PageHeight ? true : false;

            // Set the paper size.
            if (mc.SourceRdl != null)
            {
                System.Xml.XmlDocument docxml = new System.Xml.XmlDocument();
                docxml.LoadXml(mc.SourceRdl);

                float height = 11;
                float width = 8.5f;
                XmlNodeList heightList = docxml.GetElementsByTagName("PageHeight");
                for (int i = 0; i < heightList.Count; i++)
                {
                  height = Conversions.MeasurementTypeAsHundrethsOfAnInch(heightList[i].InnerText);
                }

                XmlNodeList widthList = docxml.GetElementsByTagName("PageWidth");
                for (int i = 0; i < widthList.Count; i++)
                {
                    width = Conversions.MeasurementTypeAsHundrethsOfAnInch(widthList[i].InnerText);
                }

                pd.DefaultPageSettings.PaperSize = new PaperSize("Custom", (int)width, (int)height);
            }
            using (PrintDialog dlg = new PrintDialog())
            {
                dlg.Document = pd;
                dlg.AllowSelection = true;
                dlg.AllowSomePages = true;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        if (pd.PrinterSettings.PrintRange == PrintRange.Selection)
                        {
                            pd.PrinterSettings.FromPage = mc.PageCurrent;
                        }
                        mc.Print(pd);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Strings.RdlDesigner_Show_PrintError + ex.Message, Strings.RdlDesigner_Show_RDLDesign);
                    }
                }
                printChild = null;
            }
        }
RdlDesigner