1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| private void client_DownloadQuestConf(object sender, DownloadStringCompletedEventArgs e)
{
myProgressBar.IsEnabled = true; //load progress bar TAVU
myProgressBar.IsIndeterminate = true;
myProgressBar.Visibility = System.Windows.Visibility.Visible;
if (e.Error == null)
{
var resultat = JsonConvert.DeserializeObject<List<QuestConf>>(e.Result);
int i = 0;
foreach (rubrique rub in info_rubrique)
{
PivotItem myNewPivotItem = new PivotItem();
myNewPivotItem.Name = "piv_" + rub.id;
//ID of the pivot
myNewPivotItem.Header = rub.name;
Grid myNewGrid = new Grid();
ScrollViewer scroll = new ScrollViewer { VerticalScrollBarVisibility = ScrollBarVisibility.Visible};
StackPanel stack = new StackPanel();
foreach (QuestConf quest in resultat)
{
if (quest.question.category == rub.id)
{
TextBlock question = new TextBlock();
question.FontSize = 21;
question.TextWrapping = TextWrapping.Wrap;
question.VerticalAlignment = System.Windows.VerticalAlignment.Top;
question.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
question.Text = quest.question.name + "\n";
stack.Children.Add(question);
foreach (Answer ans in quest.answers)
{
var resp = new Button();
resp.Click += (sender1, eventArgs) =>
{
WebClient client_answer = new WebClient();
client_answer.DownloadStringCompleted += (send, down) =>
{
if (down.Result != "done")
MessageBox.Show("Erreur lors de l'envoi de données : " + down.Result);
else
{
resp.Content = "Requete envoyé !";
}
};
client_answer.DownloadStringAsync(new Uri("http://www.techdevmobile.fr/happyconf/index.php/private/api/send_answer/" + info_conf.id + "/" + info_user.id + "/" + quest.question.id + "/" + ans.id));
};
resp.Content = ans.label;
stack.Children.Add(resp);
}
}
}
scroll.Content = stack;
myNewGrid.Children.Add(scroll);
myNewPivotItem.Content = myNewGrid;
myNewGrid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
myNewGrid.Width = 410;
myNewGrid.Height = 325;
//add pivot to main list
pivotMainList.Items.Add(myNewPivotItem);
TextBlock txt = new TextBlock();
txt.Text = "> " + rub.name;
txt.FontSize = 35;
lstItemsToList.Items.Add(txt);
i++;
}
}
else
MessageBox.Show("Impossible de récupérer les données sur internet : " + e.Error);
myProgressBar.IsEnabled = false;
myProgressBar.IsIndeterminate = false;
myProgressBar.Visibility = System.Windows.Visibility.Collapsed;
} |
Partager