///<summary>Draws all the blockouts for the entire day.</summary> private void DrawBlockouts(Graphics g) { SchedDefault[] schedDefs; //for one type at a time Schedule[] schedForType; schedForType = Schedules.GetForType(SchedListDay, ScheduleType.Blockout, 0); SolidBrush blockBrush; Pen blockOutlinePen = new Pen(Color.Black, 1); Font blockFont = new Font("Arial", 8); string blockText; RectangleF rect; g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit; //to make printing clearer if (schedForType.Length == 0) //use default sched { schedDefs = SchedDefaults.GetForType(ScheduleType.Blockout, 0); for (int i = 0; i < schedDefs.Length; i++) { if (schedDefs[i].DayOfWeek == (int)Appointments.DateSelected.DayOfWeek) { blockBrush = new SolidBrush(DefB.GetColor(DefCat.BlockoutTypes, schedDefs[i].BlockoutType)); blockText = DefB.GetName(DefCat.BlockoutTypes, schedDefs[i].BlockoutType); if (schedDefs[i].Op == 0) //all ops { rect = new RectangleF( TimeWidth + ProvWidth * ProvCount + 1 , schedDefs[i].StartTime.Hour * Lh * RowsPerHr + schedDefs[i].StartTime.Minute * Lh / MinPerRow , ColWidth * ColCount - 1 , (schedDefs[i].StopTime - schedDefs[i].StartTime).Hours * Lh * RowsPerHr + (schedDefs[i].StopTime - schedDefs[i].StartTime).Minutes * Lh / MinPerRow); } else //just one op { if (ApptViewItems.GetIndexOp(schedDefs[i].Op) == -1) { continue; //don't display if op not visible } rect = new RectangleF( TimeWidth + ProvWidth * ProvCount + ColWidth * ApptViewItems.GetIndexOp(schedDefs[i].Op) + 1 , schedDefs[i].StartTime.Hour * Lh * RowsPerHr + schedDefs[i].StartTime.Minute * Lh / MinPerRow , ColWidth - 1 , (schedDefs[i].StopTime - schedDefs[i].StartTime).Hours * Lh * RowsPerHr + (schedDefs[i].StopTime - schedDefs[i].StartTime).Minutes * Lh / MinPerRow); } g.FillRectangle(blockBrush, rect); g.DrawRectangle(blockOutlinePen, rect.X + 1, rect.Y + 2, rect.Width - 2, rect.Height - 4); g.DrawString(blockText, blockFont , new SolidBrush(DefB.Short[(int)DefCat.AppointmentColors][5].ItemColor), rect); } } } else //use schedForType { for (int i = 0; i < schedForType.Length; i++) { blockBrush = new SolidBrush(DefB.GetColor(DefCat.BlockoutTypes, schedForType[i].BlockoutType)); blockText = DefB.GetName(DefCat.BlockoutTypes, schedForType[i].BlockoutType) + "\r\n" + schedForType[i].Note; if (schedForType[i].Op == 0) //all ops { rect = new RectangleF( TimeWidth + ProvWidth * ProvCount + 1 , schedForType[i].StartTime.Hour * Lh * RowsPerHr //6 + schedForType[i].StartTime.Minute * Lh / MinPerRow //10 , ColWidth * ColCount - 1 , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); } else //just one op { if (ApptViewItems.GetIndexOp(schedForType[i].Op) == -1) { continue; //don't display if op not visible } rect = new RectangleF( TimeWidth + ProvWidth * ProvCount + ColWidth * ApptViewItems.GetIndexOp(schedForType[i].Op) + 1 , schedForType[i].StartTime.Hour * Lh * RowsPerHr + schedForType[i].StartTime.Minute * Lh / MinPerRow , ColWidth - 1 , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); } g.FillRectangle(blockBrush, rect); //g.DrawRectangle(blockOutlinePen,rect.X,rect.Y+1,rect.Width-1,rect.Height-3); g.DrawLine(blockOutlinePen, rect.X, rect.Y + 1, rect.Right - 1, rect.Y + 1); g.DrawString(blockText, blockFont , new SolidBrush(DefB.Short[(int)DefCat.AppointmentColors][5].ItemColor), rect); } } }
///<summary>Including the practice schedule</summary> private void DrawMainBackground(Graphics g) { //SchedDefault[] schedDefs;//for one type at a time Schedule[] schedForType; //one giant rectangle for everything closed g.FillRectangle(closedBrush, TimeWidth, 0, ColWidth * ColCount + ProvWidth * ProvCount, Height); //then, loop through each day and operatory Operatory curOp; bool isHoliday; if (IsWeeklyView) { for (int d = 0; d < NumOfWeekDaysToDisplay; d++) { isHoliday = false; for (int i = 0; i < SchedListPeriod.Length; i++) { if (SchedListPeriod[i].SchedType != ScheduleType.Practice) { continue; } if (SchedListPeriod[i].Status != SchedStatus.Holiday) { continue; } if ((int)SchedListPeriod[i].SchedDate.DayOfWeek != d + 1) { continue; } isHoliday = true; break; } if (isHoliday) { g.FillRectangle(holidayBrush, TimeWidth + 1 + d * ColDayWidth, 0, ColDayWidth, Height); } for (int j = 0; j < ColCount; j++) { curOp = Operatories.ListShort[ApptViewItems.VisOps[j]]; if (curOp.ProvDentist != 0 && !curOp.IsHygiene) //dentist { schedForType = Schedules.GetForType(SchedListPeriod, ScheduleType.Provider, curOp.ProvDentist); } else if (curOp.ProvHygienist != 0 && curOp.IsHygiene) //hygienist { schedForType = Schedules.GetForType(SchedListPeriod, ScheduleType.Provider, curOp.ProvHygienist); } else //no provider set { schedForType = Schedules.GetForType(SchedListPeriod, ScheduleType.Provider, PrefB.GetInt("ScheduleProvUnassigned")); } for (int i = 0; i < schedForType.Length; i++) { if ((int)schedForType[i].SchedDate.DayOfWeek != d + 1) { continue; } g.FillRectangle(openBrush , TimeWidth + 1 + d * ColDayWidth + (float)j * ColAptWidth , schedForType[i].StartTime.Hour * Lh * RowsPerHr + (int)schedForType[i].StartTime.Minute * Lh / MinPerRow //6RowsPerHr 10MinPerRow , ColAptWidth , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr //6 + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); //10 } } } } else //only one day showing { isHoliday = false; for (int i = 0; i < SchedListPeriod.Length; i++) { if (SchedListPeriod[i].SchedType != ScheduleType.Practice) { continue; } if (SchedListPeriod[i].Status != SchedStatus.Holiday) { continue; } isHoliday = true; break; } for (int j = 0; j < ColCount; j++) { curOp = Operatories.ListShort[ApptViewItems.VisOps[j]]; if (curOp.ProvDentist != 0 && !curOp.IsHygiene) //dentist { schedForType = Schedules.GetForType(SchedListPeriod, ScheduleType.Provider, curOp.ProvDentist); } else if (curOp.ProvHygienist != 0 && curOp.IsHygiene) //hygienist { schedForType = Schedules.GetForType(SchedListPeriod, ScheduleType.Provider, curOp.ProvHygienist); } else //no provider set { schedForType = Schedules.GetForType(SchedListPeriod, ScheduleType.Provider, PrefB.GetInt("ScheduleProvUnassigned")); } if (isHoliday) { g.FillRectangle(holidayBrush, TimeWidth + ProvWidth * ProvCount + j * ColWidth, 0, ColWidth, Height); } else { for (int i = 0; i < schedForType.Length; i++) { g.FillRectangle(openBrush , TimeWidth + ProvWidth * ProvCount + j * ColWidth , schedForType[i].StartTime.Hour * Lh * RowsPerHr + (int)schedForType[i].StartTime.Minute * Lh / MinPerRow //6RowsPerHr 10MinPerRow , ColWidth , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr //6 + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); //10 } } } } }
///<summary>Including the practice schedule</summary> private void DrawMainBackground(Graphics g) { SchedDefault[] schedDefs; //for one type at a time Schedule[] schedForType; //one giant rectangle for everything closed g.FillRectangle(closedBrush, TimeWidth, 0, ColWidth * ColCount + ProvWidth * ProvCount, Height); //then, loop through each operatory Operatory curOp; for (int j = 0; j < ColCount; j++) { curOp = Operatories.ListShort[ApptViewItems.VisOps[j]]; if (curOp.ProvDentist != 0 && !curOp.IsHygiene) //dentist { schedForType = Schedules.GetForType(SchedListDay, ScheduleType.Provider, curOp.ProvDentist); } else if (curOp.ProvHygienist != 0 && curOp.IsHygiene) //hygienist { schedForType = Schedules.GetForType(SchedListDay, ScheduleType.Provider, curOp.ProvHygienist); } else //practice { schedForType = Schedules.GetForType(SchedListDay, ScheduleType.Practice, 0); } if (schedForType.Length == 0) //use default sched { if (curOp.ProvDentist != 0 && !curOp.IsHygiene) //dentist { schedDefs = SchedDefaults.GetForType(ScheduleType.Provider, curOp.ProvDentist); } else if (curOp.ProvHygienist != 0 && curOp.IsHygiene) //hygienist { schedDefs = SchedDefaults.GetForType(ScheduleType.Provider, curOp.ProvHygienist); } else //practice { schedDefs = SchedDefaults.GetForType(ScheduleType.Practice, 0); } for (int i = 0; i < schedDefs.Length; i++) { if (schedDefs[i].DayOfWeek == (int)Appointments.DateSelected.DayOfWeek) { g.FillRectangle(openBrush , TimeWidth + ProvWidth * ProvCount + j * ColWidth , schedDefs[i].StartTime.Hour * Lh * RowsPerHr + schedDefs[i].StartTime.Minute * Lh / MinPerRow , ColWidth , (schedDefs[i].StopTime - schedDefs[i].StartTime).Hours * Lh * RowsPerHr + (schedDefs[i].StopTime - schedDefs[i].StartTime).Minutes * Lh / MinPerRow); } } } else //use schedForType { for (int i = 0; i < schedForType.Length; i++) { if (schedForType[i].Status == SchedStatus.Holiday) { //g.FillRectangle(holidayBrush,TimeWidth+ProvWidth*ProvCount,0,ColWidth*ColCount,Height); g.FillRectangle(holidayBrush, TimeWidth + ProvWidth * ProvCount + j * ColWidth, 0, ColWidth, Height); } else { g.FillRectangle(openBrush , TimeWidth + ProvWidth * ProvCount + j * ColWidth , schedForType[i].StartTime.Hour * Lh * RowsPerHr + (int)schedForType[i].StartTime.Minute * Lh / MinPerRow //6RowsPerHr 10MinPerRow , ColWidth , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * Lh * RowsPerHr //6 + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * Lh / MinPerRow); //10 } } } //else use schedForType } //for colCount }