private void OnServerResponse(PredictResponse _predictedData)
 {
     waitPopup.Close();
     imagePredicted.Show();
     imagePredicted.SetData(imageFilePath, _predictedData);
     Hide();
 }
Exemple #2
0
 public void SetData(string _fileLocation, PredictResponse _response)
 {
     if (!string.IsNullOrEmpty(_fileLocation))
     {
         imageBox.Image = Image.FromFile(_fileLocation);
     }
     ComputeTextPredicted(_response);
 }
Exemple #3
0
 private void OnServerResponse(PredictResponse _predictedData)
 {
     waitPopup.Close();
     textPredicted.Init(type);
     textPredicted.Show();
     textPredicted.SetDataPredicted(textToPredict, _predictedData);
     Hide();
 }
Exemple #4
0
 public void SetDataPredicted(string _textToPredict, PredictResponse _response)
 {
     if (!string.IsNullOrEmpty(_textToPredict))
     {
         textBox1.Text = _textToPredict;
     }
     ComputeTextPredicted(_response);
 }
Exemple #5
0
 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));
     }
 }
Exemple #6
0
        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();
            }
        }