Skip to content

Commit

Permalink
added whatsnew function
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyeao committed Jul 29, 2023
1 parent 8c9346c commit fa6a8b3
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 2 deletions.
3 changes: 3 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<setting name="UpdateSettings" serializeAs="String">
<value>True</value>
</setting>
<setting name="LastSeenVersion" serializeAs="String">
<value />
</setting>
</Elite_Dangerous_Addon_Launcer_V2.Properties.Settings>
</userSettings>
</configuration>
4 changes: 2 additions & 2 deletions Elite Dangerous Addon Launcher V2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<RootNamespace>Elite_Dangerous_Addon_Launcer_V2</RootNamespace>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<AssemblyVersion>1.1.2.329</AssemblyVersion>
<FileVersion>1.1.2.329</FileVersion>
<AssemblyVersion>1.1.2.335</AssemblyVersion>
<FileVersion>1.1.2.335</FileVersion>
<ApplicationIcon>elite-dangerous-icon.ico</ApplicationIcon>
<PackageIcon>app.png</PackageIcon>
<PackageProjectUrl>https://github.com/jimmyeao/Elite-Dangerous-Addon-Launcher-V2</PackageProjectUrl>
Expand Down
61 changes: 61 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace Elite_Dangerous_Addon_Launcer_V2
Expand Down Expand Up @@ -356,6 +357,65 @@ private void Btn_Edit_Click(object sender, RoutedEventArgs e)
addAppWindow.ShowDialog();
}
}
public void ShowWhatsNewIfUpdated()
{
// Get the current assembly version.
var assemblyVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

// Get the last seen version from the application settings.
var lastSeenVersion = Properties.Settings.Default.LastSeenVersion;

// If the last seen version is empty (which it will be the first time this method is run)
// or if the assembly version is greater than the last seen version, show the what's new dialog.
if (string.IsNullOrEmpty(lastSeenVersion) || new Version(lastSeenVersion) < assemblyVersion)
{
ShowWhatsNew();

// Update the last seen version in the application settings.
Properties.Settings.Default.LastSeenVersion = assemblyVersion.ToString();

// Save the application settings.
Properties.Settings.Default.Save();
}
}

public void ShowWhatsNew()
{
WhatsNewWindow whatsNewWindow = new WhatsNewWindow();

// Set the text to what's new
Paragraph titleParagraph = new Paragraph();
titleParagraph.Inlines.Add(new Bold(new Run("New for this version")));
whatsNewWindow.WhatsNewText.Document.Blocks.Add(titleParagraph);

List list = new List();

ListItem listItem1 = new ListItem(new Paragraph(new Run("Launch Options For Elite")));
list.ListItems.Add(listItem1);

ListItem listItem2 = new ListItem(new Paragraph(new Run("Profile Options for import/export and copy/rename/delete")));
list.ListItems.Add(listItem2);

ListItem listItem3 = new ListItem(new Paragraph(new Run("Added themed dialogs")));
list.ListItems.Add(listItem3);

ListItem listItem4 = new ListItem(new Paragraph(new Run("Fly safe, Cmdr! o7")));
list.ListItems.Add(listItem4);

whatsNewWindow.WhatsNewText.Document.Blocks.Add(list);

whatsNewWindow.Owner = this; // Set owner to this MainWindow
whatsNewWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; // Center the window over its owner

whatsNewWindow.ShowDialog();
}








private void Btn_Launch_Click(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -577,6 +637,7 @@ private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
CheckEdLaunchInProfile();
_isChecking = false;
}
ShowWhatsNewIfUpdated();
}

private void ModifyTheme(Uri newThemeUri)
Expand Down
12 changes: 12 additions & 0 deletions 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 Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
<Setting Name="UpdateSettings" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="LastSeenVersion" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
39 changes: 39 additions & 0 deletions WhatsNew.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Window x:Class="Elite_Dangerous_Addon_Launcer_V2.WhatsNewWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Elite_Dangerous_Addon_Launcer_V2"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
Title="What's New"
Width="600"
Height="400"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="14"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}">
<materialDesign:Card>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<RichTextBox x:Name="WhatsNewText"
Grid.Row="0"
IsReadOnly="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
Margin="10">
<FlowDocument/>
</RichTextBox>

<Button x:Name="CloseButton"
Grid.Row="1"
Content="Close"
Margin="10"
HorizontalAlignment="Right"
Click="Bt_Close_Click"/>
</Grid>
</materialDesign:Card>
</Window>
31 changes: 31 additions & 0 deletions WhatsNew.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Elite_Dangerous_Addon_Launcer_V2
{
/// <summary>
/// Interaction logic for WhatsNew.xaml
/// </summary>
public partial class WhatsNewWindow : Window
{
public WhatsNewWindow()
{
InitializeComponent();
}
private void Bt_Close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

0 comments on commit fa6a8b3

Please sign in to comment.