Ejemplo n.º 1
0
        /// <summary>
        /// Let users provide their own print function for specific a control type
        /// </summary>
        /// <param name="stringType">Control type name</param>
        /// <param name="printFunction">function (must match with FormReportPrinter.ControlPrinting delegate)</param>
        public void AddPrintDelegateControl(string inControlTypeName, ControlPrinting inPrintFunction)
        {
            PrintDelegateControl curDelegate = new PrintDelegateControl();

            curDelegate.TypeName      = inControlTypeName;
            curDelegate.PrintFunction = inPrintFunction;
            myPrintDelegates.Add(curDelegate);
        }
Ejemplo n.º 2
0
        public bool PrintControl(Control inControlToPrint, int inPageAdjX, int inPageAdjY)
        {
            bool isDrawBox      = false;
            bool isVAlignCenter = false;

            string topControlType = myControlToPrint.GetType().ToString();

            if (inControlToPrint.Visible == true || topControlType.IndexOf("TabControl") > 0)
            {
                string curControlType = inControlToPrint.GetType().ToString();
                bool   controlFound   = false;
                //First check if it's a text box like control
                foreach (string tmpControlType in myTextBoxLikeControls)
                {
                    if (curControlType.IndexOf(tmpControlType) >= 0)
                    {
                        controlFound = true;
                        Single curFontHeight = FontHeight(new Font(inControlToPrint.Font.Name, inControlToPrint.Font.Size));
                        PrintText(inControlToPrint, inPageAdjX, inPageAdjY, isDrawBox, isVAlignCenter, HorizontalAlignment.Left);
                        break;
                    }
                }

                if (!(controlFound))
                {
                    for (int curIdx = myPrintDelegates.Count - 1; curIdx >= 0; curIdx--)
                    {
                        PrintDelegateControl curDelegate = (PrintDelegateControl)myPrintDelegates[curIdx];
                        if (curControlType.EndsWith(curDelegate.TypeName))
                        {
                            curDelegate.PrintFunction(inControlToPrint, inPageAdjX, inPageAdjY);
                            if (inControlToPrint.Controls.Count > 0)
                            {
                                int curControlX = inPageAdjX + inControlToPrint.Location.X;
                                int curControlY = inPageAdjY + inControlToPrint.Location.Y;
                                PrintControls(inControlToPrint, curControlX, curControlY);
                            }
                            break;
                        }
                    }
                }
                mytraceLog.Append(curControlType + "  " + inControlToPrint.Name + ":" + inControlToPrint.Text + " X=" + (inControlToPrint.Location.X + inPageAdjX).ToString() + " Y=" + (inControlToPrint.Location.Y + inPageAdjY).ToString() + " H=" + inControlToPrint.Height.ToString() + " W=" + inControlToPrint.Width + System.Environment.NewLine);
            }
            return(false);
        }
Ejemplo n.º 3
0
        public bool WriteControl(StreamWriter outBuffer, Control inControlToPrint, int inPageAdjX, int inPageAdjY)
        {
            string topControlType = myControlToPrint.GetType().ToString();

            if (inControlToPrint.Visible == true || topControlType.IndexOf("TabControl") > 0)
            {
                string curControlType = inControlToPrint.GetType().ToString();
                bool   controlFound   = false;
                //First check if it's a text box like control
                foreach (string tmpControlType in myTextBoxLikeControls)
                {
                    if (curControlType.IndexOf(tmpControlType) >= 0)
                    {
                        controlFound = true;
                        WriteText(outBuffer, inControlToPrint, inPageAdjX, inPageAdjY);
                        break;
                    }
                }

                if (!(controlFound))
                {
                    for (int curIdx = myPrintDelegates.Count - 1; curIdx >= 0; curIdx--)
                    {
                        PrintDelegateControl curDelegate = (PrintDelegateControl)myPrintDelegates[curIdx];
                        if (curControlType.EndsWith(curDelegate.TypeName))
                        {
                            curDelegate.PrintFunction(outBuffer, inControlToPrint, inPageAdjX, inPageAdjY);
                            if (inControlToPrint.Controls.Count > 0)
                            {
                                int curControlX = inPageAdjX + inControlToPrint.Location.X;
                                int curControlY = inPageAdjY + inControlToPrint.Location.Y;
                                WriteControls(outBuffer, inControlToPrint, curControlX, curControlY);
                            }
                            break;
                        }
                    }
                }
            }
            return(false);
        }
 /// <summary>
 /// Let users provide their own print function for specific a control type
 /// </summary>
 /// <param name="stringType">Control type name</param>
 /// <param name="printFunction">function (must match with FormReportPrinter.ControlPrinting delegate)</param>
 public void AddPrintDelegateControl( string inControlTypeName, ControlPrinting inPrintFunction )
 {
     PrintDelegateControl curDelegate = new PrintDelegateControl();
     curDelegate.TypeName = inControlTypeName;
     curDelegate.PrintFunction = inPrintFunction;
     myPrintDelegates.Add( curDelegate );
 }