Beispiel #1
0
        public HairChartView(HairAppBl.Interfaces.IHairBl hairbl, HairChartController controller)
        {
            mModel                     = new PlotModel();
            mController                = controller;
            mPictContainer             = new StackLayout();
            mPictContainer.Orientation = StackOrientation.Horizontal;

            mEditButton          = Common.GetButton("edit.png", hairbl);
            mEditButton.Clicked += (sender, e) =>
            {
                Edited?.Invoke(this, new EditEventArgs(mCurrentHairLength));
            };

            var allPoints = new List <DataPoint>();

            foreach (var l in mController.GetCharts())
            {
                allPoints.AddRange(l.Points);
            }

            if (allPoints.Any())
            {
                //Y Axis
                var maxY = allPoints.Max(p => p.Y) + 5;
                var minY = allPoints.Min(p => p.Y) - 5;

                var yAxis = new LinearAxis()
                {
                    Position = AxisPosition.Right, Minimum = minY, Maximum = maxY, StringFormat = "00cm"
                };

                //X Axis
                var minX  = allPoints.Min(p => p.X) - 3;
                var maxX  = allPoints.Max(p => p.X) + 3;
                var xAxis = new DateTimeAxis()
                {
                    Position = AxisPosition.Bottom, Minimum = minX, Maximum = maxX, StringFormat = "dd.MM.yy"
                };

                mModel.Axes.Add(yAxis);
                mModel.Axes.Add(xAxis);
            }

            foreach (var l in mController.GetCharts())
            {
                var ls = new LineSeries();
                ls.TrackerFormatString   = "{4}cm";
                ls.MarkerType            = MarkerType.Circle;
                ls.MarkerStrokeThickness = 3;
                ls.TouchStarted         += Ls_TouchStarted;
                ls.Title           = l.Name;
                ls.SelectionMode   = OxyPlot.SelectionMode.Single;
                ls.StrokeThickness = 4;
                ls.Points.AddRange(l.Points);
                ls.Color = l.Color;

                mModel.Series.Add(ls);
            }
            mModel.IsLegendVisible = false;

            var lengths = mController.GetLengths().OrderBy(x => x.Day);

            foreach (var hl in lengths)
            {
                var image = new HairLengthImage(hairbl, hl)
                {
                    Source = hl.Picture,
                };
                image.Clicked += Image_Clicked;
                mPictContainer.Children.Add(image);
            }

            mScrollContainer = new ScrollView
            {
                Orientation   = ScrollOrientation.Horizontal,
                Content       = mPictContainer,
                HeightRequest = 100,
            };

            if (lengths.Any())
            {
                FillData(lengths.Last());
                SelectImage((HairLengthImage)mPictContainer.Children.Last());
                SelectAllPoints(lengths.Last());
            }


            Padding         = new Thickness(0, 0, 0, 0);
            VerticalOptions = LayoutOptions.FillAndExpand;
            BackgroundColor = Color.Transparent;
            this.Content    = new StackLayout
            {
                BackgroundColor = Color.Transparent,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        =
                {
                    new Frame
                    {
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        CornerRadius    = 4,
                        Content         = new StackLayout
                        {
                            VerticalOptions = LayoutOptions.FillAndExpand,
                            Children        =
                            {
                                new PlotView
                                {
                                    Model             = mModel,
                                    VerticalOptions   = LayoutOptions.FillAndExpand,
                                    HorizontalOptions = LayoutOptions.Fill,
                                },
                                mScrollContainer
                            }
                        }
                    },
                    new Frame
                    {
                        CornerRadius = 4,
                        Content      = GetDataFields()
                    }
                }
            };
        }
Beispiel #2
0
 private void SelectImage(HairLengthImage image)
 {
     image.Select();
     image.Focus();
     mScrollContainer.ScrollToAsync(image.X, 0, true);
 }