public GenerateFloatingObjectViewModel(BaseViewModel parentViewModel, GenerateFloatingObjectModel dataModel)
            : base(parentViewModel)
        {

            _dataModel = dataModel;
            // Will bubble property change events from the Model to the ViewModel.
            _dataModel.PropertyChanged += (sender, e) => OnPropertyChanged(e.PropertyName);
        }
        public void AddItemExecuted()
        {
            var model = new GenerateFloatingObjectModel();
            var position = new MyPositionAndOrientation(Vector3D.Zero, Vector3.Forward, Vector3.Up);
            var settings = SpaceEngineersCore.WorldResource.Checkpoint.Settings;

            model.Load(position, settings.MaxFloatingObjects);
            var loadVm = new GenerateFloatingObjectViewModel(this, model);
            var result = _dialogService.ShowDialog<WindowGenerateFloatingObject>(this, loadVm);
            if (result == true)
            {
                var newEntities = loadVm.BuildEntities();
                if (loadVm.IsValidItemToImport)
                {
                    for (var i = 0; i < newEntities.Length; i++)
                    {
                        var item = ((MyObjectBuilder_FloatingObject)newEntities[i]).Item;
                        _dataModel.Additem(item);
                    }

                    //  TODO: need to bubble change up to MainViewModel.IsModified = true;
                }
            }
        }
Exemplo n.º 3
0
 public void CreateFloatingItemExecuted()
 {
     var model = new GenerateFloatingObjectModel();
     var position = ThePlayerCharacter != null ? ThePlayerCharacter.PositionAndOrientation.Value : new MyPositionAndOrientation(Vector3D.Zero, Vector3.Forward, Vector3.Up);
     model.Load(position, _dataModel.ActiveWorld.Checkpoint.MaxFloatingObjects);
     var loadVm = new GenerateFloatingObjectViewModel(this, model);
     var result = _dialogService.ShowDialog<WindowGenerateFloatingObject>(this, loadVm);
     if (result == true)
     {
         IsBusy = true;
         var newEntities = loadVm.BuildEntities();
         if (loadVm.IsValidItemToImport)
         {
             _selectNewStructure = true;
             for (var i = 0; i < newEntities.Length; i++)
             {
                 _dataModel.AddEntity(newEntities[i]);
             }
             _selectNewStructure = false;
         }
         IsBusy = false;
     }
 }