当前位置: 首页>>代码示例>>C#>>正文


C# Connection.PrepareConnection方法代码示例

本文整理汇总了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();
 }
开发者ID:hypereddie,项目名称:FILO,代码行数:6,代码来源:MainWindow.xaml.cs

示例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();
        }
开发者ID:hypereddie,项目名称:FILO,代码行数:57,代码来源:MainWindow.xaml.cs

示例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();
 }
开发者ID:hypereddie,项目名称:FILO,代码行数:7,代码来源:MainWindow.xaml.cs

示例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();
        }
开发者ID:hypereddie,项目名称:FILO,代码行数:64,代码来源:MainWindow.xaml.cs


注:本文中的Connection.PrepareConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。