70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
using System;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using JD.Core;
|
|
|
|
namespace JD.Remoting.Gui.WPF
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for NewConnectionSettingUserControl.xaml
|
|
/// </summary>
|
|
public partial class NewConnectionSettingUserControl : UserControl
|
|
{
|
|
public EngineConnectionManager EngineConnectionManager { get; set; }
|
|
|
|
public NewConnectionSettingUserControl()
|
|
{
|
|
InitializeComponent();
|
|
_textBoxIP.Clear();
|
|
|
|
foreach (object targetName in Enum.GetValues(typeof(PlatformId)))
|
|
_comboBoxTarget.Items.Add(targetName);
|
|
if (_comboBoxTarget.Items.Count > 0)
|
|
_comboBoxTarget.SelectedIndex = 0;
|
|
|
|
}
|
|
|
|
#region properties
|
|
|
|
private Brush GetColor(bool condition)
|
|
{
|
|
if (condition)
|
|
{
|
|
return Brushes.LightGreen;
|
|
}
|
|
else
|
|
{
|
|
return Brushes.LightCoral;
|
|
}
|
|
}
|
|
|
|
public bool AreSettingsOK
|
|
{
|
|
get
|
|
{
|
|
return EngineConnectionManager.IsAddressValid(_textBoxIP.Text) &&
|
|
EngineConnectionManager.IsPortValid(_textBoxPort.Text);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region handlers
|
|
|
|
private void OnIpAddressTextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
string text = _textBoxIP.Text;
|
|
if (EngineConnectionManager != null)
|
|
_textBoxIP.Background = GetColor(EngineConnectionManager.IsAddressValid(text));
|
|
}
|
|
|
|
private void OnPortTextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
string text = _textBoxPort.Text;
|
|
if (EngineConnectionManager != null)
|
|
_textBoxPort.Background = GetColor(EngineConnectionManager.IsPortValid(text));
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|