Skip to content

Commit

Permalink
1.2.0 (#13)
Browse files Browse the repository at this point in the history
* Font selection for map overlay text
  • Loading branch information
o4oren authored Jun 23, 2023
1 parent f58b66d commit abb2db4
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 75 deletions.
3 changes: 3 additions & 0 deletions FSTRaK/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<setting name="IsStartAutomatically" serializeAs="String">
<value>True</value>
</setting>
<setting name="FontName" serializeAs="String">
<value>Slopes</value>
</setting>
</FSTRaK.Properties.Settings>
</userSettings>
<connectionStrings>
Expand Down
6 changes: 2 additions & 4 deletions FSTRaK/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<FontFamily x:Key="Slopes">pack://application:,,,/Resources/Fonts/#Slopes</FontFamily>
</ResourceDictionary>
<ResourceDictionary Source="Resources/ButtonsTheme.xaml" />
<ResourceDictionary Source="Resources/Theme.xaml" />
<ResourceDictionary Source="Resources/ButtonsTheme.xaml" />
<ResourceDictionary Source="Resources/Images.xaml" />
<ResourceDictionary Source="Resources/MapProvidersDictionary.xaml"/>
<ResourceDictionary Source="Resources/AircraftIconsDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
<FontFamily x:Key="Slopes">pack://application:,,,/Resources/Fonts/#Slopes</FontFamily>
<BooleanToVisibilityConverter x:Key="BoolToVis" />
</ResourceDictionary>
</Application.Resources>
Expand Down
5 changes: 4 additions & 1 deletion FSTRaK/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ void OnApplicationStart(object sender, StartupEventArgs args)
}
});

var airportResolver = AirportResolver.Instance;
// Set font according to settings
FontUtil.SetFont(FSTRaK.Properties.Settings.Default.FontName);

var airportResolver = AirportResolver.Instance;

}

Expand Down
1 change: 1 addition & 0 deletions FSTRaK/FSTRaK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
<Compile Include="Models\FlightManager\State\TaxiInState.cs" />
<Compile Include="Models\FlightManager\State\TaxiOutState.cs" />
<Compile Include="RelayCommand.cs" />
<Compile Include="Utils\FontUtil.cs" />
<Compile Include="Utils\HyperlinkText.cs" />
<Compile Include="Utils\MapProviderResolver.cs" />
<Compile Include="Utils\MathUtils.cs" />
Expand Down
1 change: 1 addition & 0 deletions FSTRaK/FSTrAk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
<Compile Include="Models\FlightManager\State\TaxiInState.cs" />
<Compile Include="Models\FlightManager\State\TaxiOutState.cs" />
<Compile Include="RelayCommand.cs" />
<Compile Include="Utils\FontUtil.cs" />
<Compile Include="Utils\HyperlinkText.cs" />
<Compile Include="Utils\MapProviderResolver.cs" />
<Compile Include="Utils\MathUtils.cs" />
Expand Down
4 changes: 2 additions & 2 deletions FSTRaK/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: NeutralResourcesLanguage("en")]
14 changes: 13 additions & 1 deletion FSTRaK/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions FSTRaK/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@
<Setting Name="IsStartAutomatically" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="FontName" Type="System.String" Scope="User">
<Value Profile="(Default)">Slopes</Value>
</Setting>
</Settings>
</SettingsFile>
21 changes: 13 additions & 8 deletions FSTRaK/Resources/Theme.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF" xmlns:system="clr-namespace:System;assembly=mscorlib">


<!-- Font params -->
<system:String x:Key="ThemeFontName">Slopes</system:String>


<!--Pallete-->
<Color x:Key="PrimaryBright">#F2F5F8</Color>
Expand Down Expand Up @@ -234,7 +239,7 @@
Margin="5,5,10,5"
FontSize="34"
FontWeight="Bold"
FontFamily="{StaticResource Slopes}"
FontFamily="{DynamicResource Slopes}"
Foreground="{StaticResource UnselectedTextColor}"/>
</Border>
</Grid>
Expand Down Expand Up @@ -274,7 +279,7 @@
Foreground="{StaticResource BrightTextColor}"
FontSize="24"
Margin="7"
FontFamily="{StaticResource Slopes}"
FontFamily="{DynamicResource Slopes}"
TextWrapping="Wrap"
MinWidth="200"/>
</Grid>
Expand Down Expand Up @@ -322,7 +327,7 @@
x:Key="FSTrAkLabel">
<Style.Setters>
<Setter Property="Background" Value="Transparent" />
<Setter Property="FontFamily" Value="{StaticResource Slopes}"/>
<Setter Property="FontFamily" Value="{DynamicResource Slopes}"/>
<Setter Property="FontSize" Value="28" />
<Setter Property="Foreground" Value="{StaticResource TextColor}" />
</Style.Setters>
Expand Down Expand Up @@ -457,7 +462,7 @@
</ContentPresenter>
<TextBox x:Name="PART_EditableTextBox"
Style="{x:Null}"
FontFamily="{StaticResource Slopes}"
FontFamily="{DynamicResource Slopes}"
Template="{StaticResource ComboBoxTextBox}"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Expand Down Expand Up @@ -526,7 +531,7 @@
<Setter Property="SnapsToDevicePixels"
Value="true" />
<Setter Property="FontFamily"
Value="{StaticResource Slopes}" />
Value="{DynamicResource Slopes}" />
<Setter Property="FontSize"
Value="20" />
<Setter Property="OverridesDefaultStyle"
Expand Down Expand Up @@ -646,7 +651,7 @@
Margin="10 0 10 0"
BorderThickness="0"
BorderBrush="Transparent"
FontFamily="{StaticResource Slopes}" FontSize="22" Foreground="{StaticResource TextColor}"
FontFamily="{DynamicResource Slopes}" FontSize="22" Foreground="{StaticResource TextColor}"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text, UpdateSourceTrigger=PropertyChanged}"

