public void AddAsset() { GameObject newDevice = Instantiate(devicePrefab, transform); newDevice.GetComponent <Asset> ().active = true; //open modal window linking new prefab modalController.ShowModal(newDevice, true); }
public MainWindowViewModel() { ModalController = new ModalController(); _repo = PackageRepositoryFactory.Default.CreateRepository("https://www.nuget.org/api/v2/"); _random = new Random(); Page = 0; PageSize = 25; HasError = false; Load = ReactiveCommand.CreateAsyncObservable(_ => SearchImpl(Page, PageSize), RxApp.TaskpoolScheduler); Load.ThrownExceptions.Subscribe(HandleSearchError); Load.IsExecuting.ObserveOn(RxApp.MainThreadScheduler).ToPropertyEx(this, x => x.IsBusy); Load.ToReadOnlyList(GetPackageCardViewModel) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.Packages, new List <PackageCardViewModel>().AsReadOnly()); var canNext = this.WhenAny(x => x.IsBusy, busy => !busy.Value); Next = ReactiveCommand.CreateAsyncObservable(canNext, _ => { Page = Page + 1; return(Load.ExecuteAsync()); }); Next.ThrownExceptions.Subscribe(ex => this.Log().Error($"Error occurred: {ex.ToString()}")); var canPrevious = this.WhenAny(x => x.IsBusy, x => x.Page, (busy, page) => !busy.Value && page.Value > 0); Previous = ReactiveCommand.CreateAsyncObservable(canPrevious, _ => { Page = Page - 1; return(Load.ExecuteAsync()); }); Previous.ThrownExceptions.Subscribe(ex => this.Log().Error($"Error occurred: {ex.ToString()}")); ShowDialog = ReactiveCommand.Create(); ShowDialog.Subscribe(_ => ModalController.ShowModal(new FirstModalViewModel())); this.WhenActivated(d => { d(Load.ExecuteAsync().Subscribe()); }); }