private void Print(LocalPrintServer localPrinter, PrintQueue pq) { if (printDlg == null) { printDlg = new PrintDialog(); if (printDlg.ShowDialog() != true) { return; } } BarcodeText.Text = $"Lot: {Barcode.LotNumber} | Exp: {Barcode.ExpirationDate} | {Barcode.AntigenName}"; // SET BARCODE GENERATOR FOR EACH BARCODE AND ASSING BarcodeImage SOURCE. CODE BELOW IS FOR TechnoRiver // (CHANGE THIS IF OTHER BARCODE GENERATOR USED) // ******************************* barcodeGenerator.BarcodeData = Barcode.LotNumber; var barcodeImg = barcodeGenerator.GetBitMap(); var ScreenCapture = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( barcodeImg.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(600, 150)); BarcodeImage.Source = ScreenCapture; // ******************************* //get selected printer capabilities var capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket); //get the size of the printer page Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight); //update the layout of the visual to the printer page size. PrintGrid.Measure(sz); PrintGrid.Arrange(new Rect(new Point(3, -5), sz)); //now print the visual to printer to fit on the one page. for (int i = 0; i < NumberOfLabels; i++) { printDlg.PrintVisual(PrintGrid, null); } }
public void Should_Test_GridPrintEvent() { // arrange var output = new StubOutput(); var fileInput = new FileReader(); var grid = new Universe(fileInput); var gridLength = 3; var gridWidth = 3; grid.SetUpGrid(gridLength, gridWidth); grid.Initialise(); var expected = "|"; PrintGrid += GridPrintEvent.HandlePrintGrid; // act grid.SetUpGrid(Constants.GridLength, Constants.GridWidth); grid.Initialise(); PrintGrid?.Invoke(this, new GridPrintEventArgs(output, grid.Grid)); // assert Assert.Equal(expected, output.GetWriteLine()); }
public void RunGame() { _grid.SetUpGrid(Constants.GridLength, Constants.GridWidth); _grid.Initialise(); var grid = _grid; //_universeGeneratorLogger.LogInformation("New universe grid created", grid); do { while (!_input.ConsoleKeyAvailable()) { _output.Clear(); _output.WriteLine("Welcome to Game of Life"); _output.WriteLine($"Press 'Q' to stop {System.Environment.NewLine}"); PrintGrid?.Invoke(this, new GridPrintEventArgs(_output, grid.Grid)); grid = _game.LoopThroughEachCell(); Thread.Sleep(400); var hashCode = grid.GetHashCode(); //_universeGeneratorLogger.LogInformation($"This is the Grid's hashcode: {hashCode}"); } }while (_input.ReadKey(true).Key != ConsoleKey.Q); }