当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.DrawIcon方法代码示例

本文整理汇总了C#中System.Drawing.Graphics.DrawIcon方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawIcon方法的具体用法?C# Graphics.DrawIcon怎么用?C# Graphics.DrawIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Graphics的用法示例。


在下文中一共展示了Graphics.DrawIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render


//.........这里部分代码省略.........
                        tab.Active
                            ? _activeRightSideImage
                            : _inactiveRightSideImage, new Rectangle(
                                (tab.Active
                                    ? _activeLeftSideImage
                                        .Width
                                    : _inactiveLeftSideImage
                                        .Width) +
                                _tabContentWidth, 0,
                                tab.Active
                                    ? _activeRightSideImage
                                        .Width
                                    : _inactiveRightSideImage
                                        .Width,
                                tab.Active
                                    ? _activeRightSideImage
                                        .Height
                                    : _inactiveRightSideImage
                                        .Height), 0, 0,
                        tab.Active
                            ? _activeRightSideImage.Width
                            : _inactiveRightSideImage.Width, tab.Active
                                ? _activeRightSideImage.Height
                                : _inactiveRightSideImage.
                                    Height,
                        GraphicsUnit.Pixel);

                    // Draw the close button
                    if (tab.ShowCloseButton)
                    {
                        Image closeButtonImage = IsOverCloseButton(tab, cursor)
                            ? _closeButtonHoverImage
                            : _closeButtonImage;

                        tab.CloseButtonArea = new Rectangle(
                            area.Width - (tab.Active
                                ? _activeRightSideImage.Width
                                : _inactiveRightSideImage.Width) -
                            CloseButtonMarginRight - closeButtonImage.Width,
                            CloseButtonMarginTop, closeButtonImage.Width,
                            closeButtonImage.Height);

                        tabGraphicsContext.DrawImage(
                            closeButtonImage, tab.CloseButtonArea, 0, 0,
                            closeButtonImage.Width, closeButtonImage.Height,
                            GraphicsUnit.Pixel);
                    }
                }

                tab.Area = area;
            }

            // Render the tab's saved image to the screen
            graphicsContext.DrawImage(
                tab.TabImage, area, 0, 0, tab.TabImage.Width, tab.TabImage.Height,
                GraphicsUnit.Pixel);

            // Render the icon for the tab's content, if it exists and there's room for it in the tab's content area
            if (tab.Content.ShowIcon && _tabContentWidth > 16 + IconMarginLeft + (tab.ShowCloseButton
                ? CloseButtonMarginLeft +
                  tab.CloseButtonArea.Width +
                  CloseButtonMarginRight
                : 0))
            {
                graphicsContext.DrawIcon(
                    new Icon(tab.Content.Icon, 16, 16),
                    new Rectangle(area.X + OverlapWidth + IconMarginLeft, IconMarginTop + area.Y, 16, 16));
            }

            // Render the caption for the tab's content if there's room for it in the tab's content area
            if (_tabContentWidth > (tab.Content.ShowIcon
                ? 16 + IconMarginLeft + IconMarginRight
                : 0) + CaptionMarginLeft + CaptionMarginRight + (tab.ShowCloseButton
                    ? CloseButtonMarginLeft +
                      tab.CloseButtonArea.Width +
                      CloseButtonMarginRight
                    : 0))
            {
                graphicsContext.DrawString(
                    tab.Caption, SystemFonts.CaptionFont, Brushes.Black,
                    new Rectangle(
                        area.X + OverlapWidth + CaptionMarginLeft + (tab.Content.ShowIcon
                            ? IconMarginLeft +
                              16 +
                              IconMarginRight
                            : 0),
                        CaptionMarginTop + area.Y,
                        _tabContentWidth - (tab.Content.ShowIcon
                            ? IconMarginLeft + 16 + IconMarginRight
                            : 0) - (tab.ShowCloseButton
                                ? _closeButtonImage.Width +
                                  CloseButtonMarginRight +
                                  CloseButtonMarginLeft
                                : 0), tab.TabImage.Height),
                    new StringFormat(StringFormatFlags.NoWrap)
                    {
                        Trimming = StringTrimming.EllipsisCharacter
                    });
            }
        }
开发者ID:rajeshwarn,项目名称:EasyTabs,代码行数:101,代码来源:BaseTabRenderer.cs

