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


C# Graphics.DrawIcon方法代码示例

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


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

示例1: DrawTabStrip_ToolWindow

                private void DrawTabStrip_ToolWindow(Graphics g)
                {
                    // TODO: Clean up and add properties for colors
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                    for (int i = 0; i <= Tabs.Count - 1; i++)
                    {
                        Rectangle tabrect = GetTabRectangle(i);
                        Rectangle rectIcon = new Rectangle(tabrect.X + ToolWindowImageGapLeft, tabrect.Y + tabrect.Height - 1 - ToolWindowImageGapBottom - ToolWindowImageHeight, ToolWindowImageWidth, ToolWindowImageHeight);
                        Rectangle rectText = rectIcon;

                        rectText.X += rectIcon.Width + ToolWindowImageGapRight;
                        rectText.Width = tabrect.Width - rectIcon.Width - ToolWindowImageGapLeft - ToolWindowImageGapRight - ToolWindowTextGapRight;

                        if (DockPane.ActiveContent == Tabs[i].Content)
                        {

                            // color area as the tab
                            g.FillRectangle(new SolidBrush(Color.FromArgb(252, 252, 254)), ClientRectangle.X, ClientRectangle.Y - 1, ClientRectangle.Width - 1, tabrect.Y + 2);

                            DrawHelper.DrawTab(g, tabrect, Corners.Bottom, GradientType.Flat, Color.FromArgb(252, 252, 254), Color.FromArgb(252, 252, 254), Color.FromArgb(172, 168, 153), false);

                            // line to the left
                            g.DrawLine(TabSeperatorPen, tabrect.X, tabrect.Y + 1, ClientRectangle.X, tabrect.Y + 1);

                            // line to the right
                            g.DrawLine(TabSeperatorPen, tabrect.X + tabrect.Width, tabrect.Y + 1, ClientRectangle.Width, tabrect.Y + 1);

                            // text
                            g.DrawString(Tabs[i].Content.DockHandler.TabText, Font, new SolidBrush(Color.Black), rectText, ToolWindowTextStringFormat);

                        }
                        else
                        {
                            if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(Tabs[i].Content) + 1 && Tabs.IndexOf(Tabs[i].Content) != Tabs.Count - 1)
                            {
                                g.DrawLine(TabSeperatorPen, tabrect.X + tabrect.Width - 1, tabrect.Y + ToolWindowTabSeperatorGapTop, tabrect.X + tabrect.Width - 1, tabrect.Y + tabrect.Height - 1 - ToolWindowTabSeperatorGapBottom);
                            }
                            g.DrawString(Tabs[i].Content.DockHandler.TabText, Font, InactiveTextBrush, rectText, ToolWindowTextStringFormat);
                        }

                        if (tabrect.Contains(rectIcon))
                        {
                            g.DrawIcon(Tabs[i].Content.DockHandler.Icon, rectIcon);
                        }
                    }
                }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:46,代码来源:DockPaneStripFromBase.cs

示例2: DrawTab_Document

                private void DrawTab_Document(Graphics g, IDockContent content, Rectangle rect, int index)
                {
                    Rectangle rectText = rect;
                    rectText.X += 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;
                            if (index == 0)
                            {
                                rectIcon = new Rectangle(rect.X + DocumentIconGapLeft + _DocumentTabOverlap, rectText.Y + (rect.Height - DocumentIconHeight) / 2, DocumentIconWidth, DocumentIconHeight);
                            }
                            else
                            {
                                rectIcon = new Rectangle(rect.X + DocumentIconGapLeft + _DocumentTabOverlap, 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

示例3: DrawApplicationImageAndCaption

            private void DrawApplicationImageAndCaption(Graphics graphics, string text, Icon icon)
            {
                using (SolidBrush ForecolorBrush = new SolidBrush(this.ForeColor))
                {
                    RectangleF TextRectangle = new RectangleF();

                    if (icon == null)
                    {
                        TextRectangle.Location = new PointF(6, 2);
                        TextRectangle.Size = new SizeF(SystemButtonMinimize.Left - 8, SystemButtonMinimize.Height);
                    }
                    else
                    {
                        TextRectangle.Location = new PointF(26, 2);
                        TextRectangle.Size = new SizeF(SystemButtonMinimize.Left - 30, SystemButtonMinimize.Height);

                        int OffsetY = (int)((TextRectangle.Height - 16) / 2);

                        graphics.DrawIcon(icon, new Rectangle(8, 2 + OffsetY, 16, 16));
                    }

                    SizeF TextSize = graphics.MeasureString(text, SystemFonts.CaptionFont, TextRectangle.Size);

                    TextRectangle.Y += ((TextRectangle.Height - TextSize.Height) / 2);
                    TextRectangle.Size = TextSize;

                    graphics.DrawString(text, SystemFonts.CaptionFont, ForecolorBrush, TextRectangle);
                }
            }
开发者ID:ArchangelNexus,项目名称:Abstract-Design-Utility,代码行数:29,代码来源:BorderlessWindow.cs

示例4: 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

示例5: 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();
                    Brush brushTabBackGround = this.BrushTabBackGround;
                    Pen penTabBorder = this.PenTabBorder;
                    Brush brushTabText = this.BrushTabText;

                    g.SmoothingMode = SmoothingMode.AntiAlias;
                    if (dockState == dockState.DockTopAutoHide || dockState == dockState.DockRightAutoHide)
                    {
                        DrawHelper.DrawTab(g, rectTab, Corners.Bottom, GradientType.Flat, Color.FromArgb(244, 242, 232), Color.FromArgb(244, 242, 232), Color.FromArgb(172, 168, 153), true);
                    }
                    else
                    {
                        DrawHelper.DrawTab(g, rectTab, Corners.Top, GradientType.Flat, Color.FromArgb(244, 242, 232), Color.FromArgb(244, 242, 232), Color.FromArgb(172, 168, 153), true);
                    }

                    // 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 = this.ImageWidth;
                    if (imageHeight > this.ImageHeight)
                    {
                        imageWidth = this.ImageWidth * (imageHeight / this.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:okyereadugyamfi,项目名称:softlogik,代码行数:63,代码来源:AutoHideStripFromBase.cs


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