Exemple #1
0
        private HitObject GetHitPart(int x, int y, TVItem item)
        {
            HitObject hit = null;

            //Debugger.Log(0, "", "Item: " + item.Name + " " + item.PaintRect.ToString() + "\n");
            if (item.PaintRect.Contains(x, y))
            {
                hit      = new HitObject();
                hit.Item = item;
                hit.Part = HitObjectPart.Title;
                if (x < item.PaintRect.X + item.PaintRect.Height && item.IsExpandable())
                {
                    hit.Part = HitObjectPart.ExpandButton;
                }
                else if (x > item.PaintRect.Right - ItemHeight)
                {
                    hit.Part = HitObjectPart.ActionButton;
                }
            }
            else if (item.IsExpandable() && item.Expanded)
            {
                foreach (TVItem sub in item.Children)
                {
                    hit = GetHitPart(x, y, sub);
                    if (hit != null)
                    {
                        break;
                    }
                }
            }

            return(hit);
        }
Exemple #2
0
 public void SetObject(MNDocument data)
 {
     this.Tree = new TItemDocument(this)
     {
         Document = data, Name = "Document"
     };
     this.Tree.Expand(true);
 }
Exemple #3
0
        private void ShowActionsForObject(TVItem to, Point clientPoint)
        {
            if (to == null)
            {
                return;
            }

            if (to.GetContentData() == null)
            {
                return;
            }

            if (OnInitializeActionMenu == null)
            {
                return;
            }

            TreeObjectViewEventArgs e = new TreeObjectViewEventArgs();

            e.Item        = to;
            e.ScreenPoint = PointToScreen(clientPoint);
            OnInitializeActionMenu(this, e);
        }
Exemple #4
0
        private bool FindAndSelectNode(object p, TVItem item)
        {
            if (item != null)
            {
                if (item.IdenticalData(p))
                {
                    SelectedNode = item;
                    return(true);
                }

                if (item.Expanded)
                {
                    foreach (TVItem ch in item.Children)
                    {
                        if (FindAndSelectNode(p, ch))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemple #5
0
        private int PaintItem(TVItem item, int y, int level, int width, Graphics g)
        {
            string itemName = item.GetName();
            SizeF  textSize = g.MeasureString(itemName, ItemFont);
            int    lastY    = y + ItemHeight;

            item.PaintRect.X      = level * ItemHeight;
            item.PaintRect.Y      = y;
            item.PaintRect.Height = ItemHeight;
            item.PaintRect.Width  = width - level * ItemHeight;
            //Debugger.Log(0, "", "Draw Item: " + item.Name + ", rect:" + item.PaintRect.ToString() + "\n");

            if (item.IdenticalData(p_futureSelection))
            {
                SelectedNode = item;
            }

            if (SelectedNode == item)
            {
                g.FillRectangle(CellSelBackColor, item.PaintRect);
            }

            if (item.IsExpandable())
            {
                int pp = ItemHeight / 5;
                g.DrawImage((item.Expanded ? Properties.Resources.iconCollapse : Properties.Resources.iconExpand),
                            new Rectangle(item.PaintRect.X, item.PaintRect.Y, ItemHeight, ItemHeight));
            }

            g.DrawString(itemName, ItemFont, Brushes.Black, item.PaintRect.X + ItemHeight, item.PaintRect.Y + (int)(ItemHeight - textSize.Height) / 2);

            if (item == SelectedNode && item.GetActions() != null)
            {
                g.DrawImage(Properties.Resources.IconActions, width - ItemHeight, y, ItemHeight, ItemHeight);
            }

            if (item.Expanded)
            {
                // padding before
                lastY += 4;
                int topY = lastY;

                if (item.Children != null && item.Children.Count > 0)
                {
                    // higher level of children
                    level++;


                    g.DrawLine(CellBorderPen, level * ItemHeight, lastY, level * ItemHeight + 8, lastY);
                    for (int i = 0; i < item.Children.Count; i++)
                    {
                        lastY = PaintItem(item.Children[i], lastY, level, width - 2, g);
                        g.DrawLine(CellBorderPen, level * ItemHeight, lastY, level * ItemHeight + 8, lastY);
                    }

                    // vertical line
                    //g.DrawLine(CellBorderPen, width - 1, topY, width - 1, lastY);
                    g.DrawLine(CellBorderPen, level * ItemHeight, topY, level * ItemHeight, lastY);
                }
                else
                {
                    textSize = g.MeasureString("(empty)", ItemEmptyFont);
                    g.DrawString("(empty)", ItemEmptyFont, Brushes.Black, item.PaintRect.X + ItemHeight, lastY + (int)(ItemHeight - textSize.Height) / 2);
                    lastY += ItemHeight;
                }

                // padding after
                lastY += 4;
            }

            return(lastY);
        }