示例2: draw

		internal override void draw(Graphics g)
		{
			RectangleF rcNode = item.getRotatedBounds();
			Rectangle rcDev = Utilities.docToDevice(g, getIconRect(rcNode));

			if (rcDev.Width < 6 || rcDev.Height < 6) return;
GraphicsState state = g.Save();
item.flowChart.unsetTransforms(g);
			if ((item as Node).Expanded)
				g.DrawIcon(imgExpanded, rcDev.X, rcDev.Y);
			else
				g.DrawIcon(imgCollapsed, rcDev.X, rcDev.Y);
g.Restore(state);
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:14,代码来源:Expander.cs

示例3: LegendSymbol_Painted

 /// <summary>
 /// Draws the icon to the legend
 /// </summary>
 /// <param name="g"></param>
 /// <param name="box"></param>
 public override void LegendSymbol_Painted(Graphics g, Rectangle box)
 {
     if (_icon != null)
     {
         g.DrawIcon(_icon, box);
     }
 }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:12,代码来源:LegendIcon.cs

示例4: Draw

		public override void Draw(Graphics graphics, RenderMode rm) {
			if (icon != null) {
				graphics.SmoothingMode = SmoothingMode.HighQuality;
				graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
				graphics.CompositingQuality = CompositingQuality.Default;
				graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
				graphics.DrawIcon(icon, Bounds);
			}
		}
开发者ID:logtcn,项目名称:greenshot,代码行数:9,代码来源:IconContainer.cs

示例5: DrawIcon

        public static void DrawIcon(Graphics g,Icon icon,Rectangle drawRect,bool grayed,bool pushed)
        {
            // If Graphics or Icon isn't valid,
            // just skip this function.
            if(g == null || icon == null){
                return;
            }

            // Icon pushed state, update icon location.
            if(pushed){
                drawRect.Location = new Point(drawRect.X + 1,drawRect.Y + 1);
            }

            //----- Draw Icon ---
            if(grayed){
                // Draw grayed icon
                Size s = new Size(drawRect.Size.Width-1,drawRect.Size.Height-1);
                ControlPaint.DrawImageDisabled(g,new Bitmap(icon.ToBitmap(),s),drawRect.X,drawRect.Y,Color.Transparent);
            }
            else{
                // Draw normal icon
                g.DrawIcon(icon,drawRect);
            }
        }
开发者ID:NasuTek,项目名称:NasuTek-Inventory-Services,代码行数:24,代码来源:Painter.cs

示例6: DrawTab

		private void DrawTab(Graphics g, AutoHideTabFromBase tab)
		{
			Rectangle rectTab = GetTabRectangle(tab);
			if (rectTab.IsEmpty)
				return;

			DockState dockState = tab.Content.DockHandler.DockState;
			IDockContent content = tab.Content;
			
			BeginDrawTab();

			
			Pen penTabBorder = PenTabBorder;
			Brush brushTabText = new SolidBrush(ColorMixer.AutoHideTabTextColor);

			if (dockState == DockState.DockTopAutoHide || dockState == DockState.DockRightAutoHide)
				DrawUtil.DrawVSTab(g,rectTab,Color.WhiteSmoke,Color.DimGray,false);
			else
				DrawUtil.DrawVSTab(g,rectTab,Color.WhiteSmoke,Color.DimGray,false);

//			g.FillRectangle(new LinearGradientBrush(rectTab,ColorMixer.DarkColor,ColorMixer.LightColor,LinearGradientMode.Vertical)
//				, rectTab);
//
//			g.DrawLine(penTabBorder, rectTab.Left, rectTab.Top, rectTab.Left, rectTab.Bottom);
//			g.DrawLine(penTabBorder, rectTab.Right, rectTab.Top, rectTab.Right, rectTab.Bottom);
//			if (dockState == DockState.DockTopAutoHide || dockState == DockState.DockRightAutoHide)
//				g.DrawLine(penTabBorder, rectTab.Left, rectTab.Bottom, rectTab.Right, rectTab.Bottom);
//			else
//				g.DrawLine(penTabBorder, rectTab.Left, rectTab.Top, rectTab.Right, rectTab.Top);


			// Set no rotate for drawing icon and text
			Matrix matrixRotate = g.Transform;
			g.Transform = MatrixIdentity;

			// Draw the icon
			Rectangle rectImage = rectTab;
			rectImage.X += ImageGapLeft;
			rectImage.Y += ImageGapTop;
			int imageHeight = rectTab.Height - ImageGapTop - ImageGapBottom;
			int imageWidth = ImageWidth;
			if (imageHeight > ImageHeight)
				imageWidth = ImageWidth * (imageHeight/ImageHeight);
			rectImage.Height = imageHeight;
			rectImage.Width = imageWidth;
			rectImage = GetTransformedRectangle(dockState, rectImage);
			g.DrawIcon(content.DockHandler.Icon, rectImage);

			// Draw the text
			if (content == content.DockHandler.Pane.ActiveContent)
			{
				Rectangle rectText = rectTab;
				rectText.X += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
				rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
				rectText = GetTransformedRectangle(dockState, rectText);
				if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide)
					g.DrawString(content.DockHandler.TabText, Font, brushTabText, rectText, StringFormatTabVertical);
				else
					g.DrawString(content.DockHandler.TabText, Font, brushTabText, rectText, StringFormatTabHorizontal);
			}

			// Set rotate back
			g.Transform = matrixRotate;

			EndDrawTab();
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:66,代码来源:AutoHideStripFromBase.cs

示例7: DrawTab_ToolWindow

        private void DrawTab_ToolWindow(Graphics g, IDockContent content, Rectangle rect, int index)
        {
            Rectangle rectIcon = new Rectangle(rect.X + ToolWindowImageGapLeft, rect.Y + rect.Height - 1 - ToolWindowImageGapBottom - ToolWindowImageHeight, ToolWindowImageWidth, ToolWindowImageHeight);
            Rectangle rectText = rectIcon;
            rectText.X += rectIcon.Width + ToolWindowImageGapRight;
            rectText.Width = rect.Width - rectIcon.Width - ToolWindowImageGapLeft - ToolWindowImageGapRight - ToolWindowTextGapRight;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            if (DockPane.ActiveContent == content)
            {
                DrawHelper.DrawTab(g, rect, Corners.Bottom, GradientType.Flat, Color.LightBlue, Color.WhiteSmoke, Color.Gray, false);
                g.DrawString(content.DockHandler.TabText, Font, ActiveTextBrush, rectText, ToolWindowTextStringFormat);
            }
            else
            {
                if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(content) + 1)
                {
                    g.DrawLine(TabSeperatorPen, rect.X + rect.Width - 1, rect.Y + ToolWindowTabSeperatorGapTop, rect.X + rect.Width - 1, rect.Y + rect.Height - 1 - ToolWindowTabSeperatorGapBottom);
                }
                g.DrawString(content.DockHandler.TabText, Font, InactiveTextBrush, rectText, ToolWindowTextStringFormat);
            }
            if (rect.Contains(rectIcon))
            {
                g.DrawIcon(content.DockHandler.Icon, rectIcon);
            }
        }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:26,代码来源:DockPaneStripFromBase.cs

