public static void DrawTabItem(Graphics g, Rectangle bounds, bool focused, TabItemState state)
 {
     InitializeRenderer(VisualStyleElement.Tab.TabItem.Normal, (int) state);
     visualStyleRenderer.DrawBackground(g, bounds);
     Rectangle rectangle = Rectangle.Inflate(bounds, -3, -3);
     if (focused)
     {
         ControlPaint.DrawFocusRectangle(g, rectangle);
     }
 }
示例#2
0
       /// <include file='doc\TabRenderer.uex' path='docs/doc[@for="TabRenderer.DrawTabItem1"]/*' />
       /// <devdoc>
       ///    <para>
       ///       Renders a Tab item.
       ///    </para>
       /// </devdoc>
       public static void DrawTabItem(Graphics g, Rectangle bounds, bool focused, TabItemState state) {
           InitializeRenderer(VisualStyleElement.Tab.TabItem.Normal, (int)state);

           visualStyleRenderer.DrawBackground(g, bounds);

           // I need this hack since GetBackgroundContentRectangle() returns same rectangle
           // as bounds for this control!
           Rectangle contentBounds = Rectangle.Inflate(bounds, -3, -3);
           if (focused) {
               ControlPaint.DrawFocusRectangle(g, contentBounds);
           }
       }
 public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, TextFormatFlags flags, bool focused, TabItemState state)
 {
     InitializeRenderer(VisualStyleElement.Tab.TabItem.Normal, (int) state);
     visualStyleRenderer.DrawBackground(g, bounds);
     Rectangle rectangle = Rectangle.Inflate(bounds, -3, -3);
     Color foreColor = visualStyleRenderer.GetColor(ColorProperty.TextColor);
     TextRenderer.DrawText(g, tabItemText, font, rectangle, foreColor, flags);
     if (focused)
     {
         ControlPaint.DrawFocusRectangle(g, rectangle);
     }
 }
		/// <summary>
		/// </summary>
		public static NuGenControlState ToControlState(TabItemState tabItemState)
		{
			switch (tabItemState)
			{
				case TabItemState.Disabled:
				{
					return NuGenControlState.Disabled;
				}
				case TabItemState.Hot:
				{
					return NuGenControlState.Hot;
				}
				case TabItemState.Selected:
				{
					return NuGenControlState.Pressed;
				}
				default:
				{
					return NuGenControlState.Normal;
				}
			}
		}
		public static void DrawTabItem (Graphics g, Rectangle bounds, string tabItemText, Font font, TextFormatFlags flags, Image image, Rectangle imageRectangle, bool focused, TabItemState state)
		{
			if (!IsSupported)
				throw new InvalidOperationException ();
				
			VisualStyleRenderer vsr;
			
			switch (state) {
				case TabItemState.Disabled:
					vsr = new VisualStyleRenderer (VisualStyleElement.Tab.TabItem.Disabled);
					break;
				case TabItemState.Hot:
					vsr = new VisualStyleRenderer (VisualStyleElement.Tab.TabItem.Hot);
					break;
				case TabItemState.Normal:
				default:
					vsr = new VisualStyleRenderer (VisualStyleElement.Tab.TabItem.Normal);
					break;
				case TabItemState.Selected:
					vsr = new VisualStyleRenderer (VisualStyleElement.Tab.TabItem.Pressed);
					break;
			}

			vsr.DrawBackground (g, bounds);
			
			if(image != null)
				vsr.DrawImage(g, imageRectangle, image);
				
			bounds.Offset(3,3);
			bounds.Height -= 6;
			bounds.Width -= 6;
			
			if(tabItemText != String.Empty)
				TextRenderer.DrawText(g, tabItemText, font, bounds, SystemColors.ControlText,flags);
				
			if(focused)
				ControlPaint.DrawFocusRectangle(g, bounds);
		}
示例#6
0
        /// <summary>
        ///  Renders a Tab item.
        /// </summary>
        public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, TextFormatFlags flags, bool focused, TabItemState state)
        {
            InitializeRenderer(VisualStyleElement.Tab.TabItem.Normal, (int)state);
            visualStyleRenderer.DrawBackground(g, bounds);

            // GetBackgroundContentRectangle() returns same rectangle as bounds for this control!
            Rectangle contentBounds = Rectangle.Inflate(bounds, -3, -3);
            Color     textColor     = visualStyleRenderer.GetColor(ColorProperty.TextColor);

            TextRenderer.DrawText(g, tabItemText, font, contentBounds, textColor, flags);

            if (focused)
            {
                ControlPaint.DrawFocusRectangle(g, contentBounds);
            }
        }
示例#7
0
 /// <summary>
 ///  Renders a Tab item.
 /// </summary>
 public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, TabItemState state)
 {
     DrawTabItem(g, bounds, tabItemText, font, false, state);
 }
