Ejemplo n.º 1
0
        internal int InsertPage(int index, TabListPage page)
        {
            if (_pages == null)
            {
                _pages = new TabListPage[1];
            }
            else if (_pages.Length == this.TabListPageCount)
            {
                // no room left, so resize the array
                TabListPage[] copy;

                copy = new TabListPage[_pages.Length + 1];
                Array.Copy(_pages, copy, _pages.Length);
                _pages = copy;
            }

            // if this is an insert rather than append, move the array around
            if (index < this.TabListPageCount)
            {
                Array.Copy(_pages, index, _pages, index + 1, _pages.Length - index);
            }

            // update the array and page count
            _pages[index] = page;
            this.TabListPageCount++;
            this.UpdatePages();
            this.UpdateSelectedPage();

            // finally trigger filename redraw of the control
            this.Invalidate();

            return(index);
        }
      public void Add(TabListPage value)
      {
        if (value == null)
          throw new ArgumentNullException("value");

        this.Owner.Controls.Add(value);
      }
Ejemplo n.º 3
0
            public void Add(TabListPage value)
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }

                this.Owner.Controls.Add(value);
            }
Ejemplo n.º 4
0
            public bool Contains(TabListPage value)
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }

                return(this.IndexOf(value) != -1);
            }
Ejemplo n.º 5
0
            public void Insert(int index, TabListPage value)
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }

                this.Owner.InsertPage(index, value);
                this.Owner.Controls.Add(value);
                this.Owner.Controls.SetChildIndex(value, index);
            }
Ejemplo n.º 6
0
            public IEnumerator GetEnumerator()
            {
                TabListPage[] tabPages;

                tabPages = this.Owner.GetTabListPages();
                if (tabPages == null)
                {
                    tabPages = new TabListPage[0];
                }

                return(tabPages.GetEnumerator());
            }
Ejemplo n.º 7
0
        internal TabListPage[] GetTabListPages()
        {
            TabListPage[] copy;

            copy = new TabListPage[this.TabListPageCount];

            if (this.TabListPageCount > 0)
            {
                Array.Copy(_pages, copy, this.TabListPageCount);
            }

            return(copy);
        }
Ejemplo n.º 8
0
        internal int AddPage(TabListPage page)
        {
            int index;

            index = this.InsertPage(this.TabListPageCount, page);

            if (this.SelectedIndex == -1)
            {
                this.SelectedIndex = index;
            }

            return(index);
        }
      public TabListPage Add(string text)
      {
        TabListPage page;

        page = new TabListPage
        {
          Text = text
        };

        this.Add(page);

        return page;
      }
Ejemplo n.º 10
0
            public TabListPage Add(string text)
            {
                TabListPage page;

                page = new TabListPage()
                {
                    Text = text
                };

                this.Add(page);

                return(page);
            }
Ejemplo n.º 11
0
        /// <summary>
        /// Renders the header for the given <see cref="TabListPage"/>.
        /// </summary>
        /// <param name="g">The <see cref="Graphics"/> to draw on.</param>
        /// <param name="page">The <see cref="TabListPage"/> to be processed.</param>
        /// <param name="state">One of the <see cref="TabListPageState"/> values that specifies the state
        /// of the <see cref="TabListPage"/> to render.</param>
        /// <seealso cref="M:Cyotek.Windows.Forms.TabListPageRenderer.RenderHeader(Graphics,TabListPage,TabListPageState)"/>
        public override void RenderHeader(Graphics g, TabListPage page, TabListPageState state)
        {
            Color           fillColor;
            Color           textColor;
            Rectangle       fillBounds;
            Rectangle       textRectangle;
            TextFormatFlags flags;

            fillBounds    = page.HeaderBounds;
            textRectangle = Rectangle.Inflate(fillBounds, -4, -4);

            // define the most appropriate colors
            if ((state & TabListPageState.Selected) == TabListPageState.Selected)
            {
                fillColor = SystemColors.Highlight;
                textColor = SystemColors.HighlightText;
            }
            else if ((state & TabListPageState.HotLight) == TabListPageState.HotLight)
            {
                fillColor = SystemColors.ControlLight;
                textColor = page.Owner.ForeColor;
            }
            else
            {
                fillColor = SystemColors.Window;
                textColor = page.Owner.ForeColor;
            }

            // fill the background
            using (Brush brush = new SolidBrush(fillColor))
            {
                g.FillRectangle(brush, fillBounds);
            }

            // draw the text
            flags = TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis;
            TextRenderer.DrawText(g, page.Text, page.Font, textRectangle, textColor, fillColor, flags);

            // focus
            if ((state & TabListPageState.Focused) == TabListPageState.Focused)
            {
                NativeMethods.DrawFocusRectangle(g, fillBounds);
            }
        }
