private void EnterClick(object sender, RoutedEventArgs e)
        {
            Task task = client.SendCommand("Login", loginText.Text, passwordText.Password);

            task.Wait();
            Entering();
        }
Example #2
0
 private void Connect(object sender, RoutedEventArgs e)
 {
     client = new ClientWork(ipText.Text);
     client.SendCommand("start", "");
     client.GetCommand();
     Content = new LoginPage(this, client);
 }
        private void DownloadClick(object sender, RoutedEventArgs e)
        {
            if (listFiles.SelectedItem != null)
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();

                if (saveFileDialog.ShowDialog() == true)
                {
                    fileForUpload = saveFileDialog.FileName;
                    var builder = new StringBuilder();
                    builder.Append(fileForUpload);
                    builder.Replace(saveFileDialog.SafeFileName, string.Empty);
                    fileForUpload = builder.ToString();

                    string fileName = (string)listFiles.SelectedItem;
                    KeyValuePair <string, string> fileElement = new KeyValuePair <string, string>();

                    foreach (KeyValuePair <string, string> keyValue in client.fileList)
                    {
                        if (fileName == keyValue.Key)
                        {
                            fileElement = keyValue;
                        }
                    }

                    string fileNameForDownload = fileElement.Key.Trim();

                    if (fileNameForDownload[2] == 'i')
                    {
                        fileNameForDownload = fileNameForDownload.Remove(0, 6);
                        Task task = client.SendCommand("DownloadFile", fileForUpload + fileNameForDownload, fileElement.Value);
                        task.Wait();
                        isDownload = true;
                        Downloading();
                    }

                    else
                    {
                        fileNameForDownload = fileNameForDownload.Remove(0, 8);
                        Task task = client.SendCommand("DownloadFolder", fileForUpload + fileNameForDownload, fileElement.Value);
                        task.Wait();
                        isDownload = true;
                        Downloading();
                    }
                }

                else
                {
                    fileForUpload = "";
                }
            }

            else
            {
                MessageBox.Show("Выберите файл который хотите скачать");
            }
        }
        private void Registration(object sender, RoutedEventArgs e)
        {
            key = keyText.Text;

            if (key == string.Empty || loginText.Text == string.Empty || passwordText.Text.Length < 4 || loginText.Text.Any(symbol => letters.Any(sub => sub == symbol)) == true ||
                passwordText.Text.Any(symbol => letters.Any(sub => sub == symbol)) == true || loginText.Text.Length < 1)
            {
                Ex();
            }

            else
            {
                Task task = client.SendCommand("GetKey", key);
                task.Wait();
                CheckingKey();
            }
        }