コード例 #1
0
        async void ExecuteAddPerkAsync(object obj)
        {
            var nav = DependencyService.Get <INavigationService>();

            var vm = new AddPerkViewModel(this);

            await nav.Navigate(vm);
        }
コード例 #2
0
        async void ExecuteEditPerkAsync(object obj)
        {
            var vm = obj as AddPerkViewModel;

            if (vm != null)
            {
                var edit = new AddPerkViewModel(this, vm.GetModel());
                var nav  = DependencyService.Get <INavigationService>();
                await nav.Navigate(edit);
            }
        }
コード例 #3
0
        void OnPerkSaved(AddPerkViewModel obj)
        {
            var match = this.Perks.FirstOrDefault(x => x.Id == obj.Id);

            if (match != null)
            {
                var idx = this.Perks.IndexOf(match);

                this.Perks.RemoveAt(idx);
                this.Perks.Insert(idx, obj);
            }
            else if (obj.Vehicle == this)
            {
                this.Perks.Add(obj);
            }

            this.RaiseAllPropertiesChanged();
        }
コード例 #4
0
        // restore data
        public AddVehicleViewModel(AddTeamViewModel team, UserVehicle userVehicle) : this(team)
        {
            this.Id   = userVehicle.Id;
            this.Name = userVehicle.VehicleName;

            this.VehicleType = new SelectVehicleViewModel(this, userVehicle.VehicleType);

            //this.SelectedVehicleType = this.VehicleTypes.FirstOrDefault(x => x.vtype == userVehicle.VehicleType?.vtype);

            this.Weapons.Clear();
            foreach (var w in userVehicle.Weaposn)
            {
                var vm = new AddWeaponViewModel(this, w);
                this.Weapons.Add(vm);
            }

            this.Perks.Clear();
            foreach (var p in userVehicle.Perks)
            {
                var vm = new AddPerkViewModel(this, p);
                this.Perks.Add(vm);
            }

            this.Upgrades.Clear();
            foreach (var u in userVehicle.Upgrades)
            {
                var vm = new AddUpgradeViewModel(this, u);
                this.Upgrades.Add(vm);
            }

            this.Trailers.Clear();
            foreach (var t in userVehicle.Trailers)
            {
                var vm = new AddTrailerViewModel(this, t.Trailer, t.Cargo);
                this.Trailers.Add(vm);

                // run trailer support logic
                this.AddTrailerSupport();
            }

            // todo: restore
        }