示例8: DrawTab_ToolWindow

		private void DrawTab_ToolWindow(Graphics g, DockContent content, Rectangle rect)
		{
			Rectangle rectIcon = new Rectangle(
				rect.X + ToolWindowImageGapLeft,
				rect.Y + rect.Height - 1 - ToolWindowImageGapBottom - ToolWindowImageHeight,
				ToolWindowImageWidth, ToolWindowImageHeight);
			Rectangle rectText = rectIcon;
			rectText.X += rectIcon.Width + ToolWindowImageGapRight;
			rectText.Width = rect.Width - rectIcon.Width - ToolWindowImageGapLeft - 
				ToolWindowImageGapRight - ToolWindowTextGapRight;

			if (DockPane.ActiveContent == content)
			{
				g.FillRectangle(ActiveBackBrush, rect);
				g.DrawLine(OutlineOuterPen,
					rect.X, rect.Y, rect.X, rect.Y + rect.Height - 1);
				g.DrawLine(OutlineInnerPen,
					rect.X, rect.Y + rect.Height - 1, rect.X + rect.Width - 1, rect.Y + rect.Height - 1);
				g.DrawLine(OutlineInnerPen,
					rect.X + rect.Width - 1, rect.Y, rect.X + rect.Width - 1, rect.Y + rect.Height - 1);
				g.DrawString(content.TabText, Font, ActiveTextBrush, rectText, ToolWindowTextStringFormat);
			}
			else
			{
				if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(content) + 1)
					g.DrawLine(TabSeperatorPen,
						rect.X + rect.Width - 1,
						rect.Y + ToolWindowTabSeperatorGapTop,
						rect.X + rect.Width - 1,
						rect.Y + rect.Height - 1 - ToolWindowTabSeperatorGapBottom);
				g.DrawString(content.TabText, Font, InactiveTextBrush, rectText, ToolWindowTextStringFormat);
			}

			if (rect.Contains(rectIcon))
				g.DrawIcon(content.Icon, rectIcon);
		}
