Exemplo n.º 1
0
        public tl GetByIndex(int index)
        {
            tl tmp = null;

            if (index == -1)
            {
                return(tmp);
            }
            RevListElement t = (RevListElement)(control.ht[control.Items[index]]);

            if (t != null)
            {
                tmp = t.main;
            }
            return(tmp);
        }
Exemplo n.º 2
0
        public void CreateItems(tl el, bool sub = false)
        {
            tl     tmp;
            double selrand = -100, lrand = -100, rrand = -100;

            if (sela != null && selb != null && sela.rand == selb.rand)
            {
                selrand = sela.rand;
            }
            if (sela != null)
            {
                lrand = sela.rand;
            }
            if (selb != null)
            {
                rrand = selb.rand;
            }
            RevListElement last = null;

            for (int a = el.count - 1; a >= 0; a--)
            {
                RevListElement rve = new RevListElement(); last = rve;
                tmp = el.children[a];

                rve.rand   = tmp.rand;
                rve.rand_s = rve.rand + "";
                rve.main   = tmp;
                rve.sub    = sub;

                if (!curr.page.is_flagged)
                {
                    rve.color = 1;
                }
                else if (tmp.revision.flagged)
                {
                    rve.color = 3;
                }
                else
                {
                    rve.color = 2;
                }

                if (selrand == rve.rand)
                {
                    rve.selected = true;
                }
                if (lrand == rve.rand)
                {
                    rve.offset = 1;
                }
                if (rrand == rve.rand)
                {
                    rve.offset = 2;
                }

                //if(tmp.revision.flagged

                if (tmp.type == 0 && tmp.count == 1)
                {
                    CreateItems(tmp); continue;
                }
                else if (tmp.type == 0)
                {
                    rve.state = 0;
                    control.AddAssigned(rve.rand_s, rve);
                    if (!tmp.hidden)
                    {
                        rve.state = 1; CreateItems(tmp, true);
                    }
                }
                else if (tmp.type == 1)
                {
                    rve.state = 2;
                    control.AddAssigned(rve.rand_s, rve);
                }
            }
            if (last != null)
            {
                last.last = true;
            }
        }
Exemplo n.º 3
0
 public void AddAssigned(String key, RevListElement value)
 {
     ht[key] = value;
     this.Items.Add(key);
     this.items2_list.Add(value);
 }
