88 lines
2.6 KiB
C#
88 lines
2.6 KiB
C#
using BreCalClient.misc.Model;
|
|
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
|
|
namespace BreCalClient
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for EditShipDialog.xaml
|
|
/// </summary>
|
|
public partial class EditShipDialog : Window
|
|
{
|
|
public EditShipDialog()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public Ship Ship { get; set; } = new();
|
|
|
|
public List<Participant> Participants { get; } = new List<Participant>();
|
|
|
|
private void buttonCancel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.DialogResult = false;
|
|
this.Close();
|
|
}
|
|
|
|
private void buttonOK_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
this.Ship.Name = this.textBoxName.Text.ToUpper().Trim();
|
|
|
|
if (this.comboBoxParticipants.SelectedItem != null)
|
|
{
|
|
this.Ship.ParticipantId = ((Participant)this.comboBoxParticipants.SelectedItem).Id;
|
|
this.Ship.IsTug = true;
|
|
}
|
|
else
|
|
{
|
|
this.Ship.IsTug = false;
|
|
}
|
|
this.Ship.Imo = this.integerUpDownIMO.Value;
|
|
this.Ship.Callsign = this.textBoxCallsign.Text.ToUpper().Trim();
|
|
this.Ship.Length = this.doubleUpDownLength.Value;
|
|
this.Ship.Width = this.doubleUpDownWidth.Value;
|
|
this.DialogResult = true;
|
|
this.Close();
|
|
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
this.DataContext = this.Ship;
|
|
this.comboBoxParticipants.ItemsSource = this.Participants;
|
|
|
|
if(this.Ship.ParticipantId != null)
|
|
{
|
|
foreach(Participant p in this.Participants)
|
|
{
|
|
if(this.Ship.ParticipantId == p.Id)
|
|
this.comboBoxParticipants.SelectedItem = p;
|
|
}
|
|
}
|
|
this.EnableOK();
|
|
}
|
|
|
|
private void buttonResetParticipant_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.comboBoxParticipants.SelectedItem = null;
|
|
}
|
|
|
|
private void textBoxName_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
|
{
|
|
this.EnableOK();
|
|
}
|
|
|
|
private void integerUpDownIMO_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
|
{
|
|
this.EnableOK();
|
|
}
|
|
|
|
private void EnableOK()
|
|
{
|
|
this.buttonOK.IsEnabled = (this.textBoxName.Text.Length > 2) && (this.integerUpDownIMO.Value.HasValue);
|
|
}
|
|
}
|
|
}
|