开发者ID:tropology,项目名称:ceptr,代码行数:36,代码来源:DockPaneStripVS2003.cs

示例9: DrawIconAndText

        /// <summary>
        /// 绘制窗体图标和文本
        /// </summary>
        private void DrawIconAndText(Graphics g)
        {
            Rectangle iconRect = Rectangle.Empty;
            Rectangle textRect = Rectangle.Empty;

            if (isDrawIcon && this.Icon != null)
            {
                iconRect = new Rectangle(new Point(8, 6), SystemInformation.SmallIconSize);

                if (this.Text.Length > 0)
                {
                    textRect = new Rectangle(iconRect.Right + 2, iconRect.Top - (textFont.Height - iconRect.Height) / 2, Width - (8 + iconRect.Width + 2 + 27 * 2), textFont.Height);
                }
            }
            else
            {
                if (this.Text.Length > 0)
                {
                    textRect = new Rectangle(8, 4, Width - 8, textFont.Height);
                }
            }

            if (isDrawIcon && this.Icon != null)
            {
                g.DrawIcon(this.Icon, iconRect);
            }

            if (this.Text.Length > 0)
            {
                TextRenderer.DrawText(
                g,
                this.Text,
                textFont,
                textRect,
                textForeColor,
                TextFormatFlags.SingleLine | TextFormatFlags.EndEllipsis);
            }
        }
开发者ID:yienit,项目名称:KST,代码行数:41,代码来源:NuiFormBase.cs

示例10: DrawTab_ToolWindow

        private void DrawTab_ToolWindow(Graphics g, TabVS2005 tab, Rectangle rect)
        {
            Rectangle rectIcon = new Rectangle(
                rect.X + ToolWindowImageGapLeft,
                rect.Y + rect.Height - 1 - ToolWindowImageGapBottom - ToolWindowImageHeight,
                ToolWindowImageWidth, ToolWindowImageHeight);
            Rectangle rectText = rectIcon;
            rectText.X += rectIcon.Width + ToolWindowImageGapRight;
            rectText.Width = rect.Width - rectIcon.Width - ToolWindowImageGapLeft -
                ToolWindowImageGapRight - ToolWindowTextGapRight;

            Rectangle rectTab = DrawHelper.RtlTransform(this, rect);
            rectText = DrawHelper.RtlTransform(this, rectText);
            rectIcon = DrawHelper.RtlTransform(this, rectIcon);
            GraphicsPath path = GetTabOutline(tab, true, false);
            if (DockPane.ActiveContent == tab.Content)
            {
                Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor;
                Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor;
                LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.LinearGradientMode;
                g.FillPath(new LinearGradientBrush(rectTab, startColor, endColor, gradientMode), path);
                g.DrawPath(PenToolWindowTabBorder, path);

                Color textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor;
                TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, ToolWindowTextFormat);
            }
            else
            {
                Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.StartColor;
                Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.EndColor;
                LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.LinearGradientMode;
                g.FillPath(new LinearGradientBrush(rectTab, startColor, endColor, gradientMode), path);

                if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(tab) + 1)
                {
                    Point pt1 = new Point(rect.Right, rect.Top + ToolWindowTabSeperatorGapTop);
                    Point pt2 = new Point(rect.Right, rect.Bottom - ToolWindowTabSeperatorGapBottom);
                    g.DrawLine(PenToolWindowTabBorder, DrawHelper.RtlTransform(this, pt1), DrawHelper.RtlTransform(this, pt2));
                }

                Color textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.TextColor;
                TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, ToolWindowTextFormat);
            }

            if (rectTab.Contains(rectIcon))
                g.DrawIcon(new Icon(tab.Content.DockHandler.Icon, new Size(rectIcon.Width, rectIcon.Height)), rectIcon);
        }
