From 3456af5101c5937c0b89ddfb355c4691fc2f41bf Mon Sep 17 00:00:00 2001 From: KP9lKk Date: Fri, 6 Dec 2024 11:04:11 +0300 Subject: [PATCH] add filepicker --- Presence.Desktop/ViewModels/GroupViewModel.cs | 23 +++++++++++++++++-- Presence.Desktop/Views/GroupView.axaml | 2 +- Presence.Desktop/Views/GroupView.axaml.cs | 22 +++++++++++++++++- console_ui/console_ui.csproj | 1 - presnce.sln | 6 ----- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/Presence.Desktop/ViewModels/GroupViewModel.cs b/Presence.Desktop/ViewModels/GroupViewModel.cs index 5a49629..5c7c18a 100644 --- a/Presence.Desktop/ViewModels/GroupViewModel.cs +++ b/Presence.Desktop/ViewModels/GroupViewModel.cs @@ -8,16 +8,28 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Reactive.Linq; +using System.Threading.Tasks; +using System.Windows.Input; using Tmds.DBus.Protocol; namespace Presence.Desktop.ViewModels { public class GroupViewModel : ViewModelBase, IRoutableViewModel { + public ICommand OpenFileDialog { get; } + public Interaction SelectFileInteraction => _SelectFileInteraction; + public readonly Interaction _SelectFileInteraction; + private string? _selectedFile; + public string? SelectedFile + { + get => _selectedFile; + set => this.RaiseAndSetIfChanged(ref _selectedFile, value); + } + private readonly List _groupPresentersDataSource = new List(); private ObservableCollection _groups; public ObservableCollection Groups => _groups; - + public GroupPresenter? SelectedGroupItem { get => _selectedGroupItem; set => this.RaiseAndSetIfChanged(ref _selectedGroupItem, value); } @@ -31,6 +43,8 @@ namespace Presence.Desktop.ViewModels public GroupViewModel(IGroupUseCase groupUseCase) { _groupUseCase = groupUseCase; + _SelectFileInteraction = new Interaction(); + OpenFileDialog = ReactiveCommand.CreateFromTask(SelectFile); _users = new ObservableCollection(); RefreshGroups(); this.WhenAnyValue(vm => vm.SelectedGroupItem) @@ -38,7 +52,6 @@ namespace Presence.Desktop.ViewModels { RefreshGroups(); SetUsers(); }); - } private void SetUsers() @@ -74,6 +87,12 @@ namespace Presence.Desktop.ViewModels } _groups = new ObservableCollection(_groupPresentersDataSource); } + + private async Task SelectFile() + { + Console.WriteLine("clock"); + SelectedFile = await _SelectFileInteraction.Handle("Chose csv file"); + } public string? UrlPathSegment { get; } public IScreen HostScreen { get; } } diff --git a/Presence.Desktop/Views/GroupView.axaml b/Presence.Desktop/Views/GroupView.axaml index e82f70e..45c6661 100644 --- a/Presence.Desktop/Views/GroupView.axaml +++ b/Presence.Desktop/Views/GroupView.axaml @@ -27,7 +27,7 @@ - +