示例#8
0
        /// <summary>
        /// Draws certain tab.
        /// </summary>
        /// <param name="g">The <see cref="T:System.Drawing.Graphics"/> object used to draw tab control.</param>
        /// <param name="index">Index of the tab being drawn.</param>
        /// <param name="state">State of the tab item.</param>
        /// <param name="tabRect">The <see cref="T:System.Drawing.Rectangle"/> object specifying tab bounds.</param>
        /// <param name="textFmt">The <see cref="T:System.Drawing.StringFormat"/> object specifying text formatting
        /// in the tab.</param>
        private void DrawTabItem(Graphics g, int index, TabItemState state, Rectangle tabRect, StringFormat textFmt)
        {
            //if scroller is visible and the tab is fully placed under it we don't need to draw such tab
            if (fUpDown.X <= 0 || tabRect.X < fUpDown.X)
            {
                /* We will draw our tab on the bitmap and then will transfer image on the control
                 * graphic context.*/

                using (Bitmap bmp = new Bitmap(tabRect.Width, tabRect.Height))
                {
                    Rectangle drawRect = new Rectangle(0, 0, tabRect.Width, tabRect.Height);
                    using (Graphics bitmapContext = Graphics.FromImage(bmp))
                    {
                        TabRenderer.DrawTabItem(bitmapContext, drawRect, state);
                        if (state == TabItemState.Selected && tabRect.X == 0)
                        {
                            int corrY = bmp.Height - 1;
                            bmp.SetPixel(0, corrY, bmp.GetPixel(0, corrY - 1));
                        }

                        /* Important moment. If tab alignment is bottom we should flip image to display tab
                         * correctly.*/

                        if (this.Alignment == TabAlignment.Bottom)
                        {
                            bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
                        }

                        Rectangle focusRect = Rectangle.Inflate(drawRect, -3, -3);
                        //focus rect
                        TabPage pg = this.TabPages[index];
                        //tab page whose tab we're drawing
                        //trying to get tab image if any
                        Image pagePict = GetImageByIndexOrKey(pg.ImageIndex, pg.ImageKey);
                        if (pagePict != null)
                        {
                            //If tab image is present we should draw it.
                            Point imgLoc = state == TabItemState.Selected ? new Point(8, 2) : new Point(6, 2);
                            if (this.Alignment == TabAlignment.Bottom)
                            {
                                imgLoc.Y = drawRect.Bottom - 2 - pagePict.Height;
                            }
                            bitmapContext.DrawImageUnscaled(pagePict, imgLoc);
                            //Correcting rectangle for drawing text.
                            drawRect.X     += imgLoc.X + pagePict.Width;
                            drawRect.Width -= imgLoc.X + pagePict.Width;
                        }
                        //drawing tab text
                        using (Brush b = new SolidBrush(SystemColors.ControlText))
                            bitmapContext.DrawString(pg.Text, this.Font, b, (RectangleF)drawRect, textFmt);
                        //and finally drawing focus rect(if needed)
                        if (this.Focused && state == TabItemState.Selected)
                        {
                            ControlPaint.DrawFocusRectangle(bitmapContext, focusRect);
                        }
                    }
                    //If the tab has part under scroller we shouldn't draw that part.
                    int shift = state == TabItemState.Selected ? 2 : 0;
                    if (fUpDown.X > 0 && fUpDown.X >= tabRect.X - shift && fUpDown.X < tabRect.Right + shift)
                    {
                        tabRect.Width -= tabRect.Right - fUpDown.X + shift;
                    }
                    g.DrawImageUnscaledAndClipped(bmp, tabRect);
                }
            }
        }
示例#9
0
        public static void DrawTabItem(Graphics g, Rectangle bounds, Image image, Rectangle imageRectangle, bool focused, TabItemState state)
        {
            InitializeRenderer(VisualStyleElement.Tab.TabItem.Normal, (int)state);

            visualStyleRenderer.DrawBackground(g, bounds);

            // GetBackgroundContentRectangle() returns same rectangle as bounds for this control!
            Rectangle contentBounds = Rectangle.Inflate(bounds, -3, -3);

            visualStyleRenderer.DrawImage(g, imageRectangle, image);

            if (focused)
            {
                ControlPaint.DrawFocusRectangle(g, contentBounds);
            }
        }
示例#10
0
        public void DrawTabItem(Graphics g, Rectangle bounds, TabItemState state)
        {
            int offset = bounds.Height - Tab_Height;

            SmoothingMode _Old = SmoothingMode.None;
            bool _ModifiedSmoothMode = false;
            if (g.SmoothingMode != SmoothingMode.AntiAlias && g.SmoothingMode != SmoothingMode.HighQuality)
            {
                _Old = g.SmoothingMode;
                g.SmoothingMode = SmoothingMode.AntiAlias;
                _ModifiedSmoothMode = true;
            }
            bounds = GetModifiedBounds(bounds);
            GraphicsPath path = new GraphicsPath();

            path.AddLine(bounds.X, bounds.Y + Tab_Height, bounds.X + Tab_SlopeWidth - 4, bounds.Y + 2);
            path.AddLine(bounds.X + Tab_SlopeWidth - 4, bounds.Y + 2, bounds.X + Tab_SlopeWidth, bounds.Y);
            path.AddLine(bounds.X + Tab_SlopeWidth, bounds.Y, bounds.X + bounds.Width, bounds.Y);
            path.AddLine(bounds.X + bounds.Width, bounds.Y, bounds.X + bounds.Width, bounds.Y + bounds.Height);
            path.CloseFigure();

            LinearGradientBrush background = new LinearGradientBrush(bounds, SystemColors.ControlLightLight, SystemColors.Control, LinearGradientMode.Vertical);

            LinearGradientBrush background_active = new LinearGradientBrush(bounds, SystemColors.Control, SystemColors.GradientInactiveCaption, LinearGradientMode.Vertical);

            if (state == TabItemState.Selected)
            {
                g.FillPath(background, path);
                g.DrawPath(SystemPens.ControlDark, path);
            }
            else if (state == TabItemState.Normal)
            {
                g.FillPath(background_active, path);
                g.DrawPath(SystemPens.InactiveCaption, path);
            }

            if (_ModifiedSmoothMode)
                g.SmoothingMode = _Old;
        }
