private async void ImageLoad_OnClick(object sender, RoutedEventArgs e) { OpenFileDialog imageDialog = new OpenFileDialog() { Filter = "Image/photo (*.jpg;*.bnp;*.ico;*.img)|*.jpg;*.bnp;*.ico;*.img" + "|Все файлы (*.*)|*.* ", CheckFileExists = true, Multiselect = false }; if (imageDialog.ShowDialog() == true) { FileStream stream = new FileStream( imageDialog.FileName, FileMode.Open, FileAccess.Read); BinaryReader reader = new BinaryReader(stream); byte[] photo = reader.ReadBytes((int)stream.Length); DataExchangeWithServer updateImage = new DataExchangeWithServer("ChangeUserImage", "POST", $"sendImage={JsonConvert.SerializeObject(photo)}&name={_nameUser}", "application/x-www-form-urlencoded", true); string result = await updateImage.SendToServer(); if (result == null) { return; } MemoryStream read = new MemoryStream(photo); BitmapImage enterImage = new BitmapImage(); enterImage.BeginInit(); enterImage.CacheOption = BitmapCacheOption.OnLoad; enterImage.StreamSource = read; enterImage.EndInit(); _changeProfilImage(enterImage as ImageSource); } }
private async void SinglUp_OnClick(object sender, RoutedEventArgs e) { if (Password.Password == PasswordSecond.Password && Password.Password.Replace(" ", "") != "" && Name.Text.Replace(" ", "") != "" && Email.Text.Replace(" ", "") != "") { RegistrationObject sendParams = new RegistrationObject() { Name = Name.Text, EMail = Email.Text, Password = Password.Password }; DataExchangeWithServer registrationSend = new DataExchangeWithServer("Registration", "POST", JsonConvert.SerializeObject(sendParams), "application/json", true); string result = await registrationSend.SendToServer(); if (result == null) { return; } MessageBox.Show("OK!", "Result"); this.Close(); } else { Error.Visibility = Visibility.Visible; } }
private async void SubmitList_SelectionChanged(object sender, SelectionChangedEventArgs e) { string wordFromItemsList = SubmitList.SelectedValue.ToString(); string[] get = wordFromItemsList?.Split(new char[] { '|' }); DataExchangeWithServer getResultCompareFromSubmitList = new DataExchangeWithServer("SearchFromListSubmit", "POST", $"tagForSearch={get[get.Length - 1]}", "application/x-www-form-urlencoded", true); string result = await getResultCompareFromSubmitList.SendToServer(); if (result == null) { return; } _resultMethod(JsonConvert.DeserializeObject <ResultCompareObject>(result)); }
private async void LoadListSubmit() { DataExchangeWithServer getAllSubmit = new DataExchangeWithServer("GetListSubmit", "GET", "", "application/json", true); string result = await getAllSubmit.SendToServer(); if (result == null) { return; } List <string> listSubm = JsonConvert.DeserializeObject <List <string> >(result); foreach (string submit in listSubm) { SubmitList.Items.Add(submit); } }
private async void PrintCompilName(string lang) { DataExchangeWithServer getCompilName = new DataExchangeWithServer("GetComipeType", "POST", $"lang={lang}", "application/x-www-form-urlencoded", true); string result = await getCompilName.SendToServer(); if (result == null) { return; } List <string> typeCompl = JsonConvert.DeserializeObject <List <string> >(result); foreach (var typeCompil in typeCompl) { CompilName.Items.Add(typeCompil); } }
private async void UpdateHistoryList() { DataExchangeWithServer getHistory = new DataExchangeWithServer("GetListHistory", "GET", "", "application/json", true); string result = await getHistory.SendToServer(); if (result == null) { return; } List <string> listHistory = JsonConvert.DeserializeObject <List <string> >(result); FileListCompil.Items.Clear(); foreach (var desc in listHistory) { FileListCompil.Items.Add(desc); } }
private async void Load() { AddingCodeObject sendParams = new AddingCodeObject() { Name = _name, Description = _description, CompileType = _typeCompile, IsSearch = _isSearch, FileMane = _fileName, Code = _code, CompareLocal = _compareLocal }; DataExchangeWithServer getCompilName = new DataExchangeWithServer("AddCode", "POST", JsonConvert.SerializeObject(sendParams), "application/json", true); string result = await getCompilName.SendToServer(); if (result == null) { return; } FillTheListBackResult(JsonConvert.DeserializeObject <ResultCompareObject>(result)); this.Close(); }
private async void LoginButton_OnClick(object sender, RoutedEventArgs e) { List <object> isComplite; DataExchangeWithServer authorization = new DataExchangeWithServer("Autification", "POST", $"login={Email.Text}&password={Password.Password}", "application/x-www-form-urlencoded", true); string result = await authorization.SendToServer(); if (result == null) { return; } isComplite = JsonConvert.DeserializeObject <List <object> >(result); if ((bool)isComplite[0] == true) { _nameUserGet((string)isComplite[1]); ConvertToImage(JsonConvert.DeserializeObject <byte[]>((string)isComplite[2])); visibleMainWindow(); this.Close(); } else { Error.Visibility = Visibility.Visible; } }