當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。