Added logic to return to the previously selected tab page on a detail control,

but only if the control has a tab control and the save button was hit. In this case a complete reload happens.
This commit is contained in:
Daniel Schick 2025-03-07 16:04:53 +01:00
parent 83d57328fc
commit d1c131c52b
13 changed files with 99 additions and 19 deletions

View File

@ -192,6 +192,10 @@ namespace ENI2
e.Handled = true;
}
public virtual int SelectedTabIndex { get; set; } = -1;
#endregion
#region event handling for control content changes (signal dirty etc)
protected void RegisterTextboxChange(TextBox textBox, Message.NotificationClass notificationClass)
@ -347,8 +351,6 @@ namespace ENI2
#endregion
#endregion
#region IHighlightControlContainer implementation
public virtual void HighlightErrorMessageContainer()

View File

@ -485,6 +485,7 @@ namespace ENI2
{
Util.UIHelper.SetBusyState();
int currentMainTabIndex = -1;
if (this.detailView.Children[0] is DetailBaseControl currentControl)
{
@ -499,10 +500,24 @@ namespace ENI2
// ggf. hat sich die Ticketnr geändert..
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(currentControl.Core);
}
}
currentMainTabIndex = currentControl.SelectedTabIndex;
}
this.DetailControl_RequestReload(this.Core.Id.Value);
System.Action<int> SetTabAction = (int x) =>
{
// this hopefully happens *after* the view was completely reloaded
if (this.detailView.Children[0] is DetailBaseControl currentNewControl)
{
currentNewControl.SelectedTabIndex = x;
}
};
if (currentMainTabIndex >= 0)
Dispatcher.BeginInvoke(SetTabAction, currentMainTabIndex);
}
}
private void SaveMessage(Message message)
@ -553,6 +568,7 @@ namespace ENI2
{
Util.UIHelper.SetBusyState();
int currentMainTabIndex = -1;
foreach (Message message in this._messages)
{
@ -564,12 +580,27 @@ namespace ENI2
{
// ggf. hat sich die Ticketnr geändert..
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(currentControl.Core);
currentMainTabIndex = currentControl.SelectedTabIndex;
}
this.buttonSaveAll.Visibility = Visibility.Hidden;
this.buttonSave.Visibility = Visibility.Hidden;
}
this.DetailControl_RequestReload(this.Core.Id.Value);
System.Action<int> SetTabAction = (int x) =>
{
// this hopefully happens *after* the view was completely reloaded
if (this.detailView.Children[0] is DetailBaseControl currentNewControl)
{
currentNewControl.SelectedTabIndex = x;
}
};
if(currentMainTabIndex >= 0)
Dispatcher.BeginInvoke(SetTabAction, currentMainTabIndex);
}
}
private void DetailControl_NotificationClassChanged(Message.NotificationClass? notificationClass)

View File

@ -246,6 +246,12 @@ namespace ENI2.DetailViewControls
#endregion
}
public override int SelectedTabIndex
{
get { return this.mainFrame.SelectedIndex; }
set { this.mainFrame.SelectedIndex = value; }
}
#region Grid copy handlers
private void CopyPASDItem_Click(object sender, RoutedEventArgs e)

View File

@ -197,6 +197,12 @@ namespace ENI2.DetailViewControls
this._initialized = true;
}
public override int SelectedTabIndex
{
get { return this.tabControlPositions.SelectedIndex; }
set { this.tabControlPositions.SelectedIndex = value; }
}
#region SetEnabled
public override void SetEnabled(bool enabled)

View File

@ -130,6 +130,12 @@ namespace ENI2.DetailViewControls
}
public override int SelectedTabIndex
{
get { return this.mainFrame.SelectedIndex; }
set { this.mainFrame.SelectedIndex = value; }
}
#region SetEnabled
public override void SetEnabled(bool enabled)

View File

@ -116,6 +116,12 @@ namespace ENI2.DetailViewControls
}
public override int SelectedTabIndex
{
get { return this.mainFrame.SelectedIndex; }
set { this.mainFrame.SelectedIndex = value; }
}
#region SetEnabled
public override void SetEnabled(bool enabled)

