Exemplo n.º 1
0
        public Step1Page()
        {
            InitializeComponent();

            foreach (var str in OptimizeModeToPickerIdxCov.Names)
            {
                _opMode.Items.Add(str);
            }

            foreach (var str in RowSprayingModeToPickerIdxCov.Names)
            {
                _rowSprayingMode.Items.Add(str);
            }

            BindingContext = App.Container.GetInstance<Step1VM>();

            ViewUtils.SetupStepView(_rLayout, _helpSv, _questionContainer, VM.Common.QuestionTapped);

            var sprayerLP = new ListingPage<Sprayer>(true);
            sprayerLP.ItemChosen += (sender, arg) =>
            {
                VM.CurrSprayer = arg.ChosenItem;
            };
            var sprayerAIO = new AddItemOption()
            {
                CurrItemPropertyName = "CurrSprayer",
                MenuItem = new MenuItem(L10n.Localize("Sprayers", null), () => sprayerLP)
            };

            var orchardBlockLP = new ListingPage<OrchardBlock>(true);
            orchardBlockLP.ItemChosen += (sender, arg) =>
            {
                VM.CurrOrchardBlock = arg.ChosenItem;
            };
            var obAIO = new AddItemOption()
            {
                CurrItemPropertyName = "CurrOrchardBlock",
                MenuItem = new MenuItem("Orchard Blocks", () => orchardBlockLP)
            };

            var opLP = new ListingPage<Operator>(true);
            opLP.ItemChosen += (sender, arg) =>
            {
                VM.CurrOperator = arg.ChosenItem;
            };
            var opAIO = new AddItemOption()
            {
                CurrItemPropertyName = "CurrOperator",
                MenuItem = new MenuItem("Operators", () => opLP)
            };

            var mItems = new List<NPCBase>
            {
                sprayerAIO,
                obAIO,
                opAIO
            };

            _itemList.ItemsSource = mItems;
            _itemList.ItemTemplate = new DataTemplate(() =>
            {
                var vCell = new TextCellWithDisclosure();
                vCell.SetBinding(TextCell.TextProperty, "MenuItem.MenuTitle");
                vCell.SetBinding(TextCell.DetailProperty, "DetailText");
                return vCell;
            });
            _itemList.ItemTapped += (object sender, ItemTappedEventArgs e) =>
            {
                var currAIO = (AddItemOption)(e.Item);

                Navigation.PushAsync(currAIO.MenuItem.RootPage);
                _itemList.SelectedItem = null;
            };
        }
Exemplo n.º 2
0
        public Step1Page()
        {
            InitializeComponent();

            foreach (var str in OptimizeModeToPickerIdxCov.Names)
            {
                _opMode.Items.Add(str);
            }

            foreach (var str in RowSprayingModeToPickerIdxCov.Names)
            {
                _rowSprayingMode.Items.Add(str);
            }

            BindingContext = App.Container.GetInstance <Step1VM>();

            ViewUtils.SetupStepView(_rLayout, _helpSv, _questionContainer, VM.Common.QuestionTapped);

            var sprayerLP = new ListingPage <Sprayer>(true);

            sprayerLP.ItemChosen += (sender, arg) =>
            {
                VM.CurrSprayer = arg.ChosenItem;
            };
            var sprayerAIO = new AddItemOption()
            {
                CurrItemPropertyName = "CurrSprayer",
                MenuItem             = new MenuItem(L10n.Localize("Sprayers", null), () => sprayerLP)
            };

            var orchardBlockLP = new ListingPage <OrchardBlock>(true);

            orchardBlockLP.ItemChosen += (sender, arg) =>
            {
                VM.CurrOrchardBlock = arg.ChosenItem;
            };
            var obAIO = new AddItemOption()
            {
                CurrItemPropertyName = "CurrOrchardBlock",
                MenuItem             = new MenuItem("Orchard Blocks", () => orchardBlockLP)
            };

            var opLP = new ListingPage <Operator>(true);

            opLP.ItemChosen += (sender, arg) =>
            {
                VM.CurrOperator = arg.ChosenItem;
            };
            var opAIO = new AddItemOption()
            {
                CurrItemPropertyName = "CurrOperator",
                MenuItem             = new MenuItem("Operators", () => opLP)
            };

            var mItems = new List <NPCBase>
            {
                sprayerAIO,
                obAIO,
                opAIO
            };

            _itemList.ItemsSource  = mItems;
            _itemList.ItemTemplate = new DataTemplate(() =>
            {
                var vCell = new TextCellWithDisclosure();
                vCell.SetBinding(TextCell.TextProperty, "MenuItem.MenuTitle");
                vCell.SetBinding(TextCell.DetailProperty, "DetailText");
                return(vCell);
            });
            _itemList.ItemTapped += (object sender, ItemTappedEventArgs e) =>
            {
                var currAIO = (AddItemOption)(e.Item);

                Navigation.PushAsync(currAIO.MenuItem.RootPage);
                _itemList.SelectedItem = null;
            };
        }