/>
Expand Down Expand Up @@ -692,7 +697,7 @@
</Style>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="Background" Value="White" />
<Setter Property="FontFamily" Value="{StaticResource Slopes}" />
<Setter Property="FontFamily" Value="{DynamicResource Slopes}" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Foreground" Value="{StaticResource TextColor}" />
<Setter Property="Template">
Expand Down
32 changes: 32 additions & 0 deletions FSTRaK/Utils/FontUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FSTRaK.Utils
{
internal class FontUtil
{
public static void SetFont(string fontName)
{
var themeDictionary = System.Windows.Application.Current.Resources.MergedDictionaries[0];
themeDictionary.Remove("ThemeFontName");
themeDictionary.Remove("HeaderFontSize");
themeDictionary.Remove("TextFontSize");

if (fontName == "Slopes")
{
themeDictionary.Add("ThemeFontName", fontName);
themeDictionary.Add("HeaderFontSize", 18.0);
themeDictionary.Add("TextFontSize", 22.0);
}
else if (fontName == "Arial")
{
themeDictionary.Add("ThemeFontName", fontName);
themeDictionary.Add("HeaderFontSize", 14.0);
themeDictionary.Add("TextFontSize", 17.0);
}
}
}
}
20 changes: 20 additions & 0 deletions FSTRaK/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,25 @@ public bool IsStartAutomatically
}
}



public ObservableCollection<string> Fonts { get; set; } = new ObservableCollection<string>(new []{"Slopes", "Arial"});
private string _fontName = "Slopes";
public string FontName
{
get => _fontName;
set
{
if (value != null && value != _fontName)
{
_fontName = value;
FontUtil.SetFont(_fontName);
Properties.Settings.Default.FontName = _fontName;
OnPropertyChanged();
}
}
}

public SettingsViewModel() : base()
{
var mapProviders = new ResourceDictionary();
Expand Down Expand Up @@ -196,6 +215,7 @@ public void OnLoaded()
IsStartMinimized = Properties.Settings.Default.IsStartMinimized;
IsMinimizeToTray = Properties.Settings.Default.IsMinimizeToTray;
IsStartAutomatically = Properties.Settings.Default.IsStartAutomatically;
FontName = Properties.Settings.Default.FontName;
}
}
}
12 changes: 6 additions & 6 deletions FSTRaK/Views/FlightDetailsParamsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
d:DataContext="{d:DesignInstance Type=viewModels:FlightDetailsParamsViewModel}"
d:DesignHeight="450" d:DesignWidth="800">
<StackPanel>
<local:OverlayTextCardControl Header="Aircraft:" Text="{Binding Aircraft}" Visibility="Visible"/>
<local:OverlayTextCardControl Header="Aircraft" Text="{Binding Aircraft}" Visibility="Visible"/>

<Grid
Margin="5"
Expand All @@ -29,19 +29,19 @@
/>
<Label Grid.Row="0"
Foreground="{StaticResource BrightTextColor}"
FontSize="18"
Margin="2"
FontFamily="{StaticResource Slopes}"
FontSize="{DynamicResource HeaderFontSize}"
Margin="5"
FontFamily="{DynamicResource {StaticResource ThemeFontName}}"
Content="Flight Data"
HorizontalAlignment="Left"
VerticalAlignment="Center"
/>
<TextBlock
Grid.Row="1"
Foreground="{StaticResource BrightTextColor}"
FontSize="22"
FontSize="{DynamicResource TextFontSize}"
Margin="5"
FontFamily="{StaticResource Slopes}"
FontFamily="{DynamicResource {StaticResource ThemeFontName}}"
TextWrapping="Wrap"
Text="{Binding ElementName=OverlayTextCard, Path=Text}"
HorizontalAlignment="Left"
Expand Down
2 changes: 1 addition & 1 deletion FSTRaK/Views/FlightDetailsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<map:MapItem Location="{Binding Location}">
<Canvas Width="50" Height="80">
<Path Data="M 0,0 L 50,0 50,50 25,80 0,50 0,0" Fill="{Binding Color}" Stroke="Wheat" StrokeThickness="2" Width="50"/>
<TextBlock FontSize="14" Foreground="White" Margin="5" TextAlignment="Center" FontFamily="{StaticResource Slopes}" Text="{Binding Text}"/>
<TextBlock FontSize="14" Foreground="White" Margin="5" TextAlignment="Center" FontFamily="{DynamicResource Slopes}" Text="{Binding Text}"/>
</Canvas>
</map:MapItem>
</ControlTemplate>
Expand Down
10 changes: 5 additions & 5 deletions FSTRaK/Views/LogbookView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontFamily="{StaticResource Slopes}" FontSize="20" Foreground="{StaticResource TextColor}">
<TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" FontFamily="{DynamicResource Slopes}" FontSize="20" Foreground="{StaticResource TextColor}">
<Run Text="{Binding DepartureAirport, Mode=OneTime}"/>
</TextBlock>
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" FontFamily="{StaticResource Slopes}" FontSize="16" Foreground="{StaticResource TextColor}">
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" FontFamily="{DynamicResource Slopes}" FontSize="16" Foreground="{StaticResource TextColor}">
<Run Text="{Binding StartTime, Mode=OneTime}"/>
</TextBlock>

