我试图检测网络上的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(); }
}
}
最佳答案
我非常怀疑3D打印机会出现在Windows控制面板的“打印机”部分中,因此会被视为打印机。我认为“ 3D打印机”这个名称可能令人困惑,从Windows的正常角度来看,它并不是真正的“打印机”。
大多数打印机只知道行/列(大大简化了事情),因此制造商可以使用通用打印机驱动程序作为基础。 3D打印机的功能更加先进/专业,我猜您将需要一个SDK,该SDK将输出3D打印机可以理解的指令。
您可能可以从打印机制造商那里获取SDK。
关于c# - Visual Studio无法检测到网络上的3d打印机,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16017069/