ENI-2 Locode Control (wie können die bearbeitet werden mit der Locode-DB als Validierung)

This commit is contained in:
Daniel Schick 2017-04-18 08:54:47 +00:00
parent 2a8ee17059
commit a9f8fdbe00
12 changed files with 192 additions and 12 deletions

View File

@ -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
}

View File

@ -24,7 +24,15 @@
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Anlaufhafen" />
<TextBox Name="textBoxPoC" Grid.Row="0" Grid.Column="1" IsReadOnly="True" Text="{Binding PoC}" Margin="2"/>
<Grid Grid.Column="1" Grid.Row="0" Width="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<xctk:WatermarkComboBox Grid.Column="0" x:Name="comboBoxPoC" Margin="2" IsEditable="True" Watermark="Type for Locode.." TextBoxBase.TextChanged="ComboBox_TextChanged" ItemsSource="{Binding LocodePoCList, Mode=TwoWay}" SelectedItem="{Binding PoC, Mode=TwoWay}" />
<Image Name="imagePoCState" Grid.Column="1" Source="../Resources/bullet_ball_grey.png" />
</Grid>
<!--TextBox Name="textBoxPoC" Grid.Row="0" Grid.Column="1" IsReadOnly="True" Text="{Binding PoC}" Margin="2"/-->
<Label Grid.Row="0" Grid.Column="2" Content="Visit/Transit-ID" />
<TextBox Name="textBoxDisplayId" Grid.Row="0" Grid.Column="3" IsReadOnly="True" Margin="2"/>
<Label Grid.Row="1" Grid.Column="0" Content="IMO-Nummer" />
@ -35,8 +43,8 @@
<Label Grid.Row="2" Grid.Column="2" Content="ETD PoC" />
<Label Grid.Row="3" Grid.Column="0" Content="ATA PoC" />
<Label Grid.Row="3" Grid.Column="2" Content="ATD PoC" />
<xctk:DateTimePicker Grid.Column="1" Grid.Row="2" Value="{Binding ETA, Mode=TwoWay}" Name="dateTimePickerETA" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" />
<xctk:DateTimePicker Grid.Column="3" Grid.Row="2" Name="dateTimePickerETD" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" />
<xctk:DateTimePicker Grid.Column="1" Grid.Row="2" Value="{Binding ETA, Mode=TwoWay}" Name="dateTimePickerETA" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2"/>
<xctk:DateTimePicker Grid.Column="3" Grid.Row="2" Name="dateTimePickerETD" Format="Custom" FormatString="dd.MM.yyyy HH:mm" ShowButtonSpinner="False" VerticalContentAlignment="Center" Margin="2"/>
</Grid>
</GroupBox>

View File

@ -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
{
/// <summary>
/// Interaction logic for OverViewDetailControl.xaml
/// </summary>
public partial class OverViewDetailControl : DetailBaseControl
public partial class OverViewDetailControl : DetailBaseControl, INotifyPropertyChanged
{
private Message _message = null;
private List<string> _locodePoCList = new List<string>();
private bool _initialized = false;
public event PropertyChangedEventHandler PropertyChanged;
public OverViewDetailControl()
{
InitializeComponent();
}
public List<string> 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"));
}
}
}

View File

@ -15,6 +15,8 @@
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>true</IsWebBootstrapper>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>eni2.publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Web</InstallFrom>
@ -33,7 +35,7 @@
<MinimumRequiredVersion>3.5.1.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationRevision>5</ApplicationRevision>
<ApplicationVersion>3.5.3.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
@ -96,6 +98,10 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=1.0.105.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>packages\System.Data.SQLite.Core.1.0.105.0\lib\net451\System.Data.SQLite.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
@ -148,6 +154,9 @@
<Compile Include="..\..\..\nsw\Source\bsmd.database\Properties\AssemblyProjectKeyInfo.cs">
<Link>Properties\AssemblyProjectKeyInfo.cs</Link>
</Compile>
<Compile Include="..\..\..\nsw\Source\bsmd.ExcelReadService\LocodeDB.cs">
<Link>Locode\LocodeDB.cs</Link>
</Compile>
<Compile Include="DetailBaseControl.cs" />
<Compile Include="DetailRootControl.xaml.cs">
<DependentUpon>DetailRootControl.xaml</DependentUpon>
@ -300,6 +309,10 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Content Include="..\..\..\nsw\Source\misc\db.sqlite">
<Link>db.sqlite</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="bsmdKey.snk" />
<None Include="ENI2.licenseheader" />
<None Include="ENI2_TemporaryKey.pfx" />
@ -312,7 +325,9 @@
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<SplashScreen Include="SplashScreen.png" />
@ -389,7 +404,26 @@
<ItemGroup>
<Resource Include="Resources\ef_logo.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\bullet_ball_green.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\bullet_ball_grey.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\bullet_ball_red.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\bullet_ball_yellow.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\System.Data.SQLite.Core.1.0.105.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('packages\System.Data.SQLite.Core.1.0.105.0\build\net451\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\System.Data.SQLite.Core.1.0.105.0\build\net451\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\System.Data.SQLite.Core.1.0.105.0\build\net451\System.Data.SQLite.Core.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -100,6 +100,46 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap bullet_ball_green {
get {
object obj = ResourceManager.GetObject("bullet_ball_green", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap bullet_ball_grey {
get {
object obj = ResourceManager.GetObject("bullet_ball_grey", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap bullet_ball_red {
get {
object obj = ResourceManager.GetObject("bullet_ball_red", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap bullet_ball_yellow {
get {
object obj = ResourceManager.GetObject("bullet_ball_yellow", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>

View File

@ -169,4 +169,16 @@
<data name="ef_logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ef_logo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="bullet_ball_green" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bullet_ball_green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="bullet_ball_grey" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bullet_ball_grey.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="bullet_ball_red" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bullet_ball_red.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="bullet_ball_yellow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bullet_ball_yellow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

View File

@ -5,4 +5,5 @@ Sample license text.
<packages>
<package id="Extended.Wpf.Toolkit" version="3.0" targetFramework="net452" />
<package id="log4net" version="2.0.8" targetFramework="net452" />
<package id="System.Data.SQLite.Core" version="1.0.105.0" targetFramework="net452" />
</packages>

Binary file not shown.