72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using System;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Aurora.Design.Views.Party.NewPartyDialog
|
|
{
|
|
public class NewPartyDialogViewModel : BaseDialogViewModel
|
|
{
|
|
public NewPartyDialogViewModel()
|
|
{
|
|
this.ReturnObject = new ConnectionDetails();
|
|
HostCommand = new Command(OnHostExecute, OnHostCanExecute);
|
|
JoinCommand = new Command(OnJoinExecute, OnJoinCanCanExecute);
|
|
}
|
|
|
|
public string Hostname
|
|
{
|
|
get
|
|
{
|
|
if (ReturnObject is ConnectionDetails)
|
|
{
|
|
ConnectionDetails obj = ReturnObject as ConnectionDetails;
|
|
return obj.HostName;
|
|
};
|
|
return string.Empty;
|
|
}
|
|
set
|
|
{
|
|
if (ReturnObject is ConnectionDetails)
|
|
{
|
|
ConnectionDetails obj = ReturnObject as ConnectionDetails;
|
|
if (value != obj.HostName)
|
|
{
|
|
obj.HostName = value;
|
|
}
|
|
|
|
OnPropertyChanged(Hostname);
|
|
HostCommand.ChangeCanExecute();
|
|
JoinCommand.ChangeCanExecute();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void OnHostExecute()
|
|
{
|
|
ConnectionDetails obj = base.ReturnObject as ConnectionDetails;
|
|
obj.ConnectionType = ConnectionType.Host;
|
|
Finish();
|
|
}
|
|
|
|
public Command HostCommand { get; private set; }
|
|
public Command JoinCommand { get; private set; }
|
|
|
|
public bool OnHostCanExecute()
|
|
{
|
|
return string.IsNullOrWhiteSpace(Hostname);
|
|
}
|
|
|
|
public void OnJoinExecute()
|
|
{
|
|
ConnectionDetails obj = base.ReturnObject as ConnectionDetails;
|
|
obj.ConnectionType = ConnectionType.Join;
|
|
Finish();
|
|
}
|
|
|
|
public bool OnJoinCanCanExecute()
|
|
{
|
|
return !string.IsNullOrWhiteSpace(Hostname);
|
|
}
|
|
}
|
|
}
|