Esempio n. 1
0
        /// <summary>
        /// Handles the additions.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private async void HandleAdditionsAsync(object sender, System.EventArgs e)
        {
            string result = await UserDialogs.Instance.ActionSheetAsync("What type of data do you want to add?",
                                                                        Constants.Namings.Cancel, Constants.Namings.Cancel, null,
                                                                        new string[] { Constants.Namings.Sleep, Constants.Namings.Down });

            SleepInstanceView newSlider = null;

            switch (result)
            {
            case Constants.Namings.Cancel:

                return;

            case Constants.Namings.Down:
                if (downSpans.Count == 0)
                {
                    newSlider = new SleepInstanceView(TargetType.Bed, ReddrawCanvasView);
                }
                else
                {
                    SleepInstanceView maxHeight = downSpans.Aggregate((agg, next) => next.RangeSliderView.RangeSlider.UpperValue > agg.RangeSliderView.RangeSlider.UpperValue ? next : agg);

                    newSlider = new SleepInstanceView(TargetType.Bed, maxHeight.RangeSliderView.RangeSlider.UpperValue, ReddrawCanvasView);

                    maxHeight = null;
                }

                bedStackLayout.Children.Add(newSlider);
                downSpans.Add(newSlider);

                ReddrawCanvasView();

                break;

            case Constants.Namings.Sleep:
                if (sleepingSpans.Count == 0)
                {
                    newSlider = new SleepInstanceView(TargetType.Sleep, ReddrawCanvasView);
                }
                else
                {
                    SleepInstanceView maxHeight = sleepingSpans.Aggregate((agg, next) => next.RangeSliderView.RangeSlider.UpperValue > agg.RangeSliderView.RangeSlider.UpperValue ? next : agg);

                    newSlider = new SleepInstanceView(TargetType.Sleep, maxHeight.RangeSliderView.RangeSlider.UpperValue, ReddrawCanvasView);

                    maxHeight = null;
                }

                sleepStackLayout.Children.Add(newSlider);
                sleepingSpans.Add(newSlider);

                ReddrawCanvasView();

                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sets up view async.
        /// </summary>
        private async void SetUpViewAsync()
        {
            ProgressDialogConfig config = new ProgressDialogConfig()
                                          .SetTitle("Querying Database")
                                          .SetIsDeterministic(false)
                                          .SetMaskType(MaskType.Black);

            using (IProgressDialog progress = UserDialogs.Instance.Progress(config))
            {
                await Task.Delay(300);

                var existingData = await App.Database.GetSleepRecordsAsync(DateStringIndex);

                if (existingData != null && existingData.Count > 0)
                {
                    var sleepItems = existingData.Where(m => m.Type == Constants.Namings.SleepCode);

                    SleepInstanceView slider;

                    labelAsleep.IsVisible = true;
                    foreach (var item in sleepItems)
                    {
                        slider = new SleepInstanceView(TargetType.Sleep, Convert.ToSingle(item.Lower), Convert.ToSingle(item.Upper), ReddrawCanvasView);

                        sleepStackLayout.Children.Add(slider);
                        sleepingSpans.Add(slider);
                    }

                    var downItems = existingData.Where(m => m.Type == Constants.Namings.DownCode);

                    labelBed.IsVisible = true;
                    foreach (var item in downItems)
                    {
                        slider = new SleepInstanceView(TargetType.Bed, Convert.ToSingle(item.Lower), Convert.ToSingle(item.Upper), ReddrawCanvasView);

                        bedStackLayout.Children.Add(slider);
                        downSpans.Add(slider);
                    }
                }

                canvasView = new SleepDiagramView(sleepingSpans, downSpans);

                recordingGrid.Children.Add(canvasView, 0, 1);
            }
        }