本文整理汇总了C#中Address.AddComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Address.AddComponent方法的具体用法?C# Address.AddComponent怎么用?C# Address.AddComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address.AddComponent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSearch_Click
/// <summary>
/// We either want to start or stop searching
/// </summary>
private void btnSearch_Click(object sender, System.EventArgs e)
{
if (!isSearching)
{
if( hostAddress != null )
hostAddress.Dispose();
hostAddress = new Address();
hostAddress.ServiceProvider = deviceAddress.ServiceProvider;
// See if we should prompt the user for the remote address
if (ConnectWizard.ProviderRequiresPort(hostAddress.ServiceProvider))
{
AddressForm addressDialog = new AddressForm(connectionWizard.DefaultPort);
addressDialog.ShowDialog(this);
// If the user cancelled the address form, abort the search
if (addressDialog.DialogResult != DialogResult.OK)
return;
// If a port was specified, add the component
if (addressDialog.Hostname != "")
hostAddress.AddComponent(Address.KeyHostname, addressDialog.Hostname);
// If a hostname was specified, add the component
if (addressDialog.Port > 0)
hostAddress.AddComponent(Address.KeyPort, addressDialog.Port);
}
//Time to enum our hosts
ApplicationDescription desc = new ApplicationDescription();
desc.GuidApplication = connectionWizard.ApplicationGuid;
// If the user was not already asked for address information, DirectPlay
// should prompt with native UI
FindHostsFlags flags = 0;
if (!ConnectWizard.ProviderRequiresPort(deviceAddress.ServiceProvider))
flags = FindHostsFlags.OkToQueryForAddressing;
peer.FindHosts(desc,hostAddress,deviceAddress,null,Timeout.Infinite,0,Timeout.Infinite, flags, out findHostHandle);
isSearching = true;
btnCreate.Enabled = false;
btnSearch.Text = "Stop Search";
}
else
{
btnSearch.Text = "Stopping...";
btnSearch.Enabled = false;
if (findHostHandle != 0)
peer.CancelAsyncOperation(findHostHandle);
}
}