Example #1
0
        private void DrawBarcode(IGraphicsRenderer g, float width, float height)
        {
            SizeF originalSize = CalcBounds();
            float kx           = width / originalSize.Width;
            float ky           = height / originalSize.Height;

            Draw2DBarcode(g, kx, ky);

            //If swiss qr, draw the swiss cross
            if (text.StartsWith("SPC"))
            {
                float top = showText ? height - 21 : height;
                g.FillRectangle(Brushes.White, width / 2 - width / 100f * 7, top / 2 - top / 100 * 7, width / 100f * 14, top / 100 * 14);
                g.FillRectangle(Brushes.Black, width / 2 - width / 100f * 6, top / 2 - top / 100 * 6, width / 100f * 12, top / 100 * 12);
                g.FillRectangle(Brushes.White, width / 2 - width / 100f * 4, top / 2 - top / 100 * 1.5f, width / 100f * 8, top / 100 * 3);
                g.FillRectangle(Brushes.White, width / 2 - width / 100f * 1.5f, top / 2 - top / 100 * 4, width / 100f * 3, top / 100 * 8);
            }
            // draw the text.
            if (showText)
            {
                string data = StripControlCodes(text);
                // When we print, .Net automatically scales the font. However, we need to handle this process.
                // Downscale the font to the screen resolution, then scale by required value (ky).
                float fontZoom = 18f / (int)g.MeasureString(data, FFont).Height *ky;
                using (Font drawFont = new Font(FFont.Name, FFont.Size * fontZoom, FFont.Style))
                {
                    g.DrawString(data, drawFont, Brushes.Black, new RectangleF(0, height - 18 * ky, width, 18 * ky));
                }
            }
        }
Example #2
0
 public IntroScene(IGraphicsRenderer graphicsRenderer, ITextRenderer textRenderer, IContentProvider contentProvider, GameStateManager gameStateManager, InputManager inputManager)
     : base(graphicsRenderer, textRenderer)
 {
     this.contentProvider  = contentProvider;
     this.gameStateManager = gameStateManager;
     this.inputManager     = inputManager;
 }
Example #3
0
        internal override void Draw2DBarcode(IGraphicsRenderer g, float kx, float ky)
        {
            Brush        light = Brushes.White;
            Brush        dark  = new SolidBrush(Color);
            GraphicsPath path  = new GraphicsPath();

            for (int y = 0; y < matrix.Height; y++)
            {
                for (int x = 0; x < matrix.Width; x++)
                {
                    if (matrix.get_Renamed(x, y) == 0)
                    {
                        g.PathAddRectangle(path, new RectangleF(
                                               x * PixelSize * kx,
                                               y * PixelSize * ky,
                                               PixelSize * kx,
                                               PixelSize * ky
                                               ));
                    }
                }
            }
            if (path.PointCount > 0)
            {
                g.FillPath(dark, path);
                if (text.StartsWith("SPC"))
                {
                    ErrorCorrection = QRCodeErrorCorrection.M;
                }
            }

            dark.Dispose();
            path.Dispose();
        }
Example #4
0
        public override void DrawBarcode(IGraphicsRenderer g, RectangleF displayRect)
        {
            float width  = angle == 90 || angle == 270 ? displayRect.Height : displayRect.Width;
            float height = angle == 90 || angle == 270 ? displayRect.Width : displayRect.Height;
            IGraphicsRendererState state = g.Save();

            try
            {
                // rotate
                g.TranslateTransform(displayRect.Left, displayRect.Top);
                g.RotateTransform(angle);

                switch (angle)
                {
                case 90:
                    g.TranslateTransform(0, -displayRect.Width);
                    break;

                case 180:
                    g.TranslateTransform(-displayRect.Width, -displayRect.Height);
                    break;

                case 270:
                    g.TranslateTransform(-displayRect.Height, 0);
                    break;
                }

                DrawBarcode(g, width, height);
            }
            finally
            {
                g.Restore(state);
            }
        }