示例#11
0
        /// <summary>
        /// Draws our tab control.
        /// </summary>
        /// <param name="g">The <see cref="T:System.Drawing.Graphics"/> object used to draw the tab control.</param>
        /// <param name="clipRect">The <see cref="T:System.Drawing.Rectangle"/> that specifies the clipping rectangle
        /// of the control.</param>
        private void DrawCustomTabControl(Graphics g, Rectangle clipRect)
        {
            /* In this method we draw only those parts of the control which intersect with the
             * clipping rectangle. It's some kind of optimization.*/
            if (!this.Visible)
            {
                return;
            }

            //selected tab index and rectangle
            int       iSel    = this.SelectedIndex;
            Rectangle selRect = iSel != -1 ? this.GetTabRect(iSel) : Rectangle.Empty;

            Rectangle rcPage = this.ClientRectangle;

            //correcting page rectangle
            switch (this.Alignment)
            {
            case TabAlignment.Top:
            {
                int trunc = selRect.Height * this.RowCount + 2;
                rcPage.Y += trunc; rcPage.Height -= trunc;
            } break;

            case TabAlignment.Bottom: rcPage.Height -= selRect.Height * this.RowCount + 1;
                break;
            }

            //draw page itself
            if (rcPage.IntersectsWith(clipRect))
            {
                TabRenderer.DrawTabPage(g, rcPage);
            }

            int tabCount = this.TabCount;

            if (tabCount == 0)
            {
                return;
            }

            //drawing unselected tabs
            this.lastHotIndex = HitTest();//hot tab
            VisualStyleRenderer tabRend = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal);

            for (int iTab = 0; iTab < tabCount; iTab++)
            {
                if (iTab != iSel)
                {
                    Rectangle tabRect = this.GetTabRect(iTab);
                    if (tabRect.Right >= 3 && tabRect.IntersectsWith(clipRect))
                    {
                        TabItemState state = iTab == this.lastHotIndex ? TabItemState.Hot : TabItemState.Normal;
                        tabRend.SetParameters(tabRend.Class, tabRend.Part, (int)state);
                        DrawTabItem(g, iTab, tabRect, tabRend);
                    }
                }
            }

            /* Drawing of a selected tab. We'll also increase the selected tab's rectangle. It should be a little
             * bigger than other tabs.*/
            selRect.Inflate(2, 2);
            if (iSel != -1 && selRect.IntersectsWith(clipRect))
            {
                tabRend.SetParameters(tabRend.Class, tabRend.Part, (int)TabItemState.Selected);
                DrawTabItem(g, iSel, selRect, tabRend);
            }
        }
示例#12
0
 /// <include file='doc\TabRenderer.uex' path='docs/doc[@for="TabRenderer.DrawTabItem3"]/*' />
 /// <devdoc>
 ///    <para>
 ///       Renders a Tab item.
 ///    </para>
 /// </devdoc>
 public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, bool focused, TabItemState state) {
     DrawTabItem(g, bounds, tabItemText, font, 
                 TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine,
                 focused, state);
 }
		public static void DrawTabItem (Graphics g, Rectangle bounds, string tabItemText, Font font, TabItemState state)
		{
			DrawTabItem (g, bounds, tabItemText, font, TextFormatFlags.HorizontalCenter, null, Rectangle.Empty, false, state);
		}
		public static void DrawTabItem (Graphics g, Rectangle bounds, bool focused, TabItemState state)
		{
			DrawTabItem (g, bounds, String.Empty, null, TextFormatFlags.Default, null, Rectangle.Empty, focused, state);
		}
示例#15
0
        /// <summary>
        /// 绘制我们的选项卡控件。
        /// </summary>
        /// <param name="g">The <see cref="T:System.Drawing.Graphics"/> 用于绘制选项卡控制的对象.</param>
        /// <param name="clipRect">The <see cref="T:System.Drawing.Rectangle"/> the that specifies the clipping rectangle
        /// of the control.</param>
        private void DrawCustomTabControl(Graphics g, Rectangle clipRect)
        {
            /*在这个方法中,我们只绘制这些地区的控制相交的
             *              *剪辑矩形。这是某种形式的优化。*/
            if (!this.Visible)
            {
                return;
            }

            //所选的选项卡索引和矩形
            int       iSel    = this.SelectedIndex;
            Rectangle selRect = iSel != -1 ? this.GetTabRect(iSel) : Rectangle.Empty;

            Rectangle rcPage = this.ClientRectangle;

            //纠正页的矩形
            switch (this.Alignment)
            {
            case TabAlignment.Top:
            {
                int trunc = selRect.Height * this.RowCount + 2;
                rcPage.Y += trunc; rcPage.Height -= trunc;
            } break;

            case TabAlignment.Bottom: rcPage.Height -= selRect.Height * this.RowCount + 1;
                break;
            }

            //显示页面本身
            if (rcPage.IntersectsWith(clipRect))
            {
                TabRenderer.DrawTabPage(g, rcPage);
            }

            int tabCount = this.TabCount;

            if (tabCount == 0)
            {
                return;
            }

            //绘制未选中的标签
            this.lastHotIndex = HitTest();//hot tab
            VisualStyleRenderer tabRend = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal);

            for (int iTab = 0; iTab < tabCount; iTab++)
            {
                if (iTab != iSel)
                {
                    Rectangle tabRect = this.GetTabRect(iTab);
                    if (tabRect.Right >= 3 && tabRect.IntersectsWith(clipRect))
                    {
                        TabItemState state = iTab == this.lastHotIndex ? TabItemState.Hot : TabItemState.Normal;
                        tabRend.SetParameters(tabRend.Class, tabRend.Part, (int)state);
                        DrawTabItem(g, iTab, tabRect, tabRend);
                    }
                }
            }

            /*绘制一个选择的选项卡。我们也将增加选定的选项卡的矩形。它应该是一个小
             *              *大于其他选项卡。*/
            selRect.Inflate(2, 2);
            if (iSel != -1 && selRect.IntersectsWith(clipRect))
            {
                tabRend.SetParameters(tabRend.Class, tabRend.Part, (int)TabItemState.Selected);
                DrawTabItem(g, iSel, selRect, tabRend);
            }
        }
		private NuGenControlState GetControlState(TabItemState tabItemState)
		{
			return NuGenTabItemStateTranslator.ToControlState(tabItemState);
		}
 private NuGenControlState GetControlState(TabItemState tabItemState)
 {
     return(NuGenTabItemStateTranslator.ToControlState(tabItemState));
 }
