semesterWork/Presence.Desktop/Views/GroupView.axaml.cs
2024-12-13 08:47:52 +03:00

56 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Platform.Storage;
using Avalonia.ReactiveUI;
using data;
using data.Repository;
using domain.Service;
using Microsoft.Extensions.DependencyInjection;
using Presence.Desktop.DI;
using Presence.Desktop.ViewModels;
using ReactiveUI;
namespace Presence.Desktop.Views
{
public partial class GroupView : Window
{
public GroupView()
{
InitializeComponent();
}
private void SelectingItemsControl_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
if (DataContext is GroupViewModel viewModel)
{
viewModel.UpdateSelectionStates();
}
}
private void SwapToPresences(object? sender, RoutedEventArgs e)
{
try
{
var serviceCollection = new ServiceCollection();
serviceCollection.AddPresenceService();
var services = serviceCollection.BuildServiceProvider();
var presenceViewModel = services.GetRequiredService<PresenceViewModel>();
var window = new PresenceView
{
DataContext = presenceViewModel
};
window.Show();
}
catch (Exception ex)
{
}
}
}
}