當前位置: 首頁>>代碼示例>>C#>>正文


C# Rectangle.Inflated方法代碼示例

本文整理匯總了C#中System.Drawing.Rectangle.Inflated方法的典型用法代碼示例。如果您正苦於以下問題:C# Rectangle.Inflated方法的具體用法?C# Rectangle.Inflated怎麽用?C# Rectangle.Inflated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.Rectangle的用法示例。


在下文中一共展示了Rectangle.Inflated方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            var helper = new GraphicsHelper(e.Graphics);
            var orientation = SideBarOrientation.Left;

            if (SideBar != null)
            {
                orientation = SideBar.Orientation;
            }
            for (var i = 0; i < Tabs.Count; i++)
            {
                SideBarTab tab = Tabs[i];

                Point currentPosition = Point.Empty;

                Rectangle tabRect = Rectangle.Empty,
                    textRect = Rectangle.Empty;

                switch (orientation)
                {
                    case SideBarOrientation.Left:
                        currentPosition = new Point(TabMarginLeft, i*(TabHeight + TabSpacing) + TabMarginTop);
                        tabRect = new Rectangle(currentPosition.X, currentPosition.Y, Width, TabHeight);
                        break;
                    case SideBarOrientation.Right:
                        currentPosition = new Point(TabMarginLeft, i*(TabHeight + TabSpacing) + TabMarginTop);
                        tabRect = new Rectangle(currentPosition.X - TabMarginLeft*2, currentPosition.Y, Width, TabHeight);
                        break;
                }

                var leftFormat = new StringFormat();
                leftFormat.LineAlignment = StringAlignment.Center;
                leftFormat.Alignment = StringAlignment.Near;

                if (i == SelectedIndex || i == hoverIndex)
                {
                    var gradient = new Rectangle(tabRect.X + 1, tabRect.Y + 1, tabRect.Width - 3, (tabRect.Height - 1)/2);

                    if (i == SelectedIndex)
                    {
                        helper.RoundedFill(UColor.White, tabRect, 4);
                    }
                    if (i == hoverIndex)
                    {
                        helper.RoundedFill(UColor.Blend(0x50, UColor.White), tabRect, 4);
                    }
                    helper.RoundedGradient(UColor.Blend(0x05, UColor.Black), UColor.Blend(0x20, UColor.Black), tabRect,
                        90, 4);

                    if (i == SelectedIndex)
                    {
                        helper.RoundedGradient(UColor.Blend(0xdd, UColor.White), UColor.White, gradient, 90, 4);
                    }

                    helper.RoundedOutline(UColor.Blend(0x60, UColor.White), tabRect.Inflated(1), 4);

                    if (i == SelectedIndex)
                    {
                        helper.RoundedOutline(UColor.Blend(0x90, UColor.Black), tabRect, 4);
                    }
                    else if (i == hoverIndex)
                    {
                        helper.RoundedOutline(UColor.Blend(0x50, UColor.Black), tabRect, 4);
                    }
                }

                if (tab.Changed)
                {
                    helper.RoundedFill(UColor.Blend(0x30, UColor.White), tabRect, 4);
                    helper.RoundedFill(UColor.Blend(0x20, UColor.Red), tabRect, 4);
                }
                if (tab.HasIcon)
                {
                    e.Graphics.DrawImage(tab.Icon,
                        new Point(currentPosition.X + TabMarginLeft, currentPosition.Y + TabHeight/2 - tab.Icon.Height/2));
                    currentPosition.Offset(TabMarginLeft + 2 + tab.Icon.Width, 0);
                }

                textRect = new Rectangle(currentPosition.X, currentPosition.Y, Width, TabHeight);
                if (i == SelectedIndex)
                {
                    helper.Text(tab.Caption, Font, UColor.Blend(0xff, UColor.White), textRect.ShrinkedY(-2), leftFormat);
                    helper.Text(tab.Caption, Font, UColor.Blend(0xdd, UColor.Black), textRect, leftFormat);
                }
                else
                {
                    helper.Text(tab.Caption, Font, UColor.Blend(0xee, UColor.Black), textRect.ShrinkedY(-2), leftFormat);
                    helper.Text(tab.Caption, Font, UColor.Blend(0xff, UColor.White), textRect, leftFormat);
                }
            }
        }
開發者ID:matheus2984,項目名稱:SoulEngine,代碼行數:91,代碼來源:SideBarTabControl.cs

示例2: OnRenderButtonBackground

            protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
            {
                var helper = new GraphicsHelper(e.Graphics);
                var itemBounds = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);
                var button = e.Item as ToolStripButton;

                if (e.Item.Selected && !e.Item.Pressed || (button != null && button.Checked))
                {
                    helper.RoundedFill(UColor.White, itemBounds, 4);
                    helper.RoundedGradient(
                        UColor.Blend(0x80, UColor.Black),
                        UColor.Blend(0x60, UColor.Black),
                        itemBounds,
                        90, 4);
                }
                if (e.Item.Pressed)
                {
                    helper.RoundedFill(UColor.White, itemBounds, 4);
                    helper.RoundedGradient(
                        UColor.Blend(0xa0, UColor.Black),
                        UColor.Blend(0x60, UColor.Black),
                        itemBounds,
                        90, 4);
                }
                if (e.Item.Selected || e.Item.Pressed || (button != null && button.Checked))
                {
                    for (int i = innerShadow; i >= 0; i--)
                    {
                        helper.RoundedOutline(UColor.Blend((byte) ((5 + innerShadow*10) - i*10), UColor.Black),
                            itemBounds.Inflated(i + 2), i + 1);
                    }
                    helper.RoundedOutline(UColor.Blend(0x60, UColor.Black), itemBounds.Inflated(1), 4);
                    helper.RoundedOutline(UColor.Blend(0xff, UColor.White), itemBounds, 4);
                }
            }
開發者ID:matheus2984,項目名稱:SoulEngine,代碼行數:35,代碼來源:Menu.cs


注:本文中的System.Drawing.Rectangle.Inflated方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。