Exemple #1
0
        ///<summary>Draws all the blockouts for the entire period.</summary>
        public static void DrawBlockouts(Graphics g, DateTime startTime, DateTime stopTime, int colsPerPage, int pageColumn, int fontSize, bool isPrinting)
        {
            Schedule[] schedForType = Schedules.GetForType(SchedListPeriod, ScheduleType.Blockout, 0);
            SolidBrush blockBrush;
            Pen        blockOutlinePen = new Pen(Color.Black, 1);
            Pen        penOutline;
            Font       blockFont = new Font("Arial", fontSize);
            string     blockText;
            RectangleF rect;

            for (int i = 0; i < schedForType.Length; i++)
            {
                blockBrush = new SolidBrush(DefC.GetColor(DefCat.BlockoutTypes, schedForType[i].BlockoutType));
                penOutline = new Pen(DefC.GetColor(DefCat.BlockoutTypes, schedForType[i].BlockoutType), 2);
                blockText  = DefC.GetName(DefCat.BlockoutTypes, schedForType[i].BlockoutType) + "\r\n" + schedForType[i].Note;
                for (int o = 0; o < schedForType[i].Ops.Count; o++)
                {
                    int startHour = startTime.Hour;
                    if (isPrinting)                     //Filtering logic for printing.
                    {
                        int stopHour = stopTime.Hour;
                        if (stopHour == 0)
                        {
                            stopHour = 24;
                        }
                        if (schedForType[i].StartTime.Hours >= stopHour)
                        {
                            continue;                            //Blockout starts after the current time frame.
                        }
                        if (schedForType[i].StopTime.Hours <= stopHour)
                        {
                            stopHour = schedForType[i].StopTime.Hours;
                        }
                        if (GetIndexOp(schedForType[i].Ops[o]) >= (colsPerPage * pageColumn + colsPerPage) ||
                            GetIndexOp(schedForType[i].Ops[o]) < colsPerPage * pageColumn)
                        {
                            continue;                            //Blockout not on current page.
                        }
                    }
                    if (IsWeeklyView)
                    {
                        if (GetIndexOp(schedForType[i].Ops[o]) == -1)
                        {
                            continue;                            //don't display if op not visible
                        }
                        //this is a workaround because we start on Monday:
                        int dayofweek = (int)schedForType[i].SchedDate.DayOfWeek - 1;
                        if (dayofweek == -1)
                        {
                            dayofweek = 6;
                        }
                        rect = new RectangleF(
                            TimeWidth + 1 + (dayofweek) * ColDayWidth
                            + ColAptWidth * (GetIndexOp(schedForType[i].Ops[o], VisOps) - (colsPerPage * pageColumn))
                            , (schedForType[i].StartTime.Hours - startHour) * LineH * RowsPerHr
                            + schedForType[i].StartTime.Minutes * LineH / MinPerRow
                            , ColAptWidth - 1
                            , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * LineH * RowsPerHr
                            + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * LineH / MinPerRow);
                    }
                    else
                    {
                        if (GetIndexOp(schedForType[i].Ops[o]) == -1)
                        {
                            continue;                            //don't display if op not visible
                        }
                        rect = new RectangleF(
                            TimeWidth + ProvWidth * ProvCount
                            + ColWidth * (GetIndexOp(schedForType[i].Ops[o], VisOps) - (colsPerPage * pageColumn))
                            + ProvWidth * 2                         //so they don't overlap prov bars
                            , (schedForType[i].StartTime.Hours - startHour) * LineH * RowsPerHr
                            + schedForType[i].StartTime.Minutes * LineH / MinPerRow
                            , ColWidth - 1 - ProvWidth * 2
                            , (schedForType[i].StopTime - schedForType[i].StartTime).Hours * LineH * RowsPerHr
                            + (schedForType[i].StopTime - schedForType[i].StartTime).Minutes * LineH / MinPerRow);
                    }
                    //paint either solid block or outline
                    if (PrefC.GetBool(PrefName.SolidBlockouts))
                    {
                        g.FillRectangle(blockBrush, rect);
                        g.DrawLine(blockOutlinePen, rect.X, rect.Y + 1, rect.Right - 1, rect.Y + 1);
                    }
                    else
                    {
                        g.DrawRectangle(penOutline, rect.X + 1, rect.Y + 2, rect.Width - 2, rect.Height - 3);
                    }
                    g.DrawString(blockText, blockFont, new SolidBrush(DefC.Short[(int)DefCat.AppointmentColors][5].ItemColor), rect);
                }
                blockBrush.Dispose();
                penOutline.Dispose();
            }
            blockOutlinePen.Dispose();
        }
        ///<summary></summary>
        public static Point DrawElement(Graphics g, int elementI, Point drawLoc, ApptViewStackBehavior stackBehavior, ApptViewAlignment align, Brush backBrush, DataRow dataRoww, List <ApptViewItem> apptRows, DataTable tableApptFields, DataTable tablePatFields, float totalWidth, float totalHeight, int fontSize, bool isPrinting)
        {
            Font   baseFont = new Font("Arial", fontSize);
            string text     = "";
            bool   isNote   = false;

            #region FillText
            if (PIn.Long(dataRoww["AptStatus"].ToString()) == (int)ApptStatus.PtNote ||
                PIn.Long(dataRoww["AptStatus"].ToString()) == (int)ApptStatus.PtNoteCompleted)
            {
                isNote = true;
            }
            bool isGraphic = false;
            if (apptRows[elementI].ElementDesc == "ConfirmedColor")
            {
                isGraphic = true;
            }
            if (apptRows[elementI].ApptFieldDefNum > 0)
            {
                string fieldName = ApptFieldDefs.GetFieldName(apptRows[elementI].ApptFieldDefNum);
                for (int i = 0; i < tableApptFields.Rows.Count; i++)
                {
                    if (tableApptFields.Rows[i]["AptNum"].ToString() != dataRoww["AptNum"].ToString())
                    {
                        continue;
                    }
                    if (tableApptFields.Rows[i]["FieldName"].ToString() != fieldName)
                    {
                        continue;
                    }
                    text = tableApptFields.Rows[i]["FieldValue"].ToString();
                }
            }
            else if (apptRows[elementI].PatFieldDefNum > 0)
            {
                string fieldName = PatFieldDefs.GetFieldName(apptRows[elementI].PatFieldDefNum);
                for (int i = 0; i < tablePatFields.Rows.Count; i++)
                {
                    if (tablePatFields.Rows[i]["PatNum"].ToString() != dataRoww["PatNum"].ToString())
                    {
                        continue;
                    }
                    if (tablePatFields.Rows[i]["FieldName"].ToString() != fieldName)
                    {
                        continue;
                    }
                    text = tablePatFields.Rows[i]["FieldValue"].ToString();
                }
            }
            else
            {
                switch (apptRows[elementI].ElementDesc)
                {
                case "Address":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["address"].ToString();
                    }
                    break;

                case "AddrNote":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["addrNote"].ToString();
                    }
                    break;

                case "Age":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["age"].ToString();
                    }
                    break;

                case "ASAP":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        if (dataRoww["AptStatus"].ToString() == ((int)ApptStatus.ASAP).ToString())
                        {
                            text = Lans.g("enumApptStatus", "ASAP");
                        }
                    }
                    break;

                case "ASAP[A]":
                    if (dataRoww["AptStatus"].ToString() == ((int)ApptStatus.ASAP).ToString())
                    {
                        text = "A";
                    }
                    break;

                case "AssistantAbbr":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["assistantAbbr"].ToString();
                    }
                    break;

                case "ChartNumAndName":
                    text = dataRoww["chartNumAndName"].ToString();
                    break;

                case "ChartNumber":
                    text = dataRoww["chartNumber"].ToString();
                    break;

                case "CreditType":
                    text = dataRoww["CreditType"].ToString();
                    break;

                case "Guardians":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["guardians"].ToString();
                    }
                    break;

                case "HasIns[I]":
                    text = dataRoww["hasIns[I]"].ToString();
                    break;

                case "HmPhone":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["hmPhone"].ToString();
                    }
                    break;

                case "InsToSend[!]":
                    text = dataRoww["insToSend[!]"].ToString();
                    break;

                case "Lab":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["lab"].ToString();
                    }
                    break;

                case "MedOrPremed[+]":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["medOrPremed[+]"].ToString();
                    }
                    break;

                case "MedUrgNote":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["MedUrgNote"].ToString();
                    }
                    break;

                case "Note":
                    text = dataRoww["Note"].ToString();
                    break;

                case "PatientName":
                    text = dataRoww["patientName"].ToString();
                    break;

                case "PatientNameF":
                    text = dataRoww["patientNameF"].ToString();
                    break;

                case "PatNum":
                    text = dataRoww["patNum"].ToString();
                    break;

                case "PatNumAndName":
                    text = dataRoww["patNumAndName"].ToString();
                    break;

                case "PremedFlag":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["preMedFlag"].ToString();
                    }
                    break;

                case "Procs":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["procs"].ToString();
                    }
                    break;

                case "ProcsColored":
                    string   value  = dataRoww["procsColored"].ToString();
                    string[] lines  = value.Split(new string[] { "</span>" }, StringSplitOptions.RemoveEmptyEntries);
                    Point    tempPt = new Point();
                    tempPt = drawLoc;
                    int lastH = 0;
                    int count = 1;
                    for (int i = 0; i < lines.Length; i++)
                    {
                        Match  m      = Regex.Match(lines[i], "^<span color=\"(-?[0-9]*)\">(.*)$");
                        string rgbInt = m.Result("$1");
                        string proc   = m.Result("$2");
                        if (lines[i] != lines[lines.Length - 1])
                        {
                            proc += ",";
                        }
                        if (rgbInt == "")
                        {
                            rgbInt = apptRows[elementI].ElementColorXml.ToString();
                        }
                        Color            c          = Color.FromArgb(Convert.ToInt32(rgbInt));
                        StringFormat     procFormat = new StringFormat();
                        RectangleF       procRect   = new RectangleF(0, 0, 1000, 1000);
                        CharacterRange[] ranges     = { new CharacterRange(0, proc.Length) };
                        Region[]         regions    = new Region[1];
                        procFormat.SetMeasurableCharacterRanges(ranges);
                        regions = g.MeasureCharacterRanges(proc, baseFont, procRect, procFormat);
                        if (regions.Length == 0)
                        {
                            procRect = new RectangleF(0, 0, 0, 0);
                        }
                        else
                        {
                            procRect = regions[0].GetBounds(g);
                        }
                        if (tempPt.X + procRect.Width > totalWidth)
                        {
                            tempPt.X  = drawLoc.X;
                            tempPt.Y += lastH;
                            count++;
                        }
                        SolidBrush sb = new SolidBrush(c);
                        g.DrawString(proc, baseFont, sb, tempPt);
                        DisposeObjects(procFormat, sb);
                        tempPt.X += (int)procRect.Width + 3;                            //+3 is room for spaces
                        if ((int)procRect.Height > lastH)
                        {
                            lastH = (int)procRect.Height;
                        }
                    }
                    drawLoc.Y += lastH * count;
                    return(drawLoc);

                case "Production":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["production"].ToString();
                    }
                    break;

                case "Provider":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["provider"].ToString();
                    }
                    break;

                case "TimeAskedToArrive":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["timeAskedToArrive"].ToString();                              //could be blank
                    }
                    break;

                case "WirelessPhone":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["wirelessPhone"].ToString();
                    }
                    break;

                case "WkPhone":
                    if (isNote)
                    {
                        text = "";
                    }
                    else
                    {
                        text = dataRoww["wkPhone"].ToString();
                    }
                    break;
                }
            }
            #endregion
            if (text == "" && !isGraphic)
            {
                return(drawLoc);               //next element will draw at the same position as this one would have.
            }
            SolidBrush brush      = new SolidBrush(apptRows[elementI].ElementColor);
            SolidBrush brushWhite = new SolidBrush(Color.White);
            //SolidBrush noteTitlebrush = new SolidBrush(DefC.Long[(int)DefCat.AppointmentColors][8].ItemColor);
            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Near;
            int        charactersFitted;     //not used, but required as 'out' param for measureString.
            int        linesFilled;
            SizeF      noteSize;
            RectangleF rect;
            RectangleF rectBack;
            #region Main
            if (align == ApptViewAlignment.Main)           //always stacks vertical
            {
                if (isGraphic)
                {
                    Bitmap bitmap = new Bitmap(12, 12);
                    noteSize = new SizeF(bitmap.Width, bitmap.Height);
                    rect     = new RectangleF(drawLoc, noteSize);
                    using (Graphics gfx = Graphics.FromImage(bitmap)) {
                        gfx.SmoothingMode = SmoothingMode.HighQuality;
                        Color      confirmColor = DefC.GetColor(DefCat.ApptConfirmed, PIn.Long(dataRoww["Confirmed"].ToString()));
                        SolidBrush confirmBrush = new SolidBrush(confirmColor);
                        gfx.FillEllipse(confirmBrush, 0, 0, 11, 11);
                        gfx.DrawEllipse(Pens.Black, 0, 0, 11, 11);
                        confirmBrush.Dispose();
                    }
                    g.DrawImage(bitmap, drawLoc.X, drawLoc.Y);
                    DisposeObjects(brush, brushWhite, format, bitmap);
                    return(new Point(drawLoc.X, drawLoc.Y + (int)noteSize.Height));
                }
                else
                {
                    noteSize = g.MeasureString(text, baseFont, (int)totalWidth - 9);
                    //Problem: "limited-tooth bothering him ", the trailing space causes measuring error, resulting in m getting partially chopped off.
                    //Tried TextRenderer, but it caused premature wrapping
                    //Size noteSizeInt=TextRenderer.MeasureText(text,baseFont,new Size(totalWidth-9,1000));
                    //noteSize=new SizeF(noteSizeInt.totalWidth,noteSizeInt.totalHeight);
                    noteSize.Width = (float)Math.Ceiling((double)noteSize.Width);                  //round up to nearest int solves specific problem discussed above.
                    if (drawLoc.Y + noteSize.Height > totalHeight && isPrinting)
                    {
                        //This keeps text from drawing off the appointment when font is large. Only if isPrinting cause not sure if this will cause bugs.
                        //No need to do this check when drawing to the appt screen cause its just an image on a control which clips itself.
                        noteSize.Height = totalHeight - drawLoc.Y;
                    }
                    g.MeasureString(text, baseFont, noteSize, format, out charactersFitted, out linesFilled);
                    rect = new RectangleF(drawLoc, noteSize);
                    g.DrawString(text, baseFont, brush, rect, format);
                    DisposeObjects(brush, brushWhite, format);
                    return(new Point(drawLoc.X, drawLoc.Y + linesFilled * ApptDrawing.LineH));
                }
            }
            #endregion
            #region UR
            else if (align == ApptViewAlignment.UR)
            {
                if (stackBehavior == ApptViewStackBehavior.Vertical)
                {
                    float w = totalWidth - 9;
                    if (isGraphic)
                    {
                        Bitmap bitmap = new Bitmap(12, 12);
                        noteSize = new SizeF(bitmap.Width, bitmap.Height);
                        Point drawLocThis = new Point(drawLoc.X - (int)noteSize.Width, drawLoc.Y + 1);                 //upper left corner of this element
                        rect = new RectangleF(drawLoc, noteSize);
                        using (Graphics gfx = Graphics.FromImage(bitmap)) {
                            gfx.SmoothingMode = SmoothingMode.HighQuality;
                            Color      confirmColor = DefC.GetColor(DefCat.ApptConfirmed, PIn.Long(dataRoww["Confirmed"].ToString()));
                            SolidBrush confirmBrush = new SolidBrush(confirmColor);
                            gfx.FillEllipse(confirmBrush, 0, 0, 11, 11);
                            gfx.DrawEllipse(Pens.Black, 0, 0, 11, 11);
                            confirmBrush.Dispose();
                        }
                        g.DrawImage(bitmap, drawLocThis.X, drawLocThis.Y);
                        DisposeObjects(brush, brushWhite, format, bitmap);
                        return(new Point(drawLoc.X, drawLoc.Y + (int)noteSize.Height));
                    }
                    else
                    {
                        noteSize = g.MeasureString(text, baseFont, (int)w);
                        noteSize = new SizeF(noteSize.Width, ApptDrawing.LineH + 1);                   //only allowed to be one line high.
                        if (noteSize.Width < 5)
                        {
                            noteSize = new SizeF(5, noteSize.Height);
                        }
                        //g.MeasureString(text,baseFont,noteSize,format,out charactersFitted,out linesFilled);
                        Point drawLocThis = new Point(drawLoc.X - (int)noteSize.Width, drawLoc.Y);                   //upper left corner of this element
                        rect     = new RectangleF(drawLocThis, noteSize);
                        rectBack = new RectangleF(drawLocThis.X, drawLocThis.Y + 1, noteSize.Width, ApptDrawing.LineH);
                        if (apptRows[elementI].ElementDesc == "MedOrPremed[+]" ||
                            apptRows[elementI].ElementDesc == "HasIns[I]" ||
                            apptRows[elementI].ElementDesc == "InsToSend[!]")
                        {
                            g.FillRectangle(brush, rectBack);
                            g.DrawString(text, baseFont, Brushes.Black, rect, format);
                        }
                        else
                        {
                            g.FillRectangle(brushWhite, rectBack);
                            g.DrawString(text, baseFont, brush, rect, format);
                        }
                        g.DrawRectangle(Pens.Black, rectBack.X, rectBack.Y, rectBack.Width, rectBack.Height);
                        DisposeObjects(brush, brushWhite, format);
                        return(new Point(drawLoc.X, drawLoc.Y + ApptDrawing.LineH));                    //move down a certain number of lines for next element.
                    }
                }
                else                       //horizontal
                {
                    int w = drawLoc.X - 9; //drawLoc is upper right of each element.  The first element draws at (totalWidth-1,0).
                    if (isGraphic)
                    {
                        Bitmap bitmap = new Bitmap(12, 12);
                        noteSize = new SizeF(bitmap.Width, bitmap.Height);
                        Point drawLocThis = new Point(drawLoc.X - (int)noteSize.Width, drawLoc.Y + 1);                 //upper left corner of this element
                        rect = new RectangleF(drawLoc, noteSize);
                        using (Graphics gfx = Graphics.FromImage(bitmap)) {
                            gfx.SmoothingMode = SmoothingMode.HighQuality;
                            Color      confirmColor = DefC.GetColor(DefCat.ApptConfirmed, PIn.Long(dataRoww["Confirmed"].ToString()));
                            SolidBrush confirmBrush = new SolidBrush(confirmColor);
                            gfx.FillEllipse(confirmBrush, 0, 0, 11, 11);
                            gfx.DrawEllipse(Pens.Black, 0, 0, 11, 11);
                            confirmBrush.Dispose();
                        }
                        g.DrawImage(bitmap, drawLocThis.X, drawLocThis.Y);
                        DisposeObjects(brush, brushWhite, format, bitmap);
                        return(new Point(drawLoc.X - (int)noteSize.Width - 2, drawLoc.Y));
                    }
                    else
                    {
                        noteSize = g.MeasureString(text, baseFont, w);
                        noteSize = new SizeF(noteSize.Width, ApptDrawing.LineH + 1);                   //only allowed to be one line high.  Needs an extra pixel.
                        if (noteSize.Width < 5)
                        {
                            noteSize = new SizeF(5, noteSize.Height);
                        }
                        Point drawLocThis = new Point(drawLoc.X - (int)noteSize.Width, drawLoc.Y);                   //upper left corner of this element
                        rect     = new RectangleF(drawLocThis, noteSize);
                        rectBack = new RectangleF(drawLocThis.X, drawLocThis.Y + 1, noteSize.Width, ApptDrawing.LineH);
                        if (apptRows[elementI].ElementDesc == "MedOrPremed[+]" ||
                            apptRows[elementI].ElementDesc == "HasIns[I]" ||
                            apptRows[elementI].ElementDesc == "InsToSend[!]")
                        {
                            g.FillRectangle(brush, rectBack);
                            g.DrawString(text, baseFont, Brushes.Black, rect, format);
                        }
                        else
                        {
                            g.FillRectangle(brushWhite, rectBack);
                            g.DrawString(text, baseFont, brush, rect, format);
                        }
                        g.DrawRectangle(Pens.Black, rectBack.X, rectBack.Y, rectBack.Width, rectBack.Height);
                        DisposeObjects(brush, brushWhite, format);
                        return(new Point(drawLoc.X - (int)noteSize.Width - 1, drawLoc.Y));                  //Move to left.  Might also have to subtract a little from x to space out elements.
                    }
                }
            }
            #endregion
            #region LR
            else              //LR
            {
                if (stackBehavior == ApptViewStackBehavior.Vertical)
                {
                    float w = totalWidth - 9;
                    if (isGraphic)
                    {
                        Bitmap bitmap = new Bitmap(12, 12);
                        noteSize = new SizeF(bitmap.Width, bitmap.Height);
                        Point drawLocThis = new Point(drawLoc.X - (int)noteSize.Width, drawLoc.Y + 1 - ApptDrawing.LineH);               //upper left corner of this element
                        rect = new RectangleF(drawLoc, noteSize);
                        using (Graphics gfx = Graphics.FromImage(bitmap)) {
                            gfx.SmoothingMode = SmoothingMode.HighQuality;
                            Color      confirmColor = DefC.GetColor(DefCat.ApptConfirmed, PIn.Long(dataRoww["Confirmed"].ToString()));
                            SolidBrush confirmBrush = new SolidBrush(confirmColor);
                            gfx.FillEllipse(confirmBrush, 0, 0, 11, 11);
                            gfx.DrawEllipse(Pens.Black, 0, 0, 11, 11);
                            confirmBrush.Dispose();
                        }
                        g.DrawImage(bitmap, drawLocThis.X, drawLocThis.Y);
                        DisposeObjects(brush, brushWhite, format, bitmap);
                        return(new Point(drawLoc.X, drawLoc.Y - (int)noteSize.Height));
                    }
                    else
                    {
                        noteSize = g.MeasureString(text, baseFont, (int)w);
                        noteSize = new SizeF(noteSize.Width, ApptDrawing.LineH + 1);                   //only allowed to be one line high.  Needs an extra pixel.
                        if (noteSize.Width < 5)
                        {
                            noteSize = new SizeF(5, noteSize.Height);
                        }
                        //g.MeasureString(text,baseFont,noteSize,format,out charactersFitted,out linesFilled);
                        Point drawLocThis = new Point(drawLoc.X - (int)noteSize.Width, drawLoc.Y - ApptDrawing.LineH);                 //upper left corner of this element
                        rect     = new RectangleF(drawLocThis, noteSize);
                        rectBack = new RectangleF(drawLocThis.X, drawLocThis.Y + 1, noteSize.Width, ApptDrawing.LineH);
                        if (apptRows[elementI].ElementDesc == "MedOrPremed[+]" ||
                            apptRows[elementI].ElementDesc == "HasIns[I]" ||
                            apptRows[elementI].ElementDesc == "InsToSend[!]")
                        {
                            g.FillRectangle(brush, rectBack);
                            g.DrawString(text, baseFont, Brushes.Black, rect, format);
                        }
                        else
                        {
                            g.FillRectangle(brushWhite, rectBack);
                            g.DrawString(text, baseFont, brush, rect, format);
                        }
                        g.DrawRectangle(Pens.Black, rectBack.X, rectBack.Y, rectBack.Width, rectBack.Height);
                        DisposeObjects(brush, brushWhite, format);
                        return(new Point(drawLoc.X, drawLoc.Y - ApptDrawing.LineH));                    //move up a certain number of lines for next element.
                    }
                }
                else                       //horizontal
                {
                    int w = drawLoc.X - 9; //drawLoc is upper right of each element.  The first element draws at (totalWidth-1,0).
                    if (isGraphic)
                    {
                        Bitmap bitmap = new Bitmap(12, 12);
                        noteSize = new SizeF(bitmap.Width, bitmap.Height);
                        Point drawLocThis = new Point(drawLoc.X - (int)noteSize.Width + 1, drawLoc.Y + 1 - ApptDrawing.LineH);             //upper left corner of this element
                        rect = new RectangleF(drawLoc, noteSize);
                        using (Graphics gfx = Graphics.FromImage(bitmap)) {
                            gfx.SmoothingMode = SmoothingMode.HighQuality;
                            Color      confirmColor = DefC.GetColor(DefCat.ApptConfirmed, PIn.Long(dataRoww["Confirmed"].ToString()));
                            SolidBrush confirmBrush = new SolidBrush(confirmColor);
                            gfx.FillEllipse(confirmBrush, 0, 0, 11, 11);
                            gfx.DrawEllipse(Pens.Black, 0, 0, 11, 11);
                            confirmBrush.Dispose();
                        }
                        g.DrawImage(bitmap, drawLocThis.X, drawLocThis.Y);
                        DisposeObjects(brush, brushWhite, format, bitmap);
                        return(new Point(drawLoc.X - (int)noteSize.Width - 1, drawLoc.Y));
                    }
                    else
                    {
                        noteSize = g.MeasureString(text, baseFont, w);
                        noteSize = new SizeF(noteSize.Width, ApptDrawing.LineH + 1);                   //only allowed to be one line high.  Needs an extra pixel.
                        if (noteSize.Width < 5)
                        {
                            noteSize = new SizeF(5, noteSize.Height);
                        }
                        Point drawLocThis = new Point(drawLoc.X - (int)noteSize.Width, drawLoc.Y - ApptDrawing.LineH);                 //upper left corner of this element
                        rect     = new RectangleF(drawLocThis, noteSize);
                        rectBack = new RectangleF(drawLocThis.X, drawLocThis.Y + 1, noteSize.Width, ApptDrawing.LineH);
                        if (apptRows[elementI].ElementDesc == "MedOrPremed[+]" ||
                            apptRows[elementI].ElementDesc == "HasIns[I]" ||
                            apptRows[elementI].ElementDesc == "InsToSend[!]")
                        {
                            g.FillRectangle(brush, rectBack);
                            g.DrawString(text, baseFont, Brushes.Black, rect, format);
                        }
                        else
                        {
                            g.FillRectangle(brushWhite, rectBack);
                            g.DrawString(text, baseFont, brush, rect, format);
                        }
                        g.DrawRectangle(Pens.Black, rectBack.X, rectBack.Y, rectBack.Width, rectBack.Height);
                        DisposeObjects(brush, brushWhite, format);
                        return(new Point(drawLoc.X - (int)noteSize.Width - 1, drawLoc.Y));                  //Move to left.  Subtract a little from x to space out elements.
                    }
                }
            }
            #endregion
        }