开发者ID:n1nj4n,项目名称:renderdoc,代码行数:47,代码来源:VS2005DockPaneStrip.cs

示例11: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            g = e.Graphics;
            Bmp = ResClass.GetImgRes("login_png_bkg");
            g.DrawImage(Bmp, new Rectangle(0, 0, 5, 31), 0, 0, 5, 31, GraphicsUnit.Pixel);
            g.DrawImage(Bmp, new Rectangle(5, 0, this.Width - 10, 31), 5, 0, Bmp.Width - 10, 31, GraphicsUnit.Pixel);
            g.DrawImage(Bmp, new Rectangle(this.Width - 5, 0, 5, 31), Bmp.Width - 5, 0, 5, 31, GraphicsUnit.Pixel);

            g.DrawImage(Bmp, new Rectangle(0, 31, 2, 25), 0, 31, 2, 25, GraphicsUnit.Pixel);
            g.DrawImage(Bmp, new Rectangle(2, 31, this.Width - 4, 25), 2, 31, 5, 25, GraphicsUnit.Pixel);
            g.DrawImage(Bmp, new Rectangle(this.Width - 2, 31, 2, 25), Bmp.Width - 2, 31, 2, 25, GraphicsUnit.Pixel);

            g.DrawImage(Bmp, new Rectangle(0, this.Height - 34, 5, 34), 0, Bmp.Height - 34, 5, 34, GraphicsUnit.Pixel);
            g.DrawImage(Bmp, new Rectangle(5, this.Height - 34, this.Width - 10, 34), 5, Bmp.Height - 34, Bmp.Width - 10, 34, GraphicsUnit.Pixel);
            g.DrawImage(Bmp, new Rectangle(this.Width - 5, this.Height - 34, 5, 34), Bmp.Width - 5, Bmp.Height - 34, 5, 34, GraphicsUnit.Pixel);

            g.DrawImage(Bmp, new Rectangle(0, 56, 5, Height-90), 0, Bmp.Height - 230, 5, 130, GraphicsUnit.Pixel);
            g.DrawImage(Bmp, new Rectangle(5, 56, this.Width - 10, Height - 90), 5, Bmp.Height - 230, Bmp.Width - 10, 130, GraphicsUnit.Pixel);
            g.DrawImage(Bmp, new Rectangle(this.Width - 5, 56, 5, Height - 90), Bmp.Width - 5, Bmp.Height - 230, 5, 130, GraphicsUnit.Pixel);

            if (this.ShowIcon)
            {
                g.DrawIcon(icon, new Rectangle(8, 7, 16, 16));
            }
            else
            {
                strX = 10;
            }
            //Bmp = ResClass.GetResObj("MainPanel_TitleBackgroundBluelight_background");
            Font f = null;
            if (Environment.OSVersion.Version.Major >= 6)
            {
                f = new Font("微软雅黑", 11F, FontStyle.Regular);
                g.DrawString(this.Text, f, titleColor, strX, 4);
                //g.DrawImage(Bmp, new Rectangle(strX, 4, (int)SkinUtil.GetStrWidth(Text, f), 20), 0, 0, Bmp.Width, Bmp.Height, GraphicsUnit.Pixel);
            }
            else
            {
                f = new Font("宋体", 11F, FontStyle.Regular);
                g.DrawString(this.Text, f, titleColor, strX, 8);
            }
            f.Dispose();
            Bmp.Dispose();
        }
开发者ID:songques,项目名称:CSSIM_Solution,代码行数:45,代码来源:BasicForm.cs

示例12: DrawTab_Document


