Skip to content

Commit

Permalink
Merge pull request #88 from opensky-to/simple-type-add
Browse files Browse the repository at this point in the history
Simple type add
  • Loading branch information
sushiat authored Dec 13, 2023
2 parents 4c912fd + 7c17970 commit 863d890
Show file tree
Hide file tree
Showing 9 changed files with 954 additions and 199 deletions.
1 change: 1 addition & 0 deletions OpenSky.Agent.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ OpenSky project ${CurrentDate.Year}
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/GrammarAndSpelling/GrammarChecking/Exceptions/=MOD_0020commands_0020visibility_002E/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=apptoken/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Autobrake/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=AUTOBRAKES/@EntryIndexedValue">True</s:Boolean>
Expand Down
8 changes: 8 additions & 0 deletions OpenSky.Agent/OpenSky.Agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
<Compile Include="Tools\VisibilityAnimation.cs" />
<Compile Include="Tools\WindowExtensions.cs" />
<Compile Include="UserSessionService.cs" />
<Compile Include="Views\AddAircraft.xaml.cs">
<DependentUpon>AddAircraft.xaml</DependentUpon>
</Compile>
<Compile Include="Views\FlightTracking.xaml.cs">
<DependentUpon>FlightTracking.xaml</DependentUpon>
</Compile>
Expand All @@ -176,6 +179,7 @@
<Compile Include="Views\LoginNotification.xaml.cs">
<DependentUpon>LoginNotification.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Models\AddAircraftViewModel.cs" />
<Compile Include="Views\Models\FlightTrackingViewModel.cs" />
<Compile Include="Views\Models\FlightTrackingViewModel.CustomModules.cs" />
<Compile Include="Views\Models\FlightTrackingViewModel.FuelTanks.cs" />
Expand Down Expand Up @@ -237,6 +241,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\AddAircraft.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\FlightTracking.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
69 changes: 69 additions & 0 deletions OpenSky.Agent/Views/AddAircraft.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!--
====================================================================================================================
<copyright file="AddAircraft.xaml" company="OpenSky">
OpenSky project 2021-2023
</copyright>
<summary>
Add aircraft window
</summary>
====================================================================================================================
-->

