コード例 #1
0
        private async Task Init()
        {
            _viewModel = new CountyDetailsViewModel();
            await _viewModel.GetCounties();

            _viewModel.GetChapters();

            var lblCounty = new Label
            {
                VerticalOptions = LayoutOptions.Center,
                Text            = "Judet:"
            };

            _pickerCounties = new Picker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            foreach (var county in _viewModel.CountyList)
            {
                _pickerCounties.Items.Add(county.Key);
            }
            _pickerCounties.SelectedIndexChanged += pickerCounties_SelectedIndexChanged;

            var lblChapter = new Label
            {
                VerticalOptions = LayoutOptions.Center,
                Text            = "Indicator:"
            };

            _pickerChapters = new Picker()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            foreach (var chapter in _viewModel.ChapterList)
            {
                _pickerChapters.Items.Add(chapter.Key);
            }
            _pickerChapters.SelectedIndexChanged += pickerChapters_SelectedIndexChanged;

            await LoadData();

            degChapterData                   = new GridControl();
            degChapterData.IsReadOnly        = true;
            degChapterData.HorizontalOptions = LayoutOptions.FillAndExpand;
            degChapterData.VerticalOptions   = LayoutOptions.FillAndExpand;
            degChapterData.Columns.Add(new TextColumn()
            {
                Caption = "An", FieldName = "Year", IsReadOnly = true, AllowSort = DefaultBoolean.False
            });
            degChapterData.Columns.Add(new TextColumn()
            {
                Caption = "Luna", FieldName = "YearFraction", IsReadOnly = true, AllowSort = DefaultBoolean.False
            });
            var valueColumn = new TextColumn()
            {
                FieldName  = "Value",
                IsReadOnly = true,
                AllowSort  = DefaultBoolean.False
            };

            valueColumn.SetBinding(TextColumn.CaptionProperty, new Binding("ValueColumnCaption", source: _viewModel));
            degChapterData.Columns.Add(valueColumn);
            degChapterData.ItemsSource = _viewModel.ChapterDataReversed;

            plotView = new PlotView();
            plotView.HorizontalOptions = LayoutOptions.FillAndExpand;
            plotView.VerticalOptions   = LayoutOptions.FillAndExpand;
            plotView.Model             = new PlotModel();
            var series = new LineSeries();

            series.ItemsSource = _viewModel.ChapterData;
            plotView.Model.Series.Add(series);

            dataControls = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Children          = { degChapterData, plotView }
            };

            this.Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding         = new Thickness(
                    left: 0,
                    right: 0,
                    bottom: 0,
                    top: Device.OnPlatform(iOS: 20, Android: 0, WinPhone: 0)),
                Children =
                {
                    new StackLayout()
                    {
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Orientation       = StackOrientation.Horizontal,
                        Children          =
                        {
                            lblCounty, _pickerCounties
                        }
                    },
                    new StackLayout()
                    {
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Orientation       = StackOrientation.Horizontal,
                        Children          =
                        {
                            lblChapter, _pickerChapters
                        }
                    },
                    //degChapterData,
                    //plotView
                    dataControls
                }
            };

            _pickerCounties.SelectedIndex = 0;
            _pickerChapters.SelectedIndex = 0;
        }
