Esempio n. 1
0
        private TabStripPage CreateAndRegisterEntityPage(CategoryCollection categories, IConfigurablePlugin entity, int index)
        {
            TabStripPage entityPage = new TabStripPage();
            entityPage.BaseColor = System.Drawing.Color.FromArgb(215, 227, 242);
            entityPage.BaseColorOn = System.Drawing.Color.FromArgb(215, 227, 242);
            entityPage.Dock = System.Windows.Forms.DockStyle.Fill;
            entityPage.Opacity = 255;
            entityPage.Padding = new System.Windows.Forms.Padding(0, 3, 0, 0);
            entityPage.Size = new System.Drawing.Size(784, 99);
            entityPage.Speed = 1;
            entityPage.TabIndex = index;

            RibbonPageSwitcher.Controls.Add(entityPage);

            Tab entityTab = new Tab(entity.Name);
            entityTab.AutoSize = false;
            entityTab.Checked = true;
            entityTab.CheckState = CheckState.Checked;
            entityTab.ForeColor = System.Drawing.Color.FromArgb(44, 90, 154);
            entityTab.Margin = new Padding(6, 1, 0, 2);
            entityTab.Size = new Size(73, 23);
            entityTab.Text = entity.Name;
            entityTab.TabStripPage = entityPage;

            if (entity is IInternalConfigurator)
                entityTab.Image = VisualResources.Icon_16x16_Hyphen.ToBitmap();

            RibbonStrip.Items.Add(entityTab);

            return entityPage;
        }
        /// <summary>
        /// Method implementation for our "Add TabStripPage verb".
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eevent"></param>
        private void OnAdd(object sender, EventArgs eevent)
        {
            // fetch our designer host
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (host != null)
            {
                // Create a transaction so we're friendly to undo/redo and serialization
                DesignerTransaction t = null;
                try {
                    try {
                        t = host.CreateTransaction(TabStripControlLibrary.Properties.Resources.AddTab + Component.Site.Name);
                    }
                    catch (CheckoutException ex) {
                        if (ex == CheckoutException.Canceled)
                        {
                            return;
                        }
                        throw ex;
                    }

                    // Add a TabStripPage to the controls collection of the TabPageSwitcher

                    // Notify the TabPageSwitcher that it's control collection is changing.
                    MemberDescriptor member = TypeDescriptor.GetProperties(ControlSwitcher)["Controls"];
                    TabStripPage     page   = host.CreateComponent(typeof(TabStripPage)) as TabStripPage;
                    RaiseComponentChanging(member);

                    // add the page to the controls collection.
                    ControlSwitcher.Controls.Add(page);

                    // set the SelectedTabStripPage to the current page so that it opens correctly
                    SetProperty("SelectedTabStripPage", page);

                    // Raise event that we're done changing the controls property.
                    RaiseComponentChanged(member, null, null);

                    // if we have an associated TabStrip,
                    // add a matching Tab to the TabStrip.
                    if (ControlSwitcher.TabStrip != null)
                    {
                        // add a tab to the toolstrip designer
                        MemberDescriptor itemsProp = TypeDescriptor.GetProperties(ControlSwitcher.TabStrip)["Items"];

                        Tab tab = host.CreateComponent(typeof(Tab)) as Tab;
                        RaiseComponentChanging(itemsProp);

                        ControlSwitcher.TabStrip.Items.Add(tab);
                        RaiseComponentChanged(itemsProp, null, null);

                        SetProperty(tab, "DisplayStyle", ToolStripItemDisplayStyle.ImageAndText);
                        SetProperty(tab, "Text", tab.Name);
                        SetProperty(tab, "TabStripPage", page);
                        SetProperty(ControlSwitcher.TabStrip, "SelectedTab", tab);
                    }
                }
                finally {
                    if (t != null)
                    {
                        t.Commit();
                    }
                }
            }
        }
Esempio n. 3
0
        private void PopulateCategoryPanel(TabStripPage entityPage, Category category, IConfigurablePlugin plugin, int index)
        {
            TabPanel categoryPanel = CreateCategoryPanel(category, index);
            entityPage.Controls.Add(categoryPanel);

            if (CanNavigateTo(plugin, category))
                RibbonPageSwitcher.SelectedTabStripPage = entityPage;

            Point nextLocation = new Point();

            foreach (CategoryItem item in category.Items)
            {
                RibbonButton btn = CreateButton(item, ref nextLocation);
                categoryPanel.Controls.Add(btn);

                if (CanNavigateTo(item))
                    RibbonButton_Click(btn, EventArgs.Empty);
            }
        }