/// <summary> /// Raised when some child port selected /// </summary> void SchemeControl_PortSelected(object sender, RoutedEventArgs e) { if (_selectedPort == null) { StartConnectionCreation(e.OriginalSource as PortControl); } else { if (!CurConnection.First.IsLoaded) { CurConnection = null; return; } // Connection created event args will contains CanBeCreated property ConnectionCreatedEventArgs r; OnConnectionCreated(out r, _selectedPort, e.OriginalSource as PortControl); if (r.CanBeCreated) { (e.OriginalSource as PortControl).IsConnected = true; PortControl.UnSelectCommand.Execute(null, e.OriginalSource as PortControl); EndConnectionCreation(); } } }
/// <summary> /// Start create new conenction /// </summary> /// <param name="port"></param> private void StartConnectionCreation(PortControl port) { // If there is no selected port, we just set current as selected _selectedPort = port; _selectedPort.IsConnected = true; CurConnection = new ConnectionControl(_selectedPort, this); }
/// <summary> /// End connection creation /// </summary> private void EndConnectionCreation() { PortControl.UnSelectCommand.Execute(null, _selectedPort); CurConnection.Dispose(); Connections.Remove(CurConnection); CurConnection = null; _selectedPort = null; }