コード例 #1
0
 public void Restore([NotNull] GDIGraphics graphics)
 {
     Debug.Assert(graphics != null, "graphics != null");
     graphics._resourceManager = ResourceManager;
     graphics.FillStyle        = FillStyle;
     graphics.SetLineStyle(LineStyle);
     graphics.Transform = Transform;
 }
コード例 #2
0
 public State([NotNull] GDIGraphics graphics)
 {
     Debug.Assert(graphics != null, "graphics != null");
     Debug.Assert(graphics._lineStyle != null, "_style != null");
     FillStyle       = graphics.FillStyle;
     LineStyle       = graphics._lineStyle;
     ResourceManager = graphics._resourceManager;
     Transform       = graphics.Transform;
 }
コード例 #3
0
        /// <summary>
        ///     Raises the <see cref="E:System.Drawing.Printing.PrintDocument.PrintPage" /> event. It is called before a page
        ///     prints.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Drawing.Printing.PrintPageEventArgs" /> that contains the event data. </param>
        protected override void OnPrintPage(PrintPageEventArgs e)
        {
            base.OnPrintPage(e);

            if (_resourceManager == null) return;

            e.Graphics.SetClip(e.MarginBounds);

            using (GDIGraphics graphics = new GDIGraphics(
                e.Graphics,
                _resourceManager,
                SolidColourStyle.White,
                _lineStyle))
            {
                Matrix3x2 transform, inverseTransform;
                _getTranform(
                    e.MarginBounds.ToRectangle(),
                    out transform,
                    out inverseTransform);

                graphics.Transform = transform;

                Vector2 tl = new Vector2(e.MarginBounds.Left, e.MarginBounds.Top);
                Vector2 br = new Vector2(e.MarginBounds.Right, e.MarginBounds.Bottom);

                tl = Vector2.Transform(tl, inverseTransform);
                br = Vector2.Transform(br, inverseTransform);

                Rectangle bounds = Rectangle.ContainingPoints(tl, br);

                switch (PrintMode)
                {
                    case TilingPrintMode.TilingFull:
                        if (Tiling == null) throw new InvalidOperationException("The Tiling is not set");

                        Tiling.DrawTiling(GetTiles(bounds), graphics, Tiling.StyleManager.LineStyle);
                        break;
                    case TilingPrintMode.TilingLines:
                        if (Tiling == null) throw new InvalidOperationException("The Tiling is not set");

                        Tiling.DrawTiling(GetTiles(bounds), graphics, _lineStyle, SolidColourStyle.White);
                        break;
                    case TilingPrintMode.SingleTileFull:
                        if (Tile == null) throw new InvalidOperationException("The Tile is not set");

                        DrawTile(graphics, Tiling?.StyleManager.LineStyle ?? _lineStyle);
                        break;
                    case TilingPrintMode.SingleTileLines:
                        if (Tile == null) throw new InvalidOperationException("The Tile is not set");

                        DrawTile(graphics, _lineStyle, SolidColourStyle.White);
                        break;
                    default:
                        Debug.Fail($"Unexpected print mode {PrintMode}");
                        throw new NotSupportedException();
                }
            }
        }
コード例 #4
0
        /// <summary>
        ///     Raises the <see cref="E:System.Drawing.Printing.PrintDocument.PrintPage" /> event. It is called before a page
        ///     prints.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Drawing.Printing.PrintPageEventArgs" /> that contains the event data. </param>
        protected override void OnPrintPage(PrintPageEventArgs e)
        {
            base.OnPrintPage(e);

            if (_resourceManager == null)
            {
                return;
            }

            e.Graphics.SetClip(e.MarginBounds);

            using (GDIGraphics graphics = new GDIGraphics(
                       e.Graphics,
                       _resourceManager,
                       SolidColourStyle.White,
                       _lineStyle))
            {
                Matrix3x2 transform, inverseTransform;
                _getTranform(
                    e.MarginBounds.ToRectangle(),
                    out transform,
                    out inverseTransform);

                graphics.Transform = transform;

                Vector2 tl = new Vector2(e.MarginBounds.Left, e.MarginBounds.Top);
                Vector2 br = new Vector2(e.MarginBounds.Right, e.MarginBounds.Bottom);

                tl = Vector2.Transform(tl, inverseTransform);
                br = Vector2.Transform(br, inverseTransform);

                Rectangle bounds = Rectangle.ContainingPoints(tl, br);

                switch (PrintMode)
                {
                case TilingPrintMode.TilingFull:
                    if (Tiling == null)
                    {
                        throw new InvalidOperationException("The Tiling is not set");
                    }

                    Tiling.DrawTiling(GetTiles(bounds), graphics, Tiling.StyleManager.LineStyle);
                    break;

                case TilingPrintMode.TilingLines:
                    if (Tiling == null)
                    {
                        throw new InvalidOperationException("The Tiling is not set");
                    }

                    Tiling.DrawTiling(GetTiles(bounds), graphics, _lineStyle, SolidColourStyle.White);
                    break;

                case TilingPrintMode.SingleTileFull:
                    if (Tile == null)
                    {
                        throw new InvalidOperationException("The Tile is not set");
                    }

                    DrawTile(graphics, Tiling?.StyleManager.LineStyle ?? _lineStyle);
                    break;

                case TilingPrintMode.SingleTileLines:
                    if (Tile == null)
                    {
                        throw new InvalidOperationException("The Tile is not set");
                    }

                    DrawTile(graphics, _lineStyle, SolidColourStyle.White);
                    break;

                default:
                    Debug.Fail($"Unexpected print mode {PrintMode}");
                    throw new NotSupportedException();
                }
            }
        }