Esempio n. 1
0
 /// <summary>
 /// obtenir l'index du sous la souris
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public int GetTabUnderMouse(int x, int y)
 {
     if (TabOrientation == TabOrientation.Right)
     {
         int oldX = x;
         x = y;
         y = this.ClientRectangle.Width - oldX;
     }
     else if (TabOrientation == TabOrientation.Left)
     {
         int oldY = y;
         y = x;
         x = this.ClientRectangle.Height - oldY;
     }
     if (SelectedIndex >= 0 && SelectedIndex < Tabs.Count)
     {
         GeniusTab tab = Tabs[SelectedIndex];
         if (tab.PathOffset != null && tab.PathOffset.IsVisible(x, y))
         {
             return(SelectedIndex);
         }
     }
     for (int index = StartIndex; x >= 0 && index < Tabs.Count; index++)
     {
         GeniusTab tab = Tabs[index];
         if (tab.PathOffset != null && tab.PathOffset.IsVisible(x, y))
         {
             return(index);
         }
     }
     return(-1);
 }
Esempio n. 2
0
 private void RecalcTabPath(GeniusTab aTab)
 {
     if (aTab != null)
     {
         using (Graphics g = this.CreateGraphics())
         {
             string sText = aTab.Text;
             SizeF  size  = g.MeasureString(sText, this.Font);
             aTab.Path = TabPath(Hauteur, Size.Truncate(size).Width + 3);
         }
     }
     else
     {
         foreach (GeniusTab tab in Tabs)
         {
             RecalcTabPath(tab);
         }
     }
 }
Esempio n. 3
0
        private void DrawTab(GeniusTab tab, Graphics g, int hauteur, bool isSelected)
        {
            //pas de dessin du tab, s'il n'est pas entier, sauf pour le premier
            if (tab.PathOffset == null || (tab.PathOffset.GetBounds().Right > GetRight && tab != Tabs[StartIndex]))
            {
                return;
            }
            string     sText = tab.Text;
            SizeF      size  = g.MeasureString(sText, this.Font);
            RectangleF r     = Rectangle.Empty;

            r = tab.PathOffset.GetBounds();
            Color unselectedColor = FUnSelectedColor;

            if (FUseTabColor)
            {
                unselectedColor = tab.Color;
            }
            using (Pen p = new Pen(isSelected ? FSelectedColor : unselectedColor))
            {
                using (Brush b = new SolidBrush(isSelected ? FSelectedColor : unselectedColor))
                {
                    g.FillPath(b, tab.PathOffset);
                    g.DrawLine(p, r.Left, r.Bottom, r.Right, r.Bottom);
                }
            }
            using (Pen p = new Pen(isSelected ? FSelectedLineColor : FUnSelectedLineColor))
            {
                g.DrawPath(p, tab.PathOffset);
                if (isSelected)
                {
                    g.DrawLine(p, 0, r.Bottom, r.Left, r.Bottom);
                    g.DrawLine(p, r.Right, r.Bottom, GetRight, r.Bottom);
                }
            }
            using (var brush = new SolidBrush(this.ForeColor))
            {
                g.DrawString(sText, this.Font, brush, r.Left + hauteur, (GetHeight - size.Height) / 2);
            }
        }
Esempio n. 4
0
        private void RecalcTabRect()
        {
            if (Tabs.Count == 0)
            {
                return;
            }

            GeniusTab tab = Tabs[StartIndex];

            if (tab.Path == null)
            {
                return;
            }
            tab.PathOffset = (GraphicsPath)tab.Path.Clone();
            using (Matrix m = new Matrix())
            {
                m.Translate(0, FTopMargin);
                tab.PathOffset.Transform(m);
            }
            int   hauteur = Hauteur;
            float w       = tab.Width - hauteur / 2;

            for (int i = StartIndex - 1; i > 0; i--)
            {
                Tabs[i].PathOffset = null;
            }

            for (int i = StartIndex + 1; i < Tabs.Count; i++)
            {
                tab            = Tabs[i];
                tab.PathOffset = (GraphicsPath)tab.Path.Clone();
                using (Matrix m = new Matrix())
                {
                    m.Translate(w, FTopMargin);
                    tab.PathOffset.Transform(m);
                }
                w += tab.Width - hauteur / 2;
            }
        }
Esempio n. 5
0
 /// <summary>
 /// ajout d'un tab
 /// </summary>
 /// <param name="aTab"></param>
 /// <returns></returns>
 public int Add(GeniusTab aTab)
 {
     return(this.InnerList.Add(aTab));
 }
Esempio n. 6
0
 /// <summary>
 /// dessin des tabs
 /// </summary>
 /// <param name="e"></param>
 protected override void OnPaint(PaintEventArgs e)
 {
     try
     {
         bool recalcPathOffset = false;
         if (this.Count <= 0)
         {
             return;
         }
         int hauteur = Hauteur;
         //calcul du path
         foreach (GeniusTab tab in this.Tabs)
         {
             if (tab.DocTabs == null)
             {
                 tab.DocTabs = this;
             }
             if (tab.Path == null)
             {
                 RecalcTabPath(tab);
                 recalcPathOffset = true;
             }
         }
         if (recalcPathOffset)
         {
             RecalcTabRect();
         }
         if (FOrientation == TabOrientation.Right)
         {
             using (Matrix m = new Matrix())
             {
                 m.Translate(this.ClientRectangle.Width, 0);
                 m.Rotate(90);
                 e.Graphics.Transform = m;
             }
         }
         else if (FOrientation == TabOrientation.Left)
         {
             using (Matrix m = new Matrix())
             {
                 m.Translate(0, this.ClientRectangle.Height);
                 m.Rotate(270);
                 e.Graphics.Transform = m;
             }
         }
         for (int i = Tabs.Count - 1; i >= StartIndex; i--)
         {
             GeniusTab tab = Tabs[i];
             if (i == SelectedIndex)
             {
                 continue;
             }
             DrawTab(Tabs[i], e.Graphics, hauteur, false);
         }
         if (SelectedIndex >= 0)
         {
             GeniusTab tab = Tabs[SelectedIndex];
             DrawTab(tab, e.Graphics, hauteur, true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.ToString());
         Trace.TraceError("OnPaint error : {0}", ex);
     }
 }