diff options
Diffstat (limited to 'Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineConnectionIcon.cs')
| -rw-r--r-- | Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineConnectionIcon.cs | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineConnectionIcon.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineConnectionIcon.cs new file mode 100644 index 000000000..d739ac6e5 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/MachineConnectionIcon.cs @@ -0,0 +1,83 @@ +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.FSE.Common.Connection; +using Tango.Integration.ExternalBridge; + +namespace Tango.FSE.Common.Controls +{ + public class MachineConnectionIcon : Control + { + 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 MachineConnectionTypes ExternalBridgeClientType + { + get { return (MachineConnectionTypes)GetValue(ExternalBridgeClientTypeProperty); } + set { SetValue(ExternalBridgeClientTypeProperty, value); } + } + public static readonly DependencyProperty ExternalBridgeClientTypeProperty = + DependencyProperty.Register("ExternalBridgeClientType", typeof(MachineConnectionTypes), typeof(MachineConnectionIcon), new PropertyMetadata(MachineConnectionTypes.USB)); + + private void OnExternalBridgeClientChanged() + { + if (ExternalBridgeClient != null) + { + if (ExternalBridgeClient.GetType() == typeof(ExternalBridgeUsbClient)) + { + ExternalBridgeClientType = MachineConnectionTypes.USB; + } + else if (ExternalBridgeClient.GetType() == typeof(ExternalBridgeTcpFirmwareClient)) + { + ExternalBridgeClientType = MachineConnectionTypes.TCP; + MachineType = MachineTypes.Eureka; + } + else if (ExternalBridgeClient.GetType() == typeof(ExternalBridgeTcpClient)) + { + ExternalBridgeClientType = MachineConnectionTypes.Wifi; + MachineType = ExternalBridgeClient.MachineType; + } + else if (ExternalBridgeClient.GetType() == typeof(ExternalBridgeSignalRClient)) + { + ExternalBridgeClientType = MachineConnectionTypes.SignalR; + MachineType = ExternalBridgeClient.MachineType; + } + else if (ExternalBridgeClient.GetType() == typeof(EmulatorExternalBridge)) + { + ExternalBridgeClientType = MachineConnectionTypes.Emulator; + } + } + } + + static MachineConnectionIcon() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(MachineConnectionIcon), new FrameworkPropertyMetadata(typeof(MachineConnectionIcon))); + } + } +} |
