using System.Threading.Tasks; using Aurora.Proto.Party; using Aurora.Design.Views.Party.NewPartyDialog; using Aurora.Services.Settings; using Aurora.Services; namespace Aurora.Design.Views.Party { delegate void EventHandler(BaseEvent e); public class PartyViewModel : BasePartyViewModel { public PartyViewModel(ISettingsService settingsService, Global global): base(settingsService, global) { } /// /// Called by framework when view becomes active /// /// public override Task OnActive() { OnPropertyChanged("SelectedTabIndex"); switch(this._global.State) { case PartyState.Hosting: { this.SetView.Invoke(typeof(PartyView), typeof(HostPartyViewModel)); break; } case PartyState.InParty: { // TODO break; } default: { //Open host selection modal NewPartyDialogViewModel vm = new NewPartyDialogViewModel(); ConnectionDetails details = new ConnectionDetails(); vm.Finish = () => { this.HideModal(); details = vm.ReturnObject as ConnectionDetails; this._hostname = details.HostName; switch (details.ConnectionType) { case ConnectionType.Host: { this.SetView.Invoke(typeof(PartyView), typeof(HostPartyViewModel)); break; } case ConnectionType.Join: { // TODO break; } } }; this.ShowModal(typeof(NewPartyDialog.NewPartyDialog), vm); break; } } return Task.FromResult(null); } /// /// Called by framework when view becomes inactive /// /// public override Task OnInactive() { // if(this._eventCancellationTokenSource != null){ // this._eventCancellationTokenSource.Cancel(); // } return Task.FromResult(null); } } }