Skip to content

Commit

Permalink
Merge pull request #252 from jannikbecker/staging
Browse files Browse the repository at this point in the history
Version 1.2.0
  • Loading branch information
jannikbecker authored May 15, 2024
2 parents 4912d6f + a489ef3 commit 6c05467
Show file tree
Hide file tree
Showing 32 changed files with 613 additions and 529 deletions.
1 change: 1 addition & 0 deletions Leibit.BLL/InitializationBLL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ private void __ResolveDuplicates(List<Schedule> schedules)
var Duplicate = schedules.FirstOrDefault(s => s.Train == Schedule.Train
&& s.Track == Schedule.Track
&& s.Handling != eHandling.Start
&& s.Arrival <= Schedule.Departure
&& __AreSchedulesClose(s, Schedule)
&& s != Schedule);

Expand Down
2 changes: 1 addition & 1 deletion Leibit.BLL/Leibit.BLL.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
Expand Down
31 changes: 20 additions & 11 deletions Leibit.BLL/LiveDataBLL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ private void __RefreshTrainInformation(TrainInformation Train, Block Block, ESTW
if (Block != null)
{
// Dummy track for stations without platforms (e.g. Üst)
if (!Estw.SchedulesLoaded || Block.Track.Name.IsNullOrEmpty())
if (!Estw.SchedulesLoaded || Block.Track.Name == null)
{
Train.Block = Block;
}
Expand All @@ -629,22 +629,31 @@ private void __RefreshTrainInformation(TrainInformation Train, Block Block, ESTW
{
Track LiveTrack = null;

// Too difficult to explain -> LTA...
if (CurrentSchedule.Schedule.Track == null
|| !CurrentSchedule.Schedule.Track.IsPlatform
|| CurrentSchedule.Schedule.Track.Name.Equals(Block.Track.Name, StringComparison.InvariantCultureIgnoreCase)
|| (CurrentSchedule.Schedule.Track.Alternatives.Count == 0 && CurrentSchedule.Schedule.Track.Parent.Alternatives.Count == 0)
|| CurrentSchedule.Schedule.Track.Alternatives.Any(a => a.Name.Equals(Block.Track.Name, StringComparison.InvariantCultureIgnoreCase)))
/** Imagine this station layout for the following examples
*
* -----<|-----1A-----<|>-----1B-----|>-----
* -----<|-----2A-----<|>-----2B-----|>-----
* -----<|-------------3-------------|>-----
* -----<|-------------4-------------|>-----
*
*/

if (CurrentSchedule.Schedule.Track == null // special or misdirected trains
|| !CurrentSchedule.Schedule.Track.IsPlatform // Abzw/Üst
|| CurrentSchedule.Schedule.Track.Name.Equals(Block.Track.Name, StringComparison.InvariantCultureIgnoreCase) // Normal case
|| (CurrentSchedule.Schedule.Track.Alternatives.Count == 0 && CurrentSchedule.Schedule.Track.Parent.Alternatives.Count == 0) // No alternatives defined
|| CurrentSchedule.Schedule.Track.Alternatives.Any(a => a.Name.Equals(Block.Track.Name, StringComparison.InvariantCultureIgnoreCase))) // Schedule = 3, Block = 4 => LiveTrack = 4
{
LiveTrack = Block.Track;
}
else if (CurrentSchedule.Schedule.Track.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase)
|| CurrentSchedule.Schedule.Track.Alternatives.Any(a => a.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase)))
else if (CurrentSchedule.Schedule.Track.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase) // Schedule = 1, Block = 1A => LiveTrack = 1
|| CurrentSchedule.Schedule.Track.Alternatives.Any(a => a.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase))) // Schedule = 1, Block = 2A => LiveTrack = 2
{
LiveTrack = Block.Track.Parent;
}
else if (CurrentSchedule.Schedule.Track.Parent.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase)
|| CurrentSchedule.Schedule.Track.Parent.Alternatives.Any(a => a.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase)))
// These conditions must be evaluated after the second block, otherwise those case won't work.
else if (/*CurrentSchedule.Schedule.Track.Parent.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase) || */ // Schedule = 1A, Block = 1B, => LiveTrack = 1B ==> That seems wrong
CurrentSchedule.Schedule.Track.Parent.Alternatives.Any(a => a.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase))) // Schedule = 1A, Block = 2A => LiveTrack = 2A -OR- Schedule = 1A, Block = 2B => LiveTrack = 2B
{
LiveTrack = Block.Track;
}
Expand Down
19 changes: 1 addition & 18 deletions Leibit.BLL/SerializationBLL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;

