-
using
System
;
-
using
System.Drawing
;
-
using
System.Collections.Generic
;
-
using
System.Collections
;
-
using
System.Collections.Specialized
;
-
using
System.Data
;
-
using
System.Data.SqlClient
;
-
using
System.Data.Common
;
-
using
System.Linq.Expressions
;
-
using
System.Linq
;
-
using
System.Text
;
-
using
System.Threading.Tasks
;
-
using
System.Windows.Forms
;
-
using
System.IO
;
-
using
System.Xml
;
-
using
WeifenLuo.WinFormsUI.Docking
;
-
using
PPL_Lib
;
-
using
MigraDoc
;
-
using
MD
= MigraDoc
.
DocumentObjectModel
;
-
using
MDT
= MigraDoc
.
DocumentObjectModel
.
Tables
;
-
-
namespace OCalcProReporting
-
{
-
-
public
static
class ReportFont
-
{
-
public
static
double cPageWidth
=
6.25
;
-
public
static
string cFontName
=
"Arial"
;
-
public
static MD
.
Unit cFontSizeLarge
= MD
.
Unit
.
FromPoint
(
9.75
)
;
-
public
static MD
.
Unit cFontSizeSmall
= MD
.
Unit
.
FromPoint
(
7.85
)
;
-
}
-
-
public
partial
class Report
: PPL_Lib
.
ReportTemplate
-
{
-
-
//globally defined colors and fonts
-
MD
.
Color Yellow
= MD
.
Colors
.
LightYellow
;
-
MD
.
Color White
= MD
.
Colors
.
White
;
-
MD
.
ParagraphAlignment JustifyRight
= MD
.
ParagraphAlignment
.
Right
;
-
MD
.
ParagraphAlignment JustifyLeft
= MD
.
ParagraphAlignment
.
Left
;
-
MD
.
ParagraphAlignment JustifyCenter
= MD
.
ParagraphAlignment
.
Center
;
-
MD
.
Font SmallFont
=
new MD
.
Font
(ReportFont
.
cFontName, ReportFont
.
cFontSizeSmall
)
;
-
MD
.
Font StandardFont
=
new MD
.
Font
(ReportFont
.
cFontName, ReportFont
.
cFontSizeLarge
)
;
-
FontModifier Bold
=
new FontModifier
(
true,
false,
false
)
;
-
-
-
//implement more than one additional report subtype (total will be this number plus the master)
-
public
override
int SubtypesCount
{
get
{
return
0
;
}
}
-
-
public
override REPORT_TYPE Type
{
get
{
return REPORT_TYPE
.
INTEGRATED
;
}
}
-
public
override
String Name
{
get
{
return
"Applied Loads Summary"
;
}
}
-
public
override
String Description
{
get
{
return Name
;
}
}
-
-
//make sure to implement ToString to show report name
-
public
override
String ToString
(
)
{
return Name
;
}
-
-
//determine if this report is applicable for a structure
-
public
override
bool IsApplicable
(PPLMain pPPLMain, PPLPole pPole
)
-
{
-
if
(Filtered
)
return
false
;
-
return
true
;
-
}
-
public
override
bool IsApplicableForType
(PPLMain
.
POLE_TYPE pType
)
-
{
-
if
(Filtered
)
return
false
;
-
return
true
;
-
}
-
-
MigraDoc
.
DocumentObjectModel
.
Document cDocument
=
null
;
-
PPLMain cPPLMain
=
null
;
-
MDT
.
Table cCurrentTable
=
null
;
-
MDT
.
Row cCurrentRow
=
null
;
-
MD
.
Unit cMaxRowHeight
=
0
;
-
-
//methods to create integrated report
-
public
override
void CreateReport
(PPLMain pPPLMain, List
<FileInfo
> pSelectedFiles
)
-
{
-
cPPLMain
= pPPLMain
;
-
cDocument
=
new MigraDoc
.
DocumentObjectModel
.
Document
(
)
;
-
MD
.
Section section
= cPPLMain
.
BuildStandardReportHeader
(cDocument, Name,
true
)
;
-
cDocument
.
DefaultPageSetup
.
Orientation
= MD
.
Orientation
.
Portrait
;
-
cDocument
.
LastSection
.
PageSetup
.
Orientation
= MigraDoc
.
DocumentObjectModel
.
Orientation
.
Portrait
;
-
MigraDoc
.
DocumentObjectModel
.
Paragraph paragraph
=
null
;
-
paragraph
= section
.
AddParagraph
(
"\n"
)
;
-
paragraph
.
Format
.
Borders
.
Top
.
Color
= MigraDoc
.
DocumentObjectModel
.
Colors
.
Blue
;
-
paragraph
.
Format
.
Borders
.
Top
.
Width
=
new MigraDoc
.
DocumentObjectModel
.
Unit
(
0.025, MigraDoc
.
DocumentObjectModel
.
UnitType
.
Inch
)
;
-
}
-
-
public
override
void AddPole
(PPLPole pPole,
String pPoleName
)
-
{
-
-
-
PoleLoadInfo poleInfoMaster
= cPPLMain
.
CurrentPoleLoadInfo
;
-
-
CreateTable
(ReportFont
.
cPageWidth,
4
)
;
-
cCurrentTable
.
Format
.
Font
= SmallFont
.
Clone
(
)
;
-
cCurrentTable
.
Borders
.
Visible
=
true
;
-
-
PPLPole pole
= cPPLMain
.
GetPole
(
)
;
-
-
List
<ForceSummary
> loads
=
new List
<ForceSummary
>
(
)
;
-
-
foreach
(PPLElement elem
in pole
.
Children
)
-
{
-
ForceSummary fs
= elem
.
BuildForceSummaryIncludingChildren
(poleInfoMaster
.
cLAC, PPLElement
.
FORCE_SUMMARY_MODE
.
MAX_PRECISION
)
;
-
if
(fs
.
ForceAxisA
==
0
&& fs
.
ForceAxisB
==
0
)
continue
;
-
loads
.
Add
(fs
)
;
-
}
-
-
loads
.
Sort
(
delegate
(ForceSummary f1, ForceSummary f2
)
-
{
-
return f2
.
cHeightOfForceApplicationAboveGLinInches
.
CompareTo
(f1
.
cHeightOfForceApplicationAboveGLinInches
)
;
-
}
)
;
-
-
-
if
(PPLGridModel
.
Attribute
.
UnitsConvention
== PPLGridModel
.
Attribute
.
UNITS_CONVENTION
.
METRIC
)
-
{
-
AddRow
(Cell
(
"Height (M)"
), Cell
(
"Force A (N)"
), Cell
(
"Force B (N)"
), Cell
(
"Force V (N)"
)
)
;
-
foreach
(ForceSummary fs
in loads
)
-
{
-
AddRow
(
-
Cell
(PPLGridModel
.
Attribute
.
InchesToMeters
(fs
.
cHeightOfForceApplicationAboveGLinInches
)
.
ToString
(
"0.##"
)
),
-
Cell
(PPLGridModel
.
Attribute
.
PoundsToNewtons
(fs
.
ForceAxisA
)
.
ToString
(
"0.##"
)
),
-
Cell
(PPLGridModel
.
Attribute
.
PoundsToNewtons
(fs
.
ForceAxisB
)
.
ToString
(
"0.##"
)
),
-
Cell
(PPLGridModel
.
Attribute
.
PoundsToNewtons
(fs
.
ForceVertical
)
.
ToString
(
"0.##"
)
)
)
;
-
}
-
}
-
else
-
{
-
AddRow
(Cell
(
"Height (ft)"
), Cell
(
"Force A (lbs)"
), Cell
(
"Force B (lbs)"
), Cell
(
"Force V (lbs)"
)
)
;
-
foreach
(ForceSummary fs
in loads
)
-
{
-
AddRow
(
-
Cell
(PPLGridModel
.
Attribute
.
InchesToFeet
(fs
.
cHeightOfForceApplicationAboveGLinInches
)
.
ToString
(
"0.##"
)
),
-
Cell
(fs
.
ForceAxisA
.
ToString
(
"0.##"
)
),
-
Cell
(fs
.
ForceAxisB
.
ToString
(
"0.##"
)
),
-
Cell
(fs
.
ForceVertical
.
ToString
(
"0.##"
)
)
)
;
-
}
-
}
-
-
cCurrentTable
.
BottomPadding
= MD
.
Unit
.
FromInch
(
0.03
)
;
-
cCurrentTable
.
TopPadding
= MD
.
Unit
.
FromInch
(
0.03
)
;
-
-
FinalizeTable
(
)
;
-
cDocument
.
LastSection
.
AddParagraph
(
"\n"
)
;
-
-
}
-
-
public
override MigraDoc
.
DocumentObjectModel
.
Document GetReport
(
)
-
{
-
System.Diagnostics
.
Debug
.
Assert
(Type
== REPORT_TYPE
.
INTEGRATED
|| Type
== REPORT_TYPE
.
BULK_SUMMARY
)
;
-
return cDocument
;
-
}
-
-
//display standalone report
-
public
override
void ShowReport
(PPLMain pPPLMain, PPLPole pPole
)
-
{
-
System.Diagnostics
.
Debug
.
Assert
(Type
== REPORT_TYPE
.
STANDALONE
)
;
-
throw
new NotImplementedException
(
"Report is not REPORT_TYPE.STANDALONE"
)
;
-
}
-
-
//housekeeping
-
public
override
void Reset
(
)
-
{
-
cPPLMain
=
null
;
-
cDocument
=
null
;
-
}
-
-
-
-
private
int cIndentStore
=
0
;
-
private
int cIndent
-
{
-
set
-
{
-
cIndentStore
= Math
.
Max
(
0,
value
)
;
-
}
-
get
-
{
-
return cIndentStore
;
-
}
-
}
-
-
private
String Indent
(
)
-
{
-
return
new
String
(
'\xA0', cIndentStore
*
3
)
;
-
}
-
-
}
-
}