示例#1
0
        private void FormTPsign_Load(object sender, System.EventArgs e)
        {
            //this window never comes up for new TP.  Always saved ahead of time.
            if (!Security.IsAuthorized(Permissions.TreatPlanSign, TPcur.DateTP))
            {
                butOK.Enabled = false;
                signatureBoxWrapper.Enabled = false;
            }
            LayoutToolBar();
            ToolBarMain.Buttons["FullPage"].Pushed = true;
            previewContr.Location = new Point(0, ToolBarMain.Bottom);
            previewContr.Size     = new Size(ClientRectangle.Width, ClientRectangle.Height - ToolBarMain.Height - panelSig.Height);
            if (Document.DefaultPageSettings.PrintableArea.Height == 0)
            {
                Document.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100);
            }
            SetSize();
            previewContr.Document = Document;
            ToolBarMain.Buttons["PageNum"].Text = (previewContr.StartPage + 1).ToString()
                                                  + " / " + TotalPages.ToString();
            proctpList = ProcTPs.RefreshForTP(TPcur.TreatPlanNum);
            signatureBoxWrapper.SignatureMode = UI.SignatureBoxWrapper.SigMode.TreatPlan;
            string keyData = TreatPlans.GetKeyDataForSignatureHash(TPcur, proctpList);

            signatureBoxWrapper.FillSignature(TPcur.SigIsTopaz, keyData, TPcur.Signature);
        }
