Example #1
0
        public DetailGeneralPage(T currItem)
        {
            var dgv = new DetailGeneralView();

            dgv.SetupHandlers(ImageClicked, DelClicked);
            Content = dgv;
            _sl     = dgv.MainStackLayout;


            var currType = typeof(T);

            if (currType == typeof(Operator))
            {
                BindingContext = new DetailVM <Operator>(x => x.Copy(), (x, y) =>
                {
                    x.Name = y.Name;
                    x.CertificationNumber = y.CertificationNumber;
                    x.Note = y.Note;
                })
                {
                    CurrItem = (Operator)((object)currItem)
                };
            }
            else if (currType == typeof(Sprayer))
            {
                BindingContext = new DetailVM <Sprayer>(x => x.Copy(), (x, y) =>
                {
                    x.Name             = y.Name;
                    x.Model            = y.Model;
                    x.Category         = y.Category;
                    x.Tractor          = y.Tractor;
                    x.TractorGear      = y.TractorGear;
                    x.TractorRPM       = y.TractorRPM;
                    x.TankCapacity     = y.TankCapacity;
                    x.TankCapacityUnit = y.TankCapacityUnit;
                    x.NumOfNozzles     = y.NumOfNozzles;
                    x.RefillTime       = y.RefillTime;
                    x.RowTurnTime      = y.RowTurnTime;
                })
                {
                    CurrItem = (Sprayer)((object)currItem)
                };
            }
            else if (currType == typeof(OrchardBlock))
            {
                BindingContext = new DetailVM <OrchardBlock>(x => x.Copy(), (x, y) =>
                {
                    x.Name               = y.Name;
                    x.VarietiesPlanted   = y.VarietiesPlanted;
                    x.RootStock          = y.RootStock;
                    x.YearPlanted        = y.YearPlanted;
                    x.BlockSize          = y.BlockSize;
                    x.BlockSizeUnit      = y.BlockSizeUnit;
                    x.AvgTreeHeight      = y.AvgTreeHeight;
                    x.AvgTreeHeightUnit  = y.AvgTreeHeightUnit;
                    x.AvgCanopyWidth     = y.AvgCanopyWidth;
                    x.AvgCanopyWidthUnit = y.AvgCanopyWidthUnit;
                    x.AvgRowLength       = y.AvgRowLength;
                    x.AvgRowLengthUnit   = y.AvgRowLengthUnit;
                    x.AvgTreeShape       = y.AvgTreeShape;
                })
                {
                    CurrItem = (OrchardBlock)((object)currItem)
                };
            }
            SetupUIForType(currType);


            ToolbarItems.Add(new ToolbarItem("Done", null, () =>
            {
                VM.DoneCmd.Execute(null);
                if (!VM.IsEditing)
                {
                    IssueNeedRefreshData();
                }
                Navigation.PopAsync();
            }));
        }