-
Notifications
You must be signed in to change notification settings - Fork 0
/
DGVPrinter.cs
3881 lines (3357 loc) · 156 KB
/
DGVPrinter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.IO;
using System.Diagnostics;
//[module:CLSCompliant(true)]
namespace DGVPrinterHelper //AllocationRequest
{
#region Supporting Classes
/// <summary>
/// Setup and implements logs for internal logging
/// </summary>
class LogManager
{
/// <summary>
/// Path to log file
/// </summary>
private String basepath;
public String BasePath
{
get { return basepath; }
set { basepath = value; }
}
/// <summary>
/// Header for log file name
/// </summary>
private String logheader;
public String LogNameHeader
{
get { return logheader; }
set { logheader = value; }
}
private int useFrame = 1;
/// <summary>
/// Define logging message categories
/// </summary>
public enum Categories
{
Info = 1,
Warning,
Error,
Exception
}
/// <summary>
/// Constructor, allow user to override path and name of logging file
/// </summary>
/// <param name="userbasepath"></param>
/// <param name="userlogname"></param>
public LogManager(String userbasepath, String userlogname)
{
BasePath = String.IsNullOrEmpty(userbasepath) ? "." : userbasepath;
LogNameHeader = String.IsNullOrEmpty(userlogname) ? "MsgLog" : userlogname;
Log(Categories.Info, "********************* New Trace *********************");
}
/// <summary>
/// Log a message, using the provided category
/// </summary>
/// <param name="category"></param>
/// <param name="msg"></param>
public void Log(Categories category, String msg)
{
// get call stack
StackTrace stackTrace = new StackTrace();
// get calling method name
String caller = stackTrace.GetFrame(useFrame).GetMethod().Name;
// log it
LogWriter.Write(caller, category, msg, BasePath, LogNameHeader);
// reset frame pointer
useFrame = 1;
}
/// <summary>
/// Log an informational message
/// </summary>
/// <param name="msg"></param>
public void LogInfoMsg(String msg)
{
useFrame++; // bump up the stack frame pointer to skip this entry
Log(Categories.Info, msg);
}
/// <summary>
/// Log an error message
/// </summary>
/// <param name="msg"></param>
public void LogErrorMsg(String msg)
{
useFrame++; // bump up the stack frame pointer to skip this entry
Log(Categories.Error, msg);
}
/// <summary>
/// Log an exception
/// </summary>
/// <param name="ex"></param>
public void Log(Exception ex)
{
useFrame++; // bump up the stack frame pointer to skip this entry
Log(Categories.Exception, String.Format("{0} from {1}", ex.Message, ex.Source));
}
}
/// <summary>
/// Do the actual log writing using setup info in Log Manager class
/// </summary>
class LogWriter
{
/// <summary>
/// Create standard log file name with "our" name format
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
private static String LogFileName(String name)
{
return String.Format("{0}_{1:yyyyMMdd}.Log", name, DateTime.Now);
}
/// <summary>
/// Write the log entry to the file. Note that the log file is always flushed and closed. This
/// will impact performance, but ensures that messages aren't lost
/// </summary>
/// <param name="from"></param>
/// <param name="category"></param>
/// <param name="msg"></param>
/// <param name="path"></param>
/// <param name="name"></param>
public static void Write(String from, LogManager.Categories category, String msg, String path, String name)
{
StringBuilder line = new StringBuilder();
line.Append(DateTime.Now.ToShortDateString().ToString());
line.Append("-");
line.Append(DateTime.Now.ToLongTimeString().ToString());
line.Append(", ");
line.Append(category.ToString().PadRight(6, ' '));
line.Append(",");
line.Append(from.PadRight(13, ' '));
line.Append(",");
line.Append(msg);
StreamWriter w = new StreamWriter(path + "\\" + LogFileName(name), true);
w.WriteLine(line.ToString());
w.Flush();
w.Close();
}
}
/// <summary>
/// Class for the ownerdraw event. Provide the caller with the cell data, the current
/// graphics context and the location in which to draw the cell.
/// </summary>
public class DGVCellDrawingEventArgs : EventArgs
{
public Graphics g;
public RectangleF DrawingBounds;
public DataGridViewCellStyle CellStyle;
public int row;
public int column;
public Boolean Handled;
public DGVCellDrawingEventArgs(Graphics g, RectangleF bounds, DataGridViewCellStyle style,
int row, int column)
: base()
{
this.g = g;
DrawingBounds = bounds;
CellStyle = style;
this.row = row;
this.column = column;
Handled = false;
}
}
/// <summary>
/// Delegate for ownerdraw cells - allow the caller to provide drawing for the cell
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public delegate void CellOwnerDrawEventHandler(object sender, DGVCellDrawingEventArgs e);
/// <summary>
/// Hold Extension methods
/// </summary>
public static class Extensions
{
/// <summary>
/// Extension method to print all the "ImbeddedImages" in a provided list
/// </summary>
/// <typeparam name="?"></typeparam>
/// <param name="list"></param>
/// <param name="g"></param>
/// <param name="pagewidth"></param>
/// <param name="pageheight"></param>
/// <param name="margins"></param>
public static void DrawImbeddedImage<T>(this IEnumerable<T> list,
Graphics g, int pagewidth, int pageheight, Margins margins)
{
foreach (T t in list)
{
if (t is DGVPrinter.ImbeddedImage)
{
DGVPrinter.ImbeddedImage ii = (DGVPrinter.ImbeddedImage)Convert.ChangeType(t, typeof(DGVPrinter.ImbeddedImage));
// Fix - DrawImageUnscaled was actually scaling the images!!?! Oh well...
//g.DrawImageUnscaled(ii.theImage, ii.upperleft(pagewidth, pageheight, margins));
g.DrawImage(ii.theImage,
new Rectangle(ii.upperleft(pagewidth, pageheight, margins),
new Size(ii.theImage.Width, ii.theImage.Height)));
}
}
}
}
#endregion
/// <summary>
/// Data Grid View Printer. Print functions for a datagridview, since MS
/// didn't see fit to do it.
/// </summary>
public class DGVPrinter
{
public enum Alignment { NotSet, Left, Right, Center }
public enum Location { Header, Footer, Absolute }
public enum SizeType { CellSize, StringSize, Porportional }
public enum PrintLocation { All, FirstOnly, LastOnly, None }
//---------------------------------------------------------------------
// internal classes/structs
//---------------------------------------------------------------------
#region Internal Classes
// Identify the reason for a new page when tracking rows
enum paging { keepgoing, outofroom, datachange };
// Allow the user to provide images that will be printed as either logos in the
// header and/or footer or watermarked as in printed behind the text.
public class ImbeddedImage
{
public Image theImage { get; set; }
public Alignment ImageAlignment { get; set; }
public Location ImageLocation { get; set; }
public Int32 ImageX { get; set; }
public Int32 ImageY { get; set; }
internal Point upperleft(int pagewidth, int pageheight, Margins margins)
{
int y = 0;
int x = 0;
// if we've been given an absolute location, just use it
if (ImageLocation == Location.Absolute)
return new Point(ImageX, ImageY);
// set the y location based on header or footer
switch (ImageLocation)
{
case Location.Header:
y = margins.Top;
break;
case Location.Footer:
y = pageheight - theImage.Height - margins.Bottom;
break;
default:
throw new ArgumentException(String.Format("Unkown value: {0}", ImageLocation));
}
// set the x location based on left,right,center
switch (ImageAlignment)
{
case Alignment.Left:
x = margins.Left;
break;
case Alignment.Center:
x = (int)(pagewidth / 2 - theImage.Width / 2) + margins.Left;
break;
case Alignment.Right:
x = (int)(pagewidth - theImage.Width) + margins.Left;
break;
case Alignment.NotSet:
x = ImageX;
break;
default:
throw new ArgumentException(String.Format("Unkown value: {0}", ImageAlignment));
}
return new Point(x, y);
}
}
public IList<ImbeddedImage> ImbeddedImageList = new List<ImbeddedImage>();
// handle wide-column printing - that is, lists of columns that extend
// wider than one page width. Columns are broken up into "Page Sets" that
// are printed one after another until all columns are printed.
class PageDef
{
public PageDef(Margins m, int count, int pagewidth)
{
columnindex = new List<int>(count);
colstoprint = new List<object>(count);
colwidths = new List<float>(count);
colwidthsoverride = new List<float>(count);
coltotalwidth = 0;
margins = (Margins)m.Clone();
pageWidth = pagewidth;
}
public List<int> columnindex;
public List<object> colstoprint;
public List<float> colwidths;
public List<float> colwidthsoverride;
public float coltotalwidth;
public Margins margins;
private int pageWidth;
public int printWidth
{
get { return pageWidth - margins.Left - margins.Right; }
}
}
IList<PageDef> pagesets;
int currentpageset = 0;
// class to hold settings for the PrintDialog presented to the user during
// the print process
public class PrintDialogSettingsClass
{
public bool AllowSelection = true;
public bool AllowSomePages = true;
public bool AllowCurrentPage = true;
public bool AllowPrintToFile = false;
public bool ShowHelp = true;
public bool ShowNetwork = true;
public bool UseEXDialog = true;
}
// class to identify row data for printing
public class rowdata
{
public DataGridViewRow row = null;
public float height = 0;
public bool pagebreak = false;
public bool splitrow = false;
}
#endregion
//---------------------------------------------------------------------
// global variables
//---------------------------------------------------------------------
#region global variables
// the data grid view we're printing
DataGridView dgv = null;
// print document
PrintDocument printDoc = null;
// logging
LogManager Logger = null;
// print status items
Boolean EmbeddedPrinting = false;
List<rowdata> rowstoprint;
IList colstoprint; // divided into pagesets for printing
int lastrowprinted = -1;
int currentrow = -1;
int fromPage = 0;
int toPage = -1;
const int maxPages = 2147483647;
// page formatting options
int pageHeight = 0;
float staticheight = 0;
float rowstartlocation = 0;
int pageWidth = 0;
int printWidth = 0;
float rowheaderwidth = 0;
int CurrentPage = 0;
int totalpages;
PrintRange printRange;
// calculated values
//private float headerHeight = 0;
private float footerHeight = 0;
private float pagenumberHeight = 0;
private float colheaderheight = 0;
//private List<float> rowheights;
private List<float> colwidths;
//private List<List<SizeF>> cellsizes;
#endregion
//---------------------------------------------------------------------
// properties - settable by user
//---------------------------------------------------------------------
#region properties
#region global properties
/// <summary>
/// Enable logging of of the print process. Default is to log to a file named
/// 'DGVPrinter_yyyymmdd.Log' in the current directory. Since logging may have
/// an impact on performance, it should be used for troubleshooting purposes only.
/// </summary>
protected Boolean enablelogging;
public Boolean EnableLogging
{
get { return enablelogging; }
set
{
enablelogging = value;
if (enablelogging)
{
Logger = new LogManager(".", "DGVPrinter");
}
}
}
/// <summary>
/// Allow the user to change the logging directory. Setting this enables logging by default.
/// </summary>
public String LogDirectory
{
get
{
if (null != Logger)
return Logger.BasePath;
else
return null;
}
set
{
if (null == Logger)
EnableLogging = true;
Logger.BasePath = value;
}
}
/// <summary>
/// OwnerDraw Event declaration. Callers can subscribe to this event to override the
/// cell drawing.
/// </summary>
public event CellOwnerDrawEventHandler OwnerDraw;
/// <summary>
/// provide an override for the print preview dialog "owner" field
/// Note: Changed style for VS2005 compatibility
/// </summary>
//public Form Owner
//{ get; set; }
protected Form _Owner = null;
public Form Owner
{
get { return _Owner; }
set { _Owner = value; }
}
/// <summary>
/// provide an override for the print preview zoom setting
/// Note: Changed style for VS2005 compatibility
/// </summary>
//public Double PrintPreviewZoom
//{ get; set; }
protected Double _PrintPreviewZoom = 1.0;
public Double PrintPreviewZoom
{
get { return _PrintPreviewZoom; }
set { _PrintPreviewZoom = value; }
}
/// <summary>
/// expose printer settings to allow access to calling program
/// </summary>
public PrinterSettings PrintSettings
{
get { return printDoc.PrinterSettings; }
}
/// <summary>
/// expose settings for the PrintDialog displayed to the user
/// </summary>
private PrintDialogSettingsClass printDialogSettings = new PrintDialogSettingsClass();
public PrintDialogSettingsClass PrintDialogSettings
{
get { return printDialogSettings; }
}
/// <summary>
/// Set Printer Name
/// </summary>
private String printerName;
public String PrinterName
{
get { return printerName; }
set { printerName = value; }
}
/// <summary>
/// Allow access to the underlying print document
/// </summary>
public PrintDocument printDocument
{
get { return printDoc; }
set { printDoc = value; }
}
/// <summary>
/// Allow caller to set the upper-left corner icon used
/// in the print preview dialog
/// </summary>
private Icon ppvIcon = null;
public Icon PreviewDialogIcon
{
get { return ppvIcon; }
set { ppvIcon = value; }
}
/// <summary>
/// Allow caller to set print preview dialog
/// </summary>
private PrintPreviewDialog previewdialog = null;
public PrintPreviewDialog PreviewDialog
{
get { return previewdialog; }
set { previewdialog = value; }
}
/// <summary>
/// Flag to control whether or not we print the Page Header
/// </summary>
private Boolean printHeader = true;
public Boolean PrintHeader
{
get { return printHeader; }
set { printHeader = value; }
}
/// <summary>
/// Determine the height of the header
/// </summary>
private float HeaderHeight
{
get
{
float headerheight = 0;
// Add in title and subtitle heights - this is sensitive to
// wether or not titles are printed on the current page
// TitleHeight and SubTitleHeight have their respective spacing
// already included
headerheight += TitleHeight+ SubTitleHeight;
// Add in column header heights
if ((bool)PrintColumnHeaders)
{
headerheight += colheaderheight;
}
// return calculated height
return headerheight;
}
}
/// <summary>
/// Flag to control whether or not we print the Page Footer
/// </summary>
private Boolean printFooter = true;
public Boolean PrintFooter
{
get { return printFooter; }
set { printFooter = value; }
}
/// <summary>
/// Flag to control whether or not we print the Column Header line
/// </summary>
private Boolean? printColumnHeaders;
public Boolean? PrintColumnHeaders
{
get { return printColumnHeaders; }
set { printColumnHeaders = value; }
}
/// <summary>
/// Flag to control whether or not we print the Column Header line
/// Defaults to False to match previous functionality
/// </summary>
private Boolean? printRowHeaders = false;
public Boolean? PrintRowHeaders
{
get { return printRowHeaders; }
set { printRowHeaders = value; }
}
/// <summary>
/// Flag to control whether rows are printed whole or if partial
/// rows should be printed to fill the bottom of the page. Turn this
/// "Off" (i.e. false) to print cells/rows deeper than one page
/// </summary>
private Boolean keepRowsTogether = true;
public Boolean KeepRowsTogether
{
get { return keepRowsTogether; }
set { keepRowsTogether = value; }
}
/// <summary>
/// How much of a row must show on the current page before it is
/// split when KeepRowsTogether is set to true.
/// </summary>
private float keeprowstogethertolerance = 15;
public float KeepRowsTogetherTolerance
{
get { return keeprowstogethertolerance; }
set { keeprowstogethertolerance = value; }
}
#endregion
// Title
#region title properties
// override flag
bool overridetitleformat = false;
// formatted height of title
float titleheight = 0;
/// <summary>
/// Title for this report. Default is empty.
/// </summary>
private String title;
public String Title
{
get { return title; }
set
{
title = value;
if (docName == null)
{
printDoc.DocumentName = value;
}
}
}
/// <summary>
/// Name of the document. Default is report title (can be empty)
/// </summary>
private String docName;
public String DocName
{
get { return docName; }
set { printDoc.DocumentName = value; docName = value; }
}
/// <summary>
/// Font for the title. Default is Tahoma, 18pt.
/// </summary>
private Font titlefont;
public Font TitleFont
{
get { return titlefont; }
set { titlefont = value; }
}
/// <summary>
/// Foreground color for the title. Default is Black
/// </summary>
private Color titlecolor;
public Color TitleColor
{
get { return titlecolor; }
set { titlecolor = value; }
}
/// <summary>
/// Allow override of the header cell format object
/// </summary>
private StringFormat titleformat;
public StringFormat TitleFormat
{
get { return titleformat; }
set { titleformat = value; overridetitleformat = true; }
}
/// <summary>
/// Allow the user to override the title string alignment. Default value is
/// Alignment - Near;
/// </summary>
public StringAlignment TitleAlignment
{
get { return titleformat.Alignment; }
set
{
titleformat.Alignment = value;
overridetitleformat = true;
}
}
/// <summary>
/// Allow the user to override the title string format flags. Default values
/// are: FormatFlags - NoWrap, LineLimit, NoClip
/// </summary>
public StringFormatFlags TitleFormatFlags
{
get { return titleformat.FormatFlags; }
set
{
titleformat.FormatFlags = value;
overridetitleformat = true;
}
}
/// <summary>
/// Control where in the document the title prints
/// </summary>
private PrintLocation titleprint = PrintLocation.All;
public PrintLocation TitlePrint
{
get { return titleprint; }
set { titleprint = value; }
}
/// <summary>
/// Return the title height based whether to print it or not
/// </summary>
private float TitleHeight
{
get
{
if (PrintLocation.All == TitlePrint)
return titleheight + titlespacing;
if ((PrintLocation.FirstOnly == TitlePrint) && (1 == CurrentPage))
return titleheight + titlespacing;
if ((PrintLocation.LastOnly == TitlePrint) && (totalpages == CurrentPage))
return titleheight + titlespacing;
return 0;
}
}
/// <summary>
/// Mandatory spacing between the grid and the footer
/// </summary>
private float titlespacing;
public float TitleSpacing
{
get { return titlespacing; }
set { titlespacing = value; }
}
/// <summary>
/// Title Block Background Color
/// </summary>
private Brush titlebackground;
public Brush TitleBackground
{
get { return titlebackground; }
set { titlebackground = value; }
}
/// <summary>
/// Title Block Border
/// </summary>
private Pen titleborder;
public Pen TitleBorder
{
get { return titleborder; }
set { titleborder = value; }
}
#endregion
// SubTitle
#region subtitle properties
// override flat
bool overridesubtitleformat = false;
// formatted height of subtitle
float subtitleheight = 0;
/// <summary>
/// SubTitle for this report. Default is empty.
/// </summary>
private String subtitle;
public String SubTitle
{
get { return subtitle; }
set { subtitle = value; }
}
/// <summary>
/// Font for the subtitle. Default is Tahoma, 12pt.
/// </summary>
private Font subtitlefont;
public Font SubTitleFont
{
get { return subtitlefont; }
set { subtitlefont = value; }
}
/// <summary>
/// Foreground color for the subtitle. Default is Black
/// </summary>
private Color subtitlecolor;
public Color SubTitleColor
{
get { return subtitlecolor; }
set { subtitlecolor = value; }
}
/// <summary>
/// Allow override of the header cell format object
/// </summary>
private StringFormat subtitleformat;
public StringFormat SubTitleFormat
{
get { return subtitleformat; }
set { subtitleformat = value; overridesubtitleformat = true; }
}
/// <summary>
/// Allow the user to override the subtitle string alignment. Default value is
/// Alignment - Near;
/// </summary>
public StringAlignment SubTitleAlignment
{
get { return subtitleformat.Alignment; }
set
{
subtitleformat.Alignment = value;
overridesubtitleformat = true;
}
}
/// <summary>
/// Allow the user to override the subtitle string format flags. Default values
/// are: FormatFlags - NoWrap, LineLimit, NoClip
/// </summary>
public StringFormatFlags SubTitleFormatFlags
{
get { return subtitleformat.FormatFlags; }
set
{
subtitleformat.FormatFlags = value;
overridesubtitleformat = true;
}
}
/// <summary>
/// Control where in the document the title prints
/// </summary>
private PrintLocation subtitleprint = PrintLocation.All;
public PrintLocation SubTitlePrint
{
get { return subtitleprint; }
set { subtitleprint = value; }
}
/// <summary>
/// Return the title height based whether to print it or not
/// </summary>
private float SubTitleHeight
{
get
{
if (PrintLocation.All == SubTitlePrint)
return subtitleheight + subtitlespacing;
if ((PrintLocation.FirstOnly == SubTitlePrint) && (1 == CurrentPage))
return subtitleheight + subtitlespacing;
if ((PrintLocation.LastOnly == SubTitlePrint) && (totalpages == CurrentPage))
return subtitleheight + subtitlespacing;
return 0;
}
}
/// <summary>
/// Mandatory spacing between the grid and the footer
/// </summary>
private float subtitlespacing;
public float SubTitleSpacing
{
get { return subtitlespacing; }
set { subtitlespacing = value; }
}
/// <summary>
/// Title Block Background Color
/// </summary>
private Brush subtitlebackground;
public Brush SubTitleBackground
{
get { return subtitlebackground; }
set { subtitlebackground = value; }
}
/// <summary>
/// Title Block Border
/// </summary>
private Pen subtitleborder;
public Pen SubTitleBorder
{
get { return subtitleborder; }
set { subtitleborder = value; }
}
#endregion
// Footer
#region footer properties
// override flag
bool overridefooterformat = false;
/// <summary>
/// footer for this report. Default is empty.
/// </summary>
private String footer;
public String Footer
{
get { return footer; }
set { footer = value; }
}
/// <summary>
/// Font for the footer. Default is Tahoma, 10pt.
/// </summary>
private Font footerfont;
public Font FooterFont
{
get { return footerfont; }
set { footerfont = value; }
}
/// <summary>
/// Foreground color for the footer. Default is Black
/// </summary>
private Color footercolor;
public Color FooterColor
{
get { return footercolor; }
set { footercolor = value; }
}
/// <summary>
/// Allow override of the header cell format object
/// </summary>
private StringFormat footerformat;
public StringFormat FooterFormat
{
get { return footerformat; }
set { footerformat = value; overridefooterformat = true; }
}
/// <summary>
/// Allow the user to override the footer string alignment. Default value is
/// Alignment - Center;
/// </summary>
public StringAlignment FooterAlignment
{
get { return footerformat.Alignment; }
set
{
footerformat.Alignment = value;
overridefooterformat = true;
}
}
/// <summary>
/// Allow the user to override the footer string format flags. Default values
/// are: FormatFlags - NoWrap, LineLimit, NoClip
/// </summary>
public StringFormatFlags FooterFormatFlags
{
get { return footerformat.FormatFlags; }