91 lines
5.6 KiB
C#
91 lines
5.6 KiB
C#
// Copyright (c) 2017 schick Informatik
|
|
// Description: Control für die Auftragsbearbeitung (Rahmen)
|
|
//
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Controls;
|
|
|
|
using bsmd.database;
|
|
using ENI2.DetailViewControls;
|
|
|
|
namespace ENI2
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for DetailRootControl.xaml
|
|
/// </summary>
|
|
public partial class DetailRootControl : UserControl
|
|
{
|
|
private MessageCore _core;
|
|
private List<MessageGroup> _listBoxList = new List<MessageGroup>();
|
|
private List<Message> _messages;
|
|
|
|
public DetailRootControl(MessageCore aCore)
|
|
{
|
|
_core = aCore;
|
|
InitializeComponent();
|
|
shipNameLabel.Content = aCore.Shipname;
|
|
displayIdLabel.Content = aCore.DisplayId;
|
|
|
|
// Listbox befüllen
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textOverview, MessageGroupControlType = typeof(OverViewDetailControl), ImagePath = "Resources/documents.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textPortCall, MessageGroupControlType = typeof(PortCallDetailControl), ImagePath = "Resources/eye_blue.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textPortNotification, MessageGroupControlType = typeof(PortNotificationDetailControl), ImagePath = "Resources/anchor.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textWaste, MessageGroupControlType = typeof(WasteDetailControl), ImagePath = "Resources/garbage.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textArrivalNotification, MessageGroupControlType = typeof(ArrivalNotificationDetailControl), ImagePath = "Resources/arrow_down_right_red.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textSecurity, MessageGroupControlType = typeof(SecurityDetailControl), ImagePath = "Resources/shield_yellow.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textPSC72h, MessageGroupControlType = typeof(PSC72hDetailControl), ImagePath = "Resources/alarmclock.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textMDH, MessageGroupControlType = typeof(MaritimeHealthDeclarationDetailControl), ImagePath = "Resources/medical_bag.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDepartureNotification, MessageGroupControlType = typeof(DepartureNotificationDetailControl), ImagePath = "Resources/arrow_up_right_green.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textShipData, MessageGroupControlType = typeof(ShipDataDetailControl), ImagePath = "Resources/containership.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textBorderPolice, MessageGroupControlType = typeof(BorderPoliceDetailControl), ImagePath = "Resources/policeman_german.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDGArrival, MessageGroupControlType = typeof(DangerousGoodsDetailControl), ImagePath = "Resources/sign_warning_radiation.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDGDeparture, MessageGroupControlType = typeof(DangerousGoodsDetailControl), ImagePath = "Resources/sign_warning_radiation.png" });
|
|
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textTowage, MessageGroupControlType = typeof(TowageDetailControl), ImagePath = "Resources/ship2.png" });
|
|
|
|
|
|
this.listBoxMessages.ItemsSource = this._listBoxList;
|
|
|
|
_messages = DBManager.Instance.GetMessagesForCore(_core, DBManager.MessageLoad.ALL);
|
|
Dispatcher.BeginInvoke((Action)(() => this.listBoxMessages.SelectedIndex = 0));
|
|
}
|
|
|
|
#region class MessageGroup
|
|
|
|
/// <summary>
|
|
/// Klasse um ein Element der Listbox darzustellen (notwendig für das Databinding)
|
|
/// </summary>
|
|
public class MessageGroup
|
|
{
|
|
public Type MessageGroupControlType { get; set; }
|
|
public string MessageGroupName { get; set; }
|
|
public string ImagePath { get; set; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
private void listBoxMessages_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
if(listBoxMessages.SelectedItem != null)
|
|
{
|
|
MessageGroup mg = this.listBoxMessages.SelectedItem as MessageGroup;
|
|
// create control instance for display:
|
|
DetailBaseControl detailControl = (DetailBaseControl) Activator.CreateInstance(mg.MessageGroupControlType);
|
|
detailControl.Core = _core;
|
|
detailControl.Messages = _messages;
|
|
detailControl.JumpToListElementRequest += (index) => {
|
|
if((index >= 0) && (index < _listBoxList.Count))
|
|
{
|
|
this.listBoxMessages.SelectedIndex = index;
|
|
}
|
|
};
|
|
detailControl.Initialize();
|
|
// plug it in ;-)
|
|
detailView.Children.Clear();
|
|
detailView.Children.Add(detailControl);
|
|
}
|
|
}
|
|
}
|
|
}
|