Ejemplo n.º 1
0
 public async Task PrintSelectedPokemon()
 {
     if (PokemonIsValid)
     {
         _printingService.Print(await _pokeService.GetPokemonInfoAsync(PokemonName));
     }
     else
     {
     }
 }
Ejemplo n.º 2
0
        private void PrintButton_Click(object sender, EventArgs e)
        {
            var result = SaveFileDialog.ShowDialog(this);

            if (result == DialogResult.OK || result == DialogResult.Yes)
            {
                var service  = new PrintingService();
                var fileName = SaveFileDialog.FileName;
                service.Print(fileName, programData);
                MessageBox.Show($"{fileName} has been created.");
            }
        }
Ejemplo n.º 3
0
        public void TestPrint()
        {
            Mock <IPrinter> mockPrinter = new Mock <IPrinter>();

            mockPrinter.Setup(x => x.Print(It.IsAny <IEnumerable <Label> >()));

            Label testLabel = new Label(99, new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }, 99, DateTime.Now, 99, 99, 99, new Product(), 99, 99);

            printingService.AddLabel(testLabel.SerialNumber, testLabel.EUI, testLabel.Tester, testLabel.Date, testLabel.Station, testLabel.Site, testLabel.FirmwareVersion, testLabel.Product, testLabel.HardwareVersion, testLabel.BomRevision);

            var printer = printingService.GetType().GetField("printer", BindingFlags.NonPublic | BindingFlags.Instance);

            printer.SetValue(printingService, mockPrinter.Object);

            var labels = (List <Label>) typeof(PrintingService).GetField("Labels", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(printingService);

            printingService.Print();

            mockPrinter.Verify(x => x.Print(It.IsAny <IEnumerable <Label> >()), Times.AtLeastOnce);
            Assert.AreEqual(labels.Count(), 0);
        }
Ejemplo n.º 4
0
 //Method to execute Print action
 private void OnPrintCommand(object obj)
 {
     PrintingService.ShowDialog = true;
     PrintingService.Print();
 }
Ejemplo n.º 5
0
 //Method to execute Print action
 private void OnPrintCommand(object obj)
 {
     PrintingService.Print();
 }
Ejemplo n.º 6
0
        public void OnItemClicked(object sender, MenuItemEventArgs e)
        {
            _layoutControl.PanMode = false;

            switch (e.ItemKey)
            {
            case LayoutMenuKeys.RestoreToolbars:
                _view.RestoreToolbars();
                break;

            case LayoutMenuKeys.RestorePanels:
                _view.RestorePanels();
                break;

            case LayoutMenuKeys.ShowRulers:
                _layoutControl.ShowRulers = !_layoutControl.ShowRulers;
                break;

            case LayoutMenuKeys.AdjustPages:
                _layoutControl.UpdateLayout();
                break;

            case LayoutMenuKeys.SelectAll:
                _layoutControl.SelectAll();
                break;

            case LayoutMenuKeys.SelectNone:
                _layoutControl.ClearSelection();
                break;

            case LayoutMenuKeys.InvertSelection:
                _layoutControl.InvertSelection();
                break;

            case LayoutMenuKeys.ConvertToBitmap:
                ConvertElementToBitmap();
                break;

            case LayoutMenuKeys.MoveUp:
                _layoutControl.MoveSelectionUp();
                break;

            case LayoutMenuKeys.MoveDown:
                _layoutControl.MoveSelectionDown();
                break;

            case LayoutMenuKeys.DeleteElement:
                _layoutControl.DeleteSelected();
                break;

            case LayoutMenuKeys.ShowMargins:
                _layoutControl.ShowMargins = !_layoutControl.ShowMargins;
                break;

            case LayoutMenuKeys.ShowPageNumbers:
                _layoutControl.ShowPageNumbers = !_layoutControl.ShowPageNumbers;
                break;

            case LayoutMenuKeys.NewLayout:
                if (PromptSaveExistingLayout())
                {
                    _layoutControl.Filename = string.Empty;
                    _layoutControl.ClearLayout();
                }
                break;

            case LayoutMenuKeys.SaveLayout:
                SaveLayout(false);
                break;

            case LayoutMenuKeys.SaveLayoutAs:
                SaveLayout(true);
                break;

            case LayoutMenuKeys.LoadLayout:
                var ls = new LayoutSerializer();
                ls.LoadNewLayout(_layoutControl, _context, _view.Model.Extents, _view as IWin32Window);
                break;

            case LayoutMenuKeys.Print:
            {
                var service = new PrintingService();
                service.Print(_layoutControl.Pages, _layoutControl.PrinterSettings,
                              _layoutControl.LayoutElements);
            }
            break;

            case LayoutMenuKeys.PrinterSetup:
                RunPrinterSetup();
                break;

            case LayoutMenuKeys.PageSetup:
                RunPageSetup();
                break;

            case LayoutMenuKeys.ExportToPdf:
                _pdfService.ExportToPdf(_layoutControl, ParentView);
                break;

            case LayoutMenuKeys.ExportToBitmap:
                ExportToBitmap();
                break;

            case LayoutMenuKeys.ZoomIn:
                _layoutControl.ZoomIn();
                break;

            case LayoutMenuKeys.ZoomOut:
                _layoutControl.ZoomOut();
                break;

            case LayoutMenuKeys.ZoomFitScreen:
                _layoutControl.ZoomFitToScreen();
                break;

            case LayoutMenuKeys.ZoomOriginal:
                _layoutControl.Zoom = 1;
                break;

            case LayoutMenuKeys.AddMap:
                AddMap();
                break;

            case LayoutMenuKeys.AddLegend:
                AddLegend();
                break;

            case LayoutMenuKeys.AddScaleBar:
                AddScaleBar();
                break;

            case LayoutMenuKeys.AddNorthArrow:
                _layoutControl.AddElementWithMouse(new LayoutNorthArrow());
                break;

            case LayoutMenuKeys.AddTable:
                AddTable();
                break;

            case LayoutMenuKeys.AddLabel:
                _layoutControl.AddElementWithMouse(new LayoutText());
                break;

            case LayoutMenuKeys.AddRectangle:
                _layoutControl.AddElementWithMouse(new LayoutRectangle());
                break;

            case LayoutMenuKeys.AddBitmap:
                AddBitmap();
                break;

            case LayoutMenuKeys.ZoomToMaximum:
            {
                var map = SelectedMapElement;
                if (map != null)
                {
                    map.ZoomToMaxExtents();
                }
            }
            break;

            case LayoutMenuKeys.ZoomToOriginalExtents:
            {
                var map = SelectedMapElement;
                if (map != null)
                {
                    map.ZooomToOriginalExtents();
                }
            }
            break;

            case LayoutMenuKeys.MapZoomIn:
            {
                var map = SelectedMapElement;
                if (map != null)
                {
                    _layoutControl.ZoomInMap(map);
                }
            }
            break;

            case LayoutMenuKeys.MapZoomOut:
            {
                var map = SelectedMapElement;
                if (map != null)
                {
                    _layoutControl.ZoomOutMap(map);
                }
            }
            break;

            case LayoutMenuKeys.MapPan:
            {
                _layoutControl.PanMode = true;
            }
            break;
            }

            _view.UpdateView();
        }