Пример #1
0
		private async void Discover()
		{
			Progress.IsEnabled = true;
			Progress.PrimaryMessage = "Discovering Max! Cube on network...";

			_cubes.Clear();

			await _maxCubeDiscoverer.DiscoverCubes();

			var countdownTimer = new CountdownTimer();
			countdownTimer.CountdownSecondElasped += (sender, seconds) =>
			{
				Progress.SecondaryMessage = string.Format("{0}s remaining", seconds);
			};
			countdownTimer.CountdownFinished += sender =>
			{
				var hostNames = string.Join(",", _cubes.Keys.Select(name => name.DisplayName));
				Progress.PrimaryMessage = string.Format("Discovered {0} Max! Cube{1} @ {2}", _cubes.Count, _cubes.Count > 1 ? "s" : "", hostNames);
				Progress.SecondaryMessage = "";
				Progress.IsEnabled = false;

				if (_cubes.Count == 1)
				{
					var keyValuePair = _cubes.FirstOrDefault();
					var cubeInfoWithHostName = new CubeInfoWithHostName
					{
						CubeInfo = keyValuePair.Value,
						HostName = keyValuePair.Key
					};

					_navigationService.NavigateTo(NavigationKeys.Home, cubeInfoWithHostName);
				}
			};
			countdownTimer.Start(_settingService.DiscoveryTimeOut);
		}
Пример #2
0
		public void Activate(object parameter)
		{
			if (_settingService.IsDiscoveryEnabled)
			{
				Discover();
			}
			else if (!string.IsNullOrEmpty(_settingService.CubeAddress))
			{
				var cubeInfoWithHostName = new CubeInfoWithHostName
				{
					HostName = new HostName(_settingService.CubeAddress)
				};
				_navigationService.NavigateTo(NavigationKeys.Home, cubeInfoWithHostName);
			}
		}
Пример #3
0
		private async void Connect(CubeInfoWithHostName cubeInfoWithHostName)
		{
			await _maxConnector.ConnectAsync(cubeInfoWithHostName.HostName.ToString());
		}