Esempio n. 1
0
 /// <summary>
 /// Ouverture d'un nouveau thème astral vierge
 /// </summary>
 public Task <bool> NewNatalChart()
 {
     return(CallProtectedWithDirtySaveIfRequired(() => Task.Run(() => {
         // On réinitialise le thème
         CurrentNatalChart.Reset();
         return true;
     })));
 }
Esempio n. 2
0
        /// <summary>
        /// Provoque un appel protégé avec sauvegarde si les modifications d'un thème n'ont pas été enregistré
        /// </summary>
        async Task <bool> CallProtectedWithDirtySaveIfRequired(Func <Task <bool> > call)
        {
            Exception error = null;

            try
            {
                // Si le thème actuel est à sauvegarder
                if (CurrentNatalChart.IsDirty)
                {
                    // On demande à l'utilisateur ce qu'il veut faire
                    var cr = await DialogService.Confirm(
                        AstroAssistant.Resources.Locales.SaveChangesDialogTitle,
                        AstroAssistant.Resources.Locales.SaveChangesDialogMessage,
                        DialogConfirmType.YesNoCancel);

                    if (cr == DialogConfirmResult.Cancel)
                    {
                        return(false);
                    }
                    if (cr == DialogConfirmResult.Yes)
                    {
                        if (!await CurrentNatalChart.Save())
                        {
                            return(false);
                        }
                    }
                }
                // On provoque l'appel
                return(await call());
            }
            catch (Exception ex)
            {
                error = ex;
            }
            if (error != null)
            {
                await DialogService.ShowError(error);
            }
            return(false);
        }
Esempio n. 3
0
 /// <summary>
 /// Provoque le calcul du thème astral
 /// </summary>
 /// <returns></returns>
 public Task CalculateNatalChart()
 {
     return(CallProtected(() => Task.Run(() => CurrentNatalChart.Calculate())));
 }
Esempio n. 4
0
 /// <summary>
 /// Enregistrement d'un thème astral sous un autre nom
 /// </summary>
 public Task <bool> SaveAsNatalChart()
 {
     return(CallProtectedWithDirtySaveIfRequired(() => Task.Run(() => CurrentNatalChart.SaveAs())));
 }
Esempio n. 5
0
 /// <summary>
 /// Chargement d'un thème astral
 /// </summary>
 /// <returns></returns>
 public Task <bool> LoadNatalChart()
 {
     return(CallProtectedWithDirtySaveIfRequired(() => Task.Run(() => CurrentNatalChart.LoadFromFile())));
 }