///<summary>Gets the rectangle in pixels surrounding a tooth number. Used to draw the box and to invalidate the area.</summary> private RectangleF GetNumberRec(string tooth_id, Graphics g) { float xPos = GetTransX(tooth_id); float yPos = Height / 2f; if (ToothGraphic.IsMaxillary(tooth_id)) { yPos -= 14; } else { yPos += 3; } string displayNum = tooth_id; if (useInternational) { displayNum = ToothGraphic.ToInternat(displayNum); } float strWidth = g.MeasureString(displayNum, Font).Width; xPos -= strWidth / 2f; RectangleF rec = new RectangleF(xPos - 1, yPos - 1, strWidth, 12); //this rec has origin at UL return(rec); }
///<summary>Draws the number and the rectangle behind it. Draws in the appropriate color</summary> private void DrawNumber(int intTooth, bool isSelected, bool isFullRedraw, Graphics g) { string tooth_id = intTooth.ToString(); string displayNum = intTooth.ToString(); bool hideNumber = false; string pri = ToothGraphic.PermToPri(tooth_id); try{ if (ToothGraphic.IsValidToothID(pri) && //pri is valid ListToothGraphics[pri].Visible) //and pri visible { tooth_id = pri; } if (isFullRedraw && ListToothGraphics[tooth_id].HideNumber) //if redrawing all numbers, and this is a "hidden" number { return; //skip } displayNum = tooth_id; if (useInternational) { displayNum = ToothGraphic.ToInternat(displayNum); } hideNumber = ListToothGraphics[tooth_id].HideNumber; } catch { //must be design mode. } RectangleF rec = GetNumberRec(tooth_id, g); if (isSelected) { g.FillRectangle(new SolidBrush(colorBackHighlight), rec); if (!hideNumber) //Only draw if number is not hidden. { g.DrawString(displayNum, Font, new SolidBrush(colorTextHighlight), rec.X, rec.Y); } } else { g.FillRectangle(new SolidBrush(colorBackground), rec); if (!hideNumber) //Only draw if number is not hidden. { g.DrawString(displayNum, Font, new SolidBrush(colorText), rec.X, rec.Y); } } }