本文整理汇总了C#中Connection.PrepareConnection方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.PrepareConnection方法的具体用法?C# Connection.PrepareConnection怎么用?C# Connection.PrepareConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.PrepareConnection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
var testClient = new Connection(ConnectionType.Reciever, "127.0.0.1");
testClient.OnConnectionMade += testClient_OnConnectionMade;
testClient.PrepareConnection();
}
示例2: SendButton_Click
private void SendButton_Click(object sender, RoutedEventArgs e)
{
var item = FoldersItem.SelectedItem as TreeViewItem;
if (item == null)
return;
string filePath = item.Tag.ToString();
SendButton.IsEnabled = false;
SendCancelButton.IsEnabled = true;
SendButton.Content = "Preparing";
FoldersItem.IsEnabled = false;
RecieveItem.IsEnabled = false;
SendProgressBar.Maximum = 200;
new Thread(new ThreadStart(delegate
{
int dots = 0;
var timer = new Timer(delegate
{
dots++;
if (dots > 4)
dots = 0;
string s = "Preparing";
for (int i = 0; i < dots; i++)
{
s += ".";
}
ChangeButtonContent(SendButton, s);
}, null, 0, 500);
var c = new Connection(ConnectionType.Sender);
c.PrepareConnection();
c.OnConnectionMade += connection1 => new Thread(new ThreadStart(delegate
{
connection1.SendFile(filePath);
Logger.Info("Done!");
ChangeButtonContent(SendCancelButton, "Finish");
ChangeButtonContent(SendButton, "Send");
SetEnabled(SendCancelButton, true);
SetEnabled(FoldersItem, true);
SetEnabled(SendButton, true);
SetEnabled(RecieveItem, true);
done = true;
timer.Dispose();
ChangeProgressBar(SendProgressBar, connection1.Progress);
})).Start();
timer.Dispose();
SetVisibilitySendTabControls(false);
SetEnabled(SendCancelButton, true);
SetEnabled(SendButton, true);
timer = new Timer(delegate
{
ChangeProgressBar(SendProgressBar, c.Progress);
SetLabelContent(SendStatusLabel, Logger.LastMessage);
}, null, 0, 20);
})).Start();
}
示例3: Button_Click
private void Button_Click(object sender, RoutedEventArgs e)
{
var testServer = new Connection(ConnectionType.Sender);
testServer.OnConnectionMade += testServer_OnConnectionMade;
testServer.OnPortFowardFailed += testServer_OnPortFowardFailed;
testServer.PrepareConnection();
}
示例4: PrepareRecieve
private void PrepareRecieve(string ip, string filePath)
{
SetEnabled(SendItem, false);
ChangeButtonContent(RecieveButton, "Connecting");
connection = new Connection(ConnectionType.Reciever, ip);
int dots = 0;
var timer = new Timer(delegate
{
dots++;
if (dots > 4)
dots = 0;
string s = "Connecting";
for (int i = 0; i < dots; i++)
{
s += ".";
}
ChangeButtonContent(RecieveButton, s);
}, null, 0, 500);
try
{
connection.PrepareConnection();
if (!connection.IsConnected)
{
MessageBox.Show("Could not make a connection!", "Error connecting..");
ChangeButtonContent(RecieveButton, "Connect and Recieve");
SetEnabled(RecieveButton, true);
SetEnabled(IdTextBox, true);
SetEnabled(SendItem, true);
timer.Dispose();
return;
}
}
catch
{
MessageBox.Show("An error occured while attempting to connect!", "Error connecting..");
ChangeButtonContent(RecieveButton, "Connect and Recieve");
SetEnabled(RecieveButton, true);
SetEnabled(IdTextBox, true);
SetEnabled(SendItem, true);
timer.Dispose();
return;
}
SetVisibilityRecieveTabControl(false);
SetEnabled(CancelButton, true);
SetEnabled(RecieveButton, true);
timer = new Timer(delegate
{
ChangeProgressBar(RecieveProgressBar, connection.Progress);
SetLabelContent(StatusLabel, Logger.LastMessage);
}, null, 0, 20);
connection.RecieveFile(filePath);
Logger.Info("Done!");
ChangeButtonContent(CancelButton, "Finish");
SetLabelContent(StatusLabel, "Done!");
SetEnabled(CancelButton, true);
SetEnabled(RecieveButton, true);
done = true;
timer.Dispose();
}