示例#18
0
 public static void DrawTabItem(Graphics g, Rectangle_ bounds, TabItemState state)
 {
     DrawTabItem(g, bounds, String.Empty, null, TextFormatFlags.Default, null, Rectangle_.Empty, false, state);
 }
示例#19
0
 public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, TextFormatFlags flags, Image image, Rectangle imageRectangle, bool focused, TabItemState state)
 {
     throw null;
 }
示例#20
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);
            bool vert = (Alignment > TabAlignment.Bottom);
            int  off  = 1;

            if ((e.State & DrawItemState.Selected) != 0)
            {
                off = -1;
            }

            Rectangle bounds;

            if (vert)
            {
                // tabs are aligned left or right
                System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();
                m.Translate(0, e.Bounds.Height - TabPages[0].Top);
                m.RotateAt(270, new PointF(e.Bounds.X, e.Bounds.Y));
                e.Graphics.Transform = m;
                bounds = new Rectangle(e.Bounds.Left - TabPages[0].Top, e.Bounds.Top + off,
                                       e.Bounds.Height, e.Bounds.Width);
            }
            else
            {
                // tabs are aligned top or bottom
                bounds = new Rectangle(e.Bounds.X, e.Bounds.Y + off, e.Bounds.Width, e.Bounds.Height);
            }

            if (Application.RenderWithVisualStyles)
            {
                TabItemState state = TabItemState.Normal;
                if ((e.State & DrawItemState.HotLight) != 0 ||
                    // state is never HotLight in OwnerDrawFixed mode, so use this workaround
                    (HotTrack && hotTabIndex == e.Index))
                {
                    state = TabItemState.Hot;
                }
                if ((e.State & DrawItemState.Selected) != 0)
                {
                    state = TabItemState.Selected;
                }
                if ((e.State & DrawItemState.Disabled) != 0)
                {
                    state = TabItemState.Disabled;
                }

                TextFormatFlags flags = TextFormatFlags.HorizontalCenter |
                                        TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine |
                                        TextFormatFlags.PreserveGraphicsTranslateTransform |
                                        TextFormatFlags.PreserveGraphicsClipping;
                if ((e.State & DrawItemState.NoAccelerator) != 0)
                {
                    flags |= TextFormatFlags.HidePrefix;
                }

                bool focused = (e.State & DrawItemState.Focus) != 0 &&
                               (e.State & DrawItemState.NoFocusRect) != DrawItemState.NoFocusRect;

                //bounds = GetTabRect(e.Index);

                TabRenderer.DrawTabItem(e.Graphics, bounds,
                                        TabPages[e.Index].Text, e.Font, flags, focused, state);
            }
            else
            {
                e.DrawBackground();

                using (StringFormat sf = new StringFormat(StringFormatFlags.NoClip
                                                          | StringFormatFlags.NoWrap))
                {
                    sf.HotkeyPrefix  = (e.State & DrawItemState.NoAccelerator) != 0 ? HotkeyPrefix.Hide : HotkeyPrefix.Show;
                    sf.Alignment     = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    Color textcol;

                    // state is never HotLight in OwnerDrawFixed mode, so use this workaround
                    if (HotTrack && hotTabIndex == e.Index)
                    {
                        textcol = SystemColors.HotTrack;
                    }
                    switch (e.State & ~(DrawItemState.Selected | DrawItemState.Focus | DrawItemState.Default))
                    {
                    case DrawItemState.Disabled:
                        textcol = SystemColors.GrayText;
                        break;

                    case DrawItemState.HotLight:
                        textcol = SystemColors.HotTrack;
                        break;

                    default:
                        textcol = ForeColor;
                        break;
                    }
                    using (Brush brush = new SolidBrush(textcol))
                    {
                        e.Graphics.DrawString(TabPages[e.Index].Text,
                                              e.Font, brush, bounds, sf);
                    }
                }

                if ((e.State & DrawItemState.Selected) != 0)
                {
                    e.DrawFocusRectangle();
                }
            }

            if (vert)
            {
                e.Graphics.ResetTransform();
            }
        }
示例#21
0
 public static void DrawTabItem(Graphics g, Rectangle bounds, Image image, Rectangle imageRectangle, bool focused, TabItemState state)
 {
     throw null;
 }
		public static void DrawTabItem (Graphics g, Rectangle bounds, Image image, Rectangle imageRectangle, bool focused, TabItemState state)
		{
			DrawTabItem (g, bounds, String.Empty, null, TextFormatFlags.HorizontalCenter, image, imageRectangle, focused, state);
		}
 public void SetUIState(TabItemState state)
 {
     attractionsTab.ChangeCurrentState(state);
     attractionsList.gameObject.SetActive(state == TabItemState.HIGHLIGHT);
 }
		public static void DrawTabItem (Graphics g, Rectangle bounds, string tabItemText, Font font, TextFormatFlags flags, bool focused, TabItemState state)
		{
			DrawTabItem (g, bounds, tabItemText, font, flags, null, Rectangle.Empty, focused, state);
		}