示例#2
0
        public static void CreatePdfPage(Sheet sheet, PdfPage page)
        {
            page.Width  = p(sheet.Width);         //XUnit.FromInch((double)sheet.Width/100);  //new XUnit((double)sheet.Width/100,XGraphicsUnit.Inch);
            page.Height = p(sheet.Height);        //new XUnit((double)sheet.Height/100,XGraphicsUnit.Inch);
            if (sheet.IsLandscape)
            {
                page.Orientation = PageOrientation.Landscape;
            }
            XGraphics g = XGraphics.FromPdfPage(page);

            g.SmoothingMode = XSmoothingMode.HighQuality;
            //g.PageUnit=XGraphicsUnit. //wish they had pixel
            //XTextFormatter tf = new XTextFormatter(g);//needed for text wrap
            //tf.Alignment=XParagraphAlignment.Left;
            //pd.DefaultPageSettings.Landscape=
            //already done?:SheetUtil.CalculateHeights(sheet,g);//this is here because of easy access to g.
            XFont      xfont;
            XFontStyle xfontstyle;

            //first, draw images--------------------------------------------------------------------------------------
            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.Image)
                {
                    continue;
                }
                string filePathAndName = ODFileUtils.CombinePaths(SheetUtil.GetImagePath(), field.FieldName);
                Bitmap bitmapOriginal  = null;
                if (field.FieldName == "Patient Info.gif")
                {
                    bitmapOriginal = Properties.Resources.Patient_Info;
                }
                else if (File.Exists(filePathAndName))
                {
                    bitmapOriginal = new Bitmap(filePathAndName);
                }
                else
                {
                    continue;
                }
                Bitmap bitmapResampled = (Bitmap)bitmapOriginal.Clone();
                if (bitmapOriginal.HorizontalResolution != 96 || bitmapOriginal.VerticalResolution != 96)            //to avoid slowdown for other pdfs
                //The scaling on the XGraphics.DrawImage() function causes unreadable output unless the image is in 96 DPI native format.
                //We use GDI here first to convert the image to the correct size and DPI, then pass the second image to XGraphics.DrawImage().
                {
                    bitmapResampled.Dispose();
                    bitmapResampled = null;
                    bitmapResampled = new Bitmap(field.Width, field.Height);
                    Graphics gr = Graphics.FromImage(bitmapResampled);
                    gr.DrawImage(bitmapOriginal, 0, 0, field.Width, field.Height);
                    gr.Dispose();
                }
                g.DrawImage(bitmapResampled, p(field.XPos), p(field.YPos), p(field.Width), p(field.Height));
                bitmapResampled.Dispose();
                bitmapResampled = null;
                bitmapOriginal.Dispose();
                bitmapOriginal = null;
            }
            //then, drawings--------------------------------------------------------------------------------------------
            XPen pen = new XPen(XColors.Black, p(2));

            string[]     pointStr;
            List <Point> points;
            Point        point;

            string[] xy;
            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.Drawing)
                {
                    continue;
                }
                pointStr = field.FieldValue.Split(';');
                points   = new List <Point>();
                for (int j = 0; j < pointStr.Length; j++)
                {
                    xy = pointStr[j].Split(',');
                    if (xy.Length == 2)
                    {
                        point = new Point(PIn.Int(xy[0]), PIn.Int(xy[1]));
                        points.Add(point);
                    }
                }
                for (int i = 1; i < points.Count; i++)
                {
                    g.DrawLine(pen, p(points[i - 1].X), p(points[i - 1].Y), p(points[i].X), p(points[i].Y));
                }
            }
            //then, rectangles and lines----------------------------------------------------------------------------------
            XPen pen2 = new XPen(XColors.Black, p(1));

            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType == SheetFieldType.Rectangle)
                {
                    g.DrawRectangle(pen2, p(field.XPos), p(field.YPos), p(field.Width), p(field.Height));
                }
                if (field.FieldType == SheetFieldType.Line)
                {
                    g.DrawLine(pen2, p(field.XPos), p(field.YPos),
                               p(field.XPos + field.Width),
                               p(field.YPos + field.Height));
                }
            }
            //then, draw text--------------------------------------------------------------------------------------------
            Bitmap   doubleBuffer = new Bitmap(sheet.Width, sheet.Height);
            Graphics gfx          = Graphics.FromImage(doubleBuffer);

            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.InputField &&
                    field.FieldType != SheetFieldType.OutputText &&
                    field.FieldType != SheetFieldType.StaticText)
                {
                    continue;
                }
                xfontstyle = XFontStyle.Regular;
                if (field.FontIsBold)
                {
                    xfontstyle = XFontStyle.Bold;
                }
                xfont = new XFont(field.FontName, field.FontSize, xfontstyle);
                //xfont=new XFont(field.FontName,field.FontSize,xfontstyle);
                //Rectangle rect=new Rectangle((int)p(field.XPos),(int)p(field.YPos),(int)p(field.Width),(int)p(field.Height));
                XRect xrect = new XRect(p(field.XPos), p(field.YPos), p(field.Width), p(field.Height));
                //XStringFormat format=new XStringFormat();
                //tf.DrawString(field.FieldValue,font,XBrushes.Black,xrect,XStringFormats.TopLeft);
                GraphicsHelper.DrawStringX(g, gfx, 1d / p(1), field.FieldValue, xfont, XBrushes.Black, xrect);
            }
            gfx.Dispose();
            //then, checkboxes----------------------------------------------------------------------------------
            XPen pen3 = new XPen(XColors.Black, p(1.6f));

            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.CheckBox)
                {
                    continue;
                }
                if (field.FieldValue == "X")
                {
                    g.DrawLine(pen3, p(field.XPos), p(field.YPos), p(field.XPos + field.Width), p(field.YPos + field.Height));
                    g.DrawLine(pen3, p(field.XPos + field.Width), p(field.YPos), p(field.XPos), p(field.YPos + field.Height));
                }
            }
            //then signature boxes----------------------------------------------------------------------
            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.SigBox)
                {
                    continue;
                }
                SignatureBoxWrapper wrapper = new SignatureBoxWrapper();
                wrapper.Width  = field.Width;
                wrapper.Height = field.Height;
                if (field.FieldValue.Length > 0)              //a signature is present
                {
                    bool sigIsTopaz = false;
                    if (field.FieldValue[0] == '1')
                    {
                        sigIsTopaz = true;
                    }
                    string signature = "";
                    if (field.FieldValue.Length > 1)
                    {
                        signature = field.FieldValue.Substring(1);
                    }
                    string keyData = Sheets.GetSignatureKey(sheet);
                    wrapper.FillSignature(sigIsTopaz, keyData, signature);
                }
                XImage sigBitmap = XImage.FromGdiPlusImage(wrapper.GetSigImage());
                g.DrawImage(sigBitmap, p(field.XPos), p(field.YPos), p(field.Width - 2), p(field.Height - 2));
            }
        }
