private void OnServerResponse(PredictResponse _predictedData) { waitPopup.Close(); imagePredicted.Show(); imagePredicted.SetData(imageFilePath, _predictedData); Hide(); }
public void SetData(string _fileLocation, PredictResponse _response) { if (!string.IsNullOrEmpty(_fileLocation)) { imageBox.Image = Image.FromFile(_fileLocation); } ComputeTextPredicted(_response); }
private void OnServerResponse(PredictResponse _predictedData) { waitPopup.Close(); textPredicted.Init(type); textPredicted.Show(); textPredicted.SetDataPredicted(textToPredict, _predictedData); Hide(); }
public void SetDataPredicted(string _textToPredict, PredictResponse _response) { if (!string.IsNullOrEmpty(_textToPredict)) { textBox1.Text = _textToPredict; } ComputeTextPredicted(_response); }
private void ComputeTextPredicted(PredictResponse _response) { listBox1.Items.Clear(); for (int i = 0; i < _response.keys.Count; i++) { double number = double.Parse(_response.values[i], CultureInfo.InvariantCulture) * 100; listBox1.Items.Add(string.Format(" - {0} : {1:0.##}%", _response.keys[i], number)); } }
public async void SendRequestAsync(string data, Action <PredictResponse> _callback, Action _onError) { var content = new StringContent(data, Encoding.UTF8, "application/json"); try { HttpResponseMessage postTask = await Task.Run(() => client.PostAsync(url, content)); string resp = await postTask.Content.ReadAsStringAsync(); PredictResponse response = JsonConvert.DeserializeObject <PredictResponse>(resp); _callback?.Invoke(response); } catch (Exception) { MessageBox.Show("Server error! \n Please run the server!"); _onError?.Invoke(); } }