示例#25
0
        public void DrawTabItem(Graphics g, Rectangle bounds, TabItemState state)
        {
            SmoothingMode _Old = SmoothingMode.None;
            bool _ModifiedSmoothMode = false;
            if (g.SmoothingMode != SmoothingMode.AntiAlias && g.SmoothingMode != SmoothingMode.HighQuality)
            {
                _Old = g.SmoothingMode;
                g.SmoothingMode = SmoothingMode.AntiAlias;
                _ModifiedSmoothMode = true;
            }
            bounds = GetModifiedBounds(bounds);

            if (state == TabItemState.Selected)
            {
                GraphicsPath path = new GraphicsPath();
                path.AddLine(new Point(bounds.X, bounds.Height + bounds.Y), new Point(bounds.X, bounds.Y));
                path.AddLine(new Point(bounds.X, bounds.Y), new Point(bounds.Width + bounds.X, bounds.Y));
                path.AddLine(new Point(bounds.Width + bounds.X, bounds.Y), new Point(bounds.X + bounds.Width, bounds.Height + bounds.Y));

                g.FillPath(SystemBrushes.ControlLightLight, path);
                g.DrawPath(SystemPens.ControlDark, path);
            }
            else if (state == TabItemState.Normal)
            {
                g.DrawLine(SystemPens.ControlDark, new Point(bounds.X + bounds.Width, bounds.Y + 4), new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height - 3));
                g.DrawLine(SystemPens.ControlDark, new Point(bounds.X, bounds.Y + bounds.Height), new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height));

            }
            g.DrawLine(SystemPens.ControlLightLight, new Point(bounds.X, bounds.Y + bounds.Height + 1), new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height + 1));

            if (_ModifiedSmoothMode)
                g.SmoothingMode = _Old;
        }
		public static void DrawTabItem (Graphics g, Rectangle bounds, string tabItemText, Font font, Image image, Rectangle imageRectangle, bool focused, TabItemState state)
		{
			DrawTabItem (g, bounds, tabItemText, font, TextFormatFlags.HorizontalCenter, image, imageRectangle, focused, state);
		}
示例#27
0
 public void DrawTabItem(Graphics g, Rectangle bounds, TabItemState state)
 {
     if (TabRenderer.IsSupported == false)
         (new VisualTabRenderer_VS2008()).DrawTabItem(g, bounds, state);
     bounds = GetModifiedBounds(bounds);
     TabRenderer.DrawTabItem(g, bounds, state);
 }
示例#28
0
 public static void DrawTabItem(Graphics g, Rectangle bounds, bool focused, TabItemState state)
 {
     DrawTabItem(g, bounds, String.Empty, null, TextFormatFlags.Default, null, Rectangle.Empty, focused, state);
 }
示例#29
0
        /// <summary>
        /// Draws our tab control.
        /// </summary>
        /// <param name="g">The <see cref="T:System.Drawing.Graphics"/> object used to draw tab control.</param>
        /// <param name="clipRect">The <see cref="T:System.Drawing.Rectangle"/> that specifies clipping rectangle
        /// of the control.</param>
        private void DrawCustomTabControl(Graphics g, Rectangle clipRect)
        {
            /* In this method we draw only those parts of the control which intersects with the
             * clipping rectangle. It's some kind of optimization.*/
            if (!this.Visible)
            {
                return;
            }

            //selected tab index and rectangle
            int       iSel    = this.SelectedIndex;
            Rectangle selRect = iSel != -1 ? this.GetTabRect(iSel) : Rectangle.Empty;

            Rectangle rcPage = this.ClientRectangle;

            //correcting page rectangle
            switch (this.Alignment)
            {
            case TabAlignment.Top:
            {
                int trunc = selRect.Height * this.RowCount + 2;
                rcPage.Y += trunc; rcPage.Height -= trunc;
            } break;

            case TabAlignment.Bottom: rcPage.Height -= (selRect.Height + VSTabControl.sAdjHeight) * this.RowCount; break;
            }

            //draw page itself
            if (rcPage.IntersectsWith(clipRect))
            {
                TabRenderer.DrawTabPage(g, rcPage);
            }

            int tabCount = this.TabCount;

            if (tabCount == 0)
            {
                return;
            }

            using (StringFormat textFormat = new StringFormat())
            {
                textFormat.Alignment     = StringAlignment.Center;
                textFormat.LineAlignment = StringAlignment.Center;
                //drawing unselected tabs
                this.lastHotIndex = HitTest();                //hot tab
                for (int iTab = 0; iTab < tabCount; iTab++)
                {
                    if (iTab != iSel)
                    {
                        Rectangle tabRect = this.GetTabRect(iTab);
                        if (tabRect.Right >= 3 && tabRect.IntersectsWith(clipRect))
                        {
                            TabItemState state = iTab == this.lastHotIndex ? TabItemState.Hot : TabItemState.Normal;
                            DrawTabItem(g, iTab, state, tabRect, textFormat);
                        }
                    }
                }

                /* Drawing selected tab. We'll also increase selected tab's rectangle. It should be a little
                 * bigger than other tabs.*/
                selRect.Inflate(2, 2);
                if (iSel != -1 && selRect.IntersectsWith(clipRect))
                {
                    DrawTabItem(g, iSel, TabItemState.Selected, selRect, textFormat);
                }
            }
        }
示例#30
0
 public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, TabItemState state)
 {
     DrawTabItem(g, bounds, tabItemText, font, TextFormatFlags.HorizontalCenter, null, Rectangle.Empty, false, state);
 }
示例#31
0
        public static bool IsSupported => VisualStyleRenderer.IsSupported; // no downlevel support

        /// <summary>
        ///  Renders a Tab item.
        /// </summary>
        public static void DrawTabItem(Graphics g, Rectangle bounds, TabItemState state)
        {
            InitializeRenderer(VisualStyleElement.Tab.TabItem.Normal, (int)state);

            visualStyleRenderer.DrawBackground(g, bounds);
        }
