private void Rectangle_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var selected = ((Bar)DataBindings[((Rectangle)sender).Name]).Period;

            currentSelected            = selected;
            DataBindings["CurrentDay"] = currentSelected;
        }
Exemplo n.º 2
0
 public static bool AddStepsPeriod(StepsPeriod period)
 {
     using (SQLiteConnection connection = new SQLiteConnection(PermDBCS))
     {
         int ret = connection.InsertOrReplace(period);
     }
     return(true);
 }
Exemplo n.º 3
0
 public static void UpdateStepsPeriod(StepsPeriod period)
 {
     using (SQLiteConnection connection = new SQLiteConnection(PermDBCS))
     {
         StepsPeriod entityToUpdate = connection.Table <StepsPeriod>().Where(pe => pe.ID.Equals(period.ID)).FirstOrDefault();
         entityToUpdate.Start       = period.Start;
         entityToUpdate.End         = period.End;
         entityToUpdate.TotalLength = period.TotalLength;
         entityToUpdate.RunLength   = period.RunLength;
         entityToUpdate.WalkLength  = period.WalkLength;
         entityToUpdate.RunSteps    = period.RunSteps;
         entityToUpdate.WalkSteps   = period.WalkSteps;
         connection.Update(entityToUpdate);
     }
 }
Exemplo n.º 4
0
 public static void DeleteStepsPeriod(int id)
 {
     using (SQLiteConnection connection = new SQLiteConnection(PermDBCS))
     {
         StepsPeriod period = connection.Table <StepsPeriod>().Where(pe => pe.ID.Equals(id)).FirstOrDefault();
         if (period != null)
         {
             connection.BeginTransaction();
             var blocks = connection.Table <StepsBlock>().Where(b => b.Period.Equals(id)).ToList <StepsBlock>();
             foreach (var block in blocks)
             {
                 connection.Delete(block);
             }
             connection.Delete(period);
             connection.Commit();
         }
     }
 }
        private void reloadChart()
        {
            // cargamos los periodos de los ultimos siete dias
            List <StepsPeriod> periods = DB.GetStepsPeriods(DateTime.Today.AddDays(-7), DateTime.Today);

            // referencia para escalar las barras luego
            int maxSteps = 0;

            for (int i = 0; i < 7; i++)
            {
                // buscamos si hay un periodo o no guardado
                var period = periods.Find(p => p.Start == DateTime.Today.AddDays(-i));
                Bar bar    = new Bar();
                bar.Date   = DateTime.Today.AddDays(-i).Date;
                bar.Period = period;
                bar.ScaleY = 0.0;
                // actualizamos los pasos maximos de estos dias para el escalado
                if (period != null)
                {
                    maxSteps = period.TotalSteps > maxSteps ? period.TotalSteps : maxSteps;
                }
                // FIXME no se si el acceso por clave al diccionario crea una entrada si no existe
                if (DataBindings.ContainsKey("Bar" + (i + 1)))
                {
                    DataBindings["Bar" + (i + 1)] = bar;
                }
                else
                {
                    DataBindings.Add("Bar" + (i + 1), bar);
                }
                currentSelected = bar.Period;
            }
            // una vez asignadas las barras, calculamos el escalado
            for (int i = 0; i < 7; i++)
            {
                Bar bar = ((Bar)DataBindings["Bar" + (i + 1)]);
                if (bar.Period != null)
                {
                    bar.ScaleY = (bar.Period.TotalSteps * 100) / maxSteps;
                }
            }
        }