namespace Leibit.BLL
{
Expand Down Expand Up @@ -209,23 +208,7 @@ public OperationResult<SerializationContainer> Open(string Filename)
SerializedRoot Root;

var json = File.ReadAllText(Filename);

if (json.StartsWith("{"))
{
Root = JsonConvert.DeserializeObject<SerializedRoot>(json, m_SerializerSettings);
Container.FileFormat = Entities.eFileFormat.JSON;
}
else
{
using (var stream = File.OpenRead(Filename))
{
var formatter = new BinaryFormatter();
#pragma warning disable SYSLIB0011 // Type or member is obsolete
Root = formatter.Deserialize(stream) as SerializedRoot;
#pragma warning restore SYSLIB0011 // Type or member is obsolete
Container.FileFormat = Entities.eFileFormat.Binary;
}
}
Root = JsonConvert.DeserializeObject<SerializedRoot>(json, m_SerializerSettings);

if (Root == null)
throw new OperationFailedException("Invalid file.");
Expand Down
5 changes: 3 additions & 2 deletions Leibit.Client.WPF/Leibit.Client.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<AssemblyName>LeiBIT</AssemblyName>
<TargetFramework>net6.0-windows10.0.17763.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<SccProjectName>SAK</SccProjectName>
Expand All @@ -26,7 +26,8 @@
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
<Version>1.1.1</Version>
<Version>1.2.0</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<PackageProjectUrl>https://github.com/jannikbecker/leibit</PackageProjectUrl>
<RepositoryUrl>https://github.com/jannikbecker/leibit</RepositoryUrl>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand Down
48 changes: 14 additions & 34 deletions Leibit.Client.WPF/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
using Leibit.Client.WPF.Windows.Display.Views;
using Leibit.Client.WPF.Windows.ESTWSelection.ViewModels;
using Leibit.Client.WPF.Windows.ESTWSelection.Views;
using Leibit.Client.WPF.Windows.FileConversion.ViewModels;
using Leibit.Client.WPF.Windows.FileConversion.Views;
using Leibit.Client.WPF.Windows.LocalOrders.ViewModels;
using Leibit.Client.WPF.Windows.LocalOrders.Views;
using Leibit.Client.WPF.Windows.Settings.ViewModels;
Expand Down Expand Up @@ -69,7 +67,6 @@ public class MainViewModel : WindowViewModelBase
private Thread m_RefreshingThread;
private CancellationTokenSource m_CancellationTokenSource;
private string m_CurrentFilename;
private eFileFormat m_CurrentFileFormat;
private bool m_ForceClose;
private SoftwareInfo m_BildFplInfo;
private System.Timers.Timer m_StatusBarMessageTimer;
Expand All @@ -78,7 +75,6 @@ public class MainViewModel : WindowViewModelBase
private CommandHandler m_OpenCommand;
private CommandHandler m_SaveCommand;
private CommandHandler m_SaveAsCommand;
private CommandHandler m_FileConversionCommand;
private CommandHandler m_SettingsCommand;
private CommandHandler m_EstwOnlineCommand;
private CommandHandler m_BildFplCommand;
Expand Down Expand Up @@ -129,7 +125,6 @@ public MainViewModel()
m_OpenCommand = new CommandHandler(__Open, true);
m_SaveCommand = new CommandHandler(__Save, false);
m_SaveAsCommand = new CommandHandler(() => __SaveAs(null), false);
m_FileConversionCommand = new CommandHandler(__ShowFileConversionWindow, true);
m_SettingsCommand = new CommandHandler(__Settings, true);
m_EstwOnlineCommand = new CommandHandler(__StartEstwOnline, true);
m_BildFplCommand = new CommandHandler(__StartBildFpl, IsBildFplInstalled);
Expand Down Expand Up @@ -482,16 +477,6 @@ public ICommand SaveAsCommand
}
#endregion

#region [FileConversionCommand]
public ICommand FileConversionCommand
{
get
{
return m_FileConversionCommand;
}
}
#endregion

