/// ------------------------------------------------------------------------------------
        private bool GetAreAppropriateEditorsAlreadyVisible(ICollection <Type> desiredEditorTypes)
        {
            // SP-823: The editor is being replaced instead of being reused, resulting in incorrect control tab order
            //return TabPages.Cast<TabPage>().All(tp =>
            //    (from object ctrl in tp.Controls select desiredEditorTypes.Contains(ctrl)).FirstOrDefault());

            return(TabPages.Cast <TabPage>().All(tp =>
                                                 (from object ctrl in tp.Controls select desiredEditorTypes.Contains(ctrl.GetType())).FirstOrDefault()));
        }
        protected override void OnMouseLeave(EventArgs e)
        {
            State = MouseStates.Normal;
            if (TabPages.Cast <TabPage>().Any(Tab => Tab.DisplayRectangle.Contains(_mouseLocation)))
            {
                Invalidate();
            }

            base.OnMouseLeave(e);
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            _mouseLocation = e.Location;
            if (TabPages.Cast <TabPage>().Any(Tab => Tab.DisplayRectangle.Contains(e.Location)))
            {
                Invalidate();
            }

            Invalidate();
            base.OnMouseMove(e);
        }
Exemple #4
0
        // http://stackoverflow.com/questions/1849801/c-sharp-winform-how-to-set-the-base-color-of-a-tabcontrol-not-the-tabpage
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            // fill in the whole rect
            using (SolidBrush br = new SolidBrush(Color.Black))
            {
                e.Graphics.FillRectangle(br, ClientRectangle);
            }

            // draw the tabs
            for (int i = 0; i < TabPages.Count; ++i)
            {
                TabPage tab = TabPages[i];
                // Get the text area of the current tab
                RectangleF tabTextArea = (RectangleF)GetTabRect(i);
                tabTextArea.Width  *= e.Graphics.DpiX / 96f;
                tabTextArea.Height *= e.Graphics.DpiY / 96f;

                // draw the background
                var tabColor = SelectedTab == tab ? SelectedTabBackColor : TabBackColor;
                using (SolidBrush br = new SolidBrush(tabColor))
                {
                    e.Graphics.FillRectangle(br, tabTextArea);
                }

                // draw the border
                using (Pen p = new Pen(TabBorderColor))
                {
                    e.Graphics.DrawRectangle(p, tabTextArea.X, tabTextArea.Y, tabTextArea.Width, tabTextArea.Height);
                }

                // draw the tab header text
                var textColor = SelectedTab == tab ? SelectedTabForeColor : TabForeColor;
                using (SolidBrush brush = new SolidBrush(textColor))
                {
                    var sf = new StringFormat();
                    sf.Alignment     = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    e.Graphics.DrawString(tab.Text, Font, brush, tabTextArea, sf);
                }
            }

            // draw the tab underline (same color as border)
            var bottom = TabPages.Cast <TabPage>().MaxOrDefault(t => GetTabRect(TabPages.IndexOf(t)).Bottom);

            using (Pen p = new Pen(TabBorderColor, 5))
            {
                e.Graphics.DrawLine(p, ClientRectangle.Left, bottom, ClientRectangle.Right, bottom);
            }
        }
 void Instance_ActiveSearchServiceChanged(object sender, EventArgs e)
 {
     if (ServerManager.Instance.ActiveSearchService != null)
     {
         var tab = TabPages.Cast <MultiEngineTab>().FirstOrDefault(s => s.EngineUI.RawEngines.Contains(ServerManager.Instance.ActiveSearchService));
         if (tab != null)
         {
             base.SelectedTab = tab;
         }
     }
     else
     {
         base.SelectedIndex = 0;
     }
 }
        private void SearchProvider_DisabledChanged(object sender, EventArgs e)
        {
            var provider = sender as IResourceProvider;

            if (provider.Disabled)
            {
                //禁用了。
                this.TabPages.Cast <MultiEngineTab>().Where(s => s.Providers.Length == 1 && s.Providers[0] == provider).ToArray().ForEach(s => TabPages.Remove(s));
            }
            else
            {
                //已启用
                if (!TabPages.Cast <MultiEngineTab>().Any(s => s.Providers.Contains(provider)))
                {
                    new MultiEngineTab(this, provider);
                }
            }
        }
Exemple #7
0
        protected override void OnControlAdded(ControlEventArgs e)
        {
            base.OnControlAdded(e);

            // recompute tab widths
            int maxTabLength = TabPages.Cast <TabPage>()
                               .Select(currentPage => TextRenderer.MeasureText(currentPage.Text, Font).Width + Padding.X + Padding.X + CloseButtonPadding)
                               .DefaultIfEmpty(0)
                               .Max();

            var newItemWidth = Math.Max(maxTabLength, ItemSize.Width);

            var newItemSize = new Size(newItemWidth, ItemSize.Height);

            if (ItemSize != newItemSize)
            {
                ItemSize = newItemSize;
            }
        }
Exemple #8
0
 private TabPage FindByText(string text)
 {
     return(TabPages.Cast <TabPage>().FirstOrDefault(tp => tp.Text == text));
 }