示例#32
0
		/*
		 * DrawTabButtonBackground
		 */

		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		private void DrawTabButtonBackground(Graphics g, Rectangle bounds, TabItemState state)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			Rectangle tweakedRectangle = new Rectangle(
				bounds.Left,
				bounds.Top,
				bounds.Width - _penWidth,
				bounds.Height - _penWidth
			);

			g.FillRectangle(SystemBrushes.Control, tweakedRectangle);

			Pen bottomPen = null;
			Pen leftTopPen = null;
			Pen rightPen = null;
			Pen rightShadowPen = null;

			switch (state)
			{
				case TabItemState.Disabled:
				{
					bottomPen = new Pen(SystemColors.ControlLightLight);
					leftTopPen = new Pen(SystemColors.ControlDark);
					rightPen = new Pen(SystemColors.ControlDark);
					rightShadowPen = new Pen(SystemColors.Control);
					break;
				}
				case TabItemState.Selected:
				{
					bottomPen = new Pen(SystemColors.Control);
					leftTopPen = new Pen(SystemColors.ControlLightLight);
					rightPen = new Pen(SystemColors.ControlDarkDark);
					rightShadowPen = new Pen(SystemColors.ControlDark);
					break;
				}
				default:
				{
					bottomPen = new Pen(SystemColors.ControlLightLight);
					leftTopPen = new Pen(SystemColors.ControlLightLight);
					rightPen = new Pen(SystemColors.ControlDarkDark);
					rightShadowPen = new Pen(SystemColors.ControlDark);
					break;
				}
			}

			try
			{
				g.DrawLines(leftTopPen, this.GetLeftTopNotchedPolygon(tweakedRectangle));
				g.DrawLines(rightPen, this.GetRightNotchedPolygon(tweakedRectangle));
				g.DrawLines(rightShadowPen, this.GetRightShadowNotchedPolygon(tweakedRectangle));
				g.DrawLine(
					bottomPen,
					NuGenControlPaint.RectBLCorner(tweakedRectangle),
					NuGenControlPaint.RectBRCorner(tweakedRectangle)
				);
			}
			finally
			{
				if (bottomPen != null)
				{
					bottomPen.Dispose();
				}

				if (leftTopPen != null)
				{
					leftTopPen.Dispose();
				}

				if (rightPen != null)
				{
					rightPen.Dispose();
				}
			}
		}
示例#33
0
 /// <summary>
 ///  Renders a Tab item.
 /// </summary>
 public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, bool focused, TabItemState state)
 {
     DrawTabItem(g, bounds, tabItemText, font,
                 TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine,
                 focused, state);
 }
示例#34
0
       /// <include file='doc\TabRenderer.uex' path='docs/doc[@for="TabRenderer.DrawTabItem7"]/*' />
       /// <devdoc>
       ///    <para>
       ///       Renders a Tab item.
       ///    </para>
       /// </devdoc>
       public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, TextFormatFlags flags, Image image, Rectangle imageRectangle, bool focused, TabItemState state) {
           InitializeRenderer(VisualStyleElement.Tab.TabItem.Normal, (int)state);

           visualStyleRenderer.DrawBackground(g, bounds);

           // I need this hack since GetBackgroundContentRectangle() returns same rectangle
           // as bounds for this control!
           Rectangle contentBounds = Rectangle.Inflate(bounds, -3, -3);
           visualStyleRenderer.DrawImage(g, imageRectangle, image);
           Color textColor = visualStyleRenderer.GetColor(ColorProperty.TextColor);
           TextRenderer.DrawText(g, tabItemText, font, contentBounds, textColor, flags);
           
           if (focused) {
               ControlPaint.DrawFocusRectangle(g, contentBounds);
           }
       }
示例#35
0
		/// <summary>
		/// Draws certain tab.
		/// </summary>
		/// <param name="g">The <see cref="T:System.Drawing.Graphics"/> object used to draw tab control.</param>
		/// <param name="index">Index of the tab being drawn.</param>
		/// <param name="state">State of the tab item.</param>
		/// <param name="tabRect">The <see cref="T:System.Drawing.Rectangle"/> object specifying tab bounds.</param>
		/// <param name="textFmt">The <see cref="T:System.Drawing.StringFormat"/> object specifying text formatting
		/// in the tab.</param>
		private void DrawTabItem(Graphics g, int index, TabItemState state, Rectangle tabRect, StringFormat textFmt)
		{
			//if scroller is visible and the tab is fully placed under it we don't need to draw such tab
			if (fUpDown.X <= 0 || tabRect.X < fUpDown.X)
			{
				/* We will draw our tab on the bitmap and then will transfer image on the control
				 * graphic context.*/

				using (Bitmap bmp = new Bitmap(tabRect.Width, tabRect.Height))
				{
					Rectangle drawRect = new Rectangle(0, 0, tabRect.Width, tabRect.Height);
					using (Graphics bitmapContext = Graphics.FromImage(bmp))
					{
						TabRenderer.DrawTabItem(bitmapContext, drawRect, state);
						if (state == TabItemState.Selected && tabRect.X == 0)
						{
							int corrY = bmp.Height - 1;
							bmp.SetPixel(0, corrY, bmp.GetPixel(0, corrY - 1));
						}
						/* Important moment. If tab alignment is bottom we should flip image to display tab
						 * correctly.*/

						if (this.Alignment == TabAlignment.Bottom)
							bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);

						Rectangle focusRect = Rectangle.Inflate(drawRect, -3, -3);
						//focus rect
						TabPage pg = this.TabPages[index];
						//tab page whose tab we're drawing
						//trying to get tab image if any
						Image pagePict = GetImageByIndexOrKey(pg.ImageIndex, pg.ImageKey);
						if (pagePict != null)
						{
							//If tab image is present we should draw it.
							Point imgLoc = state == TabItemState.Selected ? new Point(8, 2) : new Point(6, 2);
							if (this.Alignment == TabAlignment.Bottom)
								imgLoc.Y = drawRect.Bottom - 2 - pagePict.Height;
							bitmapContext.DrawImageUnscaled(pagePict, imgLoc);
							//Correcting rectangle for drawing text.
							drawRect.X += imgLoc.X + pagePict.Width;
							drawRect.Width -= imgLoc.X + pagePict.Width;
						}
						//drawing tab text
						using (Brush b = new SolidBrush(SystemColors.ControlText))
							bitmapContext.DrawString(pg.Text, this.Font, b, (RectangleF)drawRect, textFmt);
						//and finally drawing focus rect(if needed)
						if (this.Focused && state == TabItemState.Selected)
							ControlPaint.DrawFocusRectangle(bitmapContext, focusRect);
					}
					//If the tab has part under scroller we shouldn't draw that part.
					int shift = state == TabItemState.Selected ? 2 : 0;
					if (fUpDown.X > 0 && fUpDown.X >= tabRect.X - shift && fUpDown.X < tabRect.Right + shift)
						tabRect.Width -= tabRect.Right - fUpDown.X + shift;
					g.DrawImageUnscaledAndClipped(bmp, tabRect);
				}
			}
		}
