2019-05-27 16:23:14 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Xamarin.Forms;
|
|
|
|
|
|
2019-07-05 18:17:09 +00:00
|
|
|
|
namespace Aurora.Design.Components.HostSelector
|
2019-05-27 16:23:14 +00:00
|
|
|
|
{
|
2019-06-26 01:17:52 +00:00
|
|
|
|
public enum ConnectionType
|
|
|
|
|
{
|
|
|
|
|
Host,
|
|
|
|
|
Client,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum SelectorState
|
|
|
|
|
{
|
|
|
|
|
SelectingHost,
|
|
|
|
|
EnteringCredentials,
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:23:14 +00:00
|
|
|
|
public partial class HostSelector : ContentView
|
|
|
|
|
{
|
2019-06-26 01:17:52 +00:00
|
|
|
|
|
2019-05-27 16:23:14 +00:00
|
|
|
|
public HostSelector()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2019-06-26 01:17:52 +00:00
|
|
|
|
//Set initial conditions
|
|
|
|
|
CredentialEditorLayout.IsVisible = true;
|
|
|
|
|
|
|
|
|
|
buttonHost.Clicked += OnButtonHostClicked;
|
|
|
|
|
buttonClient.Clicked += OnButtonClientClicked;
|
|
|
|
|
HostnameEntry.TextChanged += (sender, e) =>
|
|
|
|
|
{
|
|
|
|
|
Hostname = e.NewTextValue;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// On the host button clicked.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender">Sender.</param>
|
|
|
|
|
/// <param name="e">E.</param>
|
|
|
|
|
void OnButtonHostClicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (HostCommand.CanExecute(null))
|
|
|
|
|
{
|
|
|
|
|
HostCommand.Execute(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// On the client button clicked.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender">Sender.</param>
|
|
|
|
|
/// <param name="e">E.</param>
|
|
|
|
|
void OnButtonClientClicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (JoinCommand.CanExecute(null))
|
|
|
|
|
{
|
|
|
|
|
JoinCommand.Execute(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Host Selected Command
|
|
|
|
|
public static readonly BindableProperty HostCommandProperty =
|
|
|
|
|
BindableProperty.Create(propertyName: "HostSelectedCommand",
|
|
|
|
|
returnType: typeof(Command),
|
|
|
|
|
declaringType: typeof(HostSelector));
|
|
|
|
|
|
|
|
|
|
public Command HostCommand
|
|
|
|
|
{
|
|
|
|
|
get { return (Command)GetValue(HostCommandProperty); }
|
|
|
|
|
set { SetValue(HostCommandProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Host Selected Command
|
|
|
|
|
|
|
|
|
|
#region Client Selected Command
|
|
|
|
|
public static readonly BindableProperty JoinCommandProperty =
|
|
|
|
|
BindableProperty.Create(propertyName: "JoinSelectedCommand",
|
|
|
|
|
returnType: typeof(Command),
|
|
|
|
|
declaringType: typeof(HostSelector));
|
|
|
|
|
|
|
|
|
|
public Command JoinCommand
|
|
|
|
|
{
|
|
|
|
|
get { return (Command)GetValue(JoinCommandProperty); }
|
|
|
|
|
set { SetValue(JoinCommandProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Client Selected Command
|
|
|
|
|
|
|
|
|
|
#region Hostname property
|
|
|
|
|
public static readonly BindableProperty HostnameProperty =
|
|
|
|
|
BindableProperty.Create(propertyName: "Hostname",
|
|
|
|
|
returnType: typeof(string),
|
|
|
|
|
declaringType: typeof(HostSelector),
|
|
|
|
|
defaultBindingMode: BindingMode.TwoWay,
|
|
|
|
|
propertyChanged: OnHostNameChanged);
|
|
|
|
|
|
|
|
|
|
public string Hostname
|
|
|
|
|
{
|
|
|
|
|
get { return (string)GetValue(HostnameProperty); }
|
|
|
|
|
set { SetValue(HostnameProperty, value); }
|
2019-05-27 16:23:14 +00:00
|
|
|
|
}
|
2019-06-26 01:17:52 +00:00
|
|
|
|
|
|
|
|
|
private static void OnHostNameChanged(BindableObject bindable, object oldValue, object newValue)
|
|
|
|
|
{
|
|
|
|
|
string newVal = newValue as string;
|
|
|
|
|
HostSelector instance = bindable as HostSelector;
|
2019-07-05 15:37:44 +00:00
|
|
|
|
if (instance.HostnameEntry.Text != newVal)
|
2019-06-26 01:17:52 +00:00
|
|
|
|
{
|
|
|
|
|
instance.HostnameEntry.Text = newVal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Hostname property
|
|
|
|
|
|
|
|
|
|
|
2019-05-27 16:23:14 +00:00
|
|
|
|
}
|
2019-06-26 01:17:52 +00:00
|
|
|
|
|
2019-05-27 16:23:14 +00:00
|
|
|
|
}
|