private void OnHeadClicked(MyCodeHead hd)
 {
     if (HeadClicked != null)
     {
         HeadClicked(hd.LineNumber);
     }
 }
    public bool Insert(int index)
    {
        if (index < 0 || index >= LineCount)
        {
            return(false);
        }

        string text = string.Empty;

        GameObject objLn = Instantiate(prefabLine, transLineRoot) as GameObject;
        MyCodeLine ln    = objLn.GetComponent <MyCodeLine>();

        ln.Height     = (float)Screen.height / lineCountPerScreen;
        ln.LineNumber = index;
        ln.SetText(text, Color(text));
        ln.LineClicked += OnLineClicked;
        lines.Insert(index, ln);

        GameObject objHd = Instantiate(prefabHead, transHeadRoot) as GameObject;
        MyCodeHead hd    = objHd.GetComponent <MyCodeHead>();

        hd.Height       = (float)Screen.height / lineCountPerScreen;
        hd.LineNumber   = ln.LineNumber;
        hd.HeadClicked += OnHeadClicked;
        heads.Insert(index, hd);

        for (int i = index + 1; i < LineCount; ++i)
        {
            ++lines[i].LineNumber;
            ++heads[i].LineNumber;
        }

        return(true);
    }
 public void Unselect()
 {
     for (int i = 0; i < LineCount; ++i)
     {
         MyCodeHead h = heads[i];
         h.toggleSelection.isOn = false;
     }
 }
 public void Select(int index)
 {
     if (index >= 0 && index < LineCount)
     {
         MyCodeHead h = heads[index];
         bool       e = h.SelectionEnabled;
         h.SelectionEnabled     = true;
         h.toggleSelection.isOn = true;
         h.SelectionEnabled     = e;
     }
 }
 public void Unselect(IEnumerable <int> indices)
 {
     foreach (int i in indices)
     {
         if (i >= 0 && i < LineCount)
         {
             MyCodeHead h = heads[i];
             h.toggleSelection.isOn = false;
         }
     }
 }
    public bool Unselect(int index)
    {
        if (index < 0 || index >= LineCount)
        {
            return(false);
        }

        MyCodeHead h = heads[index];

        h.toggleSelection.isOn = false;

        return(true);
    }
 public void Select(IEnumerable <int> indices)
 {
     foreach (int i in indices)
     {
         if (i >= 0 && i < LineCount)
         {
             MyCodeHead h = heads[i];
             bool       e = h.SelectionEnabled;
             h.SelectionEnabled     = true;
             h.toggleSelection.isOn = true;
             h.SelectionEnabled     = e;
         }
     }
 }
    public int Append(string text)
    {
        GameObject objLn = Instantiate(prefabLine, transLineRoot) as GameObject;
        MyCodeLine ln    = objLn.GetComponent <MyCodeLine>();

        ln.Height     = (float)Screen.height / lineCountPerScreen;
        ln.LineNumber = LineCount;
        ln.SetText(text, Color(text));
        ln.LineClicked += OnLineClicked;
        lines.Add(ln);

        GameObject objHd = Instantiate(prefabHead, transHeadRoot) as GameObject;
        MyCodeHead hd    = objHd.GetComponent <MyCodeHead>();

        hd.Height       = (float)Screen.height / lineCountPerScreen;
        hd.LineNumber   = ln.LineNumber;
        hd.HeadClicked += OnHeadClicked;
        heads.Add(hd);

        return(lines.Count);
    }
 public static RectTransform Rect(this MyCodeHead ui)
 {
     return(ui.GetComponent <RectTransform>());
 }