/// <summary> /// Executed when the user presses "Pair" /// </summary> private async Task PairButton_Click_Common() { Computer selected = (Computer)computerPicker.SelectedItem; // User hasn't selected anything or selected the placeholder if (selected == null || selected.IpAddress == null) { DialogUtils.DisplayDialog(this.Dispatcher, "No machine selected", "Pairing Failed"); return; } PairingManager p = new PairingManager(selected); // Stop polling timer while we're pairing mDnsTimer.Stop(); await p.Pair(this.Dispatcher, selected); mDnsTimer.Start(); }
/// <summary> /// Quit Game Event Handler /// </summary> private async Task QuitGame_Common() { Computer selected = (Computer)computerPicker.SelectedItem; // User hasn't selected anything or selected the placeholder if (selected == null || selected.IpAddress == null) { DialogUtils.DisplayDialog(this.Dispatcher, "No machine selected", "Quit Failed"); return; } PairingManager p = new PairingManager(selected); if (await p.QueryPairState() != true) { DialogUtils.DisplayDialog(this.Dispatcher, "Device not paired", "Quit Failed"); return; } try { NvHttp nv = new NvHttp(selected.IpAddress); XmlQuery quit = new XmlQuery(nv.BaseUrl + "/cancel?uniqueid=" + nv.GetUniqueId()); string cancelled = await quit.ReadXmlElement("cancel"); if (cancelled == "1") { DialogUtils.DisplayDialog(this.Dispatcher, "Successfully Quit Game", "Quit Game"); return; } } catch (Exception ex) { Debug.WriteLine(ex.Message); } DialogUtils.DisplayDialog(this.Dispatcher, "Unable to quit", "Quit Game"); }