update banner view to main menu
This commit is contained in:
parent
3503415876
commit
87ec7eaf58
|
@ -25,8 +25,8 @@
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="0.1*"/>
|
<RowDefinition Height="0.1*"/>
|
||||||
<RowDefinition Height="0.85*"/>
|
<RowDefinition Height="0.8*"/>
|
||||||
<RowDefinition Height="0.05*"/>
|
<RowDefinition Height="0.1*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Grid Grid.Row="0">
|
<Grid Grid.Row="0">
|
||||||
|
|
|
@ -29,16 +29,13 @@
|
||||||
<ColumnDefinition Width="0.8*"/>
|
<ColumnDefinition Width="0.8*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="0.05*"/>
|
<RowDefinition Height="0.05*" MinHeight="48"/>
|
||||||
<RowDefinition Height="0.05*"/>
|
<RowDefinition Height="0.85*"/>
|
||||||
<RowDefinition Height="0.8*"/>
|
|
||||||
<RowDefinition Height="0.1*"/>
|
<RowDefinition Height="0.1*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<WebView x:Name="BannerView" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
|
||||||
|
|
||||||
<TextBox
|
<TextBox
|
||||||
Grid.Row="1" Grid.Column="0"
|
Grid.Row="0" Grid.Column="0"
|
||||||
Margin="5,0,5,10"
|
Margin="5,0,5,10"
|
||||||
x:Name="Search"
|
x:Name="Search"
|
||||||
PlaceholderText="Search"
|
PlaceholderText="Search"
|
||||||
|
@ -46,7 +43,7 @@
|
||||||
MaxHeight="32" CornerRadius="20"
|
MaxHeight="32" CornerRadius="20"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" />
|
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>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
@ -71,32 +68,8 @@
|
||||||
</ListView>
|
</ListView>
|
||||||
</Grid>
|
</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-->
|
<!--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>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
|
@ -154,7 +127,7 @@
|
||||||
VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
|
VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
|
||||||
</Grid>
|
</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
|
<ListView
|
||||||
x:Name="FileList"
|
x:Name="FileList"
|
||||||
ItemsSource="{Binding FilteredFiles.Items, Mode=OneWay}"
|
ItemsSource="{Binding FilteredFiles.Items, Mode=OneWay}"
|
||||||
|
@ -249,5 +222,29 @@
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</ListView>
|
</ListView>
|
||||||
</Grid>
|
</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>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
@ -53,12 +53,6 @@ namespace PCUT.Pages
|
||||||
LoadRecentFiles();
|
LoadRecentFiles();
|
||||||
await ViewModels.MetadataModel.LoadAllMetadataAsync();
|
await ViewModels.MetadataModel.LoadAllMetadataAsync();
|
||||||
ViewModels.Pagination.Page = 1;
|
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)
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="0.25*"/>
|
<RowDefinition Height="0.25*"/>
|
||||||
<RowDefinition Height="0.7*"/>
|
<RowDefinition Height="0.65*"/>
|
||||||
<RowDefinition Height="0.05*"/>
|
<RowDefinition Height="0.1*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,14 +94,18 @@
|
||||||
</NavigationView.MenuItems>
|
</NavigationView.MenuItems>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="0.05*" MinHeight="36"/>
|
||||||
|
<RowDefinition Height="0.95*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="0.2*" />
|
<ColumnDefinition Width="0.2*" />
|
||||||
<ColumnDefinition Width="0.8*" />
|
<ColumnDefinition Width="0.8*" />
|
||||||
</Grid.ColumnDefinitions>
|
</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
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.RowSpan="2"
|
||||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
||||||
BorderBrush="Black" BorderThickness="0,0,1,0"
|
BorderBrush="Black" BorderThickness="0,0,1,0"
|
||||||
Visibility="{Binding IsMenuDisplay, Mode=OneWay}">
|
Visibility="{Binding IsMenuDisplay, Mode=OneWay}">
|
||||||
|
|
|
@ -46,6 +46,12 @@ namespace PCUT.Pages
|
||||||
{
|
{
|
||||||
ViewModel.Categories.Bind(CategoryList);
|
ViewModel.Categories.Bind(CategoryList);
|
||||||
await ViewModel.GetCategoriesAsync();
|
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)
|
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||||
|
|
|
@ -21,7 +21,6 @@ namespace PCUT.ViewModels
|
||||||
{
|
{
|
||||||
internal class FileListViewModel : NotificationBase
|
internal class FileListViewModel : NotificationBase
|
||||||
{
|
{
|
||||||
public const string BannerFile = "banner.html";
|
|
||||||
public PaginationViewModel Pagination { get; }
|
public PaginationViewModel Pagination { get; }
|
||||||
public MetadataViewModel MetadataModel { 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()
|
public async Task Reload()
|
||||||
{
|
{
|
||||||
await GetFilesByFilterAsync(Pagination.Page, Pagination.PageSize, Pagination.SearchText);
|
await GetFilesByFilterAsync(Pagination.Page, Pagination.PageSize, Pagination.SearchText);
|
||||||
|
|
|
@ -7,11 +7,18 @@ using Http.Core.Extensions;
|
||||||
using static Http.Core.Constants.HttpConstants;
|
using static Http.Core.Constants.HttpConstants;
|
||||||
using Http.Core.Contexts;
|
using Http.Core.Contexts;
|
||||||
using Windows.UI.Xaml;
|
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
|
namespace PCUT.ViewModels
|
||||||
{
|
{
|
||||||
public class MainMenuPageViewModel : NotificationBase
|
public class MainMenuPageViewModel : NotificationBase
|
||||||
{
|
{
|
||||||
|
public const string BannerFile = "banner.html";
|
||||||
|
|
||||||
private string _userName;
|
private string _userName;
|
||||||
public 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; }
|
public string DataCenterSearchValue { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue