async Task setUnits(Units u)
        {
            ContextDatabaseAccess database = new ContextDatabaseAccess();
            await database.InitializeAsync();

            CurrentContext.CurrentUnits = u;
            await database.SaveContextAsync(CurrentContext);
        }
示例#2
0
        async private Task SetContext()
        {
            ContextDatabaseAccess contextDB = new ContextDatabaseAccess();
            await contextDB.InitializeAsync();

            try
            {
                CurrentContext = contextDB.GetContextAsync().Result;
            }
            // Can't find definitions for SQLiteNetExtensions exceptions, so catch generic Exception e and assume there is no context.
            catch (Exception e)
            {
                CurrentContext = null;
            }
            if (CurrentContext == null)
            {
                CurrentContext = new Context(-1, Language.ENGLISH, new Units(DistanceUnits.IN, WeightUnits.OZ));
            }
            await contextDB.SaveContextAsync(CurrentContext);
        }
        async Task setLanguage(Language l)
        {
            ContextDatabaseAccess database = new ContextDatabaseAccess();
            await database.InitializeAsync();

            if (CurrentContext == null)
            {
                CurrentContext = Context.LoadCurrentContext();
            }
            CurrentContext.CurrentLanguage = l;
            await database.SaveContextAsync(CurrentContext);

            try
            {
                MasterPage.UpdateLanguage(l);
            }
            catch (Exception e)
            {
                // TODO:
            }
        }