Пример #1
0
        private void mnuItmLoad_Click(object sender, System.EventArgs e)
        {
            MiCo.MiForms.LoadedForm xloadedform;


            openFileDialog1.Filter = "Mi-Forms Templates (*.mft)|*.mft";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                xloadedform = miFormsComponent1.LoadFormFromFile(openFileDialog1.FileName);

                if (xloadedform == null)
                {
                    return;
                }

                // set the size of the component appropriately to display the page at 72 dpi
                MiCo.MiForms.FormPage xpage = (MiCo.MiForms.FormPage)xloadedform.Form.Pages[0];
                SetCanvasSize(xpage.Size.Width / 2.54, xpage.Size.Height / 2.54);

                miFormsComponent1.ActiveForm = xloadedform;

                enableToolbarButtons();
            }
        }
Пример #2
0
        /// <summary>
        /// Standard QueryPageSettings event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void printDocument_QueryPageSettings(object sender, System.Drawing.Printing.QueryPageSettingsEventArgs e)
        {
            MiCo.MiForms.LoadedForm xlform = miFormsComponent1.ActiveForm;

            // call SignalPagePrint in the component to see if the client's script
            // code wants to cancel the print...
            while ((!miFormsComponent1.SignalPagePrint(xlform, _nPageToPrint, MiCo.MiForms.RenderType.FieldValues) && _nPageToPrint <= xlform.Form.Pages.Count))
            {
                _nPageToPrint++;
            }

            bool bTooBig = false;

            if (_nPageToPrint > xlform.Form.Pages.Count)
            {
                bTooBig = true;
            }

            if (!bTooBig)
            {
                _bPagesPrinted = true;
                MiCo.MiForms.FormPage xFormPage = (MiCo.MiForms.FormPage)xlform.Form.Pages[_nPageToPrint - 1];
                if (xFormPage.Size.Width > xFormPage.Size.Height)
                {
                    e.PageSettings.Landscape = true;
                }
                else
                {
                    e.PageSettings.Landscape = false;
                }
            }
            else
            {
                if (!_bPagesPrinted)
                {
                    e.Cancel = true;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Standard PrintPage event handler
        /// </summary>
        private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            System.Drawing.Graphics xGraphics;
            xGraphics = e.Graphics;

            System.Drawing.Bitmap xBitmap;

            // create a render engine that we'll use to render the given page
            MiCo.MiForms.RenderEngine xRender = new MiCo.MiForms.RenderEngine();

            if (_bOverrideRenderType)
            {
                // this is set via the script call RequestPrint();
                xRender.Type         = _xRenderType;
                _bOverrideRenderType = false;
            }
            else
            {
                // here you could use a user preference if you wanted; we just hard-code
                // it to render field values
                xRender.Type = MiCo.MiForms.RenderType.FieldValues;
            }

            MiCo.MiForms.LoadedForm xlform    = miFormsComponent1.ActiveForm;
            MiCo.MiForms.FormPage   xFormPage = (MiCo.MiForms.FormPage)xlform.Form.Pages[_nPageToPrint - 1];
            double nMaxResolution             = 0;
            double nResolution = 0;

            foreach (MiCo.MiForms.BackgroundImage xBackground in xFormPage.BackgroundImages)
            {
                if (xBackground.Resolution > nMaxResolution)
                {
                    nMaxResolution = xBackground.Resolution;
                }
            }
            nMaxResolution *= 2.54;
            if (xGraphics.DpiX < nMaxResolution)
            {
                nResolution = xGraphics.DpiX;
            }
            else
            {
                nResolution = nMaxResolution;
            }
            nResolution /= 2.54;
            xBitmap      = xRender.RenderPage(xFormPage, nResolution);
            xGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            xGraphics.DrawImage(xBitmap, 0, 0);

            if (_bPrintPreview)
            {
                if (_nPageToPrint < xlform.Form.Pages.Count)
                {
                    _nPageToPrint++;
                    e.HasMorePages = true;
                }
                else
                {
                    e.HasMorePages = false;
                    _nPageToPrint  = 1;
                }
            }
            else if (_nPageToPrint < _printDoc.PrinterSettings.ToPage)
            {
                _nPageToPrint++;
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
                _nPageToPrint  = 1;
            }
        }