public Import3DAsteroidViewModel(BaseViewModel parentViewModel, Import3DAsteroidModel dataModel, IDialogService dialogService, Func<IOpenFileDialog> openFileDialogFactory)
            : base(parentViewModel)
        {
            Contract.Requires(dialogService != null);
            Contract.Requires(openFileDialogFactory != null);

            _dialogService = dialogService;
            _openFileDialogFactory = openFileDialogFactory;
            _dataModel = dataModel;
            // Will bubble property change events from the Model to the ViewModel.
            _dataModel.PropertyChanged += (sender, e) => OnPropertyChanged(e.PropertyName);

            IsMultipleScale = true;
            MultipleScale = 1;
            MaxLengthScale = 100;
            OutsideMaterialDepth = 1;
            IsInfrontofPlayer = true;
            Position = new BindablePoint3DModel();
            BuildDistance = 10;
        }
 public Import3DAsteroidViewModel(BaseViewModel parentViewModel, Import3DAsteroidModel dataModel)
     : this(parentViewModel, dataModel, ServiceLocator.Resolve<IDialogService>(), ServiceLocator.Resolve<IOpenFileDialog>)
 {
 }
예제 #3
0
        public void ImportAsteroidModelExecuted()
        {
            var model = new Import3DAsteroidModel();
            var position = ThePlayerCharacter != null ? ThePlayerCharacter.PositionAndOrientation.Value : new MyPositionAndOrientation(Vector3D.Zero, Vector3.Forward, Vector3.Up);
            model.Load(position);
            var loadVm = new Import3DAsteroidViewModel(this, model);

            var result = _dialogService.ShowDialog<WindowImportAsteroidModel>(this, loadVm);
            if (result == true && loadVm.IsValidEntity)
            {
                IsBusy = true;
                _dataModel.CollisionCorrectEntity(loadVm.NewEntity);
                var structure = _dataModel.AddEntity(loadVm.NewEntity);
                ((StructureVoxelModel)structure).SourceVoxelFilepath = loadVm.SourceFile; // Set the temporary file location of the Source Voxel, as it hasn't been written yet.
                if (_preSelectedStructure != null)
                    SelectedStructure = _preSelectedStructure;

                if (loadVm.SaveWhenFinsihed)
                {
                    _dataModel.SaveCheckPointAndSandBox();
                }

                IsBusy = false;
            }
        }