//.........这里部分代码省略.........
                rectText.Y = rect.Y;
                rectText.Width = rect.Width - rectIcon.Width - DocumentIconGapLeft -
                    DocumentIconGapRight - DocumentTextGapRight;
                rectText.Height = rect.Height;
            }
            else
                rectText.Width = rect.Width - DocumentIconGapLeft - DocumentTextGapRight;

            Rectangle rectTab = DrawHelper.RtlTransform(this, rect);
            rectText = DrawHelper.RtlTransform(this, rectText);
            rectIcon = DrawHelper.RtlTransform(this, rectIcon);
            GraphicsPath path = GetTabOutline(tab, true, false);

            Color stripColor = tab.Content.DockHandler.TabColor;
            if (stripColor != Color.Transparent)
            {
                Color temp = PluginCore.PluginBase.MainForm.GetThemeColor("VS2005DockPaneStrip.TabStripColor");
                if (temp != Color.Empty) stripColor = temp;
            }

            if (DockPane.ActiveContent == tab.Content)
            {
                if (tabStyle == "Rect") g.FillRectangle(BrushDocumentActiveBackground, rectTab);
                else g.FillPath(BrushDocumentActiveBackground, path);

                // Change by Mika: add color strip to tabs
                SolidBrush stripBrush = new SolidBrush(stripColor);
                Rectangle stripRect = rectTab;
                stripRect.X = stripRect.X + stripRect.Width - 2;
                stripRect.Height -= 1;
                stripRect.Width = 2;
                stripRect.Y += 1;
                g.FillRectangle(stripBrush, stripRect);

                if (tabStyle == "Rect") g.DrawRectangle(PenDocumentTabActiveBorder, rectTab);
                else g.DrawPath(PenDocumentTabActiveBorder, path);

                Color sepColor = PluginCore.PluginBase.MainForm.GetThemeColor("VS2005DockPaneStrip.TabSeparatorColor");

                // CHANGED to eliminate line between selected tab and content - NICK
                RectangleF r = path.GetBounds();
                float right = stripColor == Color.Transparent ? r.Right - 1 : r.Right - 3;

                // Choose color
                if (sepColor == Color.Empty)
                {
                    if (PluginCore.PluginBase.Settings.UseSystemColors)
                    {
                        sepColor = SystemColors.ControlLight;
                    }
                    else sepColor = Color.FromArgb(240, 239, 243);
                }
                
                // Draw separator
                using (Pen pen = new Pen(sepColor))
                {
                    if (tabStyle == "Rect") g.DrawLine(pen, rectTab.Left + 2, rectTab.Bottom - 1, right, rectTab.Bottom - 1);
                    else g.DrawLine(pen, r.Left + 2, r.Bottom - 1, right, r.Bottom - 1);
                }

                if (DockPane.IsActiveDocumentPane)
                {
                    TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, BoldFont, rectText, ColorDocumentActiveText, DocumentTextFormat);
                }
                else TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, Font, rectText, ColorDocumentInactiveText, DocumentTextFormat);
            }
            else
            {
                // CHANGE by NICK: emulate VS-style inactive tab gradient
                Brush tabBrush = new LinearGradientBrush(rectTab, SystemColors.ControlLightLight, SystemColors.ControlLight, LinearGradientMode.Vertical);

                // Choose color
                Color color = PluginCore.PluginBase.MainForm.GetThemeColor("VS2005DockPaneStrip.DocInactiveBackColor");
                if (color != Color.Empty)
                {
                    tabBrush = new SolidBrush(color);
                }

                //g.FillPath(BrushDocumentInactiveBackground, path);
                if (tabStyle == "Rect") g.FillRectangle(tabBrush, rectTab);
                else g.FillPath(tabBrush, path);

                // Change by Mika: add color strip to tabs
                SolidBrush stripBrush = new SolidBrush(stripColor);
                Rectangle stripRect = rectTab;
                stripRect.X = stripRect.X + stripRect.Width - 2;
                stripRect.Height -= 2;
                stripRect.Width = 2;
                stripRect.Y += 1;
                g.FillRectangle(stripBrush, stripRect);

                if (tabStyle == "Rect") g.DrawRectangle(PenDocumentTabInactiveBorder, rectTab);
                else g.DrawPath(PenDocumentTabInactiveBorder, path);

                TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, Font, rectText, ColorDocumentInactiveText, DocumentTextFormat);
            }

            if (rectTab.Contains(rectIcon) && DockPane.DockPanel.ShowDocumentIcon)
                g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon);
        }
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:101,代码来源:VS2005DockPaneStrip.cs

