update banner view to main menu
This commit is contained in:
parent
3503415876
commit
87ec7eaf58
|
@ -25,8 +25,8 @@
|
|||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="0.1*"/>
|
||||
<RowDefinition Height="0.85*"/>
|
||||
<RowDefinition Height="0.05*"/>
|
||||
<RowDefinition Height="0.8*"/>
|
||||
<RowDefinition Height="0.1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0">
|
||||
|
|
|
@ -29,16 +29,13 @@
|
|||
<ColumnDefinition Width="0.8*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="0.05*"/>
|
||||
<RowDefinition Height="0.05*"/>
|
||||
<RowDefinition Height="0.8*"/>
|
||||
<RowDefinition Height="0.05*" MinHeight="48"/>
|
||||
<RowDefinition Height="0.85*"/>
|
||||
<RowDefinition Height="0.1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<WebView x:Name="BannerView" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||
|
||||
<TextBox
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Margin="5,0,5,10"
|
||||
x:Name="Search"
|
||||
PlaceholderText="Search"
|
||||
|
@ -46,7 +43,7 @@
|
|||
MaxHeight="32" CornerRadius="20"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" />
|
||||
|
||||
<Grid Grid.Row="2" Grid.Column="0" BorderBrush="Black" BorderThickness="1">
|
||||
<Grid Grid.Row="1" Grid.Column="0" BorderBrush="Black" BorderThickness="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
@ -70,33 +67,9 @@
|
|||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="3" Grid.Column="1">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<Button x:Name="btnFirst" Content="First" Click="btnFirst_Click"/>
|
||||
<Button x:Name="btnPrevious" Content="Previous" Click="btnPrevious_Click"/>
|
||||
<TextBlock x:Name="txtPageNumber" VerticalAlignment="Center" Margin="10">
|
||||
<Run Text="{x:Bind ViewModels.Pagination.Page, Mode=OneWay}" />
|
||||
<Run Text="/" />
|
||||
<Run Text="{x:Bind ViewModels.Pagination.TotalPage, Mode=OneWay}" />
|
||||
</TextBlock>
|
||||
<Button x:Name="btnNext" Content="Next" Click="btnNext_Click"/>
|
||||
<Button x:Name="btnLast" Content="Last" Click="btnLast_Click"/>
|
||||
<ComboBox
|
||||
VerticalAlignment="Center"
|
||||
ItemsSource="{Binding Pagination.AvailablePageSizes}"
|
||||
SelectedItem="{Binding Pagination.PageSize, Mode=TwoWay}" />
|
||||
<TextBlock VerticalAlignment="Center" Text="records/page" />
|
||||
<TextBlock VerticalAlignment="Center">
|
||||
<Run Text=" (total" />
|
||||
<Run Text="{Binding Pagination.TotalRecords, Mode=TwoWay}" />
|
||||
<Run Text="records)" />
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!--Filter Menu-->
|
||||
<Grid Grid.Row="1" Grid.Column="1" Margin="0,0,0,10" Padding="0,0,10,0">
|
||||
<Grid Grid.Row="0" Grid.Column="1" Margin="0,0,0,10" Padding="0,0,10,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
|
@ -154,7 +127,7 @@
|
|||
VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Column="1" Grid.Row="2" BorderBrush="Black" BorderThickness="0,1,1,1">
|
||||
<Grid Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="0,1,1,1">
|
||||
<ListView
|
||||
x:Name="FileList"
|
||||
ItemsSource="{Binding FilteredFiles.Items, Mode=OneWay}"
|
||||
|
@ -249,5 +222,29 @@
|
|||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="2" Grid.Column="1">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<Button x:Name="btnFirst" Content="First" Click="btnFirst_Click"/>
|
||||
<Button x:Name="btnPrevious" Content="Previous" Click="btnPrevious_Click"/>
|
||||
<TextBlock x:Name="txtPageNumber" VerticalAlignment="Center" Margin="10">
|
||||
<Run Text="{x:Bind ViewModels.Pagination.Page, Mode=OneWay}" />
|
||||
<Run Text="/" />
|
||||
<Run Text="{x:Bind ViewModels.Pagination.TotalPage, Mode=OneWay}" />
|
||||
</TextBlock>
|
||||
<Button x:Name="btnNext" Content="Next" Click="btnNext_Click"/>
|
||||
<Button x:Name="btnLast" Content="Last" Click="btnLast_Click"/>
|
||||
<ComboBox
|
||||
VerticalAlignment="Center"
|
||||
ItemsSource="{Binding Pagination.AvailablePageSizes}"
|
||||
SelectedItem="{Binding Pagination.PageSize, Mode=TwoWay}" />
|
||||
<TextBlock VerticalAlignment="Center" Text="records/page" />
|
||||
<TextBlock VerticalAlignment="Center">
|
||||
<Run Text=" (total" />
|
||||
<Run Text="{Binding Pagination.TotalRecords, Mode=TwoWay}" />
|
||||
<Run Text="records)" />
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
|
@ -53,12 +53,6 @@ namespace PCUT.Pages
|
|||
LoadRecentFiles();
|
||||
await ViewModels.MetadataModel.LoadAllMetadataAsync();
|
||||
ViewModels.Pagination.Page = 1;
|
||||
var isBannerLoaded = await ViewModels.GetBannersAsync();
|
||||
if (isBannerLoaded)
|
||||
{
|
||||
var uri = new System.Uri($"ms-appdata:///temp/banner/{FileListViewModel.BannerFile}");
|
||||
BannerView.Navigate(uri);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="0.25*"/>
|
||||
<RowDefinition Height="0.7*"/>
|
||||
<RowDefinition Height="0.05*"/>
|
||||
<RowDefinition Height="0.65*"/>
|
||||
<RowDefinition Height="0.1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
|
|
|
@ -94,14 +94,18 @@
|
|||
</NavigationView.MenuItems>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="0.05*" MinHeight="36"/>
|
||||
<RowDefinition Height="0.95*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.2*" />
|
||||
<ColumnDefinition Width="0.8*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Frame x:Name="ContentFrame" Grid.ColumnSpan="2" Navigated="ContentFrame_Navigated"/>
|
||||
<WebView x:Name="BannerView" Grid.Row="0" Grid.ColumnSpan="2"/>
|
||||
<Frame x:Name="ContentFrame" Grid.Row="1" Grid.ColumnSpan="2" Navigated="ContentFrame_Navigated"/>
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||
BorderBrush="Black" BorderThickness="0,0,1,0"
|
||||
Visibility="{Binding IsMenuDisplay, Mode=OneWay}">
|
||||
|
|
|
@ -46,6 +46,12 @@ namespace PCUT.Pages
|
|||
{
|
||||
ViewModel.Categories.Bind(CategoryList);
|
||||
await ViewModel.GetCategoriesAsync();
|
||||
var isBannerLoaded = await ViewModel.GetBannersAsync();
|
||||
if (isBannerLoaded)
|
||||
{
|
||||
var uri = new System.Uri($"ms-appdata:///temp/banner/{MainMenuPageViewModel.BannerFile}");
|
||||
BannerView.Navigate(uri);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
|
|
|
@ -21,7 +21,6 @@ namespace PCUT.ViewModels
|
|||
{
|
||||
internal class FileListViewModel : NotificationBase
|
||||
{
|
||||
public const string BannerFile = "banner.html";
|
||||
public PaginationViewModel Pagination { get; }
|
||||
public MetadataViewModel MetadataModel { get; }
|
||||
|
||||
|
@ -81,44 +80,6 @@ namespace PCUT.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<bool> GetBannersAsync()
|
||||
{
|
||||
using (var client = HttpClientFactory.CreateClient(ClientNames.ApiClient))
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await client.GetAsync($"{Api.Banner}?page=1&pageSize={int.MaxValue}");
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var apiResponse = await response.DeserializeObjectAsync<PaginationResponse<IEnumerable<Banner>>>();
|
||||
var banners = apiResponse.Data;
|
||||
var contentBuilder = new StringBuilder();
|
||||
contentBuilder.Append(
|
||||
@"<!DOCTYPE html><html>
|
||||
<head><style>
|
||||
.marquee-container {display: flex;overflow: hidden;white-space: nowrap;animation: marquee 30s linear infinite;}
|
||||
.marquee-text {width: 100%}
|
||||
@keyframes marquee {0% {transform: translateX(100%);} 100% {transform: translateX(-100%);}}
|
||||
</style></head>
|
||||
<body><div class=""marquee-container"">");
|
||||
foreach (var banner in banners)
|
||||
{
|
||||
contentBuilder.Append(@"<div class=""marquee-text"">").Append(banner.Content).Append("</div>");
|
||||
}
|
||||
contentBuilder.Append(@"</div></body></html>");
|
||||
StorageFolder folder = await ApplicationData.Current.TemporaryFolder.CreateFolderAsync("banner", CreationCollisionOption.OpenIfExists);
|
||||
StorageFile file = await folder.CreateFileAsync(BannerFile, CreationCollisionOption.ReplaceExisting);
|
||||
await FileIO.WriteTextAsync(file, contentBuilder.ToString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (!(ex is AppOutdatedException))
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Reload()
|
||||
{
|
||||
await GetFilesByFilterAsync(Pagination.Page, Pagination.PageSize, Pagination.SearchText);
|
||||
|
|
|
@ -7,11 +7,18 @@ using Http.Core.Extensions;
|
|||
using static Http.Core.Constants.HttpConstants;
|
||||
using Http.Core.Contexts;
|
||||
using Windows.UI.Xaml;
|
||||
using Http.Core.Exceptions;
|
||||
using PCUT.Entities.ApiResponse;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace PCUT.ViewModels
|
||||
{
|
||||
public class MainMenuPageViewModel : NotificationBase
|
||||
{
|
||||
public const string BannerFile = "banner.html";
|
||||
|
||||
private string _userName;
|
||||
public string UserName
|
||||
{
|
||||
|
@ -90,6 +97,44 @@ namespace PCUT.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<bool> GetBannersAsync()
|
||||
{
|
||||
using (var client = HttpClientFactory.CreateClient(ClientNames.ApiClient))
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await client.GetAsync($"{Api.Banner}?page=1&pageSize={int.MaxValue}");
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var apiResponse = await response.DeserializeObjectAsync<PaginationResponse<IEnumerable<Banner>>>();
|
||||
var banners = apiResponse.Data;
|
||||
var contentBuilder = new StringBuilder();
|
||||
contentBuilder.Append(
|
||||
@"<!DOCTYPE html><html>
|
||||
<head><style>
|
||||
.marquee-container {display: flex;overflow: hidden;white-space: nowrap;animation: marquee 30s linear infinite;}
|
||||
.marquee-text {width: 100%}
|
||||
@keyframes marquee {0% {transform: translateX(100%);} 100% {transform: translateX(-100%);}}
|
||||
</style></head>
|
||||
<body><div class=""marquee-container"">");
|
||||
foreach (var banner in banners)
|
||||
{
|
||||
contentBuilder.Append(@"<div class=""marquee-text"">").Append(banner.Content).Append("</div>");
|
||||
}
|
||||
contentBuilder.Append(@"</div></body></html>");
|
||||
StorageFolder folder = await ApplicationData.Current.TemporaryFolder.CreateFolderAsync("banner", CreationCollisionOption.OpenIfExists);
|
||||
StorageFile file = await folder.CreateFileAsync(BannerFile, CreationCollisionOption.ReplaceExisting);
|
||||
await FileIO.WriteTextAsync(file, contentBuilder.ToString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (!(ex is AppOutdatedException))
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public string DataCenterSearchValue { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue