예제 #1
0
        private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index >= 0 && e.Index < listBox1.Items.Count)
            {
                GVTabBannerTab tab = listBox1.Items[e.Index] as GVTabBannerTab;

                if ((e.State & DrawItemState.Selected) != 0 && tab.TagName != null)
                {
                    e.Graphics.FillRectangle(SystemBrushes.MenuHighlight, e.Bounds);
                }
                else if ((e.State & DrawItemState.HotLight) != 0)
                {
                    e.Graphics.FillRectangle(SystemBrushes.HotTrack, e.Bounds);
                }
                else
                {
                    e.Graphics.FillRectangle(SystemBrushes.Menu, e.Bounds);
                }


                if (tab.TagName == null)
                {
                    e.Graphics.DrawString(tab.DisplayName, captionFont, SystemBrushes.MenuText, padding, e.Bounds.Top + padding + space);
                }
                else
                {
                    e.Graphics.DrawString(tab.DisplayName, SystemFonts.MenuFont, SystemBrushes.MenuText, 2 * padding, e.Bounds.Top + space);
                }
            }
        }
예제 #2
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (bInhbit)
            {
                return;
            }

            int eIndex = listBox1.SelectedIndex;

            if (eIndex >= 0 && eIndex < listBox1.Items.Count)
            {
                GVTabBannerTab tab = listBox1.Items[eIndex] as GVTabBannerTab;

                if (tab.TagName == null)
                {
                    SelectedIndexNoResponse = previousSelectedIndex;
                }
                else
                {
                    previousSelectedIndex = eIndex;
                    if (Controller != null)
                    {
                        Controller.ExecuteMessage(MsgListItemChanged, new GSString(tab.TagName));
                    }
                }
            }
        }
예제 #3
0
 private void GVTabBanner_MouseUp(object sender, MouseEventArgs e)
 {
     if (getTabIndexFromPoint(e.Location) == p_md_indexTab && p_md_indexTab >= 0)
     {
         int i = p_md_indexTab;
         p_md_indexTab = -1;
         GVTabBannerTab selected = DisplayedTabs[i];
         if (selected.TagName.Equals("_more"))
         {
             contextMoreItems.MenuItems.Clear();
             foreach (GVTabBannerTab tab in HiddenTabs)
             {
                 MenuItem mi = contextMoreItems.MenuItems.Add(tab.DisplayName);
                 mi.Tag    = tab.TagName;
                 mi.Click += menuItemToolStripMenuItem_Click;
             }
             contextMoreItems.Show(this, new Point(e.X, e.Y));
         }
         else
         {
             SelectTab(selected.TagName);
         }
     }
     else
     {
         p_md_indexTab = -1;
     }
 }
예제 #4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            float space         = 3;
            float padding       = 8;
            float currX         = space;
            float currY         = 0;
            float prevBarHeight = BarHeight;

            Graphics g = e.Graphics;

            CalculateTabWidths(space, padding, g);

            SortTabsVisibility(padding);

            currY = BarHeight;

            for (int i = 0; i < DisplayedTabs.Count; i++)
            {
                GVTabBannerTab tab = DisplayedTabs[i];

                if (tab.TagName.Equals(p_selectedTab))
                {
                    g.FillRectangle(SystemBrushes.MenuHighlight, currX + space, 0, tab.Width - 2 * space, tab.Height);
                    g.DrawString(tab.DisplayName, SystemFonts.MenuFont, SystemBrushes.HighlightText, currX + space + padding, padding);
                }
                else
                {
                    g.DrawString(tab.DisplayName, SystemFonts.MenuFont, SystemBrushes.MenuText, currX + space + padding, padding);
                    g.DrawLine(Pens.Black, currX, currY, currX + tab.Width, currY);
                }

                if ((trackedPoint.X >= currX && trackedPoint.X <= currX + tab.Width) ||
                    (tab.TagName.Equals(p_selectedTab)))
                {
                    PointF[] points = new PointF[] {
                        new PointF(currX, currY),
                        new PointF(currX + space, currY),
                        new PointF(currX + space, 0),
                        new PointF(currX + tab.Width - space, 0),
                        new PointF(currX + tab.Width - space, currY),
                        new PointF(currX + tab.Width, currY)
                    };

                    g.DrawLines(Pens.Black, points);
                }

                currX += tab.Width;
            }

            g.DrawLine(Pens.Black, currX, currY, this.Width, currY);

            if (prevBarHeight != BarHeight)
            {
                gvControlContainer1.Location = new Point(0, (int)BarHeight + 1);
                gvControlContainer1.Size     = new Size(Width, Height - (int)BarHeight - 1);
            }

            base.OnPaint(e);
        }
예제 #5
0
        /// <summary>
        /// Adds new tab to the list
        /// </summary>
        /// <param name="displayName"></param>
        /// <param name="tagName"></param>
        /// <returns></returns>
        public GVTabBannerTab AddTab(string displayName, string tagName)
        {
            GVTabBannerTab newtab = new GVTabBannerTab();

            newtab.DisplayName = displayName;
            newtab.TagName     = tagName;

            listBox1.Items.Add(newtab);
            return(newtab);
        }
예제 #6
0
        /// <summary>
        /// Adds new tab to the list
        /// </summary>
        /// <param name="displayName"></param>
        /// <param name="tagName"></param>
        /// <returns></returns>
        public GVTabBannerTab AddTab(string displayName, string tagName)
        {
            GVTabBannerTab newtab = new GVTabBannerTab();

            newtab.DisplayName = displayName;
            newtab.TagName     = tagName;

            Tabs.Add(newtab);

            Invalidate();

            return(newtab);
        }
예제 #7
0
        /// <summary>
        /// Selects Tab as active
        /// </summary>
        /// <param name="tabTag"></param>
        /// <returns></returns>
        public bool SelectTab(string tabTag)
        {
            if (Controller != null && p_selectedTab != null)
            {
                Controller.ExecuteMessage(MsgTabWillHide, new GSString(p_selectedTab));
                GVTabBannerTab tabBanner = FindTab(tabTag);
            }
            p_selectedTab = tabTag;
            if (ExistsTag(tabTag))
            {
                if (Controller != null)
                {
                    Controller.ExecuteMessage(MsgTabChanged, new GSString(tabTag));
                }
                Invalidate();
                return(true);
            }

            return(false);
        }
예제 #8
0
        private void listBox1_MeasureItem(object sender, MeasureItemEventArgs e)
        {
            GVTabBannerTab tab = listBox1.Items[e.Index] as GVTabBannerTab;

            if (tab == null)
            {
                return;
            }

            if (tab.Height < 0)
            {
                SizeF sf = e.Graphics.MeasureString(tab.DisplayName, SystemFonts.MenuFont);
                tab.Width  = sf.Width + 2 * padding + 2 * space;
                tab.Height = sf.Height + 2 * space;
            }

            if (tab.TagName == null)
            {
                tab.Height += padding;
            }

            e.ItemHeight = (int)tab.Height;
        }