Exemplo n.º 4
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            // Make sure we're not trying to draw something that isn't there.
            if (e.Index >= this.Items.Count || e.Index <= -1)
            {
                return;
            }

            // Get the item object.
            object item = this.Items[e.Index];

            if (item == null)
            {
                return;
            }

            string         key = item.ToString();
            RevListElement tm  = (RevListElement)(ht[key]);

            if (tm != null)
            {
                // MessageBox.Show(tm.name);
            }
            else
            {
                return;
            }

            e.DrawBackground();
            String text = ""; SizeF stringSize;

            e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);                                       // Изначально всё белое
            int x = e.Bounds.X, y = e.Bounds.Y, h = e.Bounds.Height, w = e.Bounds.Width, bw = 11, bh = h * 7 / 10; //bh = 10, bw = 10;

            if (bh % 2 == 0)
            {
                bh--;
            }
            //bw = (bh - 3) - 2 + 3;
            bw = bh + 1;//(int)((double)(3 / 2 * ((double)bh - 3) + 3));
            // if (bw % 2 == 0) { bw++; }
            //MessageBox.Show(bh + " " + bw);
            x += 2; w -= 2;
            Pen blackpen = new Pen(Color.Black);



            if (tm.selected == false && tm.offset != 0)
            {
                x += 5 * (tm.offset == 1 ? -1 : 1);
                w -= 5;
            }

            if (tm.sub == true)
            {
                x += 7;
                w -= 7;
                e.Graphics.DrawLine(blackpen, new Point(x, y), new Point(x, y + h)); //h
                x += 1;
                w -= 1;
            }
            else
            {
                e.Graphics.DrawLine(blackpen, new Point(x, y), new Point(x, y + h));
                x += 2;
                w -= 2;
                //   e.Graphics.FillRectangle(new SolidBrush(Color.Gainsboro), e.Bounds);
                // e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
            }
            Rectangle r = new Rectangle();

            r.X = x; r.Y = y; r.Width = w; r.Height = e.Bounds.Height;
            switch (tm.color)
            {
            case 0: e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds); break;

            case 1:
                if (tm.sub == false)
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 255, 230, 230)), r);
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 255, 240, 240)), r);
                }
                break;     //red

            case 2:
                if (tm.sub == false)
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(0x7ffffbdb)), r);
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 255, 254, 249)), r);
                }
                break;                                                                                                                     //yellow

            case 3: e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 221, 239, 255) /*Color.FromArgb(0x7ff0f8ff)*/), r); break; //blue
            }

            if (tm.selected)
            {
                r.Height--;
                e.Graphics.DrawRectangle(blackpen, r);
            }
            else
            {
                if (tm.offset == 1)
                {
                    text = "<<";
                    e.Graphics.DrawString(text, this.Font, new SolidBrush(Color.Black), new PointF(w - 10, e.Bounds.Y + (e.Bounds.Height - e.Graphics.MeasureString(text, this.Font).Height) / 2));
                }
                else if (tm.offset == 2)
                {
                    text = ">>";
                    e.Graphics.DrawString(text, this.Font, new SolidBrush(Color.Black), new PointF(w - 10, e.Bounds.Y + (e.Bounds.Height - e.Graphics.MeasureString(text, this.Font).Height) / 2));
                }
            }

            int startx = 0, starty = 0;


            DateTime revtime = DateTime.Parse(tm.main.revision.timestamp);
            int      a = 0, b = 0;

            switch (tm.state)
            {
            case 0:     //collapsed list



                startx = x + 1;
                starty = (h - bh) / 2 + y;    //h / 2 - bh / 2 - 1;
                e.Graphics.DrawLine(blackpen, new Point(startx, starty), new Point(startx + bw, starty));
                e.Graphics.DrawLine(blackpen, new Point(startx, starty), new Point(startx, starty + bh));
                e.Graphics.DrawLine(blackpen, new Point(startx + bw, starty), new Point(startx + bw, starty + bh));
                e.Graphics.DrawLine(blackpen, new Point(startx, starty + bh), new Point(startx + bw, starty + bh));

                a = (bh - 3) / 2 + 1;
                e.Graphics.DrawLine(blackpen, new Point(startx, starty + a), new Point(startx + bw, starty + a));

                b = (bw - 3) / 2 + 2;
                e.Graphics.DrawLine(blackpen, new Point(startx + b, starty), new Point(startx + b, starty + bh));


                x += bw + 2;

                text       = /*"[" + GetItemTime(revtime) + "] " +*/ tm.main.user + " (" + tm.main.count + ")";
                stringSize = e.Graphics.MeasureString(text, this.Font);
                e.Graphics.DrawString(text, this.Font, new SolidBrush(Color.Black), new PointF(x, e.Bounds.Y + (e.Bounds.Height - stringSize.Height) / 2));
                break;

            case 1:     //opened list

                e.Graphics.DrawLine(blackpen, new Point(x - 1, y + h - 1), new Point(x + w, y + h - 1));

                startx = x + 1;
                starty = (h - bh) / 2 + y;    //h / 2 - bh / 2 - 1;
                e.Graphics.DrawLine(blackpen, new Point(startx, starty), new Point(startx + bw, starty));
                e.Graphics.DrawLine(blackpen, new Point(startx, starty), new Point(startx, starty + bh));
                e.Graphics.DrawLine(blackpen, new Point(startx + bw, starty), new Point(startx + bw, starty + bh));
                e.Graphics.DrawLine(blackpen, new Point(startx, starty + bh), new Point(startx + bw, starty + bh));

                a = (bh - 3) / 2 + 1;
                e.Graphics.DrawLine(blackpen, new Point(startx, starty + a), new Point(startx + bw, starty + a));



                x += bw + 2;



                text       = /*"[" + GetItemTime(revtime) + "] " + */ tm.main.user + " (" + tm.main.count + ")";
                stringSize = e.Graphics.MeasureString(text, this.Font);
                e.Graphics.DrawString(text, this.Font, new SolidBrush(Color.Black), new PointF(x, e.Bounds.Y + (e.Bounds.Height - stringSize.Height) / 2));
                break;

            case 2:     //once element
                text = /*"["+GetItemTime(revtime)+"] "+*/ tm.main.user + " " + GetRevFlags(tm.main.revision);
                if (tm.sub)
                {
                    text = "[" + GetItemTime(revtime) + "] " + GetRevFlags(tm.main.revision);
                    if (tm.last)
                    {
                        e.Graphics.DrawLine(blackpen, new Point(x - 1, y + h - 1), new Point(x + w, y + h - 1));
                    }
                }
                stringSize = e.Graphics.MeasureString(text, this.Font);
                e.Graphics.DrawString(text, this.Font, new SolidBrush(Color.Black), new PointF(x, e.Bounds.Y + (e.Bounds.Height - stringSize.Height) / 2));
                break;
            }

            base.OnDrawItem(e);
        }