Ejemplo n.º 1
0
                private void AddToolStripItems()
                {
                    try
                    {
                        ToolStrip customToolStrip = new ToolStrip();
                        customToolStrip.Items.Add(btnShowProperties);
                        customToolStrip.Items.Add(btnShowInheritance);
                        customToolStrip.Items.Add(btnShowDefaultProperties);
                        customToolStrip.Items.Add(btnShowDefaultInheritance);
                        customToolStrip.Items.Add(btnHostStatus);
                        customToolStrip.Items.Add(btnIcon);
                        customToolStrip.Show();

                        ToolStrip propertyGridToolStrip = new ToolStrip();

                        ToolStrip toolStrip = default(ToolStrip);
                        foreach (Control control in pGrid.Controls)
                        {
                            toolStrip = control as ToolStrip;

                            if (toolStrip != null)
                            {
                                propertyGridToolStrip = toolStrip;
                                break; // TODO: might not be correct. Was : Exit For
                            }
                        }

                        if (toolStrip == null)
                        {
                            Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strCouldNotFindToolStripInFilteredPropertyGrid, true);
                            return;
                        }

                        if (!_originalPropertyGridToolStripItemCountValid)
                        {
                            _originalPropertyGridToolStripItemCount = propertyGridToolStrip.Items.Count;
                            _originalPropertyGridToolStripItemCountValid = true;
                        }
                        Debug.Assert(_originalPropertyGridToolStripItemCount == 5);

                        // Hide the "Property Pages" button
                        propertyGridToolStrip.Items[_originalPropertyGridToolStripItemCount - 1].Visible = false;

                        int expectedToolStripItemCount = _originalPropertyGridToolStripItemCount + customToolStrip.Items.Count;
                        if (propertyGridToolStrip.Items.Count != expectedToolStripItemCount)
                        {
                            propertyGridToolStrip.AllowMerge = true;
                            ToolStripManager.Merge(customToolStrip, propertyGridToolStrip);
                        }
                    }
                    catch (Exception ex)
                    {
                        Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strConfigUiLoadFailed + Constants.vbNewLine + ex.Message, true);
                    }
                }
 private void SetActionMenu(ToolStrip menuItems)
 {
     if (menuItems == null)
     {
         itemPanel.Hide();
     }
     else
     {
         if (!itemPanel.DetailArea.Contains(menuItems))
         {
             itemPanel.DetailArea.Controls.Add(menuItems);
             menuItems.Show();
         }
         itemPanel.Show();
     }
 }