View File

@ -187,6 +187,12 @@ namespace ENI2.DetailViewControls
}
public override int SelectedTabIndex
{
get { return this.mainFrame.SelectedIndex; }
set { this.mainFrame.SelectedIndex = value; }
}
#region Waste receipt grid event handler
private async void DataGridWasteReceipt_CreateRequested()

View File

@ -24,7 +24,7 @@
</col:ArrayList>
</UserControl.Resources>
<GroupBox Name="portCallGroupBox" Header="{x:Static p:Resources.text2PortCall}">
<TabControl>
<TabControl x:Name="mainTabControl">
<TabItem Header="{x:Static p:Resources.textTab21}">
<Grid>
<Grid.ColumnDefinitions>

View File

@ -204,15 +204,10 @@ namespace ENI2.SheetDisplayControls
}
private void CheckBoxValidExemption_Checked(object sender, RoutedEventArgs e)
public override int SelectedTabIndex
{
bool on = !(this.checkBoxValidExemption.IsChecked ?? false);
this.checkBoxAccurateCorrectDetails.IsEnabled = on;
this.locodeCtrlLastWastePort.IsEnabled = on;
this.datePickerDateLastDisposal.IsEnabled = on;
this.textBoxWasteDisposalServiceProviders.IsEnabled = on;
this.gridWasteControls.IsEnabled = on;
this.dataGridWaste.IsEnabled = on;
get { return this.mainTabControl.SelectedIndex; }
set { this.mainTabControl.SelectedIndex = value; }
}
public override void SetEnabled(bool enabled)
@ -270,7 +265,17 @@ namespace ENI2.SheetDisplayControls
this.RegisterTextboxChange(this.textBoxWasteDisposalServiceProviders, Message.NotificationClass.WAS);
this.RegisterDatePickerChange(this.datePickerDateLastDisposal, Message.NotificationClass.WAS);
}
private void CheckBoxValidExemption_Checked(object sender, RoutedEventArgs e)
{
bool on = !(this.checkBoxValidExemption.IsChecked ?? false);
this.checkBoxAccurateCorrectDetails.IsEnabled = on;
this.locodeCtrlLastWastePort.IsEnabled = on;
this.datePickerDateLastDisposal.IsEnabled = on;
this.textBoxWasteDisposalServiceProviders.IsEnabled = on;
this.gridWasteControls.IsEnabled = on;
this.dataGridWaste.IsEnabled = on;
}
private void buttonSearchPortArea_Click(object sender, RoutedEventArgs e)

View File

@ -12,7 +12,7 @@
mc:Ignorable="d"
d:DesignHeight="1050" d:DesignWidth="800">
<GroupBox Name="shipDataGroupBox" Header="{x:Static p:Resources.text3PreArrival}">
<TabControl>
<TabControl x:Name="mainTabControl">
<TabItem Header="{x:Static p:Resources.textTab51}">
<Grid>
<Grid.ColumnDefinitions>

View File

@ -123,6 +123,12 @@ namespace ENI2.SheetDisplayControls
this.shipDataGroupBox.IsEnabled = enabled;
}
public override int SelectedTabIndex
{
get { return this.mainTabControl.SelectedIndex; }
set { this.mainTabControl.SelectedIndex = value; }
}
#endregion
#region event handler

View File

@ -13,7 +13,7 @@
d:DesignHeight="1150" d:DesignWidth="800">
<GroupBox Name="voyageGroupBox" Header="{x:Static p:Resources.textVoyage}">
<TabControl>
<TabControl x:Name="mainTabControl">
<TabItem Header="{x:Static p:Resources.textTab11}">
<ScrollViewer PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
<Grid>

View File

@ -199,6 +199,12 @@ namespace ENI2.SheetDisplayControls
this.voyageGroupBox.IsEnabled = enabled;
}
public override int SelectedTabIndex
{
get { return this.mainTabControl.SelectedIndex; }
set { this.mainTabControl.SelectedIndex = value; }
}
#endregion
#region event handler