mirror of
https://github.com/vbondarevsky/OneCleaner.git
synced 2024-11-21 10:05:50 +02:00
Асинхронное заполнение списков. Интерфейс
This commit is contained in:
parent
b366d9fcfe
commit
36d9dc5441
@ -11,6 +11,8 @@
|
||||
<local:MainWindowViewModel />
|
||||
</Window.DataContext>
|
||||
<Window.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1"/>
|
||||
<local:StatusToTextConverter x:Key="StatusToTextConverter"/>
|
||||
<local:LongToSizeStringConverter x:Key="LongToSizeStringConverter"/>
|
||||
<local:StatusToTaskbarStatusConverter x:Key="StatusToTaskbarStatusConverter"/>
|
||||
@ -86,15 +88,9 @@
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock TextWrapping="Wrap" Text="Получение списка установленных версий..." HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Foreground="#FF9C9C9C" Grid.Row="1"/>
|
||||
<ListView
|
||||
ItemsSource="{Binding InstalledVersions}"
|
||||
ItemTemplate="{StaticResource installedVersionItem}"
|
||||
PreviewKeyDown="List_PreviewKeyDown"
|
||||
Grid.Row="1" />
|
||||
|
||||
|
||||
<StackPanel HorizontalAlignment="Left" Grid.Column="0" Grid.Row="0" Orientation="Horizontal">
|
||||
<StackPanel HorizontalAlignment="Left" Grid.Column="0" Grid.Row="0" Orientation="Horizontal" >
|
||||
<Button Margin="0,3" Background="{x:Null}" BorderThickness="0.4" Command="{Binding SelectAllInstalledVersionCommand}" Width="25" Height="25" HorizontalContentAlignment="Center">
|
||||
<Image Source="../Resource/checked.png" Stretch="None" />
|
||||
</Button>
|
||||
@ -105,6 +101,19 @@
|
||||
<StackPanel HorizontalAlignment="Right" Grid.Column="1" Grid.Row="0" VerticalAlignment="Center">
|
||||
<Button Content="{Binding Status, Converter={StaticResource StatusToTextConverter}, Mode=OneWay}" Height="25" Width="110" Command="{Binding UninstallCommand}"/>
|
||||
</StackPanel>
|
||||
<ListView
|
||||
ItemsSource="{Binding InstalledVersions}"
|
||||
ItemTemplate="{StaticResource installedVersionItem}"
|
||||
PreviewKeyDown="List_PreviewKeyDown"
|
||||
Grid.Row="1" />
|
||||
<TextBlock TextWrapping="Wrap"
|
||||
Text="Получение списка установленных версий..."
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="18"
|
||||
Foreground="#FF9C9C9C"
|
||||
Grid.Row="1" Visibility="{Binding InstalledVersionsArePopulating, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" />
|
||||
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Кэш">
|
||||
@ -129,6 +138,14 @@
|
||||
ItemTemplate="{StaticResource cacheItem}"
|
||||
PreviewKeyDown="List_PreviewKeyDown"
|
||||
Grid.Row="1" />
|
||||
|
||||
<TextBlock TextWrapping="Wrap"
|
||||
Text="Получение списка кэшей метаданных..."
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="18"
|
||||
Foreground="#FF9C9C9C"
|
||||
Grid.Row="1" Visibility="{Binding CacheArePopulating, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Информационные базы">
|
||||
@ -153,6 +170,15 @@
|
||||
ItemTemplate="{StaticResource infoBaseItem}"
|
||||
PreviewKeyDown="List_PreviewKeyDown"
|
||||
Grid.Row="1" />
|
||||
|
||||
<TextBlock TextWrapping="Wrap"
|
||||
Text="Получение списка информационных баз..."
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="18"
|
||||
Foreground="#FF9C9C9C"
|
||||
Grid.Row="1" Visibility="{Binding InfoBasesArePopulating, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" />
|
||||
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
@ -11,6 +11,10 @@ namespace OneCleaner
|
||||
public Status Status { get; private set; }
|
||||
public double Progress { get; private set; }
|
||||
|
||||
public bool InstalledVersionsArePopulating { get; private set; }
|
||||
public bool CacheArePopulating { get; private set; }
|
||||
public bool InfoBasesArePopulating { get; private set; }
|
||||
|
||||
public ObservableCollection<InstalledVersionItemViewModel> InstalledVersions { get; private set; }
|
||||
public ObservableCollection<CacheItemViewModel> Cache { get; private set; }
|
||||
public ObservableCollection<InfoBaseItemViewModel> InfoBases { get; private set; }
|
||||
@ -26,11 +30,9 @@ namespace OneCleaner
|
||||
InstalledVersions = new ObservableCollection<InstalledVersionItemViewModel>();
|
||||
PopulateInstalledVersions();
|
||||
|
||||
Cache = new ObservableCollection<CacheItemViewModel>();
|
||||
PopulateCache();
|
||||
|
||||
InfoBases = new ObservableCollection<InfoBaseItemViewModel>();
|
||||
PopulateInfoBases();
|
||||
Cache = new ObservableCollection<CacheItemViewModel>();
|
||||
PopulateInfoBasesAndCache();
|
||||
|
||||
UninstallCommand = new RelayCommand(Uninstall);
|
||||
|
||||
@ -39,11 +41,6 @@ namespace OneCleaner
|
||||
|
||||
UnselectAllInstalledVersionCommand = new RelayCommand(
|
||||
() => { InstalledVersions.Select(item => { item.IsChecked = false; return item; }).ToList(); });
|
||||
|
||||
foreach (var item in Cache)
|
||||
{
|
||||
item.Name = InfoBases.Where(i => i.UUID == item.UUID).FirstOrDefault()?.Name;
|
||||
}
|
||||
}
|
||||
|
||||
private async void Uninstall()
|
||||
@ -85,26 +82,35 @@ namespace OneCleaner
|
||||
Status = Status.Idle;
|
||||
}
|
||||
|
||||
private async void PopulateInfoBases()
|
||||
private async void PopulateInfoBasesAndCache()
|
||||
{
|
||||
InfoBasesArePopulating = true;
|
||||
InfoBases.Clear();
|
||||
CacheArePopulating = true;
|
||||
Cache.Clear();
|
||||
|
||||
foreach (var item in await Platform.GetInfoBases())
|
||||
{
|
||||
InfoBases.Add(new InfoBaseItemViewModel() { Name = item.Name, UUID = item.UUID, Size = item.Size, Connection = item.Connection });
|
||||
}
|
||||
}
|
||||
|
||||
private async void PopulateCache()
|
||||
{
|
||||
Cache.Clear();
|
||||
|
||||
foreach (var item in await Platform.GetCache())
|
||||
{
|
||||
Cache.Add(new CacheItemViewModel() { Path = item.Path, UUID = item.UUID, Size = item.Size });
|
||||
}
|
||||
|
||||
InfoBasesArePopulating = false;
|
||||
CacheArePopulating = false;
|
||||
|
||||
foreach (var item in Cache)
|
||||
{
|
||||
item.Name = InfoBases.Where(i => i.UUID == item.UUID).FirstOrDefault()?.Name;
|
||||
}
|
||||
}
|
||||
|
||||
private async void PopulateInstalledVersions()
|
||||
{
|
||||
InstalledVersionsArePopulating = true;
|
||||
InstalledVersions.Clear();
|
||||
foreach (var item in await Platform.GetInstalledVersions())
|
||||
{
|
||||
@ -119,6 +125,7 @@ namespace OneCleaner
|
||||
}
|
||||
);
|
||||
}
|
||||
InstalledVersionsArePopulating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user