Expand All @@ -140,16 +140,16 @@
</Path>
</ContentControl>

<TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Left" FontFamily="{StaticResource Slopes}" FontSize="20" Foreground="{StaticResource TextColor}">
<TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Left" FontFamily="{DynamicResource Slopes}" FontSize="20" Foreground="{StaticResource TextColor}">
<Run Text="{Binding ArrivalAirport, Mode=OneTime}"/>
</TextBlock>
<TextBlock Grid.Column="2" Grid.Row="1" HorizontalAlignment="Left" FontFamily="{StaticResource Slopes}" FontSize="16" Foreground="{StaticResource TextColor}">
<TextBlock Grid.Column="2" Grid.Row="1" HorizontalAlignment="Left" FontFamily="{DynamicResource Slopes}" FontSize="16" Foreground="{StaticResource TextColor}">
<Run Text="{Binding EndTime, Mode=OneTime}"/>
</TextBlock>
</Grid>

<TextBlock
FontFamily="{StaticResource Slopes}" FontSize="20" Foreground="{StaticResource TextColor}">
FontFamily="{DynamicResource Slopes}" FontSize="20" Foreground="{StaticResource TextColor}">
<Run Text="{Binding FlightDistanceNm, StringFormat=N2}"/> NM / <Run Text="{Binding FlightTime}"/>
<LineBreak />
<Run Text="{Binding Path=Aircraft.Manufacturer}"/> <Run Text="{Binding Path=Aircraft.AircraftType}"/>, <Run Text="{Binding Path=Aircraft.TailNumber}"/>
Expand Down
2 changes: 1 addition & 1 deletion FSTRaK/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<Canvas Width="128" Height="47" >
<StaticResource ResourceKey="logo"/>
</Canvas>
<Label FontSize="30" FontWeight="Bold" Foreground="{StaticResource TextColor}" FontFamily="{StaticResource Slopes}" HorizontalAlignment="Center" VerticalAlignment="Center">FSTrAk</Label>
<Label FontSize="30" FontWeight="Bold" Foreground="{StaticResource TextColor}" FontFamily="{DynamicResource Slopes}" HorizontalAlignment="Center" VerticalAlignment="Center">FSTrAk</Label>

</StackPanel>
</Border>
Expand Down
3 changes: 0 additions & 3 deletions FSTRaK/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,10 @@ private void OnLoad(object sender, RoutedEventArgs e)
ImageLoader.HttpClient.DefaultRequestHeaders.Add("User-Agent", "FSTrAk - Flight Simulator logbook and tracker");
TileImageLoader.Cache = new SQLiteCache(PathUtil.GetApplicationLocalDataPath());



if (Properties.Settings.Default.IsStartMinimized)
{
WindowState = WindowState.Minimized;
}

}

private void ButtonClick_CloseApplication (object sender, RoutedEventArgs e)
Expand Down
10 changes: 5 additions & 5 deletions FSTRaK/Views/OverlayTextCardControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<Label Grid.Row="0"
x:Name="header"
Foreground="{StaticResource BrightTextColor}"
FontSize="18"
Margin="2"
FontFamily="{StaticResource Slopes}"
FontSize="{DynamicResource HeaderFontSize}"
Margin="5"
FontFamily="{DynamicResource {StaticResource ThemeFontName}}"
Content="{Binding ElementName=OpverlayTextCard, Path=Header}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Expand All @@ -37,9 +37,9 @@
x:Name="text"
Grid.Row="1"
Foreground="{StaticResource BrightTextColor}"
FontSize="22"
FontSize="{DynamicResource TextFontSize}"
Margin="5"
FontFamily="{StaticResource Slopes}"
FontFamily="{DynamicResource {StaticResource ThemeFontName}}"
TextWrapping="Wrap"
Text="{Binding ElementName=OpverlayTextCard, Path=Text}"
HorizontalAlignment="Left"
Expand Down
Loading

0 comments on commit abb2db4

Please sign in to comment.