示例#3
0
        private static void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.HighQuality;
            Sheet sheet = SheetList[sheetsPrinted];

            SheetUtil.CalculateHeights(sheet, g);           //this is here because of easy access to g.
            Font      font;
            FontStyle fontstyle;

            //first, draw images------------------------------------------------------------------------------------
            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.Image)
                {
                    continue;
                }
                string filePathAndName = ODFileUtils.CombinePaths(SheetUtil.GetImagePath(), field.FieldName);
                Image  img             = null; //js consider switching this from an image to a bitmap
                if (field.FieldName == "Patient Info.gif")
                {
                    img = Properties.Resources.Patient_Info;
                }
                else if (File.Exists(filePathAndName))
                {
                    img = Image.FromFile(filePathAndName);
                }
                else
                {
                    continue;
                }
                g.DrawImage(img, field.XPos, field.YPos, field.Width, field.Height);
                img.Dispose();
                img = null;
            }
            //then, drawings--------------------------------------------------------------------------------------------
            Pen pen = new Pen(Brushes.Black, 2f);

            string[]     pointStr;
            List <Point> points;
            Point        point;

            string[] xy;
            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.Drawing)
                {
                    continue;
                }
                pointStr = field.FieldValue.Split(';');
                points   = new List <Point>();
                for (int p = 0; p < pointStr.Length; p++)
                {
                    xy = pointStr[p].Split(',');
                    if (xy.Length == 2)
                    {
                        point = new Point(PIn.Int(xy[0]), PIn.Int(xy[1]));
                        points.Add(point);
                    }
                }
                for (int i = 1; i < points.Count; i++)
                {
                    g.DrawLine(pen, points[i - 1].X, points[i - 1].Y, points[i].X, points[i].Y);
                }
            }
            //then, rectangles and lines----------------------------------------------------------------------------------
            Pen pen2 = new Pen(Brushes.Black, 1f);

            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType == SheetFieldType.Rectangle)
                {
                    g.DrawRectangle(pen2, field.XPos, field.YPos, field.Width, field.Height);
                }
                if (field.FieldType == SheetFieldType.Line)
                {
                    g.DrawLine(pen2, field.XPos, field.YPos,
                               field.XPos + field.Width,
                               field.YPos + field.Height);
                }
            }
            //then, draw text-----------------------------------------------------------------------------------------------
            Bitmap   doubleBuffer = new Bitmap(sheet.Width, sheet.Height);
            Graphics gfx          = Graphics.FromImage(doubleBuffer);

            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.InputField &&
                    field.FieldType != SheetFieldType.OutputText &&
                    field.FieldType != SheetFieldType.StaticText)
                {
                    continue;
                }
                fontstyle = FontStyle.Regular;
                if (field.FontIsBold)
                {
                    fontstyle = FontStyle.Bold;
                }
                font = new Font(field.FontName, field.FontSize, fontstyle);
                Plugins.HookAddCode(null, "SheetPrinting.pd_PrintPage_drawFieldLoop", field);
                GraphicsHelper.DrawString(g, gfx, field.FieldValue, font, Brushes.Black, field.Bounds);
                //g.DrawString(field.FieldValue,font,Brushes.Black,field.BoundsF);
            }
            gfx.Dispose();
            //then, checkboxes----------------------------------------------------------------------------------
            Pen pen3 = new Pen(Brushes.Black, 1.6f);

            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.CheckBox)
                {
                    continue;
                }
                if (field.FieldValue == "X")
                {
                    g.DrawLine(pen3, field.XPos, field.YPos, field.XPos + field.Width, field.YPos + field.Height);
                    g.DrawLine(pen3, field.XPos + field.Width, field.YPos, field.XPos, field.YPos + field.Height);
                }
            }
            //then signature boxes----------------------------------------------------------------------
            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.SigBox)
                {
                    continue;
                }
                SignatureBoxWrapper wrapper = new SignatureBoxWrapper();
                wrapper.Width  = field.Width;
                wrapper.Height = field.Height;
                if (field.FieldValue.Length > 0)              //a signature is present
                {
                    bool sigIsTopaz = false;
                    if (field.FieldValue[0] == '1')
                    {
                        sigIsTopaz = true;
                    }
                    string signature = "";
                    if (field.FieldValue.Length > 1)
                    {
                        signature = field.FieldValue.Substring(1);
                    }
                    string keyData = Sheets.GetSignatureKey(sheet);
                    wrapper.FillSignature(sigIsTopaz, keyData, signature);
                }
                Bitmap sigBitmap = wrapper.GetSigImage();
                g.DrawImage(sigBitmap, field.XPos, field.YPos, field.Width - 2, field.Height - 2);
            }
            g.Dispose();
            //no logic yet for multiple pages on one sheet.
            sheetsPrinted++;
            //heightsCalculated=false;
            if (sheetsPrinted < SheetList.Count)
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
                sheetsPrinted  = 0;
            }
        }