#region [SettingsCommand]
public ICommand SettingsCommand
{
Expand Down Expand Up @@ -685,6 +670,9 @@ protected override void OnSourceInitialized(object sender, EventArgs e)
if (windowSettings == null)
return;

if (!System.Windows.Forms.Screen.AllScreens.Any(s => __IsWindowVisibleOnScreen(windowSettings, s)))
return;

window.Left = windowSettings.Left;
window.Top = windowSettings.Top;
window.Width = windowSettings.Width;
Expand Down Expand Up @@ -775,7 +763,6 @@ private void __New(string AreaId)
return;

m_CurrentFilename = null;
m_CurrentFileFormat = eFileFormat.Unknown;
OnPropertyChanged(nameof(CurrentFile));

__ShowEstwSelectionWindow();
Expand All @@ -789,7 +776,7 @@ private void __Open()
return;

var Dialog = new OpenFileDialog();
Dialog.Filter = "LeiBIT-Dateien|*.leibit;*.leibit2|Alle Dateien|*.*";
Dialog.Filter = "LeiBIT-Dateien|*.leibit2|Alle Dateien|*.*";

if (Dialog.ShowDialog() == true)
{
Expand Down Expand Up @@ -983,7 +970,6 @@ private void __Open()
}

m_CurrentFilename = Filename;
m_CurrentFileFormat = OpenResult.Result.FileFormat;
OnPropertyChanged(nameof(CurrentFile));
}
}
Expand All @@ -998,12 +984,6 @@ private void __Save()
return;
}

if (m_CurrentFileFormat == eFileFormat.Binary)
{
__SaveAs(Path.GetFileNameWithoutExtension(m_CurrentFilename) + ".leibit2");
return;
}

var Container = new SerializationContainer();
Container.Area = m_CurrentArea;
Container.VisibleStations = Runtime.VisibleStations.Select(s => new SerializedStation { EstwId = s.ESTW.Id, ShortSymbol = s.ShortSymbol }).ToList();
Expand Down Expand Up @@ -1091,22 +1071,12 @@ private void __SaveAs(string proposedFileName)
}

m_CurrentFilename = Filename;
m_CurrentFileFormat = eFileFormat.JSON;
OnPropertyChanged(nameof(CurrentFile));
__Save();
}
}
#endregion

#region [__ShowFileConversionWindow]
private void __ShowFileConversionWindow()
{
var Window = new FileConversionView();
Window.DataContext = new FileConversionViewModel(Window.Dispatcher);
__OpenChildWindow(Window);
}
#endregion

#region [__Settings]
private void __Settings()
{
Expand Down Expand Up @@ -1782,6 +1752,16 @@ private void __SettingsChanged(object sender, EventArgs e)
}
#endregion

#region [__IsWindowVisibleOnScreen]
private bool __IsWindowVisibleOnScreen(WindowSettings windowSettings, System.Windows.Forms.Screen screen)
{
return windowSettings.Left >= screen.WorkingArea.Left
&& windowSettings.Left <= screen.WorkingArea.Right
&& windowSettings.Top >= screen.WorkingArea.Top
&& windowSettings.Top <= screen.WorkingArea.Bottom;
}
#endregion

#endregion

}
Expand Down
4 changes: 0 additions & 4 deletions Leibit.Client.WPF/Views/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@

<Separator Background="{DynamicResource MenuSeparatorColor}"/>

<MenuItem Header="Dateikonvertierung" Command="{Binding FileConversionCommand}" />

<Separator Background="{DynamicResource MenuSeparatorColor}"/>

<MenuItem Header="Einstellungen..." Command="{Binding SettingsCommand}">
<MenuItem.Icon>
<Image Source="{DynamicResource imgSettings}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal static List<DelayReason> GetDBDelayReasons()
{
new DelayReason(10, "Fahrplanerstellung"),
new DelayReason(12, "Fehldisposition"),
new DelayReason(13, "Vorbereitung (Betrieb)"),
new DelayReason(13, "Vorbereitung"),
new DelayReason(14, "Anfangsverspätung bei Zügen des Netzes"),
new DelayReason(18, "Betriebliches Personal DB"),
new DelayReason(19, "Sonstiges Betriebsdurchführung DB Netz"),
Expand Down Expand Up @@ -68,7 +68,7 @@ internal static List<DelayReason> GetDBDelayReasons()
new DelayReason(90, "Gefährliche Ereignisse"),
new DelayReason(91, "Zugfolge - wegen Vorrang anderer Züge"),
new DelayReason(92, "Zugfolge - betroffener Zug war verspätet"),
new DelayReason(93, "Wende"),
new DelayReason(93, "Umlauf"),
new DelayReason(94, "Anschluss"),
new DelayReason(95, "Flügeln"),
new DelayReason(96, "Anordnung NLZ - Weitere Untersuchungen erforderlich"),
Expand Down
Loading

0 comments on commit 6c05467

Please sign in to comment.