Example #5
0
 public void Print(IGraphicsRenderer graphics)
 {
     foreach (Widget widget in widgets)
     {
         widget.Print(graphics);
     }
 }
Example #6
0
        public override void DrawBarcode(IGraphicsRenderer g, RectangleF displayRect)
        {
            base.DrawBarcode(g, displayRect);
            float bearerWidth = WideBarRatio * 2 * zoom;

            using (Pen pen = new Pen(Color, bearerWidth))
            {
                float x0  = displayRect.Left;
                float x01 = displayRect.Left + bearerWidth / 2;
                float y0  = displayRect.Top;
                float y01 = displayRect.Top + bearerWidth / 2;
                float x1  = displayRect.Left + displayRect.Width;
                float x11 = displayRect.Left + displayRect.Width - bearerWidth / 2;
                float y1  = displayRect.Top + barArea.Bottom * zoom;
                float y11 = displayRect.Top + barArea.Bottom * zoom - bearerWidth / 2;

                g.DrawLine(pen, x0, y01 - 0.5F, x1, y01 - 0.5F);
                g.DrawLine(pen, x0, y11, x1, y11);
                if (this.drawVerticalBearerBars)
                {
                    g.DrawLine(pen, x01 - 0.5F, y0, x01 - 0.5F, y1);
                    g.DrawLine(pen, x11, y0, x11, y1);
                }
            }
        }
Example #7
0
        internal override void Draw2DBarcode(IGraphicsRenderer g, float kx, float ky)
        {
            Brush        light = Brushes.White;
            Brush        dark  = new SolidBrush(Color);
            GraphicsPath path  = new GraphicsPath();

            g.FillRectangle(light, 0, 0, matrix.Width * PixelSize * kx, matrix.Height * PixelSize * kx);

            for (int y = 0; y < matrix.Height; y++)
            {
                for (int x = 0; x < matrix.Width; x++)
                {
                    if (matrix.get_Renamed(x, y) == 0)
                    {
                        path.AddRectangle(new RectangleF(
                                              x * PixelSize * kx,
                                              y * PixelSize * ky,
                                              PixelSize * kx,
                                              PixelSize * ky
                                              ));
                    }
                }
            }
            if (path.PointCount > 0)
            {
                g.FillPath(dark, path);
            }
        }
Example #8
0
 public override void Print(IGraphicsRenderer graphics)
 {
     graphics.PrintText(
         string.Format(
             "Ellipse ({0},{1}) diameterH = {2} diameterV = {3} ",
             Location.X,
             Location.Y,
             horizontalDiameter,
             verticalDiameter));
 }
Example #9
0
 public override void Print(IGraphicsRenderer graphics)
 {
     graphics.PrintText(
         string.Format(
             "Rectangle ({0},{1}) width = {2} height = {3} ",
             Location.X,
             Location.Y,
             Width,
             Height));
 }
Example #10
0
 public override void Print(IGraphicsRenderer graphics)
 {
     graphics.PrintText(
         string.Format(
             "TextBlock ({0},{1})  width = {2} height = {3} text=\"{4}\" ",
             Location.X,
             Location.X,
             Width,
             Height,
             text));
 }
Example #11
0
        internal override void DrawText(IGraphicsRenderer g, string barData)
        {
            // parts of pattern: 3 + 16 + 5 + 16 + 3
            float x1 = GetWidth(pattern.Substring(0, 3));
            float x2 = GetWidth(pattern.Substring(0, 3 + 16 + 1));

            DrawString(g, x1, x2, barData.Substring(0, 4));

            x1 = GetWidth(pattern.Substring(0, 3 + 16 + 5 - 1));
            x2 = GetWidth(pattern.Substring(0, 3 + 16 + 5 + 16));
            DrawString(g, x1, x2, barData.Substring(4, 4));
        }
