Changeset 1110 for Scheduling/trunk/cs/bsdx0200GUISourceCode/Printing.cs
- Timestamp:
- Mar 21, 2011, 8:47:45 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Scheduling/trunk/cs/bsdx0200GUISourceCode/Printing.cs
r900 r1110 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 2 using System.Drawing.Printing; 6 3 using System.Drawing; 4 using System.Text; 5 using System.Drawing.Drawing2D; 6 using System.Linq; 7 7 using System.Data; 8 using System.Drawing.Drawing2D;9 8 10 9 namespace IndianHealthService.ClinicalScheduling 11 10 { 12 /// <summary> 13 /// Class that encapsulates printing functions in Clinical Scheduling 14 /// </summary> 15 public static class Printing 16 { 11 public class Printing 12 { 17 13 /// <summary> 18 14 /// Print Appointments … … 26 22 /// <param name="pageNumber">Current page number</param> 27 23 /// <remarks>beg and end have no effect on operation--they are there for documentation for user only</remarks> 28 public static void PrintAppointments(dsPatientApptDisplay2 ds, PrintPageEventArgs e, DateTime beg, DateTime end, 29 int resourceToPrint, ref int apptPrinting, int pageNumber) 24 public virtual void PrintAppointments(dsPatientApptDisplay2 ds, PrintPageEventArgs e, DateTime beg, DateTime end, int resourceToPrint, ref int apptPrinting, int pageNumber) 30 25 { 31 26 Graphics g = e.Graphics; … … 122 117 123 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> 124 324 /// Print Letter to be given or mailed to the patient 125 325 /// </summary> … … 128 328 /// <param name="letter">Contains letter string</param> 129 329 /// <param name="title">Title of the letter</param> 130 public staticvoid PrintReminderLetter(dsPatientApptDisplay2.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)330 public virtual void PrintReminderLetter(dsPatientApptDisplay2.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title) 131 331 { 132 332 … … 177 377 g.DrawString(address.ToString(), fBody, Brushes.Black, printArea, sf); 178 378 } 179 379 180 380 /// <summary> 181 381 /// Cancellation Letter to be given or mailed to the patient … … 185 385 /// <param name="letter">Contains letter string</param> 186 386 /// <param name="title">Title of the letter</param> 187 public staticvoid PrintCancelLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)387 public virtual void PrintCancelLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title) 188 388 { 189 389 Rectangle printArea = e.MarginBounds; … … 241 441 /// <param name="letter">Text of the letter to print</param> 242 442 /// <param name="title">Title to print at the top of the letter</param> 243 public staticvoid PrintRebookLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title)443 public virtual void PrintRebookLetter(dsRebookAppts.PatientApptsRow ptRow, PrintPageEventArgs e, string letter, string title) 244 444 { 245 445 Rectangle printArea = e.MarginBounds; … … 298 498 /// <param name="msg">The exact string to print.</param> 299 499 /// <param name="e">Print Page event args</param> 300 public staticvoid PrintMessage(string msg, PrintPageEventArgs e)500 public virtual void PrintMessage(string msg, PrintPageEventArgs e) 301 501 { 302 502 e.Graphics.DrawString(msg, new Font(FontFamily.GenericSerif, 14), … … 310 510 /// <param name="title">String to print for title</param> 311 511 /// <param name="e">etc</param> 312 public staticvoid PrintRoutingSlip(CGAppointment a, string title, PrintPageEventArgs e)512 public virtual void PrintRoutingSlip(CGAppointment a, string title, PrintPageEventArgs e) 313 513 { 314 514 Rectangle printArea = e.MarginBounds; … … 354 554 Font fFooter = new Font(FontFamily.GenericSerif, 8); 355 555 g.DrawString("Printed: " + DateTime.Now, fFooter, Brushes.Black, printArea, sf2); 356 357 } 556 } 557 358 558 } 559 public abstract class PrintingCreator 560 { 561 public abstract Printing PrintFactory(); 562 } 563 359 564 }
Note:
See TracChangeset
for help on using the changeset viewer.