/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { LaunchActivatedEventArgs launchArgs = e.Parameter as LaunchActivatedEventArgs; if (launchArgs.Arguments.Contains("Windows.Networking.Proximity.PeerFinder:StreamSocket")) { _isLaunchedByTap = true; if (launchArgs.Arguments.Contains("Role=Host")) { _appRole = PeerRole.Host; } else if (launchArgs.Arguments.Contains("Role=Client")) { _appRole = PeerRole.Client; } else { _appRole = PeerRole.Peer; } } PopulateScenarios(); InvalidateLayout(); }
// ReSharper disable once UnusedParameter.Local private static void SetPeerRole(PeerOptions peerOptions, JToken jsonPeer, PeerRole role) { string propName = RoleNameRemap(role); JToken val = jsonPeer[propName]; if (val != null) { bool isSet = val.Value <bool>(); /*if (isSet == null) { * // This is an invalid boolean value * throw new NetworkConfigurationException(format("Error constructing channel %s. Role %s has invalid boolean value: %s", channelName, propName, val.toString())); * }*/ if (isSet) { peerOptions.AddPeerRole(role); } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { String launchArgs = e.Parameter as String; if (launchArgs != null && launchArgs.Contains("Windows.Networking.Proximity.PeerFinder:StreamSocket")) { _isLaunchedByTap = true; if (launchArgs.Contains("Role=Host")) { _appRole = PeerRole.Host; } else if (launchArgs.Contains("Role=Client")) { _appRole = PeerRole.Client; } else { _appRole = PeerRole.Peer; } } // Populate the scenario list from the SampleConfiguration.cs file ScenarioControl.ItemsSource = scenarios; // If we have saved state return to the previously selected scenario if (SuspensionManager.SessionState.ContainsKey("SelectedScenarioIndex")) { ScenarioControl.SelectedIndex = Convert.ToInt32(SuspensionManager.SessionState["SelectedScenarioIndex"]); ScenarioControl.ScrollIntoView(ScenarioControl.SelectedItem); } else { ScenarioControl.SelectedIndex = 0; } }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { String launchArgs = e.Parameter as String; if (launchArgs != null && launchArgs.Contains("Windows.Networking.Proximity.PeerFinder:StreamSocket")) { _isLaunchedByTap = true; _appRole = PeerRole.Peer; if (!ScenarioFrame.Navigate(typeof(PeerFinderScenario))) { throw new Exception("Failed to navigate to PeerFinderScenario!"); } } SuspensionManager.RegisterFrame(ScenarioFrame, "scenarioFrame"); if (ScenarioFrame.Content == null) { // When the navigation stack isn't restored navigate to the ScenarioList if (!ScenarioFrame.Navigate(typeof(ScenarioList))) { throw new Exception("Failed to create scenario list"); } } }
private static string RoleNameRemap(PeerRole peerRole) { string remap = roleNameRemapHash.GetOrNull(peerRole); return(remap ?? peerRole.ToValue()); }