Example #12
0
        internal override void DrawBarcode(IGraphicsRenderer g, RectangleF displayRect)
        {
            float originalWidth = CalcBounds().Width / 1.25f;
            float width         = angle == 90 || angle == 270 ? displayRect.Height : displayRect.Width;
            float height        = angle == 90 || angle == 270 ? displayRect.Width : displayRect.Height;

            zoom           = width / originalWidth;
            barArea.Height = height / zoom;
            if (showText)
            {
                barArea.Height -= 14;
                if (textUp)
                {
                    barArea.Y = 14;
                }
            }
            drawArea.Height = height / zoom;

            IGraphicsRendererState state = g.Save();

            try
            {
                // rotate
                g.TranslateTransform(displayRect.Left, displayRect.Top);
                g.RotateTransform(angle);
                switch (angle)
                {
                case 90:
                    g.TranslateTransform(0, -displayRect.Width);
                    break;

                case 180:
                    g.TranslateTransform(-displayRect.Width, -displayRect.Height);
                    break;

                case 270:
                    g.TranslateTransform(-displayRect.Height, 0);
                    break;
                }

                g.TranslateTransform(barArea.Left * zoom, 0);
                DoLines(pattern, g, zoom);
                if (showText)
                {
                    DrawText(g, text);
                }
            }
            finally
            {
                g.Restore(state);
            }
        }
Example #13
0
        // public RenderTarget RenderTarget { get { return GameWindow.RenderTarget2D; } }

        public GameScene(IGraphicsRenderer graphicsRenderer, ITextRenderer textRenderer, LevelProvider levelProvider,
                         Player player, GameStateManager gameStateManager, World world)
            : base(graphicsRenderer, textRenderer)
        {
            kernel                = NinjectFactory.Kernel;
            this.levelProvider    = levelProvider;
            this.player           = player;
            this.GameStateManager = gameStateManager;
            World = world;
            GameStateManager.StateChanged += GameStateManager_StateChanged;

            Console.WriteLine("GameScene constructed.");
        }
Example #14
0
        internal override void DrawText(IGraphicsRenderer g, string barData)
        {
            DrawString(g, -8, -2, "0", true);

            // parts of pattern: 3 + 24 + 6
            float x1 = GetWidth(pattern.Substring(0, 3));
            float x2 = GetWidth(pattern.Substring(0, 3 + 24));

            DrawString(g, x1, x2, barData.Substring(0, 6));

            x1 = GetWidth(pattern) + 1;
            x2 = x1 + 7;
            DrawString(g, x1, x2, barData.Substring(6, 1), true);
        }
Example #15
0
        internal override void DrawText(IGraphicsRenderer g, string barData)
        {
            DrawString(g, -8, -2, barData.Substring(0, 1));

            // parts of pattern: 3 + 24 + 5 + 24 + 3
            float x1 = GetWidth(pattern.Substring(0, 3));
            float x2 = GetWidth(pattern.Substring(0, 3 + 24 + 1));

            DrawString(g, x1, x2, barData.Substring(1, 6));

            x1 = GetWidth(pattern.Substring(0, 3 + 24 + 5 - 1));
            x2 = GetWidth(pattern.Substring(0, 3 + 24 + 5 + 24));
            DrawString(g, x1, x2, barData.Substring(7, 6));
        }
Example #16
0
        internal override void Draw2DBarcode(IGraphicsRenderer g, float kx, float ky)
        {
            Brush light = Brushes.White;
            Brush dark  = new SolidBrush(Color);

            for (int y = 0; y < matrix.Height; y++)
            {
                for (int x = 0; x < matrix.Width; x++)
                {
                    bool b = matrix.getRow(y, null)[x];

                    Brush brush = b == true ? dark : light;
                    g.FillRectangle(brush, x * PIXEL_SIZE * kx, y * PIXEL_SIZE * ky,
                                    PIXEL_SIZE * kx, PIXEL_SIZE * ky);
                }
            }
        }
