diff --git a/Clients/TgDownloaderDesktop/App.xaml.cs b/Clients/TgDownloaderDesktop/App.xaml.cs index 648d51e4..31e83af3 100644 --- a/Clients/TgDownloaderDesktop/App.xaml.cs +++ b/Clients/TgDownloaderDesktop/App.xaml.cs @@ -72,6 +72,8 @@ public App() services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/Clients/TgDownloaderDesktop/Services/PageService.cs b/Clients/TgDownloaderDesktop/Services/PageService.cs index c17573ac..c138fc69 100644 --- a/Clients/TgDownloaderDesktop/Services/PageService.cs +++ b/Clients/TgDownloaderDesktop/Services/PageService.cs @@ -9,20 +9,21 @@ public sealed class PageService : IPageService public PageService() { - Configure(); - Configure(); + Configure(); + Configure(); + Configure(); + Configure(); Configure(); + Configure(); Configure(); Configure(); + Configure(); + Configure(); + Configure(); + Configure(); Configure(); Configure(); - Configure(); Configure(); - Configure(); - Configure(); - Configure(); - Configure(); - Configure(); } public Type GetPageType(string key) diff --git a/Clients/TgDownloaderDesktop/Strings/en-us/Resources.resw b/Clients/TgDownloaderDesktop/Strings/en-us/Resources.resw index 78dcf925..48b1b3f1 100644 --- a/Clients/TgDownloaderDesktop/Strings/en-us/Resources.resw +++ b/Clients/TgDownloaderDesktop/Strings/en-us/Resources.resw @@ -79,6 +79,9 @@ Contacts + + Edit contact + Filters @@ -750,4 +753,49 @@ A wait is required + + UID + + + ID + + + Changed + + + Access hash + + + Active + + + Bot + + + First name + + + Last name + + + User name + + + User names + + + Phone number + + + Status + + + Restriction reason + + + Language code + + + Maximum Id storis + diff --git a/Clients/TgDownloaderDesktop/Strings/ru-RU/Resources.resw b/Clients/TgDownloaderDesktop/Strings/ru-RU/Resources.resw index 5264bd73..6acf6ecc 100644 --- a/Clients/TgDownloaderDesktop/Strings/ru-RU/Resources.resw +++ b/Clients/TgDownloaderDesktop/Strings/ru-RU/Resources.resw @@ -138,6 +138,9 @@ Контакты + + Редактирование контакта + Фильтры @@ -812,4 +815,49 @@ Необходимо подождать + + УИД + + + ИД + + + Изменено + + + Хэш доступа + + + Активно + + + Бот + + + Имя + + + Фамилия + + + Имя пользователя + + + Имена пользователя + + + Номер телефона + + + Статус + + + Причина ограничения + + + Код языка + + + Максимальный Id сторис + \ No newline at end of file diff --git a/Clients/TgDownloaderDesktop/TgDownloaderDesktop.csproj b/Clients/TgDownloaderDesktop/TgDownloaderDesktop.csproj index 528d9b8d..b3d067ab 100644 --- a/Clients/TgDownloaderDesktop/TgDownloaderDesktop.csproj +++ b/Clients/TgDownloaderDesktop/TgDownloaderDesktop.csproj @@ -64,6 +64,9 @@ Designer + + Designer + Designer diff --git a/Clients/TgDownloaderDesktop/ViewModels/TgContactDetailsViewModel.cs b/Clients/TgDownloaderDesktop/ViewModels/TgContactDetailsViewModel.cs new file mode 100644 index 00000000..02439aad --- /dev/null +++ b/Clients/TgDownloaderDesktop/ViewModels/TgContactDetailsViewModel.cs @@ -0,0 +1,80 @@ +// This is an independent project of an individual developer. Dear PVS-Studio, please check it. +// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com + +namespace TgDownloaderDesktop.ViewModels; + +[DebuggerDisplay("{ToDebugString()}")] +public sealed partial class TgContactDetailsViewModel : TgPageViewModelBase +{ + #region Public and private fields, properties, constructor + + private TgEfContactRepository Repository { get; } = new(TgEfUtils.EfContext); + [ObservableProperty] + public partial Guid Uid { get; set; } = default!; + [ObservableProperty] + public partial TgEfContactDto Dto { get; set; } = default!; + public IRelayCommand LoadDataStorageCommand { get; } + public IRelayCommand ClearDataStorageCommand { get; } + public IRelayCommand UpdateOnlineCommand { get; } + + public TgContactDetailsViewModel(ITgSettingsService settingsService) : base(settingsService) + { + // Commands + ClearDataStorageCommand = new AsyncRelayCommand(ClearDataStorageAsync); + LoadDataStorageCommand = new AsyncRelayCommand(LoadDataStorageAsync); + UpdateOnlineCommand = new AsyncRelayCommand(UpdateOnlineAsync); + } + + #endregion + + #region Public and private methods + + public override async Task OnNavigatedToAsync(NavigationEventArgs e) => await LoadDataAsync(async () => + { + TgEfUtils.AppStorage = SettingsService.AppStorage; + TgEfUtils.RecreateEfContext(); + Uid = e.Parameter is Guid uid ? uid : Guid.Empty; + await LoadDataStorageCoreAsync(); + await ReloadUiAsync(); + }); + + private async Task ReloadUiAsync() + { + ConnectionDt = string.Empty; + ConnectionMsg = string.Empty; + Exception.Default(); + await TgDesktopUtils.TgClient.CheckClientIsReadyAsync(); + IsOnlineReady = TgDesktopUtils.TgClient.IsReady; + await Task.CompletedTask; + } + + private async Task ClearDataStorageAsync() => await ContentDialogAsync(ClearDataStorageCoreAsync, TgResourceExtensions.AskDataClear()); + + private async Task ClearDataStorageCoreAsync() + { + Dto = new(); + await Task.CompletedTask; + } + + private async Task LoadDataStorageAsync() => await ContentDialogAsync(LoadDataStorageCoreAsync, TgResourceExtensions.AskDataLoad(), useLoadData: true); + + private async Task LoadDataStorageCoreAsync() + { + if (!SettingsService.IsExistsAppStorage) return; + Dto = await Repository.GetDtoAsync(x => x.Uid == Uid); + } + + private async Task UpdateOnlineAsync() => await ContentDialogAsync(UpdateOnlineCoreAsync, TgResourceExtensions.AskUpdateOnline()); + + private async Task UpdateOnlineCoreAsync() + { + await LoadDataAsync(async () => { + if (!await TgDesktopUtils.TgClient.CheckClientIsReadyAsync()) return; + var tgDownloadSettings = new TgDownloadSettingsViewModel(); + await TgDesktopUtils.TgClient.SearchSourcesTgAsync(tgDownloadSettings, TgEnumSourceType.Contact); + await LoadDataStorageCoreAsync(); + }); + } + + #endregion +} \ No newline at end of file diff --git a/Clients/TgDownloaderDesktop/ViewModels/TgContactsViewModel.cs b/Clients/TgDownloaderDesktop/ViewModels/TgContactsViewModel.cs index 54683003..41058966 100644 --- a/Clients/TgDownloaderDesktop/ViewModels/TgContactsViewModel.cs +++ b/Clients/TgDownloaderDesktop/ViewModels/TgContactsViewModel.cs @@ -6,9 +6,10 @@ namespace TgDownloaderDesktop.ViewModels; [DebuggerDisplay("{ToDebugString()}")] public sealed partial class TgContactsViewModel : TgPageViewModelBase { - #region Public and private fields, properties, constructor + #region Public and private fields, properties, constructor - private TgEfContactRepository Repository { get; } = new(TgEfUtils.EfContext); + private readonly INavigationService _navigationService; + private TgEfContactRepository Repository { get; } = new(TgEfUtils.EfContext); [ObservableProperty] public partial ObservableCollection Dtos { get; set; } = []; public IRelayCommand LoadDataStorageCommand { get; } @@ -16,8 +17,9 @@ public sealed partial class TgContactsViewModel : TgPageViewModelBase public IRelayCommand DefaultSortCommand { get; } public IRelayCommand UpdateOnlineCommand { get; } - public TgContactsViewModel(ITgSettingsService settingsService) : base(settingsService) + public TgContactsViewModel(ITgSettingsService settingsService, INavigationService navigationService) : base(settingsService) { + _navigationService = navigationService; // Commands ClearDataStorageCommand = new AsyncRelayCommand(ClearDataStorageAsync); DefaultSortCommand = new AsyncRelayCommand(DefaultSortAsync); @@ -94,5 +96,13 @@ await LoadDataAsync(async () => { }); } + public void DataGrid_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) + { + if (sender is not DataGrid dataGrid) return; + if (dataGrid.SelectedItem is not TgEfContactDto dto) return; + + _navigationService.NavigateTo(typeof(TgContactDetailsViewModel).FullName!, dto.Uid); + } + #endregion } \ No newline at end of file diff --git a/Clients/TgDownloaderDesktop/Views/TgConnectPage.xaml b/Clients/TgDownloaderDesktop/Views/TgConnectPage.xaml index 915b7e54..5e6a94d6 100644 --- a/Clients/TgDownloaderDesktop/Views/TgConnectPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/TgConnectPage.xaml @@ -15,184 +15,184 @@ - - - - - - - - - - - - + + + + + + + + + + + - - - - - - + IsExpanded="True"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - + IsExpanded="True"> + + @@ -300,22 +300,24 @@ HorizontalContentAlignment="Left" Text="{x:Bind ViewModel.LastName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> - - - - + + + + + - - + IsExpanded="True"> + + @@ -549,8 +551,8 @@ Text="{x:Bind ViewModel.DataRequest, Mode=OneWay}" TextWrapping="Wrap" /> - - - - + + + + \ No newline at end of file diff --git a/Clients/TgDownloaderDesktop/Views/TgContactDetailsPage.xaml b/Clients/TgDownloaderDesktop/Views/TgContactDetailsPage.xaml new file mode 100644 index 00000000..cb30b294 --- /dev/null +++ b/Clients/TgDownloaderDesktop/Views/TgContactDetailsPage.xaml @@ -0,0 +1,377 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Clients/TgDownloaderDesktop/Views/TgContactDetailsPage.xaml.cs b/Clients/TgDownloaderDesktop/Views/TgContactDetailsPage.xaml.cs new file mode 100644 index 00000000..e7d4c5c5 --- /dev/null +++ b/Clients/TgDownloaderDesktop/Views/TgContactDetailsPage.xaml.cs @@ -0,0 +1,32 @@ +// This is an independent project of an individual developer. Dear PVS-Studio, please check it. +// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com + +namespace TgDownloaderDesktop.Views; + +public partial class TgContactDetailsPage +{ + #region Public and private fields, properties, constructor + + public TgContactDetailsViewModel ViewModel { get; } + + public TgContactDetailsPage() + { + ViewModel = App.GetService(); + InitializeComponent(); + Loaded += PageLoaded; + } + + #endregion + + #region Public and private methods + + protected override async void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + await ViewModel.OnNavigatedToAsync(e); + } + + private void PageLoaded(object sender, RoutedEventArgs e) => ViewModel.OnLoaded(XamlRoot); + + #endregion +} diff --git a/Clients/TgDownloaderDesktop/Views/TgContactsPage.xaml b/Clients/TgDownloaderDesktop/Views/TgContactsPage.xaml index 51535dde..2db88918 100644 --- a/Clients/TgDownloaderDesktop/Views/TgContactsPage.xaml +++ b/Clients/TgDownloaderDesktop/Views/TgContactsPage.xaml @@ -90,21 +90,6 @@ VerticalAlignment="Center" /> - - - @@ -144,8 +128,10 @@ AutoGenerateColumns="False" Background="Transparent" CanUserSortColumns="True" + DoubleTapped="{x:Bind ViewModel.DataGrid_DoubleTapped, Mode=OneWay}" HeadersVisibility="Column" - ItemsSource="{x:Bind ViewModel.Dtos, Mode=OneWay}"> + ItemsSource="{x:Bind ViewModel.Dtos, Mode=OneWay}" + SelectionMode="Single">