|
|
|
@ -6,18 +6,28 @@ namespace Stim;
|
|
|
|
|
|
|
|
|
|
public partial class ReviewPopUp : Popup
|
|
|
|
|
{
|
|
|
|
|
public ReviewPopUp()
|
|
|
|
|
private readonly bool editing = false;
|
|
|
|
|
private Review prevRev = null;
|
|
|
|
|
public ReviewPopUp(Review previousRev = null)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
if (previousRev != null)
|
|
|
|
|
{
|
|
|
|
|
prevRev = previousRev;
|
|
|
|
|
Entrytxt.Text = previousRev.Text;
|
|
|
|
|
Val.Text = previousRev.Rate.ToString();
|
|
|
|
|
editing = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CloseButton(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
Close(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Valider(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int res;
|
|
|
|
|
if ((App.Current as App).Manager.SelectedGame == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception();
|
|
|
|
@ -25,10 +35,23 @@ public partial class ReviewPopUp : Popup
|
|
|
|
|
bool isDouble = double.TryParse(Val.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out double rate);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Entrytxt.Text) && isDouble)
|
|
|
|
|
{
|
|
|
|
|
((App)App.Current).Manager.CurrentUser.AddReview((App.Current as App).Manager.SelectedGame, rate, Entrytxt.Text);
|
|
|
|
|
//Error.Text = "";
|
|
|
|
|
if (editing == true)
|
|
|
|
|
{
|
|
|
|
|
if (prevRev.Text != Entrytxt.Text) prevRev.EditReview(Entrytxt.Text);
|
|
|
|
|
prevRev.EditRate(rate);
|
|
|
|
|
(App.Current as App).Manager.SelectedGame.UpdateReviews();
|
|
|
|
|
res = 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
((App)App.Current).Manager.CurrentUser.AddReview((App.Current as App).Manager.SelectedGame, rate, Entrytxt.Text);
|
|
|
|
|
res = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
((App)App.Current).Manager.SaveGames();
|
|
|
|
|
Close();
|
|
|
|
|
Close(res);
|
|
|
|
|
}
|
|
|
|
|
else Error.Children.Add(new Label { Text="Champ vide ou invalide", TextColor=Colors.Red });
|
|
|
|
|
//else Error.Text = "Champ vide ou invalide";
|
|
|
|
|
}
|
|
|
|
|
}
|