private void FillScreen() { List <ContrDashProvList_Row> ListProv = new List <ContrDashProvList_Row>(); ContrDashProvList_Row row; for (int i = 0; i < table.Rows.Count; i++) { row = new ContrDashProvList_Row(); row.ProvName = Providers.GetAbbr(PIn.Long(table.Rows[i]["ProvNum"].ToString())); System.Drawing.Color c1 = Providers.GetColor(PIn.Long(table.Rows[i]["ProvNum"].ToString())); row.ProvColor = Color.FromArgb(c1.A, c1.R, c1.G, c1.B); decimal production = PIn.Decimal(table.Rows[i]["production"].ToString()); if (production == 0) { row.Production = ""; } else { row.Production = production.ToString("c0"); } decimal income = PIn.Decimal(table.Rows[i]["income"].ToString()); if (income == 0) { row.Income = ""; } else { row.Income = income.ToString("c0"); } ListProv.Add(row); } //Style style=new Style(typeof(TextBlock)); //style.Setters.Add(new Setter(TextBlock.HorizontalAlignmentProperty,HorizontalAlignment.Right)); //((DataGridTextColumn)gridMain.Columns[2]).ElementStyle=style; //((DataGridTextColumn)gridMain.Columns[2]).Binding=new Binding("Production"); //((DataGridTextColumn)gridMain.Columns[2]).Binding.StringFormat="c0"; gridMain.ItemsSource = ListProv; }
///<summary>Including the practice schedule.</summary> public static void DrawMainBackground(Graphics g, DateTime startTime, DateTime stopTime, int colsPerPage, int pageColumn) { Brush openBrush; Brush closedBrush; Brush holidayBrush; try { openBrush = new SolidBrush(DefC.Long[(int)DefCat.AppointmentColors][0].ItemColor); closedBrush = new SolidBrush(DefC.Long[(int)DefCat.AppointmentColors][1].ItemColor); holidayBrush = new SolidBrush(DefC.Long[(int)DefCat.AppointmentColors][4].ItemColor); } catch { //this is just for design-time openBrush = new SolidBrush(Color.White); closedBrush = new SolidBrush(Color.LightGray); holidayBrush = new SolidBrush(Color.FromArgb(255, 128, 128)); } List <Schedule> schedsForOp; //one giant rectangle for everything closed g.FillRectangle(closedBrush, TimeWidth, 0, ColWidth * ColCount + ProvWidth * ProvCount, ApptSheetHeight); //then, loop through each day and operatory bool isHoliday; int startHour = startTime.Hour; int stopHour = stopTime.Hour; if (stopHour == 0) { stopHour = 24; } if (IsWeeklyView) { for (int d = 0; d < NumOfWeekDaysToDisplay; d++) { isHoliday = false; for (int i = 0; i < SchedListPeriod.Count; 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, ApptSheetHeight); } //this is a workaround because we start on Monday: DayOfWeek dayofweek; if (d == 6) { dayofweek = (DayOfWeek)(0); } else { dayofweek = (DayOfWeek)(d + 1); } for (int i = 0; i < ColCount; i++) { schedsForOp = Schedules.GetSchedsForOp(SchedListPeriod, dayofweek, VisOps[i]); //OperatoryC.ListShort[ApptViewItemL.VisOps[j]]); for (int j = 0; j < schedsForOp.Count; j++) { stopHour = stopTime.Hour; //Reset stopHour every time. if (stopHour == 0) { stopHour = 24; } g.FillRectangle(openBrush , TimeWidth + 1 + d * ColDayWidth + (float)i * ColAptWidth , (schedsForOp[j].StartTime.Hours - startHour) * LineH * RowsPerHr + (int)schedsForOp[j].StartTime.Minutes * LineH / MinPerRow //6RowsPerHr 10MinPerRow , ColAptWidth , (schedsForOp[j].StopTime - schedsForOp[j].StartTime).Hours * LineH * RowsPerHr //6 + (schedsForOp[j].StopTime - schedsForOp[j].StartTime).Minutes * LineH / MinPerRow); //10 } } } } else //only one day showing { isHoliday = false; //Schedule[] schedForType; for (int i = 0; i < SchedListPeriod.Count; i++) { if (SchedListPeriod[i].SchedType != ScheduleType.Practice) { continue; } if (SchedListPeriod[i].Status != SchedStatus.Holiday) { continue; } isHoliday = true; break; } if (isHoliday) { g.FillRectangle(holidayBrush, TimeWidth + 1, 0, ColWidth * ColCount + ProvWidth * ProvCount, ApptSheetHeight); } for (int i = 0; i < colsPerPage; i++) { if (i == ApptDrawing.VisOps.Count) { break; } int k = colsPerPage * pageColumn + i; if (k >= ApptDrawing.VisOps.Count) { break; } schedsForOp = Schedules.GetSchedsForOp(SchedListPeriod, VisOps[k]); //OperatoryC.ListShort[ApptViewItemL.VisOps[j]]); for (int j = 0; j < schedsForOp.Count; j++) { stopHour = stopTime.Hour; //Reset stopHour every time. if (stopHour == 0) { stopHour = 24; } if (schedsForOp[j].StartTime.Hours >= stopHour) { continue; } if (schedsForOp[j].StopTime.Hours <= stopHour) { stopHour = schedsForOp[j].StopTime.Hours; } g.FillRectangle(openBrush , TimeWidth + ProvWidth * ProvCount + i * ColWidth , (schedsForOp[j].StartTime.Hours - startHour) * LineH * RowsPerHr + (int)schedsForOp[j].StartTime.Minutes * LineH / MinPerRow //6RowsPerHr 10MinPerRow , ColWidth , (schedsForOp[j].StopTime - schedsForOp[j].StartTime).Hours * LineH * RowsPerHr //6 + (schedsForOp[j].StopTime - schedsForOp[j].StartTime).Minutes * LineH / MinPerRow); //10 } //now, fill up to 2 timebars along the left side of each rectangle. for (int j = 0; j < schedsForOp.Count; j++) { if (schedsForOp[j].Ops.Count == 0) //if this schedule is not assigned to specific ops, skip { continue; } stopHour = stopTime.Hour; //Reset stopHour every time. if (stopHour == 0) { stopHour = 24; } if (!Providers.GetIsSec(schedsForOp[j].ProvNum)) //if the provider is a dentist { g.FillRectangle(new SolidBrush(Providers.GetColor(schedsForOp[j].ProvNum)) , TimeWidth + ProvWidth * ProvCount + i * ColWidth , (schedsForOp[j].StartTime.Hours - startHour) * LineH * RowsPerHr + (int)schedsForOp[j].StartTime.Minutes * LineH / MinPerRow //6RowsPerHr 10MinPerRow , ProvWidth , (schedsForOp[j].StopTime - schedsForOp[j].StartTime).Hours * LineH * RowsPerHr //6 + (schedsForOp[j].StopTime - schedsForOp[j].StartTime).Minutes * LineH / MinPerRow); //10 } else //hygienist { g.FillRectangle(new SolidBrush(Providers.GetColor(schedsForOp[j].ProvNum)) , TimeWidth + ProvWidth * ProvCount + i * ColWidth + ProvWidth , (schedsForOp[j].StartTime.Hours - startHour) * LineH * RowsPerHr + (int)schedsForOp[j].StartTime.Minutes * LineH / MinPerRow //6RowsPerHr 10MinPerRow , ProvWidth , (schedsForOp[j].StopTime - schedsForOp[j].StartTime).Hours * LineH * RowsPerHr //6 + (schedsForOp[j].StopTime - schedsForOp[j].StartTime).Minutes * LineH / MinPerRow); //10 } } } } openBrush.Dispose(); closedBrush.Dispose(); holidayBrush.Dispose(); }
///<summary>Set default fontSize to 8 unless printing.</summary> public static void DrawEntireAppt(Graphics g, DataRow dataRoww, string patternShowing, float totalWidth, float totalHeight, bool isSelected, bool thisIsPinBoard, long selectedAptNum, List <ApptViewItem> apptRows, ApptView apptViewCur, DataTable tableApptFields, DataTable tablePatFields, int fontSize, bool isPrinting) { Pen penB = new Pen(Color.Black); Pen penW = new Pen(Color.White); Pen penGr = new Pen(Color.SlateGray); Pen penDG = new Pen(Color.DarkSlateGray); Pen penO; //provider outline color Color backColor; Color provColor; if (dataRoww["ProvNum"].ToString() != "0" && dataRoww["IsHygiene"].ToString() == "0") //dentist { provColor = Providers.GetColor(PIn.Long(dataRoww["ProvNum"].ToString())); penO = new Pen(Providers.GetOutlineColor(PIn.Long(dataRoww["ProvNum"].ToString()))); } else if (dataRoww["ProvHyg"].ToString() != "0" && dataRoww["IsHygiene"].ToString() == "1") //hygienist { provColor = Providers.GetColor(PIn.Long(dataRoww["ProvHyg"].ToString())); penO = new Pen(Providers.GetOutlineColor(PIn.Long(dataRoww["ProvHyg"].ToString()))); } else //unknown { provColor = Color.White; penO = new Pen(Color.Black); } if (PIn.Long(dataRoww["AptStatus"].ToString()) == (int)ApptStatus.Complete) { backColor = DefC.Long[(int)DefCat.AppointmentColors][2].ItemColor; } else if (PIn.Long(dataRoww["AptStatus"].ToString()) == (int)ApptStatus.PtNote) { backColor = DefC.Long[(int)DefCat.AppointmentColors][5].ItemColor; } else if (PIn.Long(dataRoww["AptStatus"].ToString()) == (int)ApptStatus.PtNoteCompleted) { backColor = DefC.Long[(int)DefCat.AppointmentColors][6].ItemColor; } else if (PIn.Int(dataRoww["ColorOverride"].ToString()) != 0) { backColor = Color.FromArgb(PIn.Int(dataRoww["ColorOverride"].ToString())); } else { backColor = provColor; //We might want to do something interesting here. } SolidBrush backBrush = new SolidBrush(backColor); g.FillRectangle(backBrush, 7, 0, totalWidth - 7, (int)totalHeight); g.FillRectangle(Brushes.White, 0, 0, 7, (int)totalHeight); Pen penTimediv = Pens.Silver; for (int i = 0; i < patternShowing.Length; i++) //Info.MyApt.Pattern.Length;i++){ { if (patternShowing.Substring(i, 1) == "X") { if (isPrinting) { g.FillRectangle(new SolidBrush(provColor), 0, i * ApptDrawing.LineH, 7, ApptDrawing.LineH); } else { g.FillRectangle(new SolidBrush(provColor), 1, i * ApptDrawing.LineH + 1, 6, ApptDrawing.LineH); } } else { //leave empty } if (Math.IEEERemainder((double)i, (double)ApptDrawing.RowsPerIncr) == 0) //0/1 { if (isPrinting) { g.DrawLine(penTimediv, 0, i * ApptDrawing.LineH, 7, i * ApptDrawing.LineH); } else { g.DrawLine(penTimediv, 1, i * ApptDrawing.LineH, 6, i * ApptDrawing.LineH); } } } g.DrawLine(penB, 7, 0, 7, (int)totalHeight); #region Highlighting border if (isSelected || (!thisIsPinBoard && dataRoww["AptNum"].ToString() == selectedAptNum.ToString())) { //Left g.DrawLine(penO, 8, 1, 8, totalHeight - 2); g.DrawLine(penO, 9, 1, 9, totalHeight - 3); //Right g.DrawLine(penO, totalWidth - 2, 1, totalWidth - 2, totalHeight - 2); g.DrawLine(penO, totalWidth - 3, 2, totalWidth - 3, totalHeight - 3); //Top g.DrawLine(penO, 8, 1, totalWidth - 2, 1); g.DrawLine(penO, 8, 2, totalWidth - 3, 2); //bottom g.DrawLine(penO, 9, totalHeight - 2, totalWidth - 2, totalHeight - 2); g.DrawLine(penO, 10, totalHeight - 3, totalWidth - 3, totalHeight - 3); } #endregion #region Main rows Point drawLoc = new Point(9, 0); int elementI = 0; while (drawLoc.Y < totalHeight && elementI < apptRows.Count) { if (apptRows[elementI].ElementAlignment != ApptViewAlignment.Main) { elementI++; continue; } drawLoc = DrawElement(g, elementI, drawLoc, ApptViewStackBehavior.Vertical, ApptViewAlignment.Main, backBrush, dataRoww, apptRows, tableApptFields, tablePatFields, totalWidth, totalHeight, fontSize, isPrinting); //set the drawLoc to a new point, based on space used by element elementI++; } #endregion #region UR drawLoc = new Point((int)totalWidth - 1, 0); //in the UR area, we refer to the upper right corner of each element. elementI = 0; while (drawLoc.Y < totalHeight && elementI < apptRows.Count) { if (apptRows[elementI].ElementAlignment != ApptViewAlignment.UR) { elementI++; continue; } drawLoc = DrawElement(g, elementI, drawLoc, apptViewCur.StackBehavUR, ApptViewAlignment.UR, backBrush, dataRoww, apptRows, tableApptFields, tablePatFields, totalWidth, totalHeight, fontSize, isPrinting); elementI++; } #endregion #region LR drawLoc = new Point((int)totalWidth - 1, (int)totalHeight - 1); //in the LR area, we refer to the lower right corner of each element. elementI = apptRows.Count - 1; //For lower right, draw the list backwards. while (drawLoc.Y > 0 && elementI >= 0) { if (apptRows[elementI].ElementAlignment != ApptViewAlignment.LR) { elementI--; continue; } drawLoc = DrawElement(g, elementI, drawLoc, apptViewCur.StackBehavLR, ApptViewAlignment.LR, backBrush, dataRoww, apptRows, tableApptFields, tablePatFields, totalWidth, totalHeight, fontSize, isPrinting); elementI--; } #endregion //Main outline if (isPrinting) { g.DrawRectangle(new Pen(Color.Black), 0, 0, totalWidth, totalHeight); } else { g.DrawRectangle(new Pen(Color.Black), 0, 0, totalWidth - 1, totalHeight - 1); } //broken X if (dataRoww["AptStatus"].ToString() == ((int)ApptStatus.Broken).ToString()) { g.DrawLine(new Pen(Color.Black), 8, 1, totalWidth - 1, totalHeight - 1); g.DrawLine(new Pen(Color.Black), 8, totalHeight - 1, totalWidth - 1, 1); } //Dispose of the objects. DisposeObjects(penB, penW, penGr, penDG, penO, backBrush); }