コード例 #1
0
        private SidebarControl GetSidebarForCurrentSelection(object selection)
        {
            IHtmlEditorSelection htmlSelection = selection as IHtmlEditorSelection;

            if (selection == null || (!htmlSelection.IsValid && !InlineEditField.IsEditField(selection)))
            {
                return(_defaultSidebarControl);
            }

            foreach (SidebarEntry sidebarEntry in _sidebars)
            {
                ISidebar sidebar = sidebarEntry.Sidebar;
                if (sidebar.AppliesToSelection(selection))
                {
                    SidebarControl sidebarControl = sidebarEntry.SidebarControl;
                    if (sidebarControl == null)
                    {
                        // demand-create sidebar
                        sidebarEntry.SidebarControl         = CreateAndInitializeSidebar(sidebar);
                        sidebarEntry.SidebarControl.Visible = sidebarEntry.SidebarControl.Controls.Count > 0;
                    }
                    return(sidebarEntry.SidebarControl);
                }
            }

            // got this far so no active sidebar for current selection
            return(_defaultSidebarControl);
        }
コード例 #2
0
        public SidebarControl GetSidebarControlOfType(Type type)
        {
            foreach (SidebarEntry sidebarEntry in _sidebars)
            {
                SidebarControl sidebarControl = sidebarEntry.SidebarControl;
                if (sidebarControl != null && type.IsInstanceOfType(sidebarControl))
                {
                    return(sidebarControl);
                }
            }

            return(null);
        }
コード例 #3
0
        private SidebarControl CreateAndInitializeSidebar(ISidebar sidebar)
        {
            SidebarControl sidebarControl = sidebar.CreateSidebarControl(this);

            sidebarControl.Dock    = DockStyle.Fill;
            sidebarControl.Visible = false;

            //synchronize the scale of the sidebar with this control's scale
            sidebarControl.Scale(new SizeF(scale.Width, scale.Height));

            _mainPanel.Controls.Add(sidebarControl);
            return(sidebarControl);
        }
コード例 #4
0
 /// <summary>
 /// Sidebar that will show when no other sidebar needs to show for the
 /// current editor selection
 /// </summary>
 /// <param name="defaultSidebar"></param>
 public void RegisterDefaultSidebar(ISidebar defaultSidebar)
 {
     _defaultSidebarControl = CreateAndInitializeSidebar(defaultSidebar);
 }
コード例 #5
0
 /// <summary>
 /// Sidebar that will show when no other sidebar needs to show for the
 /// current editor selection
 /// </summary>
 /// <param name="defaultSidebar"></param>
 public void RegisterDefaultSidebar(ISidebar defaultSidebar)
 {
     _defaultSidebarControl = CreateAndInitializeSidebar(defaultSidebar);
 }