Exemplo n.º 1
0
        void ExecuteAddTrailer(object obj)
        {
            var vm = new AddTrailerViewModel(this);

            this.CanAddAdditionalTrailers = false;

            DependencyService.Get <INavigationService>().Navigate(vm);
        }
Exemplo n.º 2
0
        async void ExecuteEditTrailer(object obj)
        {
            var vm = obj as AddTrailerViewModel;

            if (vm != null)
            {
                var edit = new AddTrailerViewModel(this, vm.GetModel());
                var nav  = DependencyService.Get <INavigationService>();
                await nav.Navigate(vm);
            }
        }
Exemplo n.º 3
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
        }
Exemplo n.º 4
0
        void OnTrailerSaved(AddTrailerViewModel obj)
        {
            var match = this.Trailers.FirstOrDefault(x => x.Id == obj.Id);

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

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

            (this.AddTrailer as Command).ChangeCanExecute();
            (this.DeleteTrailer as Command).ChangeCanExecute();

            this.RaiseAllPropertiesChanged();
        }