Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat About window like a dialog #139

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.6.2 (Unreleased)

- Fixed rolled log files created with trailing sequence sometimes created on app startup ([#136](https://github.com/tetsuo13/TeamsStatusPub/issues/136))
- Prevent multiple About windows ([#129](https://github.com/tetsuo13/TeamsStatusPub/issues/129))

## 1.6.1 (2024-08-28)

Expand Down
4 changes: 3 additions & 1 deletion src/TeamsStatusPub/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
using Avalonia.Markup.Xaml;
using Microsoft.Extensions.DependencyInjection;
using ReactiveUI;
using TeamsStatusPub.ViewModels;
using TeamsStatusPub.Core.Configuration;
using TeamsStatusPub.Core.Services;
using TeamsStatusPub.Core.Services.AvailabilityHandlers;
using TeamsStatusPub.ViewModels;
using TeamsStatusPub.Views;

namespace TeamsStatusPub;

Expand All @@ -31,6 +32,7 @@ public override void OnFrameworkInitializationCompleted()
collection.ConfigureAppServices();
collection.AddTransient<AppViewModel>();
collection.AddTransient<AboutViewModel>();
collection.AddSingleton<AboutWindow>();

ServiceProvider = collection.BuildServiceProvider();

Expand Down
2 changes: 1 addition & 1 deletion src/TeamsStatusPub/TeamsStatusPub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<PlatformTarget>AnyCPU</PlatformTarget>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
Expand Down
15 changes: 13 additions & 2 deletions src/TeamsStatusPub/ViewModels/AppViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Reactive;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Microsoft.Extensions.DependencyInjection;
using ReactiveUI;
using TeamsStatusPub.Views;

Expand All @@ -15,8 +16,18 @@ public AppViewModel()
{
AboutCommand = ReactiveCommand.Create(() =>
{
var view = new AboutWindow();
view.Show();
// Treat the about window like a dialog: only one instance should
// ever be shown.
var view = App.ServiceProvider.GetRequiredService<AboutWindow>();

if (!view.IsVisible)
{
view.Show();
}
else
{
view.Activate();
}
});

ExitCommand = ReactiveCommand.Create(() =>
Expand Down