1 | using System;
|
---|
2 | using System.Drawing.Printing;
|
---|
3 | using System.Drawing;
|
---|
4 | using System.Text;
|
---|
5 | using System.Drawing.Drawing2D;
|
---|
6 | using System.Linq;
|
---|
7 | using System.Data;
|
---|
8 |
|
---|
9 | namespace IndianHealthService.ClinicalScheduling
|
---|
10 | {
|
---|
11 | public class Printing
|
---|
12 | {
|
---|
13 | /// <summary>
|
---|
14 | /// Print Appointments
|
---|
15 | /// </summary>
|
---|
16 | /// <param name="ds">Strongly Typed DataSet contains Resources and Appointments</param>
|
---|
17 | /// <param name="e">PrintPageEventArgs from PrintDocument Print handler</param>
|
---|
18 | /// <param name="beg">Begin Datetime to print appointments</param>
|
---|
19 | /// <param name="end">End Datetime to print appointments</param
|
---|
20 | /// <param name="resourceToPrint">The resouce to print</param>
|
---|
21 | /// <param name="apptPrinting">Current Appointment printing</param>
|
---|
22 | /// <param name="pageNumber">Current page number</param>
|
---|
23 | /// <remarks>beg and end have no effect on operation--they are there for documentation for user only</remarks>
|
---|
24 | public virtual void PrintAppointments(dsPatientApptDisplay2 ds, PrintPageEventArgs e, DateTime beg, DateTime end, int resourceToPrint, ref int apptPrinting, int pageNumber)
|
---|
25 | {
|
---|
26 | Graphics g = e.Graphics;
|
---|
27 | //g.PageUnit = GraphicsUnit.Millimeter;
|
---|
28 | //SizeF szVCB = g.VisibleClipBounds.Size;
|
---|
29 | //PointF[] ptszVCB = {new PointF(szVCB.Width,szVCB.Height)};
|
---|
30 | //g.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Device, ptszVCB);
|
---|
31 | //Create Fonts
|
---|
32 | Font f8 = new Font(FontFamily.GenericSerif, 8);
|
---|
33 | Font f10 = new Font(FontFamily.GenericSerif, 10);
|
---|
34 | Font f14bold = new Font(FontFamily.GenericSerif, 14, FontStyle.Bold);
|
---|
35 |
|
---|
36 | //Center Alignment for some stuff
|
---|
37 | StringFormat sf = new StringFormat();
|
---|
38 | sf.Alignment = StringAlignment.Center;
|
---|
39 |
|
---|
40 | //Header
|
---|
41 | g.DrawString("Confidential Patient Information", f8, Brushes.Black, e.PageBounds, sf);
|
---|
42 |
|
---|
43 | //Footer
|
---|
44 | sf.Alignment = StringAlignment.Center;
|
---|
45 | sf.LineAlignment = StringAlignment.Far;
|
---|
46 | g.DrawString("Page " + pageNumber, f8, Brushes.Black, e.PageBounds, sf);
|
---|
47 |
|
---|
48 | //Typical manipulable print area
|
---|
49 | Rectangle printArea = e.MarginBounds;
|
---|
50 |
|
---|
51 | //resource we want to print
|
---|
52 | dsPatientApptDisplay2.BSDXResourceRow r = ds.BSDXResource[resourceToPrint];
|
---|
53 |
|
---|
54 | //header
|
---|
55 | string toprint;
|
---|
56 | if (beg == end) toprint = "Appointments for " + r.RESOURCE_NAME + " on " + beg.ToLongDateString();
|
---|
57 | else toprint = "Appointments for " + r.RESOURCE_NAME + " from " + beg.ToShortDateString() + " to "
|
---|
58 | + end.ToShortDateString();
|
---|
59 | g.DrawString(toprint, f14bold, Brushes.Black, printArea);
|
---|
60 |
|
---|
61 | //Move print area down
|
---|
62 | printArea.Height -= (int)f14bold.GetHeight();
|
---|
63 | printArea.Y += (int)f14bold.GetHeight();
|
---|
64 |
|
---|
65 | //Draw Line
|
---|
66 | g.DrawLine(new Pen(Brushes.Black, 0), printArea.X, printArea.Y, printArea.X + printArea.Width, printArea.Y);
|
---|
67 |
|
---|
68 | //Move print area down
|
---|
69 | printArea.Y += 5;
|
---|
70 | printArea.Height -= 5;
|
---|
71 |
|
---|
72 | System.Data.DataRow[] appts = r.GetChildRows(ds.Relations[0]); //ds has only one relation
|
---|
73 |
|
---|
74 | StringFormat sf2 = new StringFormat(); //sf to hold tab stops
|
---|
75 | sf2.SetTabStops(50, new float[] { 100, 250, 25 });
|
---|
76 |
|
---|
77 | //appt printed starts at zero
|
---|
78 | while (apptPrinting < appts.Length)
|
---|
79 | {
|
---|
80 | dsPatientApptDisplay2.PatientApptsRow a = (dsPatientApptDisplay2.PatientApptsRow)appts[apptPrinting];
|
---|
81 |
|
---|
82 | StringBuilder apptPrintStr = new StringBuilder(200);
|
---|
83 | apptPrintStr.AppendLine(a.ApptDate.ToString() + "\t" + a.Name + " (" + a.Sex + ")" + "\t" + "DOB: " + a.DOB.ToShortDateString() + "\t" + "ID: " + a.HRN);
|
---|
84 | apptPrintStr.AppendLine("P: " + a.HOMEPHONE + "\t" + "Address: " + a.STREET + ", " + a.CITY + ", " + a.STATE + " " + a.ZIP);
|
---|
85 | apptPrintStr.AppendLine("Note: " + a.NOTE);
|
---|
86 | apptPrintStr.AppendLine("Appointment made by " + a.APPT_MADE_BY + " on " + a.DATE_APPT_MADE);
|
---|
87 |
|
---|
88 | int printedApptHeight = (int)g.MeasureString(apptPrintStr.ToString(), f10, printArea.Width).Height;
|
---|
89 | if (printedApptHeight > printArea.Height) // too much to print -- move to next page
|
---|
90 | // but don't increment the appointment to print since we haven't printed it yet.
|
---|
91 | // i.e. apptPrinting stays the same.
|
---|
92 | {
|
---|
93 | e.HasMorePages = true;
|
---|
94 | break;
|
---|
95 | }
|
---|
96 |
|
---|
97 | //otherwise print it
|
---|
98 | g.DrawString(apptPrintStr.ToString(), f10, Brushes.Black, printArea, sf2);
|
---|
99 |
|
---|
100 | //Move print area down
|
---|
101 | printArea.Y += printedApptHeight + 3;
|
---|
102 | printArea.Height -= printedApptHeight + 3;
|
---|
103 |
|
---|
104 | //Draw a divider line
|
---|
105 | Point pt1 = new Point((int)(printArea.X + printArea.Width * 0.25), printArea.Y);
|
---|
106 | Point pt2 = new Point((int)(printArea.X + printArea.Width * 0.75), printArea.Y);
|
---|
107 | g.DrawLine(Pens.Gray, pt1, pt2);
|
---|
108 |
|
---|
109 | //move down, again
|
---|
110 | printArea.Y += 3;
|
---|
111 | printArea.Height -= 3;
|
---|
112 |
|
---|
113 | //go to the next appointment
|
---|
114 | apptPrinting++;
|
---|
115 | }
|
---|
116 | }
|
---|
117 |
|
---|
118 | /// <summary>
|
---|
119 | /// Prints a single appointment slip to give to the patient
|
---|
120 | /// </summary>
|
---|
121 | /// <param name="appt">The Appointment to print</param>
|
---|
122 | /// <param name="e">PrintPageEventArgs from PrintDocument Print handler</param>
|
---|
123 | public virtual void PrintAppointmentSlip(CGAppointment appt, PrintPageEventArgs e)
|
---|
124 | {
|
---|
125 | // Prep
|
---|
126 | Graphics g = e.Graphics;
|
---|
127 | Rectangle printArea = e.MarginBounds;
|
---|
128 | Rectangle pageArea = e.PageBounds;
|
---|
129 | Rectangle headerArea = new Rectangle()
|
---|
130 | {
|
---|
131 | X = e.MarginBounds.X,
|
---|
132 | Y = e.PageBounds.Y,
|
---|
133 | Height = e.MarginBounds.Y - e.PageBounds.Y,
|
---|
134 | Width = e.MarginBounds.Width
|
---|
135 | };
|
---|
136 |
|
---|
137 | // A few fonts
|
---|
138 | Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
|
---|
139 | Font fBody = new Font(FontFamily.GenericSerif, 12);
|
---|
140 | Font fGroupTitle = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
|
---|
141 |
|
---|
142 | StringFormat sf0 = new StringFormat()
|
---|
143 | {
|
---|
144 | Alignment = StringAlignment.Center,
|
---|
145 | LineAlignment = StringAlignment.Center
|
---|
146 | };
|
---|
147 |
|
---|
148 | // Draw Header
|
---|
149 | string division = CGDocumentManager.Current.ConnectInfo.DivisionName;
|
---|
150 | g.DrawString(division, fBody, Brushes.Black, headerArea, sf0);
|
---|
151 |
|
---|
152 | // Draw Title
|
---|
153 | StringFormat sf = new StringFormat();
|
---|
154 | sf.Alignment = StringAlignment.Center; //for title & header
|
---|
155 |
|
---|
156 | string s = "Appointment Reminder Slip";
|
---|
157 | g.DrawString(s, fTitle, Brushes.Black, printArea, sf); //title
|
---|
158 |
|
---|
159 | // move down
|
---|
160 | int titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
|
---|
161 | printArea.Y += titleHeight;
|
---|
162 | printArea.Height -= titleHeight;
|
---|
163 |
|
---|
164 | // draw underline
|
---|
165 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
166 | printArea.Y += 15;
|
---|
167 | printArea.Height -= 15;
|
---|
168 |
|
---|
169 | // draw curved rectangle.
|
---|
170 | Rectangle personalInfoRectangle = new Rectangle(e.MarginBounds.X, printArea.Y + 30, 280, 300);
|
---|
171 | using (GraphicsPath path = GetRoundedRectPath(personalInfoRectangle, 10))
|
---|
172 | {
|
---|
173 | g.DrawPath(Pens.Black, path);
|
---|
174 | }
|
---|
175 |
|
---|
176 | // group header
|
---|
177 | g.DrawString("Patient Information", fGroupTitle, Brushes.Black, new Point(personalInfoRectangle.X, personalInfoRectangle.Y - 20));
|
---|
178 |
|
---|
179 | // inner rectangle for drawing strings:
|
---|
180 | Rectangle personalInfoInnerRectangle = new Rectangle(personalInfoRectangle.X + 20, personalInfoRectangle.Y + 20, 280 - 40, 300 - 40);
|
---|
181 |
|
---|
182 | // Strings to write
|
---|
183 | StringBuilder sb = new StringBuilder(500);
|
---|
184 | sb.AppendLine("Name:" + "\t" + appt.Patient.Name);
|
---|
185 | sb.AppendLine();
|
---|
186 | sb.AppendLine("ID#:" + "\t" + appt.Patient.ID);
|
---|
187 | sb.AppendLine();
|
---|
188 | sb.AppendLine("DOB:" + "\t" + appt.Patient.DOB.ToShortDateString());
|
---|
189 | sb.AppendLine();
|
---|
190 | sb.AppendLine("Age:" + "\t" + appt.Patient.UserFriendlyAge);
|
---|
191 | sb.AppendLine();
|
---|
192 | sb.AppendLine("Sex:" + "\t" + appt.Patient.Sex.ToString());
|
---|
193 |
|
---|
194 | // Draw them
|
---|
195 | g.DrawString(sb.ToString(), fBody, Brushes.Black, personalInfoInnerRectangle);
|
---|
196 |
|
---|
197 | // draw curved rectangle
|
---|
198 | Rectangle apptInfoRectangle = new Rectangle(e.MarginBounds.X + e.MarginBounds.Width - 280, printArea.Y + 30, 280, 300);
|
---|
199 | using (GraphicsPath path = GetRoundedRectPath(apptInfoRectangle, 10))
|
---|
200 | {
|
---|
201 | g.DrawPath(Pens.Black, path);
|
---|
202 | }
|
---|
203 |
|
---|
204 | // group header
|
---|
205 | g.DrawString("Appointment Information", fGroupTitle, Brushes.Black, new Point(apptInfoRectangle.X, apptInfoRectangle.Y - 20));
|
---|
206 |
|
---|
207 | // Strings to write
|
---|
208 | sb = new StringBuilder();
|
---|
209 | sb.AppendLine("Clinic: " + "\t" + appt.Resource);
|
---|
210 | sb.AppendLine();
|
---|
211 | sb.AppendLine("Date: " + "\t" + appt.StartTime.ToShortDateString());
|
---|
212 | sb.AppendLine();
|
---|
213 | sb.AppendLine("Day: " + "\t" + appt.StartTime.DayOfWeek.ToString());
|
---|
214 | sb.AppendLine();
|
---|
215 | sb.AppendLine("Time: " + "\t" + appt.StartTime.ToShortTimeString());
|
---|
216 |
|
---|
217 | // Draw them
|
---|
218 | Rectangle apptInfoInnerRectangle = new Rectangle(apptInfoRectangle.X + 20, apptInfoRectangle.Y + 20, 280 - 40, 300 - 40);
|
---|
219 |
|
---|
220 | // Draw them
|
---|
221 | g.DrawString(sb.ToString(), fBody, Brushes.Black, apptInfoInnerRectangle);
|
---|
222 |
|
---|
223 | // Move Drawing Rectangle Down
|
---|
224 | printArea.Y += 300 + 30 + 20;
|
---|
225 | printArea.Height -= 300 + 30 + 20;
|
---|
226 |
|
---|
227 | // Draw New Line
|
---|
228 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
229 | printArea.Y += 5;
|
---|
230 | printArea.Height -= 5;
|
---|
231 |
|
---|
232 | // Draw new Title
|
---|
233 | s = "Clinic Instructions";
|
---|
234 | g.DrawString(s, fTitle, Brushes.Black, printArea, sf); //title
|
---|
235 |
|
---|
236 | // move down
|
---|
237 | titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
|
---|
238 | printArea.Y += titleHeight;
|
---|
239 | printArea.Height -= titleHeight;
|
---|
240 |
|
---|
241 | // Draw New Line
|
---|
242 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
243 | printArea.Y += 15;
|
---|
244 | printArea.Height -= 15;
|
---|
245 |
|
---|
246 | // Get Resource Clinic Appointment Letter Text
|
---|
247 | DataTable resources = CGDocumentManager.Current.GlobalDataSet.Tables["Resources"];
|
---|
248 |
|
---|
249 | string ltrTxt = (from resource in resources.AsEnumerable()
|
---|
250 | where resource.Field<string>("RESOURCE_NAME") == appt.Resource
|
---|
251 | select resource.Field<string>("LETTER_TEXT")).SingleOrDefault<string>();
|
---|
252 |
|
---|
253 | if (String.IsNullOrWhiteSpace(ltrTxt)) ltrTxt = "(no instructions provided)";
|
---|
254 |
|
---|
255 | g.DrawString(ltrTxt, fBody, Brushes.Black, printArea);
|
---|
256 |
|
---|
257 | int ltrTxtHeight = (int)g.MeasureString(ltrTxt, fBody).Height;
|
---|
258 |
|
---|
259 | printArea.Y += ltrTxtHeight + 15;
|
---|
260 | printArea.Height -= ltrTxtHeight + 15;
|
---|
261 |
|
---|
262 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
263 | printArea.Y += 5;
|
---|
264 | printArea.Height -= 5;
|
---|
265 |
|
---|
266 | s = "Notes";
|
---|
267 | g.DrawString(s, fTitle, Brushes.Black, printArea, sf); // Notes title
|
---|
268 |
|
---|
269 | // move down
|
---|
270 | titleHeight = (int)g.MeasureString(s, fTitle, printArea.Width).Height;
|
---|
271 | printArea.Y += titleHeight;
|
---|
272 | printArea.Height -= titleHeight;
|
---|
273 |
|
---|
274 | // Draw New Line
|
---|
275 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
276 | printArea.Y += 15;
|
---|
277 | printArea.Height -= 15;
|
---|
278 |
|
---|
279 | // Draw Notes Area
|
---|
280 | using (GraphicsPath path = GetRoundedRectPath(printArea, 15))
|
---|
281 | {
|
---|
282 | g.DrawPath(Pens.Black, path);
|
---|
283 | }
|
---|
284 |
|
---|
285 | // Draw Footer
|
---|
286 | // Get footer rectangle
|
---|
287 | Rectangle footerArea = new Rectangle()
|
---|
288 | {
|
---|
289 | X = e.MarginBounds.X,
|
---|
290 | Y = e.MarginBounds.Height + headerArea.Height,
|
---|
291 | Width = e.MarginBounds.Width,
|
---|
292 | Height = pageArea.Height - (e.MarginBounds.Height + headerArea.Height)
|
---|
293 | };
|
---|
294 |
|
---|
295 | //use sf0 to print the footer (center all the way)
|
---|
296 | s = "Printed: " + DateTime.Now.ToString();
|
---|
297 | Font fFooter = new Font(FontFamily.GenericSerif, 7);
|
---|
298 | g.DrawString(s, fFooter, Brushes.Black, footerArea, sf0);
|
---|
299 |
|
---|
300 | }
|
---|
301 |
|
---|
302 |
|
---|
303 | private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
|
---|
304 | {
|
---|
305 | int diameter = 2 * radius;
|
---|
306 |
|
---|
307 | Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
|
---|
308 | GraphicsPath path = new GraphicsPath();
|
---|
309 |
|
---|
310 | path.AddArc(arcRect, 180, 90); //top left
|
---|
311 | arcRect.X = rect.Right - diameter;
|
---|
312 | path.AddArc(arcRect, 270, 90); // top right
|
---|
313 | arcRect.Y = rect.Bottom - diameter;
|
---|
314 | path.AddArc(arcRect, 0, 90); // bottom right
|
---|
315 | arcRect.X = rect.Left;
|
---|
316 | path.AddArc(arcRect, 90, 90); // bottom left
|
---|
317 |
|
---|
318 | path.CloseFigure();
|
---|
319 |
|
---|
320 | return path;
|
---|
321 | }
|
---|
322 |
|
---|
323 | /// <summary>
|
---|
324 | /// Print Letter to be given or mailed to the patient
|
---|
325 | /// </summary>
|
---|
326 | /// <param name="ptrow">Strongly typed PatientApptsRow to pass (just one ApptRow)</param>
|
---|
327 | /// <param name="e">You know what that is</param>
|
---|
328 | /// <param name="letter">Contains letter string</param>
|
---|
329 | /// <param name="title">Title of the letter</param>
|
---|
330 | public virtual void PrintReminderLetter(dsPatientApptDisplay2.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
|
---|
331 | {
|
---|
332 |
|
---|
333 | Rectangle printArea = e.MarginBounds;
|
---|
334 | Graphics g = e.Graphics;
|
---|
335 | StringFormat sf = new StringFormat();
|
---|
336 | sf.Alignment = StringAlignment.Center; //for title
|
---|
337 | Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
|
---|
338 | Font fBody = new Font(FontFamily.GenericSerif, 12);
|
---|
339 | g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
|
---|
340 |
|
---|
341 | // move down
|
---|
342 | int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
|
---|
343 | printArea.Y += titleHeight;
|
---|
344 | printArea.Height -= titleHeight;
|
---|
345 |
|
---|
346 | // draw underline
|
---|
347 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
348 | printArea.Y += 15;
|
---|
349 | printArea.Height -= 15;
|
---|
350 |
|
---|
351 | // write appointment date
|
---|
352 | string str = "Appointment Date: " + ptRow.ApptDate + "\n\n";
|
---|
353 | g.DrawString(str, fBody, Brushes.Black, printArea);
|
---|
354 |
|
---|
355 | // move down
|
---|
356 | int strHeight = (int)g.MeasureString(str, fBody, printArea.Width).Height;
|
---|
357 | printArea.Y += strHeight;
|
---|
358 | printArea.Height -= strHeight;
|
---|
359 |
|
---|
360 | //Text Direction
|
---|
361 | StringFormat sf2 = new StringFormat();
|
---|
362 | if (System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft)
|
---|
363 | sf2.FormatFlags = StringFormatFlags.DirectionRightToLeft;
|
---|
364 |
|
---|
365 | // write missive
|
---|
366 | g.DrawString(letter, fBody, Brushes.Black, printArea, sf2);
|
---|
367 |
|
---|
368 | //print Address in lower left corner for windowed envolopes
|
---|
369 | printArea.Location = new Point(e.MarginBounds.X, (int)(e.PageBounds.Height * 0.66));
|
---|
370 | printArea.Height = (int)(e.MarginBounds.Height * 0.20);
|
---|
371 | sf.Alignment = StringAlignment.Near;
|
---|
372 | sf.LineAlignment = StringAlignment.Center;
|
---|
373 | StringBuilder address = new StringBuilder(100);
|
---|
374 | address.AppendLine(ptRow.Name);
|
---|
375 | address.AppendLine(ptRow.STREET);
|
---|
376 | address.AppendLine(ptRow.CITY + ", " + ptRow.STATE + " " + ptRow.ZIP);
|
---|
377 | g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf);
|
---|
378 | }
|
---|
379 |
|
---|
380 | /// <summary>
|
---|
381 | /// Cancellation Letter to be given or mailed to the patient
|
---|
382 | /// </summary>
|
---|
383 | /// <param name="ptRow">Strongly typed PatientApptsRow to pass (just one ApptRow)</param>
|
---|
384 | /// <param name="e">You know what that is</param>
|
---|
385 | /// <param name="letter">Contains letter string</param>
|
---|
386 | /// <param name="title">Title of the letter</param>
|
---|
387 | public virtual void PrintCancelLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
|
---|
388 | {
|
---|
389 | Rectangle printArea = e.MarginBounds;
|
---|
390 | Graphics g = e.Graphics;
|
---|
391 | StringFormat sf = new StringFormat();
|
---|
392 | sf.Alignment = StringAlignment.Center; //for title
|
---|
393 | Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
|
---|
394 | Font fBody = new Font(FontFamily.GenericSerif, 12);
|
---|
395 | g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
|
---|
396 |
|
---|
397 | // move down
|
---|
398 | int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
|
---|
399 | printArea.Y += titleHeight;
|
---|
400 | printArea.Height -= titleHeight;
|
---|
401 |
|
---|
402 | // draw underline
|
---|
403 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
404 | printArea.Y += 15;
|
---|
405 | printArea.Height -= 15;
|
---|
406 |
|
---|
407 | // write appointment date
|
---|
408 | string str = "Appointment Date: " + ptRow.OldApptDate + "\n\n";
|
---|
409 | g.DrawString(str, fBody, Brushes.Black, printArea);
|
---|
410 |
|
---|
411 | // move down
|
---|
412 | int strHeight = (int)g.MeasureString(str, fBody, printArea.Width).Height;
|
---|
413 | printArea.Y += strHeight;
|
---|
414 | printArea.Height -= strHeight;
|
---|
415 |
|
---|
416 | //Text Direction
|
---|
417 | StringFormat sf2 = new StringFormat();
|
---|
418 | if (System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft)
|
---|
419 | sf2.FormatFlags = StringFormatFlags.DirectionRightToLeft;
|
---|
420 |
|
---|
421 | // write missive
|
---|
422 | g.DrawString(letter, fBody, Brushes.Black, printArea, sf2);
|
---|
423 |
|
---|
424 | //print Address in lower left corner for windowed envolopes
|
---|
425 | printArea.Location = new Point(e.MarginBounds.X, (int)(e.PageBounds.Height * 0.66));
|
---|
426 | printArea.Height = (int)(e.MarginBounds.Height * 0.20);
|
---|
427 | sf.Alignment = StringAlignment.Near;
|
---|
428 | sf.LineAlignment = StringAlignment.Center;
|
---|
429 | StringBuilder address = new StringBuilder(100);
|
---|
430 | address.AppendLine(ptRow.Name);
|
---|
431 | address.AppendLine(ptRow.STREET);
|
---|
432 | address.AppendLine(ptRow.CITY + ", " + ptRow.STATE + " " + ptRow.ZIP);
|
---|
433 | g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf);
|
---|
434 | }
|
---|
435 |
|
---|
436 | /// <summary>
|
---|
437 | /// Print rebook letters. Prints old and new appointments dates then the missive.
|
---|
438 | /// </summary>
|
---|
439 | /// <param name="ptRow">Strongly typed appointment row</param>
|
---|
440 | /// <param name="e">etc</param>
|
---|
441 | /// <param name="letter">Text of the letter to print</param>
|
---|
442 | /// <param name="title">Title to print at the top of the letter</param>
|
---|
443 | public virtual void PrintRebookLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)
|
---|
444 | {
|
---|
445 | Rectangle printArea = e.MarginBounds;
|
---|
446 | Graphics g = e.Graphics;
|
---|
447 | StringFormat sf = new StringFormat();
|
---|
448 | sf.Alignment = StringAlignment.Center; //for title
|
---|
449 | Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
|
---|
450 | Font fBody = new Font(FontFamily.GenericSerif, 12);
|
---|
451 | g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
|
---|
452 |
|
---|
453 | // move down
|
---|
454 | int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
|
---|
455 | printArea.Y += titleHeight;
|
---|
456 | printArea.Height -= titleHeight;
|
---|
457 |
|
---|
458 | // draw underline
|
---|
459 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
460 | printArea.Y += 15;
|
---|
461 | printArea.Height -= 15;
|
---|
462 |
|
---|
463 | // write old and new appointment dates
|
---|
464 | string str = "Old Appointment Date:\t\t" + ptRow.OldApptDate + "\n";
|
---|
465 | str += "New Appointment Date:\t\t" + ptRow.NewApptDate + "\n\n";
|
---|
466 | g.DrawString(str, fBody, Brushes.Black, printArea);
|
---|
467 |
|
---|
468 | // move down
|
---|
469 | int strHeight = (int)g.MeasureString(str, fBody, printArea.Width).Height;
|
---|
470 | printArea.Y += strHeight;
|
---|
471 | printArea.Height -= strHeight;
|
---|
472 |
|
---|
473 | //Text Direction
|
---|
474 | StringFormat sf2 = new StringFormat();
|
---|
475 | if (System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft)
|
---|
476 | sf2.FormatFlags = StringFormatFlags.DirectionRightToLeft;
|
---|
477 |
|
---|
478 | // write missive
|
---|
479 | g.DrawString(letter, fBody, Brushes.Black, printArea, sf2);
|
---|
480 |
|
---|
481 | //print Address in lower left corner for windowed envolopes
|
---|
482 | printArea.Location = new Point(e.MarginBounds.X, (int)(e.PageBounds.Height * 0.66));
|
---|
483 | printArea.Height = (int)(e.MarginBounds.Height * 0.20);
|
---|
484 | sf.Alignment = StringAlignment.Near;
|
---|
485 | sf.LineAlignment = StringAlignment.Center;
|
---|
486 | StringBuilder address = new StringBuilder(100);
|
---|
487 | address.AppendLine(ptRow.Name);
|
---|
488 | address.AppendLine(ptRow.STREET);
|
---|
489 | address.AppendLine(ptRow.CITY + ", " + ptRow.STATE + " " + ptRow.ZIP);
|
---|
490 | g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf);
|
---|
491 |
|
---|
492 | }
|
---|
493 |
|
---|
494 | /// <summary>
|
---|
495 | /// Print message on a page; typically that there are no appointments to be found.
|
---|
496 | /// Or just a test message to verify that printing works.
|
---|
497 | /// </summary>
|
---|
498 | /// <param name="msg">The exact string to print.</param>
|
---|
499 | /// <param name="e">Print Page event args</param>
|
---|
500 | public virtual void PrintMessage(string msg, PrintPageEventArgs e)
|
---|
501 | {
|
---|
502 | e.Graphics.DrawString(msg, new Font(FontFamily.GenericSerif, 14),
|
---|
503 | Brushes.Black, e.MarginBounds);
|
---|
504 | }
|
---|
505 |
|
---|
506 | /// <summary>
|
---|
507 | /// Print Routing Slip
|
---|
508 | /// </summary>
|
---|
509 | /// <param name="a">Appointment Data Structure</param>
|
---|
510 | /// <param name="title">String to print for title</param>
|
---|
511 | /// <param name="e">etc</param>
|
---|
512 | public virtual void PrintRoutingSlip(CGAppointment a, string title, PrintPageEventArgs e)
|
---|
513 | {
|
---|
514 | Rectangle printArea = e.MarginBounds;
|
---|
515 | Graphics g = e.Graphics;
|
---|
516 | StringFormat sf = new StringFormat();
|
---|
517 | sf.Alignment = StringAlignment.Center; //for title
|
---|
518 | Font fTitle = new Font(FontFamily.GenericSerif, 24, FontStyle.Bold); //for title
|
---|
519 | Font fBody = new Font(FontFamily.GenericSerif, 18);
|
---|
520 | Font fBodyEm = new Font(FontFamily.GenericSerif, 18, FontStyle.Bold);
|
---|
521 | g.DrawString(title, fTitle, Brushes.Black, printArea, sf); //title
|
---|
522 |
|
---|
523 | // move down
|
---|
524 | int titleHeight = (int)g.MeasureString(title, fTitle, printArea.Width).Height;
|
---|
525 | printArea.Y += titleHeight;
|
---|
526 | printArea.Height -= titleHeight;
|
---|
527 |
|
---|
528 | // draw underline
|
---|
529 | g.DrawLine(Pens.Black, printArea.Location, new Point(printArea.Right, printArea.Y));
|
---|
530 |
|
---|
531 | // move down
|
---|
532 | printArea.Y += 15;
|
---|
533 | printArea.Height -= 15;
|
---|
534 |
|
---|
535 | //construct what to print
|
---|
536 | string toprint = "Patient: " + a.PatientName + "\t" + "ID: " + a.HealthRecordNumber;
|
---|
537 | toprint += "\n\n";
|
---|
538 | toprint += "Clinic: " + a.Resource;
|
---|
539 | toprint += "\n\n";
|
---|
540 | toprint += "Appointment Time: " + a.StartTime;
|
---|
541 | toprint += "\n\n";
|
---|
542 | toprint += "Notes:\n" + a.Note;
|
---|
543 |
|
---|
544 | //print
|
---|
545 | g.DrawString(toprint, fBody, Brushes.Black, printArea);
|
---|
546 |
|
---|
547 | // Print Date Printed
|
---|
548 | //sf to move to bottom center
|
---|
549 | StringFormat sf2 = new StringFormat();
|
---|
550 | sf2.LineAlignment = StringAlignment.Far;
|
---|
551 | sf2.Alignment = StringAlignment.Center;
|
---|
552 |
|
---|
553 | //Print
|
---|
554 | Font fFooter = new Font(FontFamily.GenericSerif, 8);
|
---|
555 | g.DrawString("Printed: " + DateTime.Now, fFooter, Brushes.Black, printArea, sf2);
|
---|
556 | }
|
---|
557 |
|
---|
558 | }
|
---|
559 | public abstract class PrintingCreator
|
---|
560 | {
|
---|
561 | public abstract Printing PrintFactory();
|
---|
562 | }
|
---|
563 |
|
---|
564 | }
|
---|