Exemplo n.º 1
0
        private void ToolboxListBox_MouseDown(object sender, MouseEventArgs e)
        {
            int itemIndex = this.IndexFromPoint(e.Location);

            if (itemIndex != -1)
            {
                ToolBoxNode node = Items[itemIndex] as ToolBoxNode;
                if (node != null)
                {
                    DoDragDrop(node, DragDropEffects.Move);
                }
            }
        }
Exemplo n.º 2
0
        private ToolBoxNode GetNewToolChildNode(string line)
        {
            int         comma = line.IndexOf(",");
            ToolBoxNode child = null;

            if (comma > 0)
            {
                child     = new ToolBoxNode(line.Substring(0, comma));
                child.Tag = line.Substring(comma + 1);
            }
            else
            {
                child = new ToolBoxNode(line);
                child.AlwaysExpand = true;
            }

            return(child);
        }
Exemplo n.º 3
0
        private void LoadSmartFromFile(string file)
        {
            ToolBoxNode parentNode = null;

            foreach (string line in File.ReadLines(file))
            {
                ToolBoxNode new_node = GetNewToolChildNode(line);
                if (line.IndexOf(" ") == 0)
                {
                    parentNode.Nodes.Add(new_node);
                }
                else
                {
                    parentNode = new_node;
                    label1.Nodes.Add(parentNode);
                }
            }
        }
Exemplo n.º 4
0
        //Event Hanlders
        private void CustomListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (this.Items.Count == 0)
            {
                return;
            }

            ToolBoxNode item = this.Items[e.Index] as ToolBoxNode;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e = new DrawItemEventArgs(e.Graphics,
                                          e.Font,
                                          e.Bounds,
                                          e.Index,
                                          e.State ^ DrawItemState.Selected,
                                          e.ForeColor,
                                          Color.LightGray);
            }
            else if (e.Index == m_mouseIndex)
            {
                e = new DrawItemEventArgs(e.Graphics,
                                          e.Font,
                                          e.Bounds,
                                          e.Index,
                                          e.State,
                                          e.ForeColor,
                                          Color.DarkGray);
            }

            e.DrawBackground();

            Rectangle iconRect = new Rectangle(e.Bounds.X + 2, e.Bounds.Y + ((e.Bounds.Height - item.Icon.Height) / 2), item.Icon.Width, item.Icon.Height);

            e.Graphics.DrawImage(item.Icon, iconRect);

            Rectangle    fontRectangle = new Rectangle(e.Bounds.X + iconRect.Right + 2, e.Bounds.Y, e.Bounds.Width - iconRect.Width, e.Bounds.Height);
            StringFormat stringFormat  = new StringFormat();

            //stringFormat.Alignment = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;
            e.Graphics.DrawString(item.ToString(), e.Font, new SolidBrush(e.ForeColor), fontRectangle, stringFormat);
        }
Exemplo n.º 5
0
        private ToolBoxNode GetNewToolChildNode(string line)
        {
            int         comma = line.IndexOf(",");
            ToolBoxNode child = null;

            if (comma > 0)
            {
                child     = new ToolBoxNode(line.Substring(0, comma));
                child.Tag = line.Substring(comma + 1);
                Dictionary <SmartType, Dictionary <string, int> > smart_name_to_id = SmartFactory.GetInstance().smart_name_to_id;
                child.Tag2 = SmartFactory.GetInstance().NameToId(type, line.Substring(comma + 1));
            }
            else
            {
                child = new ToolBoxNode(line);
                child.AlwaysExpand = true;
            }

            return(child);
        }
Exemplo n.º 6
0
 public override bool Show(ToolBoxNode node)
 {
     return(node.Tag != null && SmartFactory.GetInstance().IsEventValidType(node.Tag.ToString(), Type));
 }