示例#36
0
 public static void DrawTabItem(Graphics g, Rectangle bounds, TabItemState state)
 {
     throw null;
 }
示例#37
0
 public static void DrawTabItem(Graphics g, Rectangle bounds, Image image, Rectangle imageRectangle, bool focused, TabItemState state)
 {
     DrawTabItem(g, bounds, String.Empty, null, TextFormatFlags.HorizontalCenter, image, imageRectangle, focused, state);
 }
示例#38
0
 public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, bool focused, TabItemState state)
 {
     throw null;
 }
示例#39
0
		/*
		 * DrawTabButtonBackgroundUsingVisualStyles
		 */

		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para>
		///		<paramref name="g"/> is <see langword="null"/>.
		/// </para>
		/// </exception>
		/// <exception cref="InvalidOperationException">
		/// <para>
		///		Visual styles are not currently available.
		/// </para>
		/// </exception>
		private void DrawTabButtonBackgroundUsingVisualStyles(
			Graphics g,
			Rectangle bounds,
			TabItemState state
			)
		{
			if (g == null)
			{
				throw new ArgumentNullException("g");
			}

			if (!VisualStyleInformation.IsEnabledByUser)
			{
				throw new InvalidOperationException(Resources.InvalidOperation_VisualStyles);
			}

			TabRenderer.DrawTabItem(g, bounds, state);
		}
示例#40
0
 public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, TextFormatFlags flags, bool focused, TabItemState state)
 {
     DrawTabItem(g, bounds, tabItemText, font, flags, null, Rectangle.Empty, focused, state);
 }
示例#41
0
       public static void DrawTabItem(Graphics g, Rectangle bounds, TabItemState state) {
           InitializeRenderer(VisualStyleElement.Tab.TabItem.Normal, (int)state);

           visualStyleRenderer.DrawBackground(g, bounds);
       }
示例#42
0
 public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, Image image, Rectangle imageRectangle, bool focused, TabItemState state)
 {
     DrawTabItem(g, bounds, tabItemText, font, TextFormatFlags.HorizontalCenter, image, imageRectangle, focused, state);
 }
示例#43
0
 /// <include file='doc\TabRenderer.uex' path='docs/doc[@for="TabRenderer.DrawTabItem2"]/*' />
 /// <devdoc>
 ///    <para>
 ///       Renders a Tab item.
 ///    </para>
 /// </devdoc>
 public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, TabItemState state) {
     DrawTabItem(g, bounds, tabItemText, font, false, state);
 }
示例#44
0
        public static void DrawTabItem(Graphics g, Rectangle bounds, string tabItemText, Font font, TextFormatFlags flags, Image image, Rectangle imageRectangle, bool focused, TabItemState state)
        {
            if (!IsSupported)
            {
                throw new InvalidOperationException();
            }

            VisualStyleRenderer vsr;

            switch (state)
            {
            case TabItemState.Disabled:
                vsr = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Disabled);
                break;

            case TabItemState.Hot:
                vsr = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Hot);
                break;

            case TabItemState.Normal:
            default:
                vsr = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal);
                break;

            case TabItemState.Selected:
                vsr = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Pressed);
                break;
            }

            vsr.DrawBackground(g, bounds);

            if (image != null)
            {
                vsr.DrawImage(g, imageRectangle, image);
            }

            bounds.Offset(3, 3);
            bounds.Height -= 6;
            bounds.Width  -= 6;

            if (tabItemText != String.Empty)
            {
                TextRenderer.DrawText(g, tabItemText, font, bounds, SystemColors.ControlText, flags);
            }

            if (focused)
            {
                ControlPaint.DrawFocusRectangle(g, bounds);
            }
        }
