예제 #1
0
 private void OnItemRemoved(BreadCrumbItem item)
 {
     if (ItemRemoved != null)
     {
         ItemRemoved(this, new BreadCrumbEventArgs(item));
     }
     RenderBreadCrumb();
 }
예제 #2
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);
            BreadCrumbItem bc = GetItemUnder(e.Location);

            if (bc != null)
            {
                if (ItemClicked != null)
                {
                    ItemClicked(this, new BreadCrumbEventArgs(bc));
                }
            }
        }
예제 #3
0
        public BreadCrumbItem AddItem(string value)
        {
            BreadCrumbItem item = new BreadCrumbItem()
            {
                ID    = Guid.NewGuid().ToString(),
                Value = value,
                Level = Items.Count()
            };

            Items.Add(item);
            OnItemAdded(Items.Last());
            return(item);
        }
예제 #4
0
 public void RemoveItemsAfter(BreadCrumbItem item)
 {
     Items.Sort();
     if (Items.Contains(item))
     {
         while (Items.Last().ID != item.ID)
         {
             Items.Remove(Items.Last());
         }
         RenderBreadCrumb();
         return;
     }
     throw new Exception("Cannot find item");
 }
예제 #5
0
        private void RenderBreadCrumb(int x = -1, int y = -1)
        {
            _mouseLocation = new Point(x, y);

            int h   = this.Height;
            int xof = this.Height;

            Items.First().Point0 = new PointF(0, 0);
            Items.First().Point1 = new PointF(0 + xof, 0);
            Items.First().Point2 = new PointF(0 + xof + h / 2, h / 2);
            Items.First().Point3 = new PointF(0 + xof, h);
            Items.First().Point4 = new PointF(0, h);
            Items.First().Point5 = new PointF(0, h / 2);
            if (Items.Count > 1)
            {
                Items.Sort();
                BreadCrumbItem lastItem = Items[0];
                foreach (BreadCrumbItem item in Items.ToList())
                {
                    if (item.Value != "Home")
                    {
                        float p1 = lastItem.Region[1].X;
                        float p2 = lastItem.Region[2].X;
                        float p3 = lastItem.Region[3].X;

                        SizeF size;
                        using (Graphics g = this.CreateGraphics())
                        {
                            size = g.MeasureString(item.Value, this.Font);
                        }
                        float padding = (h - size.Height) / 2;
                        float xoffset = size.Width + padding * 2;
                        item.Point0 = new PointF(p1, 0);
                        item.Point1 = new PointF(p1 + xoffset, 0);
                        item.Point2 = new PointF(p2 + xoffset, h / 2);
                        item.Point3 = new PointF(p3 + xoffset, h);
                        item.Point4 = new PointF(p3, h);
                        item.Point5 = new PointF(p2, h / 2);
                        //item.Region = points;
                        item.TextLocation = new PointF(p2 + padding, padding);
                    }
                    lastItem = item;
                }
            }
            Invalidate();
        }
예제 #6
0
 public BreadCrumbItem RemoveItems(BreadCrumbItem item)
 {
     Items.Sort();
     if (Items.Contains(item))
     {
         if (Items.Count(it => it.ID == item.ID) > 0)
         {
             BreadCrumbItem i = Items.Last();
             Items.Remove(i);
             while (Items.Count > 0 && i.ID != item.ID)
             {
                 i = Items.Last();
                 Items.Remove(i);
                 OnItemRemoved(i);
             }
             return(i);
         }
     }
     throw new Exception("Cannot find item");
 }
예제 #7
0
 public BreadCrumbEventArgs(BreadCrumbItem item)
 {
     BreadCrumbItem = item;
 }