81 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
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)
 | 
						|
        {
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Called by framework when view becomes active
 | 
						|
        /// </summary>
 | 
						|
        /// <returns></returns>
 | 
						|
        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<object>(null);
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// Called by framework when view becomes inactive
 | 
						|
        /// </summary>
 | 
						|
        /// <returns></returns>
 | 
						|
        public override Task OnInactive()
 | 
						|
        {
 | 
						|
            // if(this._eventCancellationTokenSource != null){
 | 
						|
            //     this._eventCancellationTokenSource.Cancel();
 | 
						|
            // }
 | 
						|
            
 | 
						|
            return Task.FromResult<object>(null);
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |