using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; using Tango.Integration.Services; using Tango.MachineStudio.Common.Notifications; using Tango.SharedUI; namespace Tango.MachineStudio.UI.ViewModels { /// /// Represents the Machine Studio connection dialog, view model. /// /// public class MachineConnectionViewVM : DialogViewVM { private ExternalBridgeScanner _scanner; /// /// Gets or sets the machine scanner. /// public ExternalBridgeScanner Scanner { get { return _scanner; } set { _scanner = value; RaisePropertyChangedAuto(); } } private IExternalBridgeClient _selectedMachine; /// /// Gets or sets the selected machine. /// public IExternalBridgeClient SelectedMachine { get { return _selectedMachine; } set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } /// /// Gets or sets the connect command. /// public RelayCommand ConnectCommand { get; set; } /// /// Initializes a new instance of the class. /// /// The scanner. public MachineConnectionViewVM(ExternalBridgeScanner scanner) { Scanner = scanner; ConnectCommand = new RelayCommand(Connect,(x) => SelectedMachine != null); } /// /// Connect to the currently selected machine. /// private void Connect() { if (SelectedMachine != null) { Scanner.Stop(); Accept(); } } protected override void Cancel() { Scanner.Stop(); base.Cancel(); } /// /// Called when the dialog has been shown. /// public override void OnShow() { base.OnShow(); Scanner.AvailableMachines.Clear(); Scanner.Start(); } } }