示例#45
0
        /*
         * DrawTabButtonBackground
         */

        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="g"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        private void DrawTabButtonBackground(Graphics g, Rectangle bounds, TabItemState state)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            Rectangle tweakedRectangle = new Rectangle(
                bounds.Left,
                bounds.Top,
                bounds.Width - _penWidth,
                bounds.Height - _penWidth
                );

            g.FillRectangle(SystemBrushes.Control, tweakedRectangle);

            Pen bottomPen      = null;
            Pen leftTopPen     = null;
            Pen rightPen       = null;
            Pen rightShadowPen = null;

            switch (state)
            {
            case TabItemState.Disabled:
            {
                bottomPen      = new Pen(SystemColors.ControlLightLight);
                leftTopPen     = new Pen(SystemColors.ControlDark);
                rightPen       = new Pen(SystemColors.ControlDark);
                rightShadowPen = new Pen(SystemColors.Control);
                break;
            }

            case TabItemState.Selected:
            {
                bottomPen      = new Pen(SystemColors.Control);
                leftTopPen     = new Pen(SystemColors.ControlLightLight);
                rightPen       = new Pen(SystemColors.ControlDarkDark);
                rightShadowPen = new Pen(SystemColors.ControlDark);
                break;
            }

            default:
            {
                bottomPen      = new Pen(SystemColors.ControlLightLight);
                leftTopPen     = new Pen(SystemColors.ControlLightLight);
                rightPen       = new Pen(SystemColors.ControlDarkDark);
                rightShadowPen = new Pen(SystemColors.ControlDark);
                break;
            }
            }

            try
            {
                g.DrawLines(leftTopPen, this.GetLeftTopNotchedPolygon(tweakedRectangle));
                g.DrawLines(rightPen, this.GetRightNotchedPolygon(tweakedRectangle));
                g.DrawLines(rightShadowPen, this.GetRightShadowNotchedPolygon(tweakedRectangle));
                g.DrawLine(
                    bottomPen,
                    NuGenControlPaint.RectBLCorner(tweakedRectangle),
                    NuGenControlPaint.RectBRCorner(tweakedRectangle)
                    );
            }
            finally
            {
                if (bottomPen != null)
                {
                    bottomPen.Dispose();
                }

                if (leftTopPen != null)
                {
                    leftTopPen.Dispose();
                }

                if (rightPen != null)
                {
                    rightPen.Dispose();
                }
            }
        }
    public void Init()
    {
        userInventory = GameManager.Instance.GetUserInventory();
        foreach (AttractionType type in Enum.GetValues(typeof(AttractionType)))
        {
            List <UserProductData> attractionsList      = userInventory.GetAllAttractionsOfType(type);
            AttractionsDataAsset   attractionsDataAsset = GameManager.Instance.GetAttractionsData();

            BasicAtractionData nextRide = null;
            TabItemState       tabState = TabItemState.IDLE;
            if (type == AttractionType.RIDE)
            {
                tabState = TabItemState.HIGHLIGHT;
            }
            if (attractionsList.Count == 0)
            {
                tabState = TabItemState.LOCKED; //IFATUtodo - this will probably be changed
            }

            List <UserProductData> rideUserItems = attractionsList.FindAll(a => a.type == type);
            if (rideUserItems != null && rideUserItems.Count > 0) // daca ai cel putin un element
            {
                Guid nextElementGuid;
                if (rideUserItems.Count > 0)
                {
                    nextElementGuid = rideUserItems[rideUserItems.Count - 1].guid;
                }
                switch (type)
                {
                case AttractionType.RIDE:
                {
                    List <RideData> assetData        = attractionsDataAsset.GetCurrentEventAssets().rideData;
                    int             lastElementIndex = 0;
                    if (rideUserItems.Count > 0)
                    {
                        lastElementIndex = assetData.FindIndex(a => a.guid == nextElementGuid);
                        if (assetData.Count > lastElementIndex + 1)
                        {
                            nextRide = assetData[lastElementIndex + 1];
                        }
                    }
                    else
                    {
                        nextRide = assetData[0];
                    }
                }
                break;

                case AttractionType.FOOD_AND_BEVERAGE:
                {
                    List <FoodAndBeverageData> assetData = attractionsDataAsset.GetCurrentEventAssets().foodAndBeverageData;
                    int lastElementIndex = 0;
                    if (rideUserItems.Count > 0)
                    {
                        lastElementIndex = assetData.FindIndex(a => a.guid == nextElementGuid);
                        if (assetData.Count > lastElementIndex + 1)
                        {
                            nextRide = assetData[lastElementIndex + 1];
                        }
                    }
                    else
                    {
                        nextRide = assetData[0];
                    }
                }
                break;

                case AttractionType.RECREATION_AREA:
                {
                    List <RecreationAreaData> assetData = attractionsDataAsset.GetCurrentEventAssets().recreationAreaData;
                    int lastElementIndex = 0;
                    if (rideUserItems.Count > 0)
                    {
                        lastElementIndex = assetData.FindIndex(a => a.guid == nextElementGuid);
                        if (assetData.Count > lastElementIndex + 1)
                        {
                            nextRide = assetData[lastElementIndex + 1];
                        }
                    }
                    else
                    {
                        nextRide = assetData[0];
                    }
                }
                break;

                default:
                    break;
                }
                if (nextRide != null)
                {
                    userInventory.OnItemBought(nextRide.guid, type, 0);

                    attractionsList.Add(new UserProductData
                    {
                        count      = 0,
                        guid       = nextRide.guid,
                        guidString = nextRide.guid.ToString(),
                        level      = 0,
                        type       = type
                    });
                }
            }

            if (tabState == TabItemState.LOCKED && nextRide != null)
            {
                bool checkNextRideUnlockConditions = UnlockManager.Instance.CheckUnlockConditions(nextRide.unlockConditionList);
                if (checkNextRideUnlockConditions)
                {
                    tabState = TabItemState.UNLOCKED;
                }
            }

            AttractionItem newItem = new AttractionItem();
            newItem.Init(type, tabState, attractionData, tabParent, listParent,
                         attractionsTabObj, attractionsListObj, attractionsList);
            //  newItem.onClick += OnTabCliked;
            attractionItemList.Add(newItem);
        }
    }