<controls:OpenSkyWindow x:Class="OpenSky.Agent.Views.AddAircraft"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:OpenSky.Agent.Controls"
xmlns:models="clr-namespace:OpenSky.Agent.Views.Models"
xmlns:ui="http://schemas.modernwpf.com/2019"
mc:Ignorable="d" d:DesignWidth="600" Loaded="AddAircraftLoaded"
Title="Add Aircraft" Height="500" Width="600" HorizontalScrollBar="False" VerticalScrollBar="False" LoadingText="{Binding LoadingText}">
<Window.DataContext>
<models:AddAircraftViewModel CloseWindow="ViewModelCloseWindow" />
</Window.DataContext>
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<GroupBox Grid.Row="0">
<GroupBox.Header>
<TextBlock FontSize="15" FontWeight="DemiBold">Aircraft identification</TextBlock>
</GroupBox.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Vertical" Margin="10">
<TextBlock FontSize="16">Aircraft currently loaded in the sim identified as:</TextBlock>
<TextBlock FontSize="22" Text="{Binding IdentifiedAircraftInfo}" />
</StackPanel>
<Button Grid.Column="1" Margin="5,0,10,0" Command="{Binding IdentifyAircraftCommand}" Style="{StaticResource OpenSkyButtonStyle}">Refresh</Button>
</Grid>
</GroupBox>
<GroupBox Grid.Row="1">
<GroupBox.Header>
<TextBlock FontSize="15" FontWeight="DemiBold">Add new aircraft</TextBlock>
</GroupBox.Header>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0">Name</TextBlock>
<TextBox Grid.Row="1" Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ui:ControlHelper.PlaceholderText="Name of the aircraft and any type identifiers" ui:ControlHelper.PlaceholderForeground="#666" />
<TextBlock Grid.Row="2" Margin="0,10,0,0">Comments</TextBlock>
<TextBox Grid.Row="3" AcceptsReturn="True" Text="{Binding Comments, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" ui:ControlHelper.PlaceholderText="Mod name and version and anything else you deem important for the moderation team." ui:ControlHelper.PlaceholderForeground="#666" />
<StackPanel Grid.Row="4" Margin="0,10,0,0" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource OpenSkyButtonStyle}" Command="{Binding AddAircraftTypeCommand}">Add aircraft</Button>
<Button Margin="5,0,0,0" Style="{StaticResource OpenSkyRedButtonStyle}" Command="{Binding CancelCommand}">Cancel</Button>
</StackPanel>
</Grid>
</GroupBox>
</Grid>
</controls:OpenSkyWindow>
110 changes: 110 additions & 0 deletions OpenSky.Agent/Views/AddAircraft.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AddAircraft.xaml.cs" company="OpenSky">
// OpenSky project 2021-2023
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace OpenSky.Agent.Views
{
using System.Windows;

using OpenSky.Agent.Views.Models;

/// -------------------------------------------------------------------------------------------------
/// <content>
/// Simple add aircraft window for users.
/// </content>
/// -------------------------------------------------------------------------------------------------
public partial class AddAircraft
{
/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="AddAircraft"/> class.
/// </summary>
/// <remarks>
/// sushi.at, 12/12/2023.
/// </remarks>
/// -------------------------------------------------------------------------------------------------
private AddAircraft()
{
this.InitializeComponent();
}

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// The single instance of this view.
/// </summary>
/// -------------------------------------------------------------------------------------------------
private static AddAircraft Instance { get; set; }

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Open the add aircraft view or bring the existing instance into view.
/// </summary>
/// <remarks>
/// sushi.at, 23/03/2021.
/// </remarks>
/// -------------------------------------------------------------------------------------------------
public static void Open()
{
if (Instance == null)
{
if (!UserSessionService.Instance.IsUserLoggedIn)
{
LoginNotification.Open();
return;
}

Instance = new AddAircraft();
Instance.Closed += (_, _) => Instance = null;
Instance.Show();
}
else
{
Instance.BringIntoView();
Instance.Activate();
}
}

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Add aircraft on loaded.
/// </summary>
/// <remarks>
/// sushi.at, 12/12/2023.
/// </remarks>
/// <param name="sender">
/// Source of the event.
/// </param>
/// <param name="e">
/// Routed event information.
/// </param>
/// -------------------------------------------------------------------------------------------------
private void AddAircraftLoaded(object sender, RoutedEventArgs e)
{
if (this.DataContext is AddAircraftViewModel viewModel)
{
viewModel.ViewReference = this;
}
}

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// View model fired close window event.
/// </summary>
/// <remarks>
/// sushi.at, 13/12/2023.
/// </remarks>
/// <param name="sender">
/// Source of the event.
/// </param>
/// <param name="e">
/// An object to process.
/// </param>
/// -------------------------------------------------------------------------------------------------
private void ViewModelCloseWindow(object sender, object e)
{
this.Close();
}
}
}
4 changes: 2 additions & 2 deletions OpenSky.Agent/Views/AircraftTypes.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace OpenSky.Agent.Views

/// -------------------------------------------------------------------------------------------------
/// <content>
/// Plane identity collector window.
/// Aircraft types management window.
/// </content>
/// -------------------------------------------------------------------------------------------------
public partial class AircraftTypes
Expand All @@ -41,7 +41,7 @@ private AircraftTypes()

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Open the plane identity collector view or bring the existing instance into view.
/// Open the aircraft type management view or bring the existing instance into view.
/// </summary>
/// <remarks>
/// sushi.at, 23/03/2021.
Expand Down
Loading

0 comments on commit 863d890

Please sign in to comment.