diff --git a/ENI-2/ENI2/ENI2/DetailBaseControl.cs b/ENI-2/ENI2/ENI2/DetailBaseControl.cs
index 2ebf9634..fb503abb 100644
--- a/ENI-2/ENI2/ENI2/DetailBaseControl.cs
+++ b/ENI-2/ENI2/ENI2/DetailBaseControl.cs
@@ -10,12 +10,22 @@ using System.Threading.Tasks;
using System.Windows.Controls;
using bsmd.database;
+using System.Windows.Media.Imaging;
namespace ENI2
{
public class DetailBaseControl : UserControl
{
+ protected enum LocodeState
+ {
+ UNKNOWN,
+ INVALID,
+ OK,
+ AMBIGUOUS
+ }
+
+
#region Properties
public MessageCore Core { get; set; }
@@ -28,6 +38,27 @@ namespace ENI2
public virtual void Initialize() { }
+ protected void SetLocodeStateImage(Image stateImage, LocodeState state)
+ {
+ switch(state)
+ {
+ case LocodeState.AMBIGUOUS:
+ stateImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/bullet_ball_yellow.png"));
+ break;
+ case LocodeState.INVALID:
+ stateImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/bullet_ball_red.png"));
+ break;
+ case LocodeState.OK:
+ stateImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/bullet_ball_green.png"));
+ break;
+ case LocodeState.UNKNOWN:
+ default:
+ stateImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/bullet_ball_grey.png"));
+ break;
+ }
+ }
+
+
#endregion
}
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml
index 5b34f39e..76c9d6a0 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml
@@ -24,7 +24,15 @@
-
+
+
+
+
+
+
+
+
+
@@ -35,8 +43,8 @@
-
-
+
+
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
index 46ce5747..3a217a8a 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
@@ -18,24 +18,40 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using bsmd.database;
-using ENI2;
+using bsmd.ExcelReadService;
+using System.ComponentModel;
namespace ENI2.DetailViewControls
{
///
/// Interaction logic for OverViewDetailControl.xaml
///
- public partial class OverViewDetailControl : DetailBaseControl
+ public partial class OverViewDetailControl : DetailBaseControl, INotifyPropertyChanged
{
private Message _message = null;
+ private List _locodePoCList = new List();
+ private bool _initialized = false;
+
+ public event PropertyChangedEventHandler PropertyChanged;
public OverViewDetailControl()
{
InitializeComponent();
-
-
}
+ public List LocodePoCList
+ {
+ get { return this._locodePoCList; }
+ set { this._locodePoCList = value; }
+ }
+
+ public string PoC
+ {
+ get { return this.Core.PoC; }
+ set { this.Core.PoC = value; }
+ }
+
+
public override void Initialize()
{
Message.NotificationClass notificationClass = this.Core.IsTransit ? Message.NotificationClass.TRANSIT : Message.NotificationClass.VISIT;
@@ -44,9 +60,14 @@ namespace ENI2.DetailViewControls
this.textBoxENI.DataContext = this.Core;
this.textBoxIMO.DataContext = this.Core;
- this.textBoxPoC.DataContext = this.Core;
+ this.comboBoxPoC.DataContext = this;
this.dateTimePickerETA.DataContext = this.Core;
- //this.dateTimePickerETD.DataContext = ..
+ //this.dateTimePickerETD.DataContext = ..
+ if (!this.Core.PoC.IsNullOrEmpty())
+ {
+ this._locodePoCList.Add(this.Core.PoC);
+ LocodeState locodeState = LocodeDB.PortNameFromLocode(this.Core.PoC).IsNullOrEmpty() ? LocodeState.INVALID : LocodeState.OK;
+ }
Binding vtBinding = new Binding();
vtBinding.Source = this.Core;
@@ -68,8 +89,41 @@ namespace ENI2.DetailViewControls
{
}
+ this._initialized = true;
}
-
+ private void ComboBox_TextChanged(object sender, RoutedEventArgs e)
+ {
+ if (!_initialized) return;
+ if(this.comboBoxPoC.Text.Length > 3)
+ {
+ // check if actual locode
+ bool isLocode = !LocodeDB.PortNameFromLocode(this.comboBoxPoC.Text).IsNullOrEmpty();
+ if(isLocode)
+ {
+ this.SetLocodeStateImage(this.imagePoCState, LocodeState.OK);
+ return;
+ }
+
+ // assume this is a harbour name typed out..
+ this.LocodePoCList = LocodeDB.AllLocodesForCityName(this.comboBoxPoC.Text + "%");
+
+ if(this.LocodePoCList.Count == 1)
+ {
+ this.comboBoxPoC.SelectedItem = this.LocodePoCList[0];
+ this.SetLocodeStateImage(this.imagePoCState, LocodeState.OK);
+ }
+ else if(this.LocodePoCList.Count == 0)
+ {
+ this.SetLocodeStateImage(this.imagePoCState, LocodeState.INVALID);
+ }
+ else
+ {
+ this.SetLocodeStateImage(this.imagePoCState, LocodeState.AMBIGUOUS);
+ }
+ }
+
+ this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocodePoCList"));
+ }
}
}
diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj
index 763c985a..60abf26c 100644
--- a/ENI-2/ENI2/ENI2/ENI2.csproj
+++ b/ENI-2/ENI2/ENI2/ENI2.csproj
@@ -15,6 +15,8 @@
4
true
true
+
+
eni2.publish\
true
Web
@@ -33,7 +35,7 @@
3.5.1.0
true
publish.html
- 3
+ 5
3.5.3.%2a
false
true
@@ -96,6 +98,10 @@
+
+ packages\System.Data.SQLite.Core.1.0.105.0\lib\net451\System.Data.SQLite.dll
+ True
+
@@ -148,6 +154,9 @@
Properties\AssemblyProjectKeyInfo.cs
+
+ Locode\LocodeDB.cs
+
DetailRootControl.xaml
@@ -300,6 +309,10 @@
ResXFileCodeGenerator
Resources.Designer.cs
+
+ db.sqlite
+ PreserveNewest
+
@@ -312,7 +325,9 @@
-
+
+ Designer
+
@@ -389,7 +404,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+