Exemple #1
0
            int IComparer.Compare(Object x, Object y)
            {
                CSelection selX = (CSelection)x;
                CSelection selY = (CSelection)y;

                return(selX.start - selY.start);
            }
Exemple #2
0
 public void ShowColor(RichTextBox textBox)
 {
     foreach (Object obj in arSelection)
     {
         CSelection sel = (CSelection)obj;
         textBox.SelectionStart  = sel.start;
         textBox.SelectionLength = sel.end - sel.start + 1;
         textBox.SelectionColor  = Color.FromArgb(sel.argb);
     }
 }
Exemple #3
0
 public void Resize(int end)
 {
     CSelection[] arSel = (CSelection[])arSelection.ToArray(typeof(CSelection));
     for (int i = 0; i < arSelection.Count; ++i)
     {
         CSelection sel = arSel[i];
         if (sel.start > end)
         {
             arSelection.Remove(sel);
         }
         else if (sel.end > end)
         {
             sel.end = end;
         }
     }
 }
Exemple #4
0
        public void AddSelection(int start, int end, int argb)
        {
            ArrayList arAdd = new ArrayList();
            ArrayList arDel = new ArrayList();

            foreach (Object obj in arSelection)
            {
                CSelection sel = (CSelection)obj;

                if (start <= sel.start && end > sel.start)
                {
                    if (end < sel.end)
                    {
                        sel.start = end + 1;
                    }
                    else
                    {
                        arDel.Add(sel);
                    }
                }
                else if (start >= sel.start && start < sel.end)
                {
                    if (end < sel.end)
                    {
                        CSelection newSel2 = new CSelection();
                        newSel2.start = end + 1;
                        newSel2.end   = sel.end;
                        newSel2.argb  = sel.argb;
                        arAdd.Add(newSel2);
                    }
                    sel.end = start - 1;
                }
            }

            arSelection.AddRange(arAdd);
            foreach (Object obj in arDel)
            {
                arSelection.Remove(obj);
            }

            if ((UInt32)argb != 0xFF000000)
            {
                CSelection newSel = new CSelection();
                newSel.start = start;
                newSel.end   = end;
                newSel.argb  = argb;
                arSelection.Add(newSel);
            }

            arSelection.Sort(new CLess());

            arDel.Clear();
            CSelection prev = null;

            foreach (Object obj in arSelection)
            {
                CSelection next = (CSelection)obj;
                if (prev != null)
                {
                    if (prev.argb == next.argb && prev.end + 1 >= next.start)
                    {
                        next.start = prev.start;
                        arDel.Add(prev);
                    }
                }
                prev = next;
            }
            foreach (Object obj in arDel)
            {
                arSelection.Remove(obj);
            }
        }