Example #17
0
        internal override void DrawText(IGraphicsRenderer g, string barData)
        {
            DrawString(g, -8, -2, barData.Substring(0, 1), true);

            // parts of pattern: 7 + 20 + 5 + 20 + 7
            float x1 = GetWidth(pattern.Substring(0, 7));
            float x2 = GetWidth(pattern.Substring(0, 7 + 20));

            DrawString(g, x1, x2, barData.Substring(1, 5));

            x1 = GetWidth(pattern.Substring(0, 7 + 20 + 5));
            x2 = GetWidth(pattern.Substring(0, 7 + 20 + 5 + 20));
            DrawString(g, x1, x2, barData.Substring(6, 5));

            x1 = GetWidth(pattern) + 1;
            x2 = x1 + 7;
            DrawString(g, x1, x2, barData.Substring(11, 1), true);
        }
Example #18
0
        private void DrawBarcode(IGraphicsRenderer g, float width, float height)
        {
            SizeF originalSize = CalcBounds();
            float kx           = width / originalSize.Width;
            float ky           = height / originalSize.Height;

            Draw2DBarcode(g, kx, ky);

            // draw the text.
            if (showText)
            {
                string data = StripControlCodes(text);
                // When we print, .Net automatically scales the font. However, we need to handle this process.
                // Downscale the font to the screen resolution, then scale by required value (ky).
                float fontZoom = 18f / (int)g.MeasureString(data, FFont).Height *ky;
                using (Font drawFont = new Font(FFont.Name, FFont.Size * fontZoom, FFont.Style))
                {
                    g.DrawString(data, drawFont, Brushes.Black, new RectangleF(0, height - 18 * ky, width, 18 * ky));
                }
            }
        }
Example #19
0
        internal void DrawString(IGraphicsRenderer g, float x1, float x2, string s, bool small)
        {
            if (String.IsNullOrEmpty(s))
            {
                return;
            }

            // when we print, .Net automatically scales the font. However, we need to handle this process.
            // Downscale the font to the screen resolution, then scale by required value (Zoom).
            float fontZoom = 14f / (int)g.MeasureString(s, FFont).Height *zoom;
            Font  font     = small ? FSmallFont : FFont;

            using (Font drawFont = new Font(font.Name, font.Size * fontZoom, font.Style))
            {
                SizeF size = g.MeasureString(s, drawFont);
                size.Width  /= zoom;
                size.Height /= zoom;

                g.DrawString(s, drawFont, new SolidBrush(Color),
                             (x1 + (x2 - x1 - size.Width) / 2) * zoom,
                             (textUp ? 0 : drawArea.Height - size.Height) * zoom);
            }
        }
Example #20
0
 public NativeGraphicsView(IDrawable drawable = null, IGraphicsRenderer renderer = null)
 {
     Drawable        = drawable;
     Renderer        = renderer;
     BackgroundColor = UIColor.White;
 }
Example #21
0
 public abstract void Print(IGraphicsRenderer graphics);
Example #22
0
 internal void DrawString(IGraphicsRenderer g, float x1, float x2, string s)
 {
     DrawString(g, x1, x2, s, false);
 }
Example #23
0
 public NativeGraphicsView(Context context, IDrawable drawable = null, IGraphicsRenderer renderer = null) : base(context)
 {
     Drawable = drawable;
     Renderer = renderer;
 }
