using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Tango.BL.Enumerations; using Tango.Emulations.ExternalBridge; using Tango.Integration.ExternalBridge; namespace Tango.MachineStudio.Common.Controls { public enum ExternalBridgeClientType { Usb, Tcp, Wifi, SignalR, Emulator, } /// /// Interaction logic for MachineConnectionIcon.xaml /// public partial class MachineConnectionIcon : UserControl { public MachineTypes MachineType { get { return (MachineTypes)GetValue(MachineTypeProperty); } set { SetValue(MachineTypeProperty, value); } } public static readonly DependencyProperty MachineTypeProperty = DependencyProperty.Register("MachineType", typeof(MachineTypes), typeof(MachineConnectionIcon), new PropertyMetadata(MachineTypes.TS1800)); public IExternalBridgeClient ExternalBridgeClient { get { return (IExternalBridgeClient)GetValue(ExternalBridgeClientProperty); } set { SetValue(ExternalBridgeClientProperty, value); } } public static readonly DependencyProperty ExternalBridgeClientProperty = DependencyProperty.Register("ExternalBridgeClient", typeof(IExternalBridgeClient), typeof(MachineConnectionIcon), new PropertyMetadata((d,e) => (d as MachineConnectionIcon).OnExternalBridgeClientChanged())); public ExternalBridgeClientType ExternalBridgeClientType { get { return (ExternalBridgeClientType)GetValue(ExternalBridgeClientTypeProperty); } set { SetValue(ExternalBridgeClientTypeProperty, value); } } public static readonly DependencyProperty ExternalBridgeClientTypeProperty = DependencyProperty.Register("ExternalBridgeClientType", typeof(ExternalBridgeClientType), typeof(MachineConnectionIcon), new PropertyMetadata(ExternalBridgeClientType.Usb)); private void OnExternalBridgeClientChanged() { if (ExternalBridgeClient != null) { if (ExternalBridgeClient.GetType() == typeof(ExternalBridgeUsbClient)) { ExternalBridgeClientType = ExternalBridgeClientType.Usb; } else if (ExternalBridgeClient.GetType() == typeof(ExternalBridgeTcpFirmwareClient)) { ExternalBridgeClientType = ExternalBridgeClientType.Tcp; MachineType = MachineTypes.Eureka; } else if (ExternalBridgeClient.GetType() == typeof(ExternalBridgeTcpClient)) { ExternalBridgeClientType = ExternalBridgeClientType.Wifi; MachineType = ExternalBridgeClient.MachineType; } else if (ExternalBridgeClient.GetType() == typeof(ExternalBridgeSignalRClient)) { ExternalBridgeClientType = ExternalBridgeClientType.SignalR; MachineType = ExternalBridgeClient.MachineType; } else if (ExternalBridgeClient.GetType() == typeof(EmulatorExternalBridge)) { ExternalBridgeClientType = ExternalBridgeClientType.Emulator; } } } public MachineConnectionIcon() { InitializeComponent(); } } }