/* ListDevices.cs
*
* This example prints all the available devices to the screen.
*
* Find more information on http://www.tiepie.com/LibTiePie .
*/
using System;
using TiePie.LibTiePie;
class ListDevicesExample
{
public static void Main()
{
// Print library information:
PrintInfo.PrintLibraryInfo();
// Enable network search:
Network.AutoDetectEnabled = true;
// Update device list:
DeviceList.Update();
// Get the number of connected devices:
UInt32 connectedDevices = DeviceList.Count;
if (connectedDevices != 0)
{
Console.WriteLine();
Console.WriteLine("Available devices:");
for (UInt32 i = 0; i < connectedDevices; i++)
{
try
{
DeviceListItem item = DeviceList.GetItemByIndex(i);
Console.WriteLine(" Name: " + item.Name);
Console.WriteLine(" Serial number : " + item.SerialNumber.ToString());
Console.WriteLine(" Available types: " + PrintInfo.DeviceTypeToStr(item.Types));
if (item.HasServer)
{
Server server = item.Server;
Console.WriteLine(" Server : " + server.URL + " (" + server.Name + ")");
}
}
catch (System.Exception e)
{
Console.WriteLine("Exception: " + e.Message);
Environment.Exit(1);
}
}
}
else
{
Console.WriteLine("No devices found!");
Environment.Exit(1);
}
Environment.Exit(0);
}
}