///<summary>Overload for SummaryField ReportObject</summary> public ReportObject(string thisSectionName, Point thisLocation, Size thisSize , SummaryOperation thisOperation, string thisSummarizedField , Font thisFont, ContentAlignment thisTextAlign, string thisFormatString) { sectionName = thisSectionName; location = thisLocation; size = thisSize; font = thisFont; textAlign = thisTextAlign; formatString = thisFormatString; fieldKind = FieldDefKind.SummaryField; valueType = FieldValueType.Number; operation = thisOperation; summarizedField = thisSummarizedField; //defaults: foreColor = Color.Black; objectKind = ReportObjectKind.FieldObject; }
private void AdjustLayout(ReportDocument icryRptDoc) { if (icryRptDoc == null) { return; } bool bAdjust1 = false, bAdjust2 = false, bAdjust3 = false; Font theFont; int refWidth = 0; for (int i = 0; i < icryRptDoc.ReportDefinition.Sections.Count; i++) { ReportObjects robjs = icryRptDoc.ReportDefinition.ReportObjects; if (robjs == null || robjs.Count == 0) { continue; } for (int j = 0; j < robjs.Count; j++) { ReportObject robj = robjs[j]; if (robj == null) { continue; } ReportObjectKind robkKind = robj.Kind; if (robkKind == ReportObjectKind.FieldObject && !string.IsNullOrEmpty(robj.Name)) { FieldObject fieldObj = (FieldObject)robj; if (fieldObj == null) { continue; } int nIndex = lstRunDetailsDisplayElements.FindIndex(x => { if ((!string.IsNullOrEmpty(x.DisplayFieldName) && x.DisplayFieldName == fieldObj.Name)) { return(true); } return(false); }); if (0 <= nIndex) { DisplayElement2 d2 = lstRunDetailsDisplayElements[nIndex]; if (d2 != null && !string.IsNullOrEmpty(d2.Name)) { float fontSize = d2.EstimateFontSize(d2.Name, new Size(fieldObj.Width / conversionFactor, fieldObj.Height / conversionFactor), fieldObj.Font); if (fontSize > 0.0f && fontSize < fieldObj.Font.Size) { theFont = new Font(fieldObj.Font.Name, fontSize, fieldObj.Font.Style, fieldObj.Font.Unit); fieldObj.ApplyFont(theFont); theFont.Dispose(); } } d2.FontSizeAdjusted = true; bool bAllAdjusted = true; foreach (DisplayElement2 de in lstRunDetailsDisplayElements) { if (de == null) { continue; } bAllAdjusted &= de.FontSizeAdjusted; } bAdjust1 = bAllAdjusted; } } if (robkKind == ReportObjectKind.TextObject && !string.IsNullOrEmpty(robj.Name)) { TextObject textObj = (TextObject)robj; if (textObj == null) { continue; } if ((!string.IsNullOrEmpty(textObj.Name) && textObj.Name == "TB_PageFooterCopyright")) { theFont = new Font(textObj.Font.Name, 6.0f, textObj.Font.Style, textObj.Font.Unit); textObj.ApplyFont(theFont); bAdjust2 = true; theFont.Dispose(); } } if (robkKind == ReportObjectKind.SubreportObject && !string.IsNullOrEmpty(robj.Name) && robj.Name == "Subreport_RunSummary") { SubreportObject subReportObj = (SubreportObject)robj; ReportDocument subReportDoc = subReportObj.OpenSubreport(subReportObj.SubreportName); if (subReportDoc == null) { break; } ReportObjects subrobjs = subReportDoc.ReportDefinition.ReportObjects; if (subrobjs == null || subrobjs.Count == 0) { continue; } // Estimate heights for (int m = 0; m < subrobjs.Count; m++) { ReportObject subrobj = subrobjs[m]; if (subrobj == null) { continue; } Font font; switch (subrobj.Name) { case "FO_RS_SampleNumber": case "FO_RS_SampleID": case "FO_RS_Protocol": case "FO_RS_SampleVol_mL": case "FO_RS_MagneticParticles": case "FO_RS_Selection_Cocktail": case "FO_RS_Antibody_Cocktail": case "FO_RS_TipRack": case "FO_RS_BufferLotID": case "FO_RS_SampleTube": case "FO_RS_SeparationTube": case "FO_RS_NegativeFractionTube": case "FO_RS_WasteTube": FieldObject fb = (FieldObject)subrobj; font = fb.Font; EstimateHeight(subrobj, font, subrobj.Name); break; } } // Set heights of cells for (int n = 0; n < subrobjs.Count; n++) { ReportObject subrobj = subrobjs[n]; if (subrobj == null) { continue; } switch (subrobj.Name) { case "TB_RS_SampleNumber": case "TB_RS_SampleID": case "TB_RS_Protocol": case "TB_RS_SampleVol_mL": case "TB_RS_MagneticParticles": case "TB_RS_Selection_Cocktail": case "TB_RS_Antibody_Cocktail": case "TB_RS_TipRack": case "TB_RS_BufferLotID": case "TB_RS_SampleTube": case "TB_RS_SeparationTube": case "TB_RS_NegativeFractionTube": case "TB_RS_WasteTube": SetHeight(subrobj, subrobj.Name); break; } } // end for for (int n = 0; n < subrobjs.Count; n++) { ReportObject subrobj = subrobjs[n]; if (subrobj == null) { continue; } switch (subrobj.Name) { case "TB_RS_SampleVol_mL": refWidth = subrobj.Width; break; case "TB_RS_MagneticParticles": case "TB_RS_Selection_Cocktail": case "TB_RS_Antibody_Cocktail": subrobj.Width = refWidth; break; } } // end for bAdjust3 = true; } // end if sub report if (bAdjust1 && bAdjust2 && bAdjust3) { break; } }// end for section object } }
///<summary>Overload for SpecialField ReportObject</summary> public ReportObject(string name,string sectionName,Point location,Size size,FieldValueType fieldValueType,SpecialFieldType specialType,Font font,ContentAlignment contentAlignment,string stringFormat) { _name=name; _sectionName=sectionName; _location=location; _size=size; _font=font; _contentAlignment=contentAlignment; _stringFormat=stringFormat; _fieldDefKind=FieldDefKind.SpecialField; _fieldValueType=fieldValueType; _specialFieldType=specialType; //defaults: _foreColor=Color.Black; _reportObjectKind=ReportObjectKind.FieldObject; }
///<summary>Overload for GroupSummary ReportObject</summary> public ReportObject(string name,string sectionName,Point location,Size size,Color color,string summarizedFieldName,string datafield,Font font,SummaryOperation summaryOperation,int offSetX,int offSetY) { _name=name; _sectionName=sectionName; _location=location; _size=size; _dataFieldName=datafield; _font=font; _fieldDefKind=FieldDefKind.SummaryField; _fieldValueType=FieldValueType.Number; _summaryOperation=summaryOperation; _summarizedFieldName=summarizedFieldName; _offSetX=offSetX; _offSetY=offSetY; _foreColor=color; //defaults: _contentAlignment=ContentAlignment.MiddleRight; _reportObjectKind=ReportObjectKind.TextObject; }
///<summary>Overload for SummaryField ReportObject</summary> public ReportObject(string name,string sectionName,Point location,Size size,SummaryOperation summaryOperation,string summarizedFieldName,Font font,ContentAlignment contentAlignment,string stringFormat) { _name=name; _sectionName=sectionName; _location=location; _size=size; _font=font; _contentAlignment=contentAlignment; _stringFormat=stringFormat; _fieldDefKind=FieldDefKind.SummaryField; _fieldValueType=FieldValueType.Number; _summaryOperation=summaryOperation; _summarizedFieldName=summarizedFieldName; //defaults: _foreColor=Color.Black; _reportObjectKind=ReportObjectKind.FieldObject; }
///<summary>Overload for LineObject.</summary> public ReportObject(string name,string sectionName,Color color,float lineThickness,LineOrientation lineOrientation,LinePosition linePosition,int linePercent,int offSetX,int offSetY) { _name=name; _sectionName=sectionName; _foreColor=color; _floatLineThickness=lineThickness; _lineOrientation=lineOrientation; _linePosition=linePosition; _intLinePercent=linePercent; _offSetX=offSetX; _offSetY=offSetY; _reportObjectKind=ReportObjectKind.LineObject; }
///<summary>Overload for BoxObject.</summary> public ReportObject(string name,string sectionName,Color color,float lineThickness,int offSetX,int offSetY) { _name=name; _sectionName=sectionName; _foreColor=color; _floatLineThickness=lineThickness; _offSetX=offSetX; _offSetY=offSetY; _reportObjectKind=ReportObjectKind.BoxObject; }
///<summary>Overload for TextObject.</summary> public ReportObject(string name,string sectionName,Point location,Size size,string staticText,Font font,ContentAlignment contentAlignment) { _name=name; _sectionName=sectionName; _location=location; _size=size; _staticText=staticText; _font=font; _contentAlignment=contentAlignment; _foreColor=Color.Black; _reportObjectKind=ReportObjectKind.TextObject; }
/// <summary>Gets the last reportObect of a particular kind. Used immediately after entering an Object to alter its properties.</summary> /// <param name="objectKind"></param> /// <returns></returns> public ReportObject GetLastRO(ReportObjectKind objectKind) { //ReportObject ro=null; for(int i=reportObjects.Count-1;i>=0;i--){//search from the end backwards if(reportObjects[i].ObjectKind==objectKind){ return ReportObjects[i]; } } MessageBox.Show("end of loop"); return null; }
///<summary>Overload for SpecialField ReportObject</summary> public ReportObject(string thisSectionName,Point thisLocation,Size thisSize ,FieldValueType thisValueType,SpecialFieldType thisSpecialType ,Font thisFont,ContentAlignment thisTextAlign,string thisFormatString) { sectionName=thisSectionName; location=thisLocation; size=thisSize; font=thisFont; textAlign=thisTextAlign; formatString=thisFormatString; fieldKind=FieldDefKind.SpecialField; valueType=thisValueType; specialType=thisSpecialType; //defaults: foreColor=Color.Black; objectKind=ReportObjectKind.FieldObject; }
///<summary>Overload for SummaryField ReportObject</summary> public ReportObject(string thisSectionName,Point thisLocation,Size thisSize ,SummaryOperation thisOperation,string thisSummarizedField ,Font thisFont,ContentAlignment thisTextAlign,string thisFormatString) { sectionName=thisSectionName; location=thisLocation; size=thisSize; font=thisFont; textAlign=thisTextAlign; formatString=thisFormatString; fieldKind=FieldDefKind.SummaryField; valueType=FieldValueType.Number; operation=thisOperation; summarizedField=thisSummarizedField; //defaults: foreColor=Color.Black; objectKind=ReportObjectKind.FieldObject; }
///<summary>Overload for TextObject.</summary> public ReportObject(string thisSectionName,Point thisLocation,Size thisSize,string thisStaticText,Font thisFont,ContentAlignment thisTextAlign) { sectionName=thisSectionName; location=thisLocation; size=thisSize; staticText=thisStaticText; font=thisFont; textAlign=thisTextAlign; foreColor=Color.Black; objectKind=ReportObjectKind.TextObject; }