Example #24
0
        private void DoLines(string data, IGraphicsRenderer g, float zoom)
        {
            using (Pen pen = new Pen(Color))
            {
                float currentWidth = 0;
                foreach (char c in data)
                {
                    float       width;
                    BarLineType lt;
                    OneBarProps(c, out width, out lt);

                    float heightStart = 0;
                    float heightEnd   = barArea.Height;

                    if (lt == BarLineType.BlackHalf)
                    {
                        heightEnd = barArea.Height * 2 / 5;
                    }
                    else if (lt == BarLineType.BlackLong && showText)
                    {
                        heightEnd += 7;
                    }
                    else if (lt == BarLineType.BlackTracker)
                    {
                        heightStart = barArea.Height * 1 / 3;
                        heightEnd   = barArea.Height * 2 / 3;
                    }
                    else if (lt == BarLineType.BlackAscender)
                    {
                        heightEnd = barArea.Height * 2 / 3;
                    }
                    else if (lt == BarLineType.BlackDescender)
                    {
                        heightStart = barArea.Height * 1 / 3;
                    }

                    width       *= zoom;
                    heightStart *= zoom;
                    heightEnd   *= zoom;
                    pen.Width    = width;

                    if (lt == BarLineType.BlackHalf)
                    {
                        g.DrawLine(pen,
                                   currentWidth + width / 2,
                                   barArea.Bottom * zoom,
                                   currentWidth + width / 2,
                                   barArea.Bottom * zoom - heightEnd);
                    }
                    else if (lt != BarLineType.White)
                    {
                        g.DrawLine(pen,
                                   currentWidth + width / 2,
                                   barArea.Top * zoom + heightStart,
                                   currentWidth + width / 2,
                                   barArea.Top * zoom + heightEnd);
                    }

                    currentWidth += width;
                }
            }
        }
Example #25
0
 public MenuScene(IGraphicsRenderer graphicsRenderer, ITextRenderer textRenderer) : base(graphicsRenderer, textRenderer)
 {
 }
Example #26
0
 public NativeGraphicsView(Context context, IAttributeSet attrs, IDrawable drawable = null, IGraphicsRenderer renderer = null) : base(context, attrs)
 {
     Drawable = drawable;
     Renderer = renderer;
 }
Example #27
0
 internal virtual void DrawText(IGraphicsRenderer g, string data)
 {
     data = StripControlCodes(data);
     DrawString(g, 0, drawArea.Width, data);
 }
Example #28
0
 public WDGraphicsView(IDrawable drawable = null, IGraphicsRenderer renderer = null)
 {
     _graphicsView = new WFGraphicsView(drawable, renderer);
     Child         = _graphicsView;
 }
Example #29
0
 public ActionRenderingExtension()
 {
     _graphicsRenderer = CalendarRenderer.Instance;
 }
Example #30
0
 public NativeGraphicsView(CGRect frame, IDrawable drawable = null, IGraphicsRenderer renderer = null) : base(frame)
 {
     Drawable        = drawable;
     Renderer        = renderer;
     BackgroundColor = UIColor.White;
 }
Example #31
0
 public Scene(IGraphicsRenderer graphicsRenderer, ITextRenderer textRenderer)
 {
     this.GraphicsRenderer = graphicsRenderer;
     this.TextRenderer     = textRenderer;
 }
Example #32
0
 internal virtual void Draw2DBarcode(IGraphicsRenderer g, float kx, float ky)
 {
 }
 public NativeGraphicsView(IDrawable drawable = null, IGraphicsRenderer renderer = null)
 {
     Drawable = drawable;
     Renderer = renderer;
 }
Example #34
0
 public override void Print(IGraphicsRenderer graphics)
 {
     graphics.PrintText(string.Format("Circle ({0},{1}) size={2}", Location.X, Location.Y, diameter));
 }
Example #35
0
 internal override void DrawText(IGraphicsRenderer g, string barData)
 {
     DrawString(g, 0, drawArea.Width, barData);
 }
Example #36
0
 public override void Print(IGraphicsRenderer graphics)
 {
     graphics.PrintText(string.Format("Square ({0},{1}) size={2}", Location.X, Location.Y, width));
 }
Example #37
0
 internal override void DrawText(IGraphicsRenderer g, string data)
 {
     data = StripControlCodes(data);
     DrawString(g, 0, drawArea.Width, data.Insert(1, " ").Insert(4, " ").Insert(10, " ").Insert(16, " "));
 }