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


C# Graphics.DrawShadow方法代码示例

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


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

示例1: OnDraw

        // Protected methods.
        /// <summary>
        /// An event handler called when drawing the annotation on the specified graphics object.
        /// </summary>
        /// <param name="graphics">The graphics object.</param>
        protected override void OnDraw(Graphics graphics)
        {
            // If the message is not visible, do nothing.
            if (!this.Visible) return;

            // Use a normal smoothing mode.
            graphics.SmoothingMode = SmoothingMode.HighQuality;

            // Create the pen.
            using (Pen pen = new Pen(this.BorderColor))
            {
                // Create the brush.
                using (SolidBrush brush = new SolidBrush(this.BackgroundColor))
                {
                    // Draw the shadow.
                    graphics.DrawShadow(this.Shadow, this.textRectangle);
                    // Draw the polygon.
                    graphics.FillPolygon(brush, this.polygon);
                    // Draw the border.
                    graphics.DrawPolygon(pen, this.polygon);
                }
            }

            // Display a message.
            TextRenderer.DrawText(graphics, this.Text, this.Font, this.textRectangle, this.TextColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
        }
开发者ID:alexbikfalvi,项目名称:DotNetApi,代码行数:31,代码来源:MapInfoAnnotation.cs

示例2: OnDraw

        /// <summary>
        /// An event handler called when drawing the annotation on the specified graphics object.
        /// </summary>
        /// <param name="graphics">The graphics object.</param>
        protected override void OnDraw(Graphics graphics)
        {
            // Call the base class method.
            base.OnDraw(graphics);

            // If the message is not visible, do nothing.
            if (!this.Visible) return;

            // Use a normal smoothing mode.
            graphics.SmoothingMode = SmoothingMode.Default;

            // Create the pen.
            using (Pen pen = new Pen(this.borderColor))
            {
                // Create the brush.
                using (SolidBrush brush = new SolidBrush(this.backgroundColor))
                {
                    // Draw the shadow.
                    graphics.DrawShadow(this.shadow, this.BorderRectangle);
                    // Draw the rectangle.
                    graphics.FillRectangle(brush, this.BorderRectangle);
                    // Draw the border.
                    graphics.DrawRectangle(pen, this.BorderRectangle);
                }
            }

            // Display a message.
            TextRenderer.DrawText(graphics, this.text, this.font, this.BorderRectangle, this.textColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
        }
开发者ID:alexbikfalvi,项目名称:DotNetApi,代码行数:33,代码来源:MapTextAnnotation.cs

示例3: DrawText

        protected static void DrawText(Graphics g, Rectangle rect, string text, ContentAlignmentEx alignment, bool multiline, Font font, Color color, Color shadow, ShadowMask mask)
        {
            if (multiline == false)
            {
                var rc = alignment.CalcTextRect(g.MeasureString(text, font), rect);

                if (mask != ShadowMask.None)
                {
                    g.DrawShadow(text, font, shadow, rc.X, rc.Y, mask);
                }

                using (var brush = new SolidBrush(color))
                {
                    g.DrawString(text, font, brush, rc.X, rc.Y);
                }
            }
            else
            {
                var texts = g.GetMultilineText(text, font, rect.Width);
                var textSize = g.CalcMultilineTextSize(texts, font);

                var rc = alignment.CalcTextRect(textSize, rect);
                using (var brush = new SolidBrush(color))
                {
                    var top = rc.Top;
                    foreach (var line in texts)
                    {
                        var size = g.MeasureString(String.IsNullOrEmpty(line) ? " " : line, font);
                        var rcLine = alignment.CalcTextRect(size, rc.Left, top, rc.Width, size.Height);

                        if (mask != ShadowMask.None)
                        {
                            g.DrawShadow(text, font, shadow, rcLine.X, rcLine.Y, mask);
                        }

                        g.DrawString(line, font, brush, rcLine.X, rcLine.Y);

                        top += rcLine.Height;
                    }
                }
            }
        }
开发者ID:usausa,项目名称:Smart-Net-CE,代码行数:42,代码来源:GraphicalControl.cs


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