示例13: DrawTab_Document

		private void DrawTab_Document(Graphics g, TabVS2005 tab, Rectangle rect)
		{
            if (tab.TabWidth == 0)
                return;

            Rectangle rectIcon = new Rectangle(
                rect.X + DocumentIconGapLeft,
                rect.Y + rect.Height - 1 - DocumentIconGapBottom - DocumentIconHeight + 1,
                DocumentIconWidth, DocumentIconHeight);
            Rectangle rectText = rectIcon;
            if (DockPane.DockPanel.ShowDocumentIcon)
            {
                rectText.X += rectIcon.Width + DocumentIconGapRight;
                rectText.Y = rect.Y;
                rectText.Width = rect.Width - rectIcon.Width - DocumentIconGapLeft -
                    DocumentIconGapRight - DocumentTextGapRight;
                rectText.Height = rect.Height;
            }
            else
            {
                rectText.Width = rect.Width - DocumentIconGapLeft - DocumentTextGapRight;
            }
            Font fnt = TextFont;
            if (DockPane.IsActiveDocumentPane)
                fnt = BoldFont;
            rectText.Y = rect.Y + Convert.ToInt32((rect.Height - fnt.Height) / 2) - 1;
            rectText.Height = fnt.Height + 1;
            Rectangle rectTab = DrawHelper.RtlTransform(this, rect);
            rectText = DrawHelper.RtlTransform(this, rectText);
            rectIcon = DrawHelper.RtlTransform(this, rectIcon);
            GraphicsPath path = GetTabOutline(tab, true, false);
            if (DockPane.ActiveContent == tab.Content)
            {
                g.FillPath(BrushDocumentActiveBackground, path);
                g.DrawPath(PenDocumentTabActiveBorder, path);
                if (DockPane.IsActiveDocumentPane)
                    TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, BoldFont, rectText, ColorDocumentActiveText, DocumentTextFormat);
                else
                    TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, ColorDocumentActiveText, DocumentTextFormat);
            }
            else
            {
                g.FillPath(BrushDocumentInactiveBackground, path);
                g.DrawPath(PenDocumentTabInactiveBorder, path);
                TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, ColorDocumentInactiveText, DocumentTextFormat);
            }

            if (rectTab.Contains(rectIcon) && DockPane.DockPanel.ShowDocumentIcon)
                g.DrawIcon(tab.Content.DockHandler.Icon, rectIcon);
        }
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:50,代码来源:VS2005DockPaneStrip.cs

示例14: DrawTab

		private void DrawTab(Graphics g, TabVS2005 tab)
		{
			Rectangle rectTabOrigin = GetTabRectangle(tab);
			if (rectTabOrigin.IsEmpty)
				return;

			DockState dockState = tab.Content.DockHandler.DockState;
			IDockContent content = tab.Content;

            GraphicsPath path = GetTabOutline(tab, false, true);
            g.FillPath(BrushTabBackground, path);
            g.DrawPath(PenTabBorder, path);

            // Set no rotate for drawing icon and text
			Matrix matrixRotate = g.Transform;
			g.Transform = MatrixIdentity;

			// Draw the icon
			Rectangle rectImage = rectTabOrigin;
			rectImage.X += ImageGapLeft;
			rectImage.Y += ImageGapTop;
			int imageHeight = rectTabOrigin.Height - ImageGapTop - ImageGapBottom;
			int imageWidth = ImageWidth;
			if (imageHeight > ImageHeight)
				imageWidth = ImageWidth * (imageHeight/ImageHeight);
			rectImage.Height = imageHeight;
			rectImage.Width = imageWidth;
			rectImage = GetTransformedRectangle(dockState, rectImage);
			//g.DrawIcon(((Form)content).Icon, RtlTransform(rectImage, dockState));
            if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide)
            {
                // The DockState is DockLeftAutoHide or DockRightAutoHide, so rotate the image 90 degrees to the right. 
                Rectangle rectTransform = RtlTransform(rectImage, dockState);
                Point[] rotationPoints = {  
new Point(rectTransform.X + rectTransform.Width, rectTransform.Y), 
new Point(rectTransform.X + rectTransform.Width, rectTransform.Y + rectTransform.Height),  
new Point(rectTransform.X, rectTransform.Y) };
                using (Icon rotatedIcon = new Icon(((Form)content).Icon, 16, 16))
                {
                    g.DrawImage(rotatedIcon.ToBitmap(), rotationPoints);
                }
            }
            else
            {
                // DockState is DockTopAutoHide or DockBottomAutoHide. 
                g.DrawIcon(((Form)content).Icon, RtlTransform(rectImage, dockState));
            } 

			// Draw the text
			Rectangle rectText = rectTabOrigin;
			rectText.X += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
			rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
			rectText = RtlTransform(GetTransformedRectangle(dockState, rectText), dockState);
			if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide)
				g.DrawString(content.DockHandler.TabText, TextFont, BrushTabText, rectText, StringFormatTabVertical);
			else
				g.DrawString(content.DockHandler.TabText, TextFont, BrushTabText, rectText, StringFormatTabHorizontal);

			// Set rotate back
			g.Transform = matrixRotate;
		}
