diff --git a/Clients/TgDownloaderConsole/Helpers/TgMenuHelperDownload.cs b/Clients/TgDownloaderConsole/Helpers/TgMenuHelperDownload.cs
index 9fdc32d..33868c8 100644
--- a/Clients/TgDownloaderConsole/Helpers/TgMenuHelperDownload.cs
+++ b/Clients/TgDownloaderConsole/Helpers/TgMenuHelperDownload.cs
@@ -2,6 +2,8 @@
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
// ReSharper disable InconsistentNaming
+using TgDownloader.Models;
+
namespace TgDownloaderConsole.Helpers;
internal partial class TgMenuHelper
@@ -101,8 +103,8 @@ private TgDownloadSettingsModel SetupDownloadSource(long? id = null)
TgDownloadSettingsModel tgDownloadSettings = TgDownloadSettingsModel.CreateNew();
//tgDownloadSettings.SourceVm.SourceFirstId = 1;
SetupDownloadSourceCore(id, tgDownloadSettings);
- Channel? channel = TgClient.PrepareChannelDownloadMessagesAsync(tgDownloadSettings, true).GetAwaiter().GetResult();
- if (channel is null)
+ TgDownloadSmartSource smartSource = TgClient.PrepareChannelDownloadMessagesAsync(tgDownloadSettings, true).GetAwaiter().GetResult();
+ if (smartSource.Channel is null)
_ = TgClient.PrepareChatBaseDownloadMessagesAsync(tgDownloadSettings, true).GetAwaiter().GetResult();
LoadTgClientSettings(tgDownloadSettings, false, false);
return tgDownloadSettings;
@@ -136,18 +138,18 @@ private void SetupDownloadSourceCore(long? id, TgDownloadSettingsModel tgDownloa
private async Task SetupDownloadSourceFirstIdAutoAsync(TgDownloadSettingsModel tgDownloadSettings)
{
- Channel? channel = await TgClient.PrepareChannelDownloadMessagesAsync(tgDownloadSettings, true);
- if (channel is not null)
+ TgDownloadSmartSource smartSource = await TgClient.PrepareChannelDownloadMessagesAsync(tgDownloadSettings, true);
+ if (smartSource.Channel is not null)
{
- await TgClient.SetChannelMessageIdFirstAsync(tgDownloadSettings, channel);
+ await TgClient.SetChannelMessageIdFirstAsync(tgDownloadSettings, smartSource.Channel);
LoadTgClientSettings(tgDownloadSettings, true, false);
return;
}
- ChatBase? chatBase = await TgClient.PrepareChatBaseDownloadMessagesAsync(tgDownloadSettings, true);
- if (chatBase is not null)
+ smartSource = await TgClient.PrepareChatBaseDownloadMessagesAsync(tgDownloadSettings, true);
+ if (smartSource.ChatBase is not null)
{
- await TgClient.SetChannelMessageIdFirstAsync(tgDownloadSettings, chatBase);
+ await TgClient.SetChannelMessageIdFirstAsync(tgDownloadSettings, smartSource.ChatBase);
LoadTgClientSettings(tgDownloadSettings, true, false);
}
}
@@ -218,7 +220,8 @@ private void LoadTgClientSettings(TgDownloadSettingsModel tgDownloadSettings, bo
private async Task ManualDownloadAsync(TgDownloadSettingsModel tgDownloadSettings)
{
ShowTableDownload(tgDownloadSettings);
- await TgClient.DownloadAllDataAsync(tgDownloadSettings);
+ await TgClient.DownloadAllDataAsync(tgDownloadSettings);
+ // Don't move up.
await UpdateSourceWithSettings(tgDownloadSettings);
}
diff --git a/Clients/TgDownloaderConsole/TgDownloaderConsole.csproj b/Clients/TgDownloaderConsole/TgDownloaderConsole.csproj
index b0550d7..32df943 100644
--- a/Clients/TgDownloaderConsole/TgDownloaderConsole.csproj
+++ b/Clients/TgDownloaderConsole/TgDownloaderConsole.csproj
@@ -4,7 +4,7 @@
net7.0
enable
enable
- 0.2.550.0
+ 0.2.570.0
LICENSE.md
AnyCPU;x64;x86
@@ -59,7 +59,7 @@
-
+
diff --git a/Clients/TgDownloaderWinDesktop/Assets/applicationIcon-01-1024.png b/Clients/TgDownloaderWinDesktop/Assets/applicationIcon-01-1024.png
new file mode 100644
index 0000000..54ec0ae
Binary files /dev/null and b/Clients/TgDownloaderWinDesktop/Assets/applicationIcon-01-1024.png differ
diff --git a/Clients/TgDownloaderWinDesktop/TgDownloaderAppIcon01.ico b/Clients/TgDownloaderWinDesktop/TgDownloaderAppIcon01.ico
new file mode 100644
index 0000000..11b8d5f
Binary files /dev/null and b/Clients/TgDownloaderWinDesktop/TgDownloaderAppIcon01.ico differ
diff --git a/Clients/TgDownloaderWinDesktop/TgDownloaderWinDesktop.csproj b/Clients/TgDownloaderWinDesktop/TgDownloaderWinDesktop.csproj
index 8179eca..02b30d9 100644
--- a/Clients/TgDownloaderWinDesktop/TgDownloaderWinDesktop.csproj
+++ b/Clients/TgDownloaderWinDesktop/TgDownloaderWinDesktop.csproj
@@ -5,25 +5,26 @@
enable
true
app.manifest
- applicationIcon.ico
+ TgDownloaderAppIcon01.ico
AnyCPU;x64;x86
- 0.2.550.0
+ 0.2.570.0
-
+
-
+
+
diff --git a/Clients/TgDownloaderWinDesktop/ViewModels/TgClientViewModel.cs b/Clients/TgDownloaderWinDesktop/ViewModels/TgClientViewModel.cs
index ebf0f15..8dca281 100644
--- a/Clients/TgDownloaderWinDesktop/ViewModels/TgClientViewModel.cs
+++ b/Clients/TgDownloaderWinDesktop/ViewModels/TgClientViewModel.cs
@@ -1,6 +1,8 @@
// 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
+using System.Linq;
+
namespace TgDownloaderWinDesktop.ViewModels;
[DebuggerDisplay("{ToDebugString()}")]
@@ -10,7 +12,7 @@ public sealed partial class TgClientViewModel : TgPageViewModelBase, INavigation
public TgMvvmAppModel AppVm { get; }
public TgSqlTableProxyViewModel ProxyVm { get; set; }
- public ObservableCollection ProxiesVms { get; }
+ public ObservableCollection ProxiesVms { get; private set; }
public string FirstName { get; set; }
public string LastName { get; set; }
@@ -90,7 +92,7 @@ public TgClientViewModel()
public void OnNavigatedTo()
{
- _ = Task.Run(InitializeViewModelAsync).ConfigureAwait(true);
+ InitializeViewModelAsync().GetAwaiter();
}
public void OnNavigatedFrom() { }
@@ -107,15 +109,18 @@ public async Task LoadProxiesForClientAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
- ProxiesVms.Clear();
- ProxiesVms.Add(new(await ContextManager.ProxyRepository.GetNewAsync()));
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ TgSqlTableProxyModel proxyNew = await ContextManager.ProxyRepository.GetAsync(AppVm.App.ProxyUid);
+ ProxiesVms = new();
foreach (TgSqlTableProxyModel proxy in ContextManager.ProxyRepository.GetEnumerable())
{
ProxiesVms.Add(new(proxy));
}
-
- ProxyVm.Proxy = await ContextManager.ProxyRepository.GetAsync(AppVm.App.ProxyUid) ??
- await ContextManager.ProxyRepository.GetNewAsync();
+ if (!ProxiesVms.Select(p => p.Proxy.UserName).Contains(proxyNew.UserName))
+ {
+ ProxyVm = new(proxyNew);
+ ProxiesVms.Add(ProxyVm);
+ }
}, false);
}
@@ -123,6 +128,7 @@ public async Task AfterClientConnectAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
//TgDesktopUtils.TgClient.UpdateStateConnect(TgDesktopUtils.TgClient.IsReady
// ? TgDesktopUtils.TgLocale.MenuClientIsConnected : TgDesktopUtils.TgLocale.MenuClientIsDisconnected);
IsFileSession = TgAppSettings.AppXml.IsExistsFileSession;
@@ -134,7 +140,8 @@ await TgDesktopUtils.RunFuncAsync(this, async () =>
public string? GetClientDesktopConfig(string what)
{
- //TgDesktopUtils.TgClient.UpdateStateMessage($"{TgDesktopUtils.TgLocale.MenuClientIsQuery}: {what}");
+ TgDesktopUtils.TgClient.UpdateStateMessageAsync($"{TgDesktopUtils.TgLocale.MenuClientIsQuery}: {what}").GetAwaiter();
+
switch (what)
{
case "api_hash":
@@ -198,6 +205,7 @@ public async Task OnClientConnectAsync(TgSqlTableProxyViewModel? proxyVm = null)
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (!TgSqlUtils.GetValidXpLite(AppVm.App).IsValid)
return;
await TgDesktopUtils.TgClient.ConnectSessionAsync(proxyVm ?? ProxyVm);
@@ -213,6 +221,7 @@ public async Task OnClientDisconnectAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
TgDesktopUtils.TgClient.Disconnect();
}, false).ConfigureAwait(false);
}
@@ -223,6 +232,7 @@ public async Task OnAppSaveAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
await ContextManager.AppRepository.DeleteAllItemsAsync();
await ContextManager.AppRepository.SaveAsync(AppVm.App);
}, false).ConfigureAwait(false);
@@ -234,6 +244,7 @@ public async Task OnAppClearAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
AppVm.App = await ContextManager.AppRepository.GetNewAsync();
}, false).ConfigureAwait(true);
}
@@ -244,6 +255,7 @@ public async Task OnAppLoadAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
AppVm.App = await ContextManager.AppRepository.GetFirstAsync();
}, false).ConfigureAwait(false);
}
@@ -254,6 +266,7 @@ public async Task OnAppEmptyAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
await ContextManager.AppRepository.DeleteAllItemsAsync();
}, false).ConfigureAwait(true);
diff --git a/Clients/TgDownloaderWinDesktop/ViewModels/TgDashboardViewModel.cs b/Clients/TgDownloaderWinDesktop/ViewModels/TgDashboardViewModel.cs
index 9d05010..a27e168 100644
--- a/Clients/TgDownloaderWinDesktop/ViewModels/TgDashboardViewModel.cs
+++ b/Clients/TgDownloaderWinDesktop/ViewModels/TgDashboardViewModel.cs
@@ -6,11 +6,27 @@ namespace TgDownloaderWinDesktop.ViewModels;
[DebuggerDisplay("{ToDebugString()}")]
public sealed partial class TgDashboardViewModel : TgPageViewModelBase, INavigationAware
{
- #region Public and private methods
+ #region Public and private fields, properties, constructor
- public void OnNavigatedTo()
+ public static string AppVersionTitle { get; set; } = string.Empty;
+ public static string AppVersionShort { get; set; } = string.Empty;
+ public static string AppVersionFull { get; set; } = string.Empty;
+
+ #endregion
+
+ #region Public and private methods
+
+ public TgDashboardViewModel()
+ {
+ AppVersionTitle = $"{TgDesktopUtils.TgLocale.AppTitleWinDesktop} " +
+ $"v{TgCommonUtils.GetTrimVersion(Assembly.GetExecutingAssembly().GetName().Version)}";
+ AppVersionShort = $"v{TgCommonUtils.GetTrimVersion(Assembly.GetExecutingAssembly().GetName().Version)}";
+ AppVersionFull = $"{TgDesktopUtils.TgLocale.AppVersion}: {AppVersionShort}";
+ }
+
+ public void OnNavigatedTo()
{
- _ = Task.Run(InitializeViewModelAsync).ConfigureAwait(true);
+ InitializeViewModelAsync().GetAwaiter();
}
public void OnNavigatedFrom() { }
@@ -23,8 +39,9 @@ public void OnNavigatedFrom() { }
[RelayCommand]
public async Task OnSettingsDefaultAsync()
{
- await TgDesktopUtils.RunActionAsync(this, () =>
+ await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
TgAppSettings.DefaultXmlSettings();
}, false).ConfigureAwait(false);
}
@@ -33,8 +50,9 @@ await TgDesktopUtils.RunActionAsync(this, () =>
[RelayCommand]
public async Task OnSettingsSaveAsync()
{
- await TgDesktopUtils.RunActionAsync(this, () =>
+ await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
TgAppSettings.StoreXmlSettingsUnsafe();
TgAppSettings.LoadXmlSettings();
}, false).ConfigureAwait(false);
diff --git a/Clients/TgDownloaderWinDesktop/ViewModels/TgFiltersViewModel.cs b/Clients/TgDownloaderWinDesktop/ViewModels/TgFiltersViewModel.cs
index 7ff9f8b..5ce290d 100644
--- a/Clients/TgDownloaderWinDesktop/ViewModels/TgFiltersViewModel.cs
+++ b/Clients/TgDownloaderWinDesktop/ViewModels/TgFiltersViewModel.cs
@@ -8,10 +8,7 @@ public sealed partial class TgFiltersViewModel : TgPageViewModelBase, INavigatio
{
#region Public and private fields, properties, constructor
- public TgFiltersViewModel()
- {
- //
- }
+ public TgFiltersViewModel() { }
#endregion
@@ -19,10 +16,10 @@ public TgFiltersViewModel()
public void OnNavigatedTo()
{
- _ = Task.Run(InitializeViewModelAsync).ConfigureAwait(true);
+ InitializeViewModelAsync().GetAwaiter();
}
- public void OnNavigatedFrom() { }
+ public void OnNavigatedFrom() { }
#endregion
}
\ No newline at end of file
diff --git a/Clients/TgDownloaderWinDesktop/ViewModels/TgItemProxyViewModel.cs b/Clients/TgDownloaderWinDesktop/ViewModels/TgItemProxyViewModel.cs
index a442ae8..6f2a035 100644
--- a/Clients/TgDownloaderWinDesktop/ViewModels/TgItemProxyViewModel.cs
+++ b/Clients/TgDownloaderWinDesktop/ViewModels/TgItemProxyViewModel.cs
@@ -24,7 +24,7 @@ public TgItemProxyViewModel()
public void OnNavigatedTo()
{
- _ = Task.Run(InitializeViewModelAsync).ConfigureAwait(true);
+ InitializeViewModelAsync().GetAwaiter();
}
public void OnNavigatedFrom() { }
@@ -52,11 +52,12 @@ public async Task OnGetProxyFromStorageAsync()
{
await TgDesktopUtils.RunFuncAsync(ViewModel ?? this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (ItemProxyVm.ProxyUid != Guid.Empty)
ProxyUid = ItemProxyVm.ProxyUid;
TgSqlTableProxyModel proxy = await ContextManager.ProxyRepository.GetAsync(ProxyUid);
SetItemProxyVm(proxy, proxy.Uid);
- }, true).ConfigureAwait(true);
+ }, true);
}
// ClearViewCommand
@@ -65,10 +66,11 @@ public async Task OnClearViewAsync()
{
await TgDesktopUtils.RunFuncAsync(ViewModel ?? this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (ItemProxyVm.ProxyUid != Guid.Empty)
ProxyUid = ItemProxyVm.ProxyUid;
ItemProxyVm.Proxy = await ContextManager.ProxyRepository.GetNewAsync();
- }, false).ConfigureAwait(true);
+ }, false);
}
// SaveProxyCommand
@@ -77,8 +79,9 @@ public async Task OnSaveProxyAsync()
{
await TgDesktopUtils.RunFuncAsync(ViewModel ?? this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
await ContextManager.ProxyRepository.SaveAsync(ItemProxyVm.Proxy, true);
- }, false).ConfigureAwait(false);
+ }, false);
}
// ReturnToSectionProxiesCommand
@@ -87,12 +90,13 @@ public async Task OnReturnToSectionProxiesAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (Application.Current.MainWindow is MainWindow navigationWindow)
{
navigationWindow.ShowWindow();
navigationWindow.Navigate(typeof(TgProxiesPage));
}
- }, false).ConfigureAwait(false);
+ }, false);
}
#endregion
diff --git a/Clients/TgDownloaderWinDesktop/ViewModels/TgItemSourceViewModel.cs b/Clients/TgDownloaderWinDesktop/ViewModels/TgItemSourceViewModel.cs
index ad344ba..9255572 100644
--- a/Clients/TgDownloaderWinDesktop/ViewModels/TgItemSourceViewModel.cs
+++ b/Clients/TgDownloaderWinDesktop/ViewModels/TgItemSourceViewModel.cs
@@ -12,26 +12,32 @@ public sealed partial class TgItemSourceViewModel : TgPageViewModelBase, INaviga
public TgPageViewModelBase? ViewModel { get; set; }
private Guid SourceUid { get; set; }
- public TgItemSourceViewModel() { }
-
#endregion
#region Public and private methods
public void OnNavigatedTo()
{
- _ = Task.Run(InitializeViewModelAsync).ConfigureAwait(true);
+ InitializeViewModelAsync().GetAwaiter();
}
public void OnNavigatedFrom() { }
protected override async Task InitializeViewModelAsync()
{
+ TgDesktopUtils.TgClient.SetupActionsForItemsSource(UpdateStateItemSourceAsync);
await base.InitializeViewModelAsync();
await OnGetSourceFromStorageAsync();
}
+ private async Task UpdateStateItemSourceAsync(long sourceId)
+ {
+ if (!ItemSourceVm.SourceId.Equals(sourceId)) return;
+
+ await OnGetSourceFromStorageAsync();
+ }
+
public void SetItemSourceVm(TgSqlTableSourceViewModel itemSourceVm) =>
SetItemSourceVm(itemSourceVm.Source, itemSourceVm.Source.Uid);
@@ -67,6 +73,7 @@ public async Task OnGetSourceFromStorageAsync()
{
await TgDesktopUtils.RunFuncAsync(ViewModel ?? this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (ItemSourceVm.SourceUid != Guid.Empty)
SourceUid = ItemSourceVm.SourceUid;
TgSqlTableSourceModel source = await ContextManager.SourceRepository.GetAsync(SourceUid);
@@ -83,6 +90,7 @@ public async Task OnUpdateSourceFromTelegramAsync()
await TgDesktopUtils.RunFuncAsync(ViewModel ?? this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (ItemSourceVm.SourceUid != Guid.Empty)
SourceUid = ItemSourceVm.SourceUid;
// Collect chats from Telegram.
@@ -113,6 +121,7 @@ public async Task OnDownloadSourceAsync()
bool result = true;
await TgDesktopUtils.RunFuncAsync(ViewModel ?? this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
// Check directory.
if (!Directory.Exists(ItemSourceVm.Source.Directory))
{
@@ -140,6 +149,7 @@ public async Task OnClearViewAsync()
{
await TgDesktopUtils.RunFuncAsync(ViewModel ?? this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (ItemSourceVm.SourceUid != Guid.Empty)
SourceUid = ItemSourceVm.SourceUid;
ItemSourceVm.Source = await ContextManager.SourceRepository.GetNewAsync();
@@ -152,16 +162,20 @@ public async Task OnSaveSourceAsync()
{
await TgDesktopUtils.RunFuncAsync(ViewModel ?? this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
await ContextManager.SourceRepository.SaveAsync(ItemSourceVm.Source, true);
}, false);
+
+ await OnGetSourceFromStorageAsync();
}
// ReturnToSectionSourcesCommand
[RelayCommand]
public async Task OnReturnToSectionSourcesAsync()
{
- await TgDesktopUtils.RunActionAsync(this, () =>
+ await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (Application.Current.MainWindow is MainWindow navigationWindow)
{
navigationWindow.ShowWindow();
diff --git a/Clients/TgDownloaderWinDesktop/ViewModels/TgProxiesViewModel.cs b/Clients/TgDownloaderWinDesktop/ViewModels/TgProxiesViewModel.cs
index 416d9aa..520e3f0 100644
--- a/Clients/TgDownloaderWinDesktop/ViewModels/TgProxiesViewModel.cs
+++ b/Clients/TgDownloaderWinDesktop/ViewModels/TgProxiesViewModel.cs
@@ -16,7 +16,7 @@ public sealed partial class TgProxiesViewModel : TgPageViewModelBase, INavigatio
public void OnNavigatedTo()
{
- _ = Task.Run(InitializeViewModelAsync).ConfigureAwait(true);
+ InitializeViewModelAsync().ConfigureAwait(true);
}
public void OnNavigatedFrom() { }
@@ -38,8 +38,9 @@ private void SetOrderProxies(IEnumerable proxies)
ProxiesVms = new();
proxies = listProxies.OrderBy(x => x.Port).ThenBy(x => x.HostName).ToList();
- foreach (TgSqlTableProxyModel proxy in proxies)
- ProxiesVms.Add(new(proxy));
+ if (proxies.Any())
+ foreach (TgSqlTableProxyModel proxy in proxies)
+ ProxiesVms.Add(new(proxy));
}
#endregion
@@ -52,6 +53,7 @@ public async Task OnLoadProxiesFromStorageAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
SetOrderProxies(ContextManager.ProxyRepository.GetEnumerable());
}, false).ConfigureAwait(false);
}
@@ -62,6 +64,7 @@ public async Task OnClearViewAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
ProxiesVms = new();
}, false).ConfigureAwait(true);
}
@@ -72,6 +75,7 @@ public async Task OnDeleteProxyAsync(TgSqlTableProxyViewModel proxyVm)
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
await ContextManager.ProxyRepository.DeleteAsync(proxyVm.Proxy);
LoadProxiesFromStorageCommand.Execute(null);
await TgDesktopUtils.TgClientVm.LoadProxiesForClientAsync();
@@ -84,6 +88,7 @@ public async Task OnEditProxyAsync(TgSqlTableProxyViewModel proxyVm)
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (Application.Current.MainWindow is MainWindow navigationWindow)
{
TgDesktopUtils.TgItemProxyVm.SetItemProxyVm(proxyVm);
@@ -99,6 +104,7 @@ public async Task OnAddProxyAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (Application.Current.MainWindow is MainWindow navigationWindow)
{
TgDesktopUtils.TgItemProxyVm.SetItemProxyVm(new TgSqlTableProxyViewModel(new TgSqlTableProxyModel()));
diff --git a/Clients/TgDownloaderWinDesktop/ViewModels/TgSettingsViewModel.cs b/Clients/TgDownloaderWinDesktop/ViewModels/TgSettingsViewModel.cs
index ef71a08..c850b76 100644
--- a/Clients/TgDownloaderWinDesktop/ViewModels/TgSettingsViewModel.cs
+++ b/Clients/TgDownloaderWinDesktop/ViewModels/TgSettingsViewModel.cs
@@ -7,12 +7,10 @@ namespace TgDownloaderWinDesktop.ViewModels;
public sealed partial class TgSettingsViewModel : TgPageViewModelBase, INavigationAware
{
public static Wpf.Ui.Appearance.ThemeType CurrentTheme { get; set; } = Wpf.Ui.Appearance.ThemeType.Unknown;
- public static string AppVersionTitle { get; set; } = string.Empty;
- public static string AppVersionFull { get; set; } = string.Empty;
public void OnNavigatedTo()
{
- _ = Task.Run(InitializeViewModelAsync).ConfigureAwait(true);
+ InitializeViewModelAsync().GetAwaiter();
}
public void OnNavigatedFrom() { }
@@ -22,21 +20,14 @@ protected override async Task InitializeViewModelAsync()
await base.InitializeViewModelAsync();
CurrentTheme = Wpf.Ui.Appearance.Theme.GetAppTheme();
- AppVersionTitle = $"{TgDesktopUtils.TgLocale.AppTitleWinDesktop} " +
- $"v{TgCommonUtils.GetTrimVersion(Assembly.GetExecutingAssembly().GetName().Version)}";
- AppVersionFull = $"{TgDesktopUtils.TgLocale.AppVersion}: v{TgCommonUtils.GetTrimVersion(Assembly.GetExecutingAssembly().GetName().Version)}";
}
- private string GetAssemblyVersion()
- {
- return Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty;
- }
-
[RelayCommand]
public async Task OnChangeThemeAsync(string parameter)
{
- await TgDesktopUtils.RunActionAsync(this, () =>
+ await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
switch (parameter)
{
case "theme_light":
diff --git a/Clients/TgDownloaderWinDesktop/ViewModels/TgSourcesViewModel.cs b/Clients/TgDownloaderWinDesktop/ViewModels/TgSourcesViewModel.cs
index e5c7676..c86e1c3 100644
--- a/Clients/TgDownloaderWinDesktop/ViewModels/TgSourcesViewModel.cs
+++ b/Clients/TgDownloaderWinDesktop/ViewModels/TgSourcesViewModel.cs
@@ -1,6 +1,7 @@
// 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
+using System;
namespace TgDownloaderWinDesktop.ViewModels;
[DebuggerDisplay("{ToDebugString()}")]
@@ -16,7 +17,7 @@ public sealed partial class TgSourcesViewModel : TgPageViewModelBase, INavigatio
public void OnNavigatedTo()
{
- _ = Task.Run(InitializeViewModelAsync).ConfigureAwait(true);
+ InitializeViewModelAsync().GetAwaiter();
}
public void OnNavigatedFrom() { }
@@ -37,14 +38,10 @@ private void SetOrderSources(IEnumerable sources)
if (!listSources.Any()) return;
SourcesVms = new();
- sources = listSources.OrderBy(x => x.Title).ThenBy(x => x.UserName).ToList();
+ sources = listSources.OrderBy(x => x.UserName).ThenBy(x => x.Title).ToList();
if (sources.Any())
- {
foreach (TgSqlTableSourceModel source in sources)
- {
SourcesVms.Add(new(source));
- }
- }
}
///
@@ -93,6 +90,7 @@ public async Task OnLoadSourcesFromStorageAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
List sources = ContextManager.SourceRepository.GetEnumerable().ToList();
//if (!sources.Any())
//{
@@ -119,6 +117,7 @@ public async Task OnUpdateSourcesFromTelegramAsync()
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
foreach (TgSqlTableSourceViewModel sourceVm in SourcesVms)
await OnUpdateSourceFromTelegramAsync(sourceVm);
}, false);
@@ -133,6 +132,7 @@ public async Task OnGetSourcesFromTelegramAsync()
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
await TgDesktopUtils.TgClient.ScanSourcesTgDesktopAsync(TgEnumSourceType.Chat, LoadFromTelegramAsync);
await TgDesktopUtils.TgClient.ScanSourcesTgDesktopAsync(TgEnumSourceType.Dialog, LoadFromTelegramAsync);
}, false);
@@ -144,6 +144,7 @@ public async Task OnClearViewAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
SourcesVms = new();
}, false);
}
@@ -156,6 +157,7 @@ public async Task OnSortViewAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
SetOrderSources(SourcesVms.Select(x => x.Source).ToList());
}, false);
}
@@ -169,10 +171,11 @@ public async Task OnSaveSourcesAsync()
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
// Checks.
if (!SourcesVms.Any())
{
- TgDesktopUtils.TgClient.UpdateStateSourceAsync(0, 0, "Empty sources list!");
+ await TgDesktopUtils.TgClient.UpdateStateSourceAsync(0, 0, "Empty sources list!");
return;
}
foreach (TgSqlTableSourceViewModel sourceVm in SourcesVms)
@@ -186,6 +189,7 @@ public async Task SaveSourceAsync(TgSqlTableSourceViewModel sourceVm)
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
TgSqlTableSourceModel sourceDb = await ContextManager.SourceRepository.GetAsync(sourceVm.Source.Id);
if (!sourceDb.IsExists)
{
@@ -208,6 +212,7 @@ public async Task OnGetSourceFromStorageAsync(TgSqlTableSourceViewModel sourceVm
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
for (int i = 0; i < SourcesVms.Count; i++)
{
if (SourcesVms[i].SourceId.Equals(sourceVm.SourceId))
@@ -235,6 +240,7 @@ public async Task OnDownloadAsync(TgSqlTableSourceViewModel sourceVm)
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
TgDesktopUtils.TgItemSourceVm.SetItemSourceVm(sourceVm);
TgDesktopUtils.TgItemSourceVm.ViewModel = this;
if (await TgDesktopUtils.TgItemSourceVm.OnDownloadSourceAsync())
@@ -248,6 +254,7 @@ public async Task OnEditSourceAsync(TgSqlTableSourceViewModel sourceVm)
{
await TgDesktopUtils.RunFuncAsync(this, async () =>
{
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
if (Application.Current.MainWindow is MainWindow navigationWindow)
{
TgDesktopUtils.TgItemSourceVm.SetItemSourceVm(sourceVm);
diff --git a/Clients/TgDownloaderWinDesktop/Views/Controls/TgClientStateUserControl.xaml.cs b/Clients/TgDownloaderWinDesktop/Views/Controls/TgClientStateUserControl.xaml.cs
index 7c85af2..d320f84 100644
--- a/Clients/TgDownloaderWinDesktop/Views/Controls/TgClientStateUserControl.xaml.cs
+++ b/Clients/TgDownloaderWinDesktop/Views/Controls/TgClientStateUserControl.xaml.cs
@@ -12,7 +12,7 @@ public sealed partial class TgClientStateUserControl : TgUserControlViewBase
public TgClientStateUserControl()
{
- TgDesktopUtils.TgClientVm.OnNavigatedTo();
+ //TgDesktopUtils.TgClientVm.OnNavigatedTo();
InitializeComponent();
}
diff --git a/Clients/TgDownloaderWinDesktop/Views/Controls/TgExceptionsUserControl.xaml.cs b/Clients/TgDownloaderWinDesktop/Views/Controls/TgExceptionsUserControl.xaml.cs
index fec416e..aaeeb4c 100644
--- a/Clients/TgDownloaderWinDesktop/Views/Controls/TgExceptionsUserControl.xaml.cs
+++ b/Clients/TgDownloaderWinDesktop/Views/Controls/TgExceptionsUserControl.xaml.cs
@@ -12,7 +12,7 @@ public sealed partial class TgExceptionsUserControl : TgUserControlViewBase
public TgExceptionsUserControl()
{
- TgDesktopUtils.TgClientVm.OnNavigatedTo();
+ //TgDesktopUtils.TgClientVm.OnNavigatedTo();
InitializeComponent();
}
diff --git a/Clients/TgDownloaderWinDesktop/Views/MainWindow.xaml b/Clients/TgDownloaderWinDesktop/Views/MainWindow.xaml
index 89c68b7..e772338 100644
--- a/Clients/TgDownloaderWinDesktop/Views/MainWindow.xaml
+++ b/Clients/TgDownloaderWinDesktop/Views/MainWindow.xaml
@@ -8,7 +8,7 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:utils="clr-namespace:TgDownloaderWinDesktop.Utils"
xmlns:views="clr-namespace:TgDownloaderWinDesktop.Views"
- Title="{Binding Source={x:Static utils:TgDesktopUtils.TgSettingsVm}, Path=AppVersionTitle, Mode=OneWay, IsAsync=True}"
+ Title="{Binding Source={x:Static utils:TgDesktopUtils.TgDashboardVm}, Path=AppVersionTitle, Mode=OneWay, IsAsync=True}"
Width="1300"
Height="800"
d:Background="{DynamicResource ApplicationBackgroundBrush}"
@@ -30,28 +30,39 @@
+
-
+
+
+
+
+
+
+
+
-
+
-
+
@@ -118,6 +132,7 @@
@@ -293,7 +293,7 @@
VerticalContentAlignment="Center"
Content="{Binding Source={x:Static utils:TgDesktopUtils.TgLocale}, Path=MenuClientProxy, Mode=OneWay, IsAsync=True}"
FontWeight="Bold" />
-
-
+ -->
+
diff --git a/Clients/TgDownloaderWinDesktop/Views/Pages/TgFiltersPage.xaml b/Clients/TgDownloaderWinDesktop/Views/Pages/TgFiltersPage.xaml
index 7a563ba..01bc885 100644
--- a/Clients/TgDownloaderWinDesktop/Views/Pages/TgFiltersPage.xaml
+++ b/Clients/TgDownloaderWinDesktop/Views/Pages/TgFiltersPage.xaml
@@ -11,7 +11,7 @@
d:Background="{DynamicResource ApplicationBackgroundBrush}"
d:DataContext="{d:DesignInstance local:TgFiltersPage,
IsDesignTimeCreatable=True}"
- d:DesignHeight="150"
+ d:DesignHeight="550"
d:DesignWidth="1300"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Tag="Filters"
diff --git a/Clients/TgDownloaderWinDesktop/Views/Pages/TgItemProxyPage.xaml b/Clients/TgDownloaderWinDesktop/Views/Pages/TgItemProxyPage.xaml
index 277f509..13aa1f1 100644
--- a/Clients/TgDownloaderWinDesktop/Views/Pages/TgItemProxyPage.xaml
+++ b/Clients/TgDownloaderWinDesktop/Views/Pages/TgItemProxyPage.xaml
@@ -13,7 +13,7 @@
d:Background="{DynamicResource ApplicationBackgroundBrush}"
d:DataContext="{d:DesignInstance local:TgItemProxyPage,
IsDesignTimeCreatable=True}"
- d:DesignHeight="450"
+ d:DesignHeight="550"
d:DesignWidth="1300"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
mc:Ignorable="d">
@@ -204,13 +204,7 @@
IsEnabled="True"
ItemsSource="{Binding Source={x:Static utils:TgDesktopUtils.TgItemProxyVm}, Path=ProxyTypes, Mode=OneWay, IsAsync=True}"
SelectedIndex="0"
- SelectedItem="{Binding Source={x:Static utils:TgDesktopUtils.TgItemProxyVm}, Path=ItemProxyVm.ProxyType, Mode=TwoWay, IsAsync=True}">
-
-
+ SelectedItem="{Binding Source={x:Static utils:TgDesktopUtils.TgItemProxyVm}, Path=ItemProxyVm.ProxyType, Mode=TwoWay, IsAsync=True}" />