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)); } } }
public IntroScene(IGraphicsRenderer graphicsRenderer, ITextRenderer textRenderer, IContentProvider contentProvider, GameStateManager gameStateManager, InputManager inputManager) : base(graphicsRenderer, textRenderer) { this.contentProvider = contentProvider; this.gameStateManager = gameStateManager; this.inputManager = inputManager; }
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(); }
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); } }
public void Print(IGraphicsRenderer graphics) { foreach (Widget widget in widgets) { widget.Print(graphics); } }
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); } } }
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); } }
public override void Print(IGraphicsRenderer graphics) { graphics.PrintText( string.Format( "Ellipse ({0},{1}) diameterH = {2} diameterV = {3} ", Location.X, Location.Y, horizontalDiameter, verticalDiameter)); }
public override void Print(IGraphicsRenderer graphics) { graphics.PrintText( string.Format( "Rectangle ({0},{1}) width = {2} height = {3} ", Location.X, Location.Y, Width, Height)); }
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)); }
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)); }
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); } }
// 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."); }
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); }
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)); }
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); } } }
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); }
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)); } } }
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); } }
public NativeGraphicsView(IDrawable drawable = null, IGraphicsRenderer renderer = null) { Drawable = drawable; Renderer = renderer; BackgroundColor = UIColor.White; }
public abstract void Print(IGraphicsRenderer graphics);
internal void DrawString(IGraphicsRenderer g, float x1, float x2, string s) { DrawString(g, x1, x2, s, false); }
public NativeGraphicsView(Context context, IDrawable drawable = null, IGraphicsRenderer renderer = null) : base(context) { Drawable = drawable; Renderer = renderer; }
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; } } }
public MenuScene(IGraphicsRenderer graphicsRenderer, ITextRenderer textRenderer) : base(graphicsRenderer, textRenderer) { }
public NativeGraphicsView(Context context, IAttributeSet attrs, IDrawable drawable = null, IGraphicsRenderer renderer = null) : base(context, attrs) { Drawable = drawable; Renderer = renderer; }
internal virtual void DrawText(IGraphicsRenderer g, string data) { data = StripControlCodes(data); DrawString(g, 0, drawArea.Width, data); }
public WDGraphicsView(IDrawable drawable = null, IGraphicsRenderer renderer = null) { _graphicsView = new WFGraphicsView(drawable, renderer); Child = _graphicsView; }
public ActionRenderingExtension() { _graphicsRenderer = CalendarRenderer.Instance; }
public NativeGraphicsView(CGRect frame, IDrawable drawable = null, IGraphicsRenderer renderer = null) : base(frame) { Drawable = drawable; Renderer = renderer; BackgroundColor = UIColor.White; }
public Scene(IGraphicsRenderer graphicsRenderer, ITextRenderer textRenderer) { this.GraphicsRenderer = graphicsRenderer; this.TextRenderer = textRenderer; }
internal virtual void Draw2DBarcode(IGraphicsRenderer g, float kx, float ky) { }
public NativeGraphicsView(IDrawable drawable = null, IGraphicsRenderer renderer = null) { Drawable = drawable; Renderer = renderer; }
public override void Print(IGraphicsRenderer graphics) { graphics.PrintText(string.Format("Circle ({0},{1}) size={2}", Location.X, Location.Y, diameter)); }
internal override void DrawText(IGraphicsRenderer g, string barData) { DrawString(g, 0, drawArea.Width, barData); }
public override void Print(IGraphicsRenderer graphics) { graphics.PrintText(string.Format("Square ({0},{1}) size={2}", Location.X, Location.Y, width)); }
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, " ")); }