示例#4
0
        private void FormTPsign_Load(object sender, System.EventArgs e)
        {
            //this window never comes up for new TP.  Always saved ahead of time.
            if (!Security.IsAuthorized(Permissions.TreatPlanSign, TPcur.DateTP))
            {
                butOK.Enabled = false;
                signatureBoxWrapper.Enabled         = false;
                signatureBoxWrapperPractice.Enabled = false;
                textTypeSig.Enabled         = false;
                textTypeSigPractice.Enabled = false;
            }
            _hasSigPractice = (SheetTP == null ? false : (SheetTP.SheetFields.Any(x => x.FieldType == SheetFieldType.SigBoxPractice) && DoPrintUsingSheets));
            LayoutToolBar();
            ToolBarMain.Buttons["FullPage"].Pushed = true;
            previewContr.Location = new Point(0, ToolBarMain.Bottom);
            previewContr.Size     = new Size(ClientRectangle.Width, ClientRectangle.Height - ToolBarMain.Height - panelSig.Height);
            if (Document == null)           //Only set when not pringing using sheets, shet via a MigraDoc.
            //TODO:Implement ODprintout pattern - MigraDoc
            //Just signing the TP, there is no way to print a Treat' Plan from the Sign TP window so suppress the printer dialogs.
            //Users will click the Print TP button from the Treat' Plan module when they want to print.
            {
                PrinterL.ControlPreviewOverride = previewContr;              //Sets the printdoc to previewContr.Document after validation. Otherwise shows error.
                SheetPrinting.Print(SheetTP, isPrintDocument: false, isPreviewMode: true);
                if (ODprintout.CurPrintout.SettingsErrorCode != PrintoutErrorCode.Success)
                {
                    DialogResult = DialogResult.Cancel;
                    return;
                }
                Document = ODprintout.CurPrintout.PrintDoc;
            }
            else              //MigraDoc
            {
                if (Document.DefaultPageSettings.PrintableArea.Height == 0)
                {
                    Document.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100);
                }
                previewContr.Document = Document;
            }
            SetSize();
            ToolBarMain.Buttons["PageNum"].Text = (previewContr.StartPage + 1).ToString()
                                                  + " / " + TotalPages.ToString();
            proctpList = ProcTPs.RefreshForTP(TPcur.TreatPlanNum);
            //Fill TP signature
            signatureBoxWrapper.SignatureMode = UI.SignatureBoxWrapper.SigMode.TreatPlan;
            string keyData = TreatPlans.GetKeyDataForSignatureHash(TPcur, proctpList);

            signatureBoxWrapper.FillSignature(TPcur.SigIsTopaz, keyData, TPcur.Signature);
            SheetField sheetField;

            if (SheetTP != null)
            {
                sheetField = SheetTP.SheetFields.FirstOrDefault(x => x.FieldType == SheetFieldType.SigBox);
                if (sheetField != null && !string.IsNullOrEmpty(sheetField.FieldName))
                {
                    labelSig.Text = $"{sheetField.FieldName} sign here --->";
                }
                sheetField = SheetTP.GetSheetFieldByName("SignatureText");
                if (sheetField != null)
                {
                    textTypeSig.Text     = TPcur.SignatureText;
                    labelTypeSig.Visible = true;
                    textTypeSig.Visible  = true;
                }
            }
            //Fill TP practice signature if printing using sheets
            if (_hasSigPractice)
            {
                signatureBoxWrapperPractice.Visible       = true;
                labelSigPractice.Visible                  = true;
                signatureBoxWrapperPractice.SignatureMode = UI.SignatureBoxWrapper.SigMode.TreatPlan;
                signatureBoxWrapperPractice.FillSignature(TPcur.SigIsTopaz, keyData, TPcur.SignaturePractice);
                sheetField = SheetTP.SheetFields.FirstOrDefault(x => x.FieldType == SheetFieldType.SigBoxPractice);
                if (sheetField != null && !string.IsNullOrEmpty(sheetField.FieldName))
                {
                    labelSigPractice.Text = $"{sheetField.FieldName} sign here --->";
                }
                sheetField = SheetTP.GetSheetFieldByName("SignaturePracticeText");
                if (sheetField != null)
                {
                    textTypeSigPractice.Text     = TPcur.SignaturePracticeText;
                    labelTypeSigPractice.Visible = true;                  //defaulted to be hidden
                    textTypeSigPractice.Visible  = true;
                }
            }
        }