开发者ID:burstas,项目名称:context-free.version2,代码行数:61,代码来源:VS2005AutoHideStrip.cs

示例15: DrawTab_Document

        private void DrawTab_Document(Graphics g, IDockContent content, Rectangle rect, int index)
        {
            Rectangle rectText = rect;
            //INSTANT C# NOTE: The VB integer division operator \ was replaced 1 time(s) by the regular division operator /
            rectText.X += (int)System.Math.Floor((double)DocumentTextExtraWidth / 2);
            rectText.Width -= DocumentTextExtraWidth;
            rectText.X += _DocumentTabOverlap;

            if (index == 0)
            {
                rect.Width += _DocumentTabOverlap;
            }
            else
            {
                rect.X += _DocumentTabOverlap;
            }

            g.SmoothingMode = SmoothingMode.AntiAlias;
            if (DockPane.ActiveContent == content)
            {

                if (index == 0)
                {
                    if (DockPane.DockPanel.ShowDocumentIcon)
                    {
                        rectText.X += DocumentIconGapLeft;
                        rectText.Width -= DocumentIconGapLeft;
                    }
                }
                else
                {
                    rect.X -= _DocumentTabOverlap;
                    rect.Width += _DocumentTabOverlap;
                    if (DockPane.DockPanel.ShowDocumentIcon)
                    {
                        rectText.X += DocumentIconGapLeft;
                        rectText.Width -= DocumentIconGapLeft;
                    }
                }

                // Draw Tab & Text
                DrawHelper.DrawDocumentTab(g, rect, Color.White, Color.White, Color.FromArgb(127, 157, 185), TabDrawType.Active, true);
                if (DockPane.IsActiveDocumentPane)
                {
                    using (Font boldFont = new Font(this.Font, FontStyle.Bold))
                    {
                        g.DrawString(content.DockHandler.TabText, boldFont, ActiveTextBrush, rectText, DocumentTextStringFormat);
                    }
                }
                else
                {
                    g.DrawString(content.DockHandler.TabText, Font, InactiveTextBrush, rectText, DocumentTextStringFormat);
                }

                // Draw Icon
                if (DockPane.DockPanel.ShowDocumentIcon)
                {
                    Icon icon = content.DockHandler.Icon;
                    Rectangle rectIcon = new Rectangle();
                    if (index == 0)
                    {
                        rectIcon = new Rectangle(rect.X + DocumentIconGapLeft + _DocumentTabOverlap, System.Convert.ToInt32(rectText.Y + (rect.Height - DocumentIconHeight) / 2), DocumentIconWidth, DocumentIconHeight);
                    }
                    else
                    {
                        rectIcon = new Rectangle(rect.X + DocumentIconGapLeft + _DocumentTabOverlap, System.Convert.ToInt32(rectText.Y + (rect.Height - DocumentIconHeight) / 2), DocumentIconWidth, DocumentIconHeight);
                    }
                    g.DrawIcon(content.DockHandler.Icon, rectIcon);
                }
            }
            else
            {
                if (index == 0)
                {
                    DrawHelper.DrawDocumentTab(g, rect, Color.FromArgb(254, 253, 253), Color.FromArgb(241, 239, 226), Color.FromArgb(172, 168, 153), TabDrawType.First, true);
                }
                else
                {
                    DrawHelper.DrawDocumentTab(g, rect, Color.FromArgb(254, 253, 253), Color.FromArgb(241, 239, 226), Color.FromArgb(172, 168, 153), TabDrawType.Inactive, true);
                }
                g.DrawLine(OutlineOuterPen, rect.X, ClientRectangle.Bottom - 1, rect.X + rect.Width, ClientRectangle.Bottom - 1);
                g.DrawString(content.DockHandler.TabText, Font, InactiveTextBrush, rectText, DocumentTextStringFormat);
            }
        }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:84,代码来源:DockPaneStripFromBase.cs


注:本文中的System.Drawing.Graphics.DrawIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。