3

我试图在网络上检测我的 3d 打印机,但由于某种原因,它只返回 2d 打印机,这有点奇怪,因为 3d 打印机连接在网络上,并且可以从本机软件检测到。关于如何显示所有网络打印机的任何想法?

using System;
using System.Printing;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace PrintQueuesExample
{
  public partial class Window1 : Window
  {
    PrintQueueCollection _Printers;

    public Window1()
    {
      _Printers = new PrintServer().GetPrintQueues(new[] { 
        EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections});

      foreach (var queue in _Printers)
      {
        Console.WriteLine(queue.Name);
        var capabilities = queue.GetPrintCapabilities();
        foreach (var size in capabilities.PageMediaSizeCapability)
        { Console.WriteLine(size.ToString()); }
        Console.WriteLine();
      }

      InitializeComponent();
    }

    public PrintQueueCollection Printers
    { get { return _Printers; } }

    private void PrintTestPageClick(object sender, RoutedEventArgs e)
    {
      var queue = _PrinterList.SelectedItem as PrintQueue;
      if (queue == null)
      {
        MessageBox.Show("Please select a printer.");
        return;
      }

      var size = _SizeList.SelectedItem as PageMediaSize;
      if (size == null)
      {
        MessageBox.Show("Please select a page size.");
        return;
      }

      queue.UserPrintTicket.PageMediaSize = size;
      queue.UserPrintTicket.PageOrientation = _PortraitRadio.IsChecked == true ? 
        PageOrientation.Portrait : PageOrientation.Landscape;

      var canvas = (Canvas)Resources["MyPrintingExample"];
      canvas.Measure(new Size(size.Width.Value, size.Height.Value));
      canvas.Arrange(new Rect(0, 0, canvas.DesiredSize.Width, 
          canvas.DesiredSize.Height));

      var writer = PrintQueue.CreateXpsDocumentWriter(queue);
      writer.Write(canvas);
    }

  }

  public class PrintQueueToPageSizesConverter : IValueConverter
  {
    public object Convert(object value, Type targetType,
      object parameter, System.Globalization.CultureInfo culture)
    {
      return value == null ? null :
        ((PrintQueue)value).GetPrintCapabilities().PageMediaSizeCapability;
    }

    public object ConvertBack(object value, Type targetType, 
      object parameter, System.Globalization.CultureInfo culture)
    { throw new NotImplementedException(); }
  }
}
4

1 回答 1

1

我非常怀疑 3D 打印机会出现在Windows 控制面板的打印机部分,因此会被视为打印机。我认为“3D 打印机”这个名称可能令人困惑,它并不是 Windows 所看到的正常意义上的“打印机”。

大多数打印机只知道行/列(大大简化了事情),因此制造商可以使用通用打印机驱动程序作为基础。3D 打印机更先进/更专业,我猜您将需要一个 SDK 来输出 3D 打印机可以理解的指令。

您可能可以从打印机制造商处获得 SDK。

于 2013-04-15T14:15:56.803 回答