Skip to content

Commit

Permalink
test adding installer version
Browse files Browse the repository at this point in the history
  • Loading branch information
the-database committed Nov 5, 2023
1 parent 8639b0b commit e570d25
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 23 deletions.
2 changes: 2 additions & 0 deletions AnimeJaNaiConverterGui/AnimeJaNaiConverterGui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<Version>0.0.6</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -27,6 +28,7 @@
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.5" />
<PackageReference Include="Clowd.Squirrel" Version="3.0.210-g5f9f594" />
<PackageReference Include="HyperText.Avalonia" Version="11.0.0-rc1" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down
27 changes: 8 additions & 19 deletions AnimeJaNaiConverterGui/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,26 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
using ReactiveUI;
using Squirrel;
using System.Threading.Tasks;

namespace AnimeJaNaiConverterGui
{
public partial class App : Application
{
public override void Initialize()
{
SquirrelAwareApp.HandleEvents();
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
public override async void OnFrameworkInitializationCompleted()
{
//if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
//{
// desktop.MainWindow = new MainWindow
// {
// DataContext = new MainWindowViewModel(),
// };
//}

//base.OnFrameworkInitializationCompleted();
// Create the AutoSuspendHelper.
//if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
//{
var suspension = new AutoSuspendHelper(ApplicationLifetime);
RxApp.SuspensionHost.CreateNewAppState = () => new MainWindowViewModel();
RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("appstate.json"));
suspension.OnFrameworkInitializationCompleted();
//}
var suspension = new AutoSuspendHelper(ApplicationLifetime);
RxApp.SuspensionHost.CreateNewAppState = () => new MainWindowViewModel();
RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("appstate.json"));
suspension.OnFrameworkInitializationCompleted();


// Load the saved view model state.
var state = RxApp.SuspensionHost.GetAppState<MainWindowViewModel>();
new MainWindow { DataContext = state }.Show();
Expand Down
18 changes: 18 additions & 0 deletions AnimeJaNaiConverterGui/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
Expand All @@ -34,6 +35,16 @@ public MainWindowViewModel()
private CancellationTokenSource? _cancellationTokenSource;
private Process? _runningProcess = null;

public string AppVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString(3);

private bool _autoUpdate = true;
[DataMember]
public bool AutoUpdateEnabled
{
get => _autoUpdate;
set => this.RaiseAndSetIfChanged(ref _autoUpdate, value);
}

private int _selectedTabIndex;
[DataMember]
public int SelectedTabIndex
Expand Down Expand Up @@ -227,6 +238,13 @@ public bool ShowConsole
set => this.RaiseAndSetIfChanged(ref _showConsole, value);
}

private bool _showAppSettings = false;
public bool ShowAppSettings
{
get => _showAppSettings;
set => this.RaiseAndSetIfChanged(ref _showAppSettings, value);
}

private string _inputStatusText = string.Empty;
public string InputStatusText
{
Expand Down
48 changes: 45 additions & 3 deletions AnimeJaNaiConverterGui/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainWindowViewModel/>
</Design.DataContext>

<Grid>
<DockPanel>

<StackPanel DockPanel.Dock="Bottom">

<StackPanel Orientation="Horizontal">
Expand Down Expand Up @@ -78,7 +77,13 @@
<materialIcons:MaterialIcon Kind="Console" VerticalAlignment="Center" />
<TextBlock Margin="5,0,5,0" VerticalAlignment="Center">Console</TextBlock>
</StackPanel>
</ToggleButton>

<ToggleButton FontSize="10" Margin="5,0,5,0" IsChecked="{Binding ShowAppSettings}">
<StackPanel Orientation="Horizontal">
<materialIcons:MaterialIcon Kind="Gear" VerticalAlignment="Center" />
<TextBlock Margin="5,0,5,0" VerticalAlignment="Center">App Settings</TextBlock>
</StackPanel>
</ToggleButton>
</StackPanel>

Expand All @@ -87,7 +92,7 @@
</StackPanel>


<ScrollViewer HorizontalScrollBarVisibility="Auto">
<ScrollViewer HorizontalScrollBarVisibility="Auto" IsVisible="{Binding !ShowAppSettings}">
<StackPanel Margin="20">
<TextBlock FontWeight="Bold" Text="Video Input and Output"></TextBlock>
<Border Classes="border">
Expand Down Expand Up @@ -291,4 +296,41 @@
</StackPanel>
</ScrollViewer>
</DockPanel>

<!-- Settings Overlay -->
<StackPanel IsVisible="{Binding ShowAppSettings}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,30">
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="20">
<DockPanel>
<TextBlock DockPanel.Dock="Left" FontWeight="Bold" Text="App Settings"></TextBlock>

</DockPanel>

<Border Classes="border">
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="10,10,0,10">
<CheckBox IsChecked="{Binding AutoUpdateEnabled}">Auto Update</CheckBox>
<TextBlock Foreground="Gray" FontSize="12" VerticalAlignment="Center" Margin="20,0,0,0">
Whether to automatically check for and install app updates.
</TextBlock>
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="10,10,0,10">
<TextBlock Text="Current Version" VerticalAlignment="Center"></TextBlock>
<TextBlock VerticalAlignment="Center" FontFamily="Consolas" Text="{Binding AppVersion}" Margin="20,0,0,0"></TextBlock>
<hypertext:Hyperlink VerticalAlignment="Center" Margin="20,0,0,0" Url="https://github.com/the-database/AnimeJaNaiConverterGui/releases"/>
</StackPanel>
</StackPanel>
</Border>

<Border Classes="border">
<ToggleButton DockPanel.Dock="Right" Margin="10,10,0,10" IsChecked="{Binding !ShowAppSettings}">
<StackPanel Orientation="Horizontal">
<materialIcons:MaterialIcon Kind="ArrowBackCircle" />
<TextBlock Margin="5,0,0,0">Return</TextBlock>
</StackPanel>
</ToggleButton>
</Border>
</StackPanel>
</StackPanel>
</Grid>
</Window>
27 changes: 27 additions & 0 deletions AnimeJaNaiConverterGui/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Avalonia.ReactiveUI;
using Material.Icons.Avalonia;
using ReactiveUI;
using Squirrel;
using System;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -59,6 +60,15 @@ private async void MainWindow_Closing(object? sender, WindowClosingEventArgs e)
Close();
}
}
else
{
using var mgr = new UpdateManager("https://github.com/the-database/AnimeJaNaiConverterGui/releases");
if (!mgr.IsInstalledApp)
{
return;
}
var newVersion = await mgr.UpdateApp();
}
}
}

Expand Down Expand Up @@ -104,6 +114,23 @@ private void MainWindow_Resized(object? sender, WindowResizedEventArgs e)

private async void OpenInputFileButtonClick(object? sender, RoutedEventArgs e)
{


// Get the resources
var resources = Application.Current.Resources;
foreach (var resourceKey in resources.Keys)
{
var resourceValue = resources[resourceKey];


//if (resourceValue.HasDynamicResource())
//{
// // This resource has a dynamic reference
// Console.WriteLine($"Resource '{resourceKey}' is a dynamic resource.");
//}
}


// Get top level from the current control. Alternatively, you can use Window reference instead.
var topLevel = TopLevel.GetTopLevel(this);

Expand Down
2 changes: 1 addition & 1 deletion AnimeJaNaiConverterGui/app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embeded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="AnimeJaNaiConverterGui.Desktop"/>
<assemblyIdentity version="0.0.6.0" name="AnimeJaNaiConverterGui.Desktop"/>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
Expand Down

0 comments on commit e570d25

Please sign in to comment.