Ejemplo n.º 1
0
        private StackLayout AddExercisesToProfilePage(MainTable mainTable)
        {
            StackLayout stackLayout = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Margin            = new Thickness(0),
                Padding           = new Thickness(10, 0, 10, 0),
                BackgroundColor   = Color.FromHex("#262626")
            };
            Frame frame = new Frame()
            {
                CornerRadius = 10,
                BorderColor  = Color.FromHex("#262626"),
                Padding      = new Thickness(0),
                Margin       = new Thickness(0, 5, 0, 5),
                //WidthRequest = 150,
                IsClippedToBounds = true,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            SfButton button = new SfButton()
            {
                ClassId        = mainTable.ID.ToString(),
                Text           = mainTable.Name,
                FontAttributes = FontAttributes.Bold,
                //WidthRequest = 150,
                HeightRequest   = 50,
                BackgroundColor = Color.FromHex("#262626"),
                TextColor       = Color.White
            };

            button.Clicked += YourButtonClick;

            Frame frame1 = new Frame()
            {
                CornerRadius      = 10,
                BorderColor       = Color.FromHex("#262626"),
                Padding           = new Thickness(0),
                Margin            = new Thickness(0, 5, 0, 5),
                IsClippedToBounds = true,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
            };
            SfButton button1 = new SfButton()
            {
                ClassId = mainTable.ID.ToString(),
                //Text = "Del",
                CornerRadius = 10,
                ImageSource  = "delete_outline_white_36dp.png",
                ImageWidth   = 36,

                ShowIcon          = true,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                HeightRequest     = 50,
                WidthRequest      = 50,
                BackgroundColor   = Color.FromHex("#262626"),
                TextColor         = Color.White
            };

            button1.Clicked += DeleteExerciseButton_Click;

            Frame frame2 = new Frame()
            {
                CornerRadius      = 10,
                Padding           = new Thickness(0),
                BorderColor       = Color.FromHex("#262626"),
                Margin            = new Thickness(0, 5, 0, 5),
                IsClippedToBounds = true,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
            };
            SfButton button2 = new SfButton()
            {
                ClassId = mainTable.ID.ToString(),
                //Text = "Edit",
                ImageSource       = "baseline_create_white_36dp.png",
                ImageWidth        = 36,
                HeightRequest     = 50,
                WidthRequest      = 50,
                ShowIcon          = true,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                //Padding = new Thickness(7, 7, 7, 7),
                BackgroundColor = Color.FromHex("#262626"),
                TextColor       = Color.White
            };

            button2.Clicked += UpdateExerciseButton_Click;

            frame.Content  = button;
            frame1.Content = button1;
            frame2.Content = button2;
            stackLayout.Children.Add(frame);
            stackLayout.Children.Add(frame1);
            stackLayout.Children.Add(frame2);

            return(stackLayout);
        }
Ejemplo n.º 2
0
        private StackLayout AddStatisticByExercise(MainTable mainTable)
        {
            int    progress = 0;
            double percent  = 0.0;

            if (mainTable.Type == (byte)App.TypeExercises.Count)
            {
                ExercisesCountTableRepository exercisesCountTableRepository = new ExercisesCountTableRepository(Path.Combine(DBSaverLoader.documentsPath, mainTable.StringID + ".db"));
                int exercisesTableLength = exercisesCountTableRepository.Count;
                if (exercisesTableLength == 0)
                {
                    return(AddStatisticFromScreen(mainTable.Name, mainTable.ID, 0, 0.0, "count.jpg"));
                }
                ExercisesCountTable lastItem = exercisesCountTableRepository.GetItem(exercisesCountTableRepository.StartPosition + exercisesTableLength - 1);
                double purpose = double.Parse(mainTable.Purpose);
                if (exercisesTableLength >= 2)
                {
                    ExercisesCountTable penultItem = exercisesCountTableRepository.GetItem(exercisesCountTableRepository.StartPosition + exercisesTableLength - 2);
                    progress = lastItem.Count - penultItem.Count;
                    percent  = (double)lastItem.Count / purpose * 100.0;
                }
                if (exercisesTableLength == 1)
                {
                    percent = (double)lastItem.Count / purpose * 100.0;
                }
            }
            else if (mainTable.Type == (byte)App.TypeExercises.Approach)
            {
                ExercisesApproachTableRepository exercisesApproachTableRepository = new ExercisesApproachTableRepository(Path.Combine(DBSaverLoader.documentsPath, mainTable.StringID + ".db"));
                int exercisesTableLength = exercisesApproachTableRepository.Count;
                if (exercisesTableLength == 0)
                {
                    return(AddStatisticFromScreen(mainTable.Name, mainTable.ID, 0, 0.0, "approach.jpg"));
                }
                int lastItem = (from item in exercisesApproachTableRepository.GetItem(exercisesApproachTableRepository.StartPosition + exercisesTableLength - 1).Count.Split('/')
                                select int.Parse(item)).Sum();
                double purpose = (from item in mainTable.Purpose.Split('/') select double.Parse(item)).Sum();
                if (exercisesTableLength >= 2)
                {
                    int penultItem = (from item in exercisesApproachTableRepository.GetItem(exercisesApproachTableRepository.StartPosition + exercisesTableLength - 2).Count.Split('/')
                                      select int.Parse(item)).Sum();
                    progress = lastItem - penultItem;
                    percent  = (double)lastItem / purpose * 100.0;
                }
                if (exercisesTableLength == 1)
                {
                    percent = (double)lastItem / purpose * 100.0;
                }
            }
            else if (mainTable.Type == (byte)App.TypeExercises.Time)
            {
                ExercisesTimeTableRepository exercisesTimeTableRepository = new ExercisesTimeTableRepository(Path.Combine(DBSaverLoader.documentsPath, mainTable.StringID + ".db"));
                int      exercisesTableLength = exercisesTimeTableRepository.Count;
                TimeSpan progressTime         = new TimeSpan(0, 0, 0);
                if (exercisesTableLength == 0)
                {
                    return(AddStatisticFromScreen(mainTable.Name, mainTable.ID, 0, 0.0, "timer.jpg"));
                }
                ExercisesTimeTable lastItem = exercisesTimeTableRepository.GetItem(exercisesTimeTableRepository.StartPosition + exercisesTableLength - 1);
                double             purpose  = double.Parse(mainTable.Purpose);
                if (exercisesTableLength >= 2)
                {
                    ExercisesTimeTable penultItem = exercisesTimeTableRepository.GetItem(exercisesTimeTableRepository.StartPosition + exercisesTableLength - 2);
                    progressTime = lastItem.Count - penultItem.Count;
                    percent      = (double)lastItem.Count.TotalSeconds / purpose * 100.0;
                }
                if (exercisesTableLength == 1)
                {
                    percent = (double)lastItem.Count.TotalSeconds / purpose * 100.0;
                }
                return(AddStatisticFromScreen(mainTable.Name, mainTable.ID, (int)progressTime.TotalSeconds, percent, "timer.jpg", true));
            }
            string photo = "";

            if (mainTable.Type == (byte)App.TypeExercises.Time)
            {
                photo = "timer.jpg";
            }
            if (mainTable.Type == (byte)App.TypeExercises.Approach)
            {
                photo = "approach.jpg";
            }
            if (mainTable.Type == (byte)App.TypeExercises.Count)
            {
                photo = "count.jpg";
            }
            return(AddStatisticFromScreen(mainTable.Name, mainTable.ID, progress, percent, photo));
        }