示例#1
0
 /// <summary>
 /// Shows the control as a floating Window child
 /// of the desktop.  To hide the control again,
 /// use the <see cref="System.Windows.Forms.Control.Visible"/> property.
 /// </summary>
 public void ShowFloating(VSNetListBarItem owner)
 {
     this.owner = owner;
     if (Handle == IntPtr.Zero)
     {
         CreateControl();
     }
     SetParent(Handle, IntPtr.Zero);
     ShowWindow(Handle, 1);
 }
        private void frmVsNetListBarTest_Load(object sender, EventArgs e)
        {
            Random randGen = new Random();

            // Add some items to the TreeView:
            tvwCustom.ImageList     = ilsIconsSmall;
            tvwCustom.ShowLines     = true;
            tvwCustom.ShowPlusMinus = true;
            TreeNode[] childNodes = new TreeNode[10];
            for (int i = 0; i < 10; i++)
            {
                int iconIndex = randGen.Next(ilsIconsSmall.Images.Count);
                childNodes[i] = new TreeNode(
                    String.Format("TreeItem {0}", i),
                    iconIndex, iconIndex);
            }
            TreeNode nodTop = new TreeNode("Connections", 0, 0, childNodes);

            tvwCustom.Nodes.Add(nodTop);
            nodTop.Expand();

            // Add some items to the ListBar:
            vsNetListBar1.LargeImageList = ilsIconsLarge;
            vsNetListBar1.SmallImageList = ilsIconsSmall;
            vsNetListBar1.ToolTip        = toolTips;

            // Add some items to the ListBar:
            for (int i = 0; i < 4; i++)
            {
                int jMax = 2 + randGen.Next(10);
                VSNetListBarItem[] subItems = new VSNetListBarItem[jMax];
                for (int j = 0; j < jMax; j++)
                {
                    subItems[j] = new VSNetListBarItem(
                        String.Format("Test Item {0} in Bar {1}", j + 1, i + 1),
                        j % 4,
                        String.Format("Tooltip text for test item {0}", j + 1));
                    if (j == 2)
                    {
                        subItems[j].Enabled = false;
                    }
                }
                vsNetListBar1.Groups.Add(
                    new VSNetListBarGroup(String.Format("Test {0}", i + 1),
                                          subItems));
            }
            // Add a bar containing the Tree control:
            VSNetListBarGroup treeGroup = vsNetListBar1.Groups.Add("Tree");

            treeGroup.ChildControl = tvwCustom;

            // Configure ListBar events:
            vsNetListBar1.ItemClicked          += listBar1_ItemClicked;
            vsNetListBar1.ItemDoubleClicked    += listBar1_ItemDoubleClicked;
            vsNetListBar1.GroupClicked         += listBar1_GroupClicked;
            vsNetListBar1.SelectedGroupChanged += listBar1_SelectedGroupChanged;

            // Group property editor
            cboGroups.SelectedIndexChanged += cboGroups_SelectedIndexChanged;
            pnlProperties.SizeChanged      += pnlProperties_SizeChanged;

            showGroupProperties();
        }