private void TryToConnect(object sender, RoutedEventArgs e)
{
Overlay.Show("Connecting");
ConnControl.Visibility = Visibility.Visible;
var conType = CreateConnection();
Dispatcher.Invoke(new Action(async () =>
{
if (conType != null)
{
_brick = new Brick(conType, true);
_brick.BrickChanged += _brick_BrickChanged;
try
{
await _brick.ConnectAsync();
ConnControl.Visibility = Visibility.Collapsed;
ConnTypeRun.Text = ConnControl.GetConnectionType().ToString();
}
catch (Exception)
{
MessageBox.Show("Could not connect", "Error", MessageBoxButton.OK);
}
}
else
{
MessageBox.Show("Invalid connection type for this device", "Error", MessageBoxButton.OK);
}
Overlay.Hide();
}));
}