Ejemplo n.º 12
0
            public int IndexOf(TabListPage value)
            {
                int index;

                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }

                index = -1;
                for (int i = 0; i < this.Count; i++)
                {
                    if (this[i] == value)
                    {
                        index = i;
                        break;
                    }
                }

                return(index);
            }
 internal void UpdatePage(TabListPage page)
 {
   this.Invalidate();
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Retrieves the size of a rectangular area into which the header area of a
 /// <see cref="TabListPage"/> can be fitted.
 /// </summary>
 /// <param name="page">The <see cref="TabListPage"/> to be processed.</param>
 /// <param name="proposedSize">The proposed size for the header.</param>
 /// <returns>
 /// An ordered pair of type <see cref="Size"/> representing the width and height of a rectangle.
 /// </returns>
 /// <seealso cref="M:Cyotek.Windows.Forms.ITabListPageRenderer.GetPreferredSize(TabListPage,Size)"/>
 public virtual Size GetPreferredSize(TabListPage page, Size proposedSize)
 {
     return(proposedSize);
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Renders the header for the given <see cref="TabListPage"/>.
        /// </summary>
        /// <param name="g">The <see cref="Graphics"/> to draw on.</param>
        /// <param name="page">The <see cref="TabListPage"/> to be processed.</param>
        /// <param name="state">One of the <see cref="TabListPageState"/> values that specifies the state
        /// of the <see cref="TabListPage"/> to render.</param>
        /// <seealso cref="M:Cyotek.Windows.Forms.TabListPageRenderer.RenderHeader(Graphics,TabListPage,TabListPageState)"/>
        public override void RenderHeader(Graphics g, TabListPage page, TabListPageState state)
        {
            Color           fillColor;
            Color           textColor;
            Rectangle       fillBounds;
            Rectangle       textRectangle;
            TextFormatFlags flags;
            int             arrowSize;

            arrowSize         = 6;
            fillBounds        = page.HeaderBounds;
            fillBounds.Width -= arrowSize;
            textRectangle     = Rectangle.Inflate(fillBounds, -4, -4);

            // define the most appropriate colors
            if ((state & TabListPageState.Selected) == TabListPageState.Selected)
            {
                fillColor = SystemColors.Highlight;
                textColor = SystemColors.HighlightText;
            }
            else if ((state & TabListPageState.HotLight) == TabListPageState.HotLight)
            {
                fillColor = SystemColors.ControlLightLight;
                textColor = page.Owner.ForeColor;
            }
            else
            {
                fillColor = page.Owner.BackColor;
                textColor = page.Owner.ForeColor;
            }

            // fill the background
            using (Brush brush = new SolidBrush(fillColor))
            {
                g.FillRectangle(brush, fillBounds);
            }

            // draw the selection arrow
            if ((state & TabListPageState.Selected) == TabListPageState.Selected)
            {
                int   y;
                int   x;
                Point point1;
                Point point2;
                Point point3;

                y = fillBounds.Top + (fillBounds.Height - arrowSize * 2) / 2;
                x = fillBounds.Right;

                point1 = new Point(x, y);
                point2 = new Point(x + arrowSize, y + arrowSize);
                point3 = new Point(x, y + arrowSize * 2);

                using (Brush brush = new SolidBrush(fillColor))
                {
                    g.FillPolygon(brush, new[]
                    {
                        point1,
                        point2,
                        point3
                    });
                }
            }

            // draw the text
            flags = TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis;
            TextRenderer.DrawText(g, page.Text, page.Font, textRectangle, textColor, fillColor, flags);

            // focus
            if ((state & TabListPageState.Focused) == TabListPageState.Focused)
            {
                SizeF textSize;
                int   offset;

                textSize = TextRenderer.MeasureText(g, page.Text, page.Font, textRectangle.Size, flags);
                offset   = 2;

                NativeMethods.DrawFocusRectangle(g, textRectangle.X, textRectangle.Y, (int)textSize.Width + offset, (int)textSize.Height + offset);
            }
        }
Ejemplo n.º 16
0
 public abstract void RenderHeader(Graphics g, TabListPage page, TabListPageState state);
      public IEnumerator GetEnumerator()
      {
        TabListPage[] tabPages;

        tabPages = this.Owner.GetTabListPages();
        if (tabPages == null)
          tabPages = new TabListPage[0];

        return tabPages.GetEnumerator();
      }
Ejemplo n.º 18
0
 public abstract void RenderHeader(Graphics g, TabListPage page, TabListPageState state);
      public bool Contains(TabListPage value)
      {
        if (value == null)
          throw new ArgumentNullException("value");

        return this.IndexOf(value) != -1;
      }
    internal TabListPage[] GetTabListPages()
    {
      TabListPage[] copy;

      copy = new TabListPage[this.TabListPageCount];

      if (this.TabListPageCount > 0)
        Array.Copy(_pages, copy, this.TabListPageCount);

      return copy;
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="TabListCancelEventArgs"/> class.
 /// </summary>
 /// <param name="tabPage">The <see cref="TabListPage"/> the event is occurring for.</param>
 /// <param name="tabPageIndex">The zero-based index of <paramref name="tabPage"/> in the <see cref="TabList.TabListPages"/> collection..</param>
 /// <param name="action">One of the <see cref="TabListAction"/> values.</param>
 public TabListCancelEventArgs(TabListPage tabPage, int tabPageIndex, TabListAction action)
 {
     _tabPage      = tabPage;
     _tabPageIndex = tabPageIndex;
     _action       = action;
 }
      public void Insert(int index, TabListPage value)
      {
        if (value == null)
          throw new ArgumentNullException("value");

        this.Owner.InsertPage(index, value);
        this.Owner.Controls.Add(value);
        this.Owner.Controls.SetChildIndex(value, index);
      }
      public int IndexOf(TabListPage value)
      {
        int index;

        if (value == null)
          throw new ArgumentNullException("value");

        index = -1;
        for (int i = 0; i < this.Count; i++)
        {
          if (this[i] == value)
          {
            index = i;
            break;
          }
        }

        return index;
      }
    internal int InsertPage(int index, TabListPage page)
    {
      if (_pages == null)
        _pages = new TabListPage[1];
      else if (_pages.Length == this.TabListPageCount)
      {
        // no room left, so resize the array
        TabListPage[] copy;

        copy = new TabListPage[_pages.Length + 1];
        Array.Copy(_pages, copy, _pages.Length);
        _pages = copy;
      }

      // if this is an insert rather than append, move the array around
      if (index < this.TabListPageCount)
        Array.Copy(_pages, index, _pages, index + 1, _pages.Length - index);

      // update the array and page count
      _pages[index] = page;
      this.TabListPageCount++;
      this.UpdatePages();
      this.UpdateSelectedPage();

      // finally trigger a redraw of the control
      this.Invalidate();

      return index;
    }
Ejemplo n.º 25
0
 /// <summary>
 /// Retrieves the size of a rectangular area into which the header area of a
 /// <see cref="TabListPage"/> can be fitted.
 /// </summary>
 /// <param name="page">The <see cref="TabListPage"/> to be processed.</param>
 /// <param name="proposedSize">The proposed size for the header.</param>
 /// <returns>
 /// An ordered pair of type <see cref="Size"/> representing the width and height of a rectangle.
 /// </returns>
 /// <seealso cref="M:Cyotek.Windows.Forms.TabListPageRenderer.GetPreferredSize(TabListPage,Size)"/>
 public override Size GetPreferredSize(TabListPage page, Size proposedSize)
 {
     return(new Size(proposedSize.Width - 4, proposedSize.Height)); // adjusted for border widths
 }
Ejemplo n.º 26
0
 internal void UpdatePage(TabListPage page)
 {
     this.Invalidate();
 }
        public override void RenderHeader(Graphics g, TabListPage page, TabListPageState state)
        {
            Color fillColor;
              Color textColor;
              Rectangle fillBounds;
              Rectangle textRectangle;
              TextFormatFlags flags;
              int arrowSize;

              arrowSize = 6;
              fillBounds = page.HeaderBounds;
              fillBounds.Width -= arrowSize;
              textRectangle = Rectangle.Inflate(fillBounds, -4, -4);

              // define the most appropriate colors
              if ((state & TabListPageState.Selected) == TabListPageState.Selected)
              {
            fillColor = SystemColors.Highlight;
            textColor = SystemColors.HighlightText;
              }
              else if ((state & TabListPageState.Hot) == TabListPageState.Hot)
              {
            fillColor = SystemColors.ControlLightLight;
            textColor = page.Owner.ForeColor;
              }
              else
              {
            fillColor = page.Owner.BackColor;
            textColor = page.Owner.ForeColor;
              }

              // fill the background
              using (Brush brush = new SolidBrush(fillColor))
            g.FillRectangle(brush, fillBounds);

              // draw the selection arrow
              if ((state & TabListPageState.Selected) == TabListPageState.Selected)
              {
            int y;
            int x;
            Point point1;
            Point point2;
            Point point3;

            y = fillBounds.Top + ((fillBounds.Height - (arrowSize * 2)) / 2);
            x = fillBounds.Right;

            point1 = new Point(x, y);
            point2 = new Point(x + arrowSize, y + arrowSize);
            point3 = new Point(x, y + (arrowSize * 2));

            using (Brush brush = new SolidBrush(fillColor))
            {
              g.FillPolygon(brush, new Point[] { point1, point2, point3 });
            }
              }

              // draw the text
              flags = TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis;
              TextRenderer.DrawText(g, page.Text, page.Font, textRectangle, textColor, fillColor, flags);

              // focus
              if ((state & TabListPageState.Focused) == TabListPageState.Focused)
              {
            SizeF textSize;
            int offset;

            textSize = TextRenderer.MeasureText(g, page.Text, page.Font, textRectangle.Size, flags);
            offset = 2;

            ControlPaint.DrawFocusRectangle(g, new Rectangle(textRectangle.X, textRectangle.Y, (int)textSize.Width + offset, (int)textSize.Height + offset), textColor, fillColor);
              }
        }
    internal int AddPage(TabListPage page)
    {
      int index;

      index = this.InsertPage(this.TabListPageCount, page);

      if (this.SelectedIndex == -1)
        this.SelectedIndex = index;

      return index;
    }