Example #1
0
        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();
        }
Example #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var testServer = new Connection(ConnectionType.Sender);

            testServer.OnConnectionMade   += testServer_OnConnectionMade;
            testServer.OnPortFowardFailed += testServer_OnPortFowardFailed;
            testServer.PrepareConnection();
        }
Example #3
0
 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();
 }
Example #4
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     var testServer = new Connection(ConnectionType.Sender);
     testServer.OnConnectionMade += testServer_OnConnectionMade;
     testServer.OnPortFowardFailed += testServer_OnPortFowardFailed;
     testServer.PrepareConnection();
 }
Example #5
0
        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();
        }
Example #6
0
        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();
        }
Example #7
0
        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();
        }
Example #8
0
        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();
        }