コード例 #2
0
        private async Task Init()
        {
            _viewModel = new CountyDetailsViewModel();
            await _viewModel.GetCounties();

            _viewModel.GetChapters();

            var lblCounty = new Label
            {
                VerticalOptions = LayoutOptions.Center,
                Text            = "Judet:"
            };

            _pickerCounties = new PickerWithNoSpellCheck()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            foreach (var county in _viewModel.CountyList)
            {
                _pickerCounties.Items.Add(county.Key);
            }

            var lblCompare = new Label
            {
                VerticalOptions = LayoutOptions.Center,
                Text            = "compara cu"
            };

            _pickerCounties2 = new PickerWithNoSpellCheck()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            _pickerCounties2.Items.Add("──────");
            foreach (var county in _viewModel.CountyList)
            {
                _pickerCounties2.Items.Add(county.Key);
            }

            var lblChapter = new Label
            {
                VerticalOptions = LayoutOptions.Center,
                Text            = "Indicator:"
            };

            _pickerChapters = new PickerWithNoSpellCheck()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            foreach (var chapter in _viewModel.ChapterList)
            {
                _pickerChapters.Items.Add(chapter.Key);
            }

            degChapterData                   = new GridControl();
            degChapterData.IsReadOnly        = true;
            degChapterData.HorizontalOptions = LayoutOptions.FillAndExpand;
            degChapterData.VerticalOptions   = LayoutOptions.FillAndExpand;
            degChapterData.Columns.Add(new TextColumn()
            {
                Caption = "An", FieldName = "Year", IsReadOnly = true, AllowSort = DefaultBoolean.False
            });
            degChapterData.Columns.Add(new TextColumn()
            {
                Caption = "Luna", FieldName = "YearFraction", IsReadOnly = true, AllowSort = DefaultBoolean.False
            });
            var valueColumn = new TextColumn()
            {
                FieldName  = "Value",
                IsReadOnly = true,
                AllowSort  = DefaultBoolean.False
            };

            valueColumn.SetBinding(TextColumn.CaptionProperty, new Binding("ValueColumnCaption", source: _viewModel));
            degChapterData.Columns.Add(valueColumn);
            var valueColumn2 = new TextColumn()
            {
                FieldName  = "Value2",
                IsReadOnly = true,
                AllowSort  = DefaultBoolean.False
            };

            valueColumn2.SetBinding(TextColumn.CaptionProperty, new Binding("Value2ColumnCaption", source: _viewModel));
            valueColumn2.SetBinding(TextColumn.IsVisibleProperty, new Binding("Value2ColumnVisibility", source: _viewModel));
            degChapterData.Columns.Add(valueColumn2);
            degChapterData.ItemsSource = _viewModel.ChapterDataReversed;
            degChapterData.RowTap     += degChapterData_RowTap;

            plotView = new PlotView();
            plotView.HorizontalOptions = LayoutOptions.FillAndExpand;
            plotView.VerticalOptions   = LayoutOptions.FillAndExpand;
            plotView.Model             = new PlotModel();
            var series = new LineSeries();

            series.ItemsSource = _viewModel.ChapterData;
            plotView.Model.Series.Add(series);
            plotView.Model.Title     = "Evolutie indicator";
            plotView.BackgroundColor = Color.FromRgb(51, 51, 51);

            dataControls = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Spacing           = 0,
                Children          = { degChapterData, plotView }
            };

            this.Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding         = new Thickness(
                    left: 0,
                    right: 0,
                    bottom: 0,
                    top: Device.OnPlatform(iOS: 20, Android: 5, WinPhone: 0)),
                Children =
                {
                    new StackLayout()
                    {
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Orientation       = StackOrientation.Horizontal,
                        Padding           = new Thickness(0, 2),
                        Children          =
                        {
                            lblCounty, _pickerCounties, lblCompare, _pickerCounties2
                        }
                    },
                    new StackLayout()
                    {
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Orientation       = StackOrientation.Horizontal,
                        Children          =
                        {
                            lblChapter, _pickerChapters
                        }
                    },
                    //degChapterData,
                    //plotView
                    dataControls
                }
            };

            _pickerCounties.SelectedIndex    = Settings.County1;
            _pickerCounties2.SelectedIndex   = Settings.County2;
            _pickerChapters.SelectedIndex    = Settings.Chapter;
            degChapterData.SelectedRowHandle = -1;

            _pickerCounties.SelectedIndexChanged  += pickerCounties_SelectedIndexChanged;
            _pickerCounties2.SelectedIndexChanged += _pickerCounties2_SelectedIndexChanged;
            _pickerChapters.SelectedIndexChanged  += pickerChapters_SelectedIndexChanged;

            await LoadData();
        }