/// <summary>method write phone row of address column to address column grid /// </summary> /// <param name="grid">address column grid</param> /// <param name="rows">array of row's strings</param> /// <param name="rowIndex">row index</param> private void WritePhoneRow(Grid grid, string[] row, int rowIndex) { int i; TextBlock text; int colCount = row.GetLength(0); GridLength[] colWidth = new GridLength[colCount]; for (i = 0; i < colCount; i++) { if (i % 2 == 0) { colWidth[i] = GridLength.Auto; } else { colWidth[i] = new GridLength(0.8 * ReportPage.DisplayResolution); } } Grid childGrid = XPSHelper.GetGrid(colWidth, 1); childGrid.Margin = new Thickness(m_HorMargin, 0, 0, 0); for (i = 0; i < colCount; i++) { text = XPSHelper.WriteTextBlockToGrid(row[i], childGrid, 0, i, HorizontalAlignment.Left, VerticalAlignment.Top, new Thickness((i % 2 == 0 ? 0 : 3), (rowIndex == 2 ? 0 : -5.0), 0, 0), m_FontSize); text.FontWeight = (i % 2 == 0 ? FontWeights.Normal : FontWeights.Bold); } XPSHelper.WriteItemToGrid(childGrid, grid, rowIndex, 0); }
/// <summary>method write "Cytogenetics/Other Exam" group to "Democratic History" section /// </summary> /// <param name="rowNo">base grid row number of group</param> private void WriteExam2Group(int rowNo) { Grid grid = XPSHelper.GetGrid(new GridLength[] { GridLength.Auto, new GridLength(1, GridUnitType.Star) }, 1); XPSHelper.WriteItemToGrid(grid, m_DemographicGrid, rowNo, 0, 0, 2); WriteCheckBox(grid, "Cytogenetics", this.m_PlacentalPathologyData.Cytogenetics, 0, 0); WriteCheckBoxAndTextBlock(grid, "Other", this.m_PlacentalPathologyData.OtherExam, 0, 1); }
/// <summary>method write "Gross/Complete Exam" group to "Democratic History" section /// </summary> /// <param name="rowNo">base grid row number of group</param> private void WriteExam1Group(int rowNo) { Grid grid = XPSHelper.GetGrid(new GridLength[] { GridLength.Auto, new GridLength(1, GridUnitType.Star) }, 1); XPSHelper.WriteItemToGrid(grid, m_DemographicGrid, rowNo, 0, 0, 2); WriteCheckBox(grid, "Gross Examination Only", this.m_PlacentalPathologyData.GrossExam, 0, 0); WriteCheckBox(grid, "Complete Examination (Includes Gross and Microscopic)", this.m_PlacentalPathologyData.CompleteExam, 0, 1); }
/// <summary>method write "Apgar" group to "Democratic History" section /// </summary> /// <param name="rowNo">base grid row number of group</param> private void WriteApgarGroup(int rowNo) { Grid grid = XPSHelper.GetGrid(new double[] { 1.3, 0.9, 1.0 }, 1); XPSHelper.WriteItemToGrid(grid, m_DemographicGrid, rowNo, 0); WriteLabelAndTextBlock(grid, "Apgar 1 min", this.m_PlacentalPathologyData.Apgar1Min, 0, 0); WriteLabelAndTextBlock(grid, "5 min", this.m_PlacentalPathologyData.Apgar5Min, 0, 1, false); WriteLabelAndTextBlock(grid, "10 min", this.m_PlacentalPathologyData.Apgar10Min, 0, 2, false); }
/// <summary>method write "Gravida/Para" group to "Democratic History" section /// </summary> /// <param name="rowNo">base grid row number of group</param> private void WriteGravidaParaGroup(int rowNo) { double col1Width = m_DemographicGridColWidth[0] * 2 / 3; double col2Width = m_DemographicGridColWidth[0] - col1Width; Grid grid = XPSHelper.GetGrid(new double[] { col1Width, col2Width }, 1); XPSHelper.WriteItemToGrid(grid, m_DemographicGrid, rowNo, 0); WriteLabelAndTextBlock(grid, "Gravida", this.m_PlacentalPathologyData.Gravida, 0, 0); WriteLabelAndTextBlock(grid, "Para", this.m_PlacentalPathologyData.Para, 0, 1); }
/// <summary>method write block with check box and text block to document grid /// </summary> /// <param name="baseGrid">block's parent grid</param> /// <param name="labelText">label of check box</param> /// <param name="stringXMLElementName">XML element name with text block value</param> /// <param name="rowNo">parent grid row number of block</param> /// <param name="colNo">parent grid column number of block</param> private void WriteCheckBoxAndTextBlock(Grid baseGrid, string labelText, string textValue, int rowNo, int colNo) { //string textValue = (stringXMLElementName != string.Empty ? m_PlacentalPathologyData.Element(stringXMLElementName).Value : string.Empty); Grid grid = XPSHelper.GetGrid(new GridLength[] { GridLength.Auto, new GridLength(1, GridUnitType.Star) }, 1, 0.0, new Thickness(0, 0, m_MarginSize * 4, 0)); XPSHelper.WriteItemToGrid(grid, baseGrid, rowNo, colNo); XPSHelper.WriteCheckBox(labelText, (textValue != string.Empty), grid, 0, 0, HorizontalAlignment.Left, VerticalAlignment.Top, new Thickness(m_MarginSize, m_MarginSize * 2, m_MarginSize, m_MarginSize), m_FontSize, null, FontWeights.Normal); XPSHelper.WriteTextBlockToGrid(textValue, grid, 0, 1, HorizontalAlignment.Stretch, VerticalAlignment.Top, new Thickness(m_MarginSize, m_MarginSize * 2, m_MarginSize, 0), m_FontSize); XPSHelper.WriteUnderliningToGridCell(grid, 0, 1); }
/// <summary>method write block with label and value to document grid /// </summary> /// <param name="baseGrid">block's parent grid</param> /// <param name="labelText">string value in label part of block</param> /// <param name="value">string value in text part of block</param> /// <param name="rowNo">parent grid row number of block</param> /// <param name="colNo">parent grid column number of block</param> /// <param name="addBullet">if true, then bullet added before label part of block</param> /// <param name="colSpan">ColSpan parameter of parent grid cell</param> private static void WriteLabelAndTextBlock(Grid baseGrid, string labelText, string value, int rowNo, int colNo, bool addBullet = true, int colSpan = 0) { Grid grid = XPSHelper.GetGrid(new GridLength[] { GridLength.Auto, new GridLength(1, GridUnitType.Star) }, 1); XPSHelper.WriteItemToGrid(grid, baseGrid, rowNo, colNo, 0, colSpan); string fullLabelText = string.Format("{0}{1}", (addBullet ? string.Format("{0} ", m_Bullet) : ""), labelText); XPSHelper.WriteTextBlockToGrid(fullLabelText, grid, 0, 0, HorizontalAlignment.Left, VerticalAlignment.Top, new Thickness(m_MarginSize, m_MarginSize + 1, m_MarginSize, m_MarginSize - 1), m_FontSize); XPSHelper.WriteTextBlockToGrid(value, grid, 0, 1, HorizontalAlignment.Stretch, VerticalAlignment.Top, new Thickness(m_MarginSize, m_MarginSize, m_MarginSize, m_MarginSize), m_FontSize); XPSHelper.WriteUnderliningToGridCell(grid, 0, 1); }
/// <summary>>method write section row (label/value block) to parent grid /// </summary> /// <param name="labelText">label text</param> /// <param name="valueText">value text</param> /// <param name="parentGrid">parent grid</param> /// <param name="rowNo">TextBlock cell row number in parent grid</param> /// <param name="colNo">TextBlock cell column number in parent grid</param> /// <param name="topMargin">top margin of "Cell Population Of Interest" section</param> protected static void WriteSectionRow(string labelText, string valueText, Grid parentGrid, double[] colWidth, int rowIndex, int colIndex, double topMargin = 0) { Grid grid = XPSHelper.GetGrid(colWidth, 1); grid.Margin = new Thickness(0, topMargin, 0, 0); TextBlock label = XPSHelper.WriteTextBlockToGrid(labelText, grid, 0, 0, HorizontalAlignment.Left, VerticalAlignment.Top, null, m_FontSize); label.FontWeight = FontWeights.Bold; XPSHelper.WriteTextBlockToGrid(valueText, grid, 0, 1, HorizontalAlignment.Left, VerticalAlignment.Top, null, m_FontSize); XPSHelper.WriteItemToGrid(grid, parentGrid, rowIndex, colIndex); }
/// <summary>method write "Result Data" and "Specimen Information" sections to document grid /// </summary> private void WriteResultDataAndSpecimenInformation() { const double leftMargin = m_LeftMargin; const double topMargin = m_TopMargin; double[] colWidth = XPSHelper.GetFullWidthGridColWidthArray(new double[] { 3.4 }, leftMargin); Grid grid = XPSHelper.GetGrid(colWidth, 1); grid.Margin = new Thickness(leftMargin, topMargin, 0, 0); XPSHelper.WriteItemToGrid(WriteResultData(), grid, 0, 0); XPSHelper.WriteItemToGrid(WriteSpecimenInformation(), grid, 0, 1); m_ReportDocument.WriteRowContent(grid); }
/// <summary>method write patient full display name and code /// </summary> /// <param name="grid">informational grid</param> private void WritePatientCode(Grid grid) { const int rowsCount = 1; GridLength[] colWidth = new GridLength[] { GridLength.Auto, new GridLength(1, GridUnitType.Star) }; XPSHelper.WriteTextBlockToGrid("Patient:", grid, 0, 0, HorizontalAlignment.Left, VerticalAlignment.Bottom, null, m_FontSize + 3); Grid childGrid = XPSHelper.GetGrid(colWidth, rowsCount); XPSHelper.WriteTextBlockToGrid(m_Data.GetPatientDisplayName(), childGrid, 0, 0, HorizontalAlignment.Left, VerticalAlignment.Bottom, new Thickness(0, 0, 10, 0), m_FontSize + 6, null, FontWeights.Bold); XPSHelper.WriteTextBlockToGrid(m_Data.GetPatientCode(), childGrid, 0, 1, HorizontalAlignment.Left, VerticalAlignment.Bottom, new Thickness(0, 0, 0, 1), m_FontSize + 1); XPSHelper.WriteItemToGrid(childGrid, grid, 0, 1); }
/// <summary>method write site column to document grid /// </summary> /// <param name="grid">document grid</param> private void WriteSiteColumn(Grid grid) { const int rowIndex = 2; const int colIndex = 2; const double topMargin = -0.7; HorizontalAlignment horAlign = m_ColAlign[colIndex]; int rowCount = m_SiteRows.GetLength(0); Grid childGrid = XPSHelper.GetGrid(rowCount, 1); for (int i = 0; i < rowCount; i++) { XPSHelper.WriteTextBlockToGrid(m_SiteRows[i], childGrid, i, 0, horAlign, VerticalAlignment.Top, new Thickness(0, topMargin, m_HorMargin, 0), m_FontSize, m_RedishBrush); } XPSHelper.WriteItemToGrid(childGrid, grid, rowIndex, colIndex); }
/// <summary>method write report name /// </summary> /// <param name="grid">logo grid</param> private void WriteReportName(Grid grid) { const int rowIndex = 0; const int colIndex = 1; Thickness reportNameMargin = new Thickness(0, 3, m_HorMargin, 0); Thickness amendmentLabelMargin = new Thickness(0, 5, m_HorMargin, 0); StackPanel stackPanel = new StackPanel() { Orientation = Orientation.Vertical }; stackPanel.Children.Add(XPSHelper.GetTextBlock(m_ReportName, HorizontalAlignment.Right, VerticalAlignment.Top, reportNameMargin, m_FontSize + 11, m_RedishBrush, FontWeights.Bold, false, false)); stackPanel.Children.Add(XPSHelper.GetTextBlock((m_Data.HasAmendments ? "Amendment" : string.Empty), HorizontalAlignment.Right, VerticalAlignment.Top, amendmentLabelMargin, m_FontSize + 7, m_RedishBrush, FontWeights.Bold, false, false)); XPSHelper.WriteItemToGrid(stackPanel, grid, rowIndex, colIndex, 0, 2); }
/// <summary>method write logo image /// </summary> /// <param name="grid">logo grid</param> private static void WriteLogo(Grid grid) { const int rowIndex = 0; const int colIndex = 0; const int rowSpan = 3; const int colSpan = 3; const string imagePath = "YellowstonePathology.Document.Xps.ReportLogo.jpg"; Assembly assembly = Assembly.GetExecutingAssembly(); Image logo = new Image() { Source = ((BitmapDecoder)(JpegBitmapDecoder.Create(assembly.GetManifestResourceStream(imagePath), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default))).Frames[0], }; XPSHelper.WriteItemToGrid(logo, grid, rowIndex, colIndex, rowSpan, colSpan); }
/// <summary>method write content to logo grid /// </summary> /// <param name="grid">root report header grid</param> private void WriteLogoGrid(Grid grid) { const int rowsCount = 2; double[] сolWidth = new double[] { 2.5, 4.0, 1.0 }; Grid logoGrid = XPSHelper.GetGrid(сolWidth, rowsCount); logoGrid.RowDefinitions[0].Height = new GridLength(1, GridUnitType.Auto); //0.2 * ReportPage.DisplayResolution logoGrid.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Star); //0.1 * ReportPage.DisplayResolution //logoGrid.RowDefinitions[2].Height = new GridLength(7, GridUnitType.Star); //0.1 * ReportPage.DisplayResolution XPSHelper.WriteItemToGrid(logoGrid, grid, 0, 0); WriteLogo(logoGrid); WriteReportName(logoGrid); //if (m_Data.HasAmendments) WriteAmendmentLabel(logoGrid); WriteReportNo(logoGrid); }
/// <summary>method write content to informational grid /// </summary> /// <param name="grid">root report header grid</param> private void WriteInformGrid(Grid grid) { int rowsCount = 6; double[] colWidth = new double[] { 0.7, 3.8, 1.5, 1.5 }; const int topMargin = 2; Grid childGrid = XPSHelper.GetGrid(colWidth, rowsCount); childGrid.Margin = new Thickness(m_HorMargin, topMargin, 0, 0); XPSHelper.WriteItemToGrid(childGrid, grid, 1, 0); WritePatientCode(childGrid); WriteLabelAndTextBlock1(childGrid, 2, "Provider:", m_Data.GetStringValue(ReportHeaderData.Provider)); WriteLabelAndTextBlock1(childGrid, 3, string.Empty, m_Data.GetStringValue("ClientName")); WriteLabelAndTextBlock1(childGrid, 5, string.Empty, "Full distribution list is provided at the end of the report.", m_FontSize, true); WriteLabelAndTextBlock2(childGrid, 1, "Master Accession #:", m_Data.GetStringValue(ReportHeaderData.MasterAccessionNo)); WriteLabelAndTextBlock2(childGrid, 2, "Date of report:", m_Data.FinalTimeString); WriteLabelAndTextBlock2(childGrid, 3, "Accessioned:", m_Data.GetDateTime("AccessionTime")); WriteLabelAndTextBlock2(childGrid, 4, "Collected:", m_Data.GetDateTime("CollectionTime", "MM/dd/yyyy")); WriteLabelAndTextBlock2(childGrid, 5, "Client Ref #:", m_Data.GetStringValue(ReportHeaderData.ClientRefNumber)); }
/// <summary>method write address column to document grid /// </summary> /// <param name="rows">array of rows strings</param> /// <param name="grid">document grid</param> /// <param name="colIndex">column index</param> private void WriteAddressColumn(string[][] rows, Grid grid, int colIndex) { const int rowIndex = 2; int colCount; HorizontalAlignment horAlign = m_ColAlign[colIndex]; int rowCount = rows.GetLength(0); Grid childGrid = XPSHelper.GetGrid(rowCount, 1); for (int i = 0; i < rowCount; i++) { colCount = rows[i].GetLength(0); if (colCount == 1) { XPSHelper.WriteTextBlockToGrid(rows[i][0], childGrid, i, 0, horAlign, VerticalAlignment.Top, new Thickness(m_HorMargin, (i == 1 ? -5.0 : 0), 0, 0), m_FontSize + 1, m_GreenishBrush); } else { WritePhoneRow(childGrid, rows[i], i); } } XPSHelper.WriteItemToGrid(childGrid, grid, rowIndex, colIndex); }