///<summary>Sets the specified permanent tooth to primary as follows: Sets ShowPrimary to true for the perm tooth.  Makes pri tooth visible=true, repositions perm tooth by translating -Y.  Moves primary tooth slightly to M or D sometimes for better alignment.  And if 2nd primary molar, then because of the larger size, it must move all perm molars to distal.  Ignores if invalid perm tooth.</summary>
 public void SetToPrimary(string toothID)
 {
     if (simpleMode)
     {
         if (!ToothGraphic.IsValidToothID(toothID))
         {
             return;
         }
         if (ToothGraphic.IsPrimary(toothID))
         {
             return;
         }
         ListToothGraphics[toothID].ShowPrimary = true;
         //ListToothGraphics[toothID].ShiftO-=12;
         ListToothGraphics[toothID].Visible = false;              //instead of shiftO
         this.Invalidate();
         if (!ToothGraphic.IsValidToothID(ToothGraphic.PermToPri(toothID)))
         {
             return;
         }
         ListToothGraphics[ToothGraphic.PermToPri(toothID)].Visible = true;
     }
     else
     {
         toothChart.SetToPrimary(toothID);
     }
 }
        ///<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);
                }
            }
        }
 ///<summary>Used by mousedown and mouse move to set teeth selected or unselected.  Also used externally to set teeth selected.  Draws the changes also.</summary>
 public void SetSelected(int intTooth, bool setValue)
 {
     if (simpleMode)
     {
         Graphics g = this.CreateGraphics();
         if (setValue)
         {
             ALSelectedTeeth.Add(intTooth);
             DrawNumber(intTooth, true, false, g);
         }
         else
         {
             ALSelectedTeeth.Remove(intTooth);
             DrawNumber(intTooth, false, false, g);
         }
         RectangleF recF = GetNumberRec(intTooth.ToString(), g);
         Rectangle  rec  = new Rectangle((int)recF.X, (int)recF.Y, (int)recF.Width, (int)recF.Height);
         Invalidate(rec);
         Application.DoEvents();
         if (ALSelectedTeeth.Count == 0)
         {
             selectedTeeth = new string[0];
         }
         else
         {
             selectedTeeth = new string[ALSelectedTeeth.Count];
             for (int i = 0; i < ALSelectedTeeth.Count; i++)
             {
                 if (ToothGraphic.IsValidToothID(ToothGraphic.PermToPri(ALSelectedTeeth[i].ToString())) &&                    //pri is valid
                     ListToothGraphics[ALSelectedTeeth[i].ToString()].ShowPrimary)                       //and set to show pri
                 {
                     selectedTeeth[i] = ToothGraphic.PermToPri(ALSelectedTeeth[i].ToString());
                 }
                 else
                 {
                     selectedTeeth[i] = ((int)ALSelectedTeeth[i]).ToString();
                 }
             }
         }
         g.Dispose();
     }
     else
     {
         toothChart.SetSelected(intTooth, setValue);
     }
 }
 ///<summary>If ListToothGraphics is empty, then this fills it, including the complex process of loading all drawing points from local resources.  Or if not empty, then this resets all 32+20 teeth to default postitions, no restorations, etc. Primary teeth set to visible false.  Also clears selected.  Should surround with SuspendLayout / ResumeLayout.</summary>
 public void ResetTeeth()
 {
     selectedTeeth = new string[0];
     if (simpleMode)
     {
         if (ListToothGraphics.Count == 0)               //so this will only happen once when program first loads.
         {
             ListToothGraphics.Clear();
             ToothGraphic tooth;
             for (int i = 1; i <= 32; i++)
             {
                 tooth         = new ToothGraphic(i.ToString());
                 tooth.Visible = true;
                 ListToothGraphics.Add(tooth);
                 //primary
                 if (ToothGraphic.PermToPri(i.ToString()) != "")
                 {
                     tooth         = new ToothGraphic(ToothGraphic.PermToPri(i.ToString()));
                     tooth.Visible = false;
                     ListToothGraphics.Add(tooth);
                 }
             }
         }
         else                                                  //list was already initially filled, but now user needs to reset it.
         {
             for (int i = 0; i < ListToothGraphics.Count; i++) //loop through all perm and pri teeth.
             {
                 ListToothGraphics[i].Reset();
             }
         }
         ALSelectedTeeth.Clear();
         selectedTeeth = new string[0];
         this.Invalidate();
     }
     else
     {
         toothChart.ResetTeeth();
     }
 }