Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

将设置页改为对话框 #121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions PixivFSUWP/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ public async void SelectNavPlaceholder(string title)
NavSelect(5);
}

private void BtnSetting_Click(object sender, RoutedEventArgs e)
private async void BtnSetting_Click(object sender, RoutedEventArgs e)
{
ContentFrame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo);
//ContentFrame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo);
await new SettingsDialog().ShowAsync();
}

private async void Page_Loaded(object sender, RoutedEventArgs e)
Expand Down
6 changes: 3 additions & 3 deletions PixivFSUWP/PixivFSUWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@
<Compile Include="SearchPage.xaml.cs">
<DependentUpon>SearchPage.xaml</DependentUpon>
</Compile>
<Compile Include="SettingsPage.xaml.cs">
<DependentUpon>SettingsPage.xaml</DependentUpon>
<Compile Include="SettingsDialog.xaml.cs">
<DependentUpon>SettingsDialog.xaml</DependentUpon>
</Compile>
<Compile Include="UserDetailPage.xaml.cs">
<DependentUpon>UserDetailPage.xaml</DependentUpon>
Expand Down Expand Up @@ -280,7 +280,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SettingsPage.xaml">
<Page Include="SettingsDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
8 changes: 4 additions & 4 deletions PixivFSUWP/SearchPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,25 +226,25 @@ private async void btnSauceNAO_Click(object sender, RoutedEventArgs e)
//读取设置项
if (localSettings.Values["SauceNAOAPI"] as string == null)
{
Frame.Navigate(typeof(SettingsPage),null, App.FromRightTransitionInfo);
Frame.Navigate(typeof(SettingsDialog),null, App.FromRightTransitionInfo);
SAUCENAO_API_KEY = sauceNAOAPI;
return;
}
else if ((localSettings.Values["SauceNAOAPI"] as string).Length == 0)
{
Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo);
Frame.Navigate(typeof(SettingsDialog), null, App.FromRightTransitionInfo);
SAUCENAO_API_KEY = sauceNAOAPI;
return;
}
if (localSettings.Values["ImgurAPI"] as string == null)
{
Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo);
Frame.Navigate(typeof(SettingsDialog), null, App.FromRightTransitionInfo);
IMGUR_API_KEY = imgurAPI;
return;
}
else if ((localSettings.Values["ImgurAPI"] as string).Length == 0)
{
Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo);
Frame.Navigate(typeof(SettingsDialog), null, App.FromRightTransitionInfo);
IMGUR_API_KEY = imgurAPI;
return;
}
Expand Down
80 changes: 52 additions & 28 deletions PixivFSUWP/SettingsPage.xaml → PixivFSUWP/SettingsDialog.xaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<Page
x:Class="PixivFSUWP.SettingsPage"
<ContentDialog
x:Class="PixivFSUWP.SettingsDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PixivFSUWP"
xmlns:viewmodels="using:PixivFSUWP.ViewModels"
xmlns:converters="using:PixivFSUWP.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{StaticResource PageBackGround}"
PrimaryButtonStyle="{StaticResource ButtonRevealStyle}"
mc:Ignorable="d">
<Page.Resources>

<FrameworkElement.Resources>
<converters:ContributionsConverter x:Key="ContributionsConverter"/>
<Style x:Key="contributorStyle" TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
</Style>
<DataTemplate x:Key="contributorTemplate" x:DataType="viewmodels:ContributorViewModel">
<Grid Margin="-3 5 -5 5" Width="350">
<Grid Margin="-3 5 -5 5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="45"/>
<ColumnDefinition/>
Expand All @@ -32,12 +37,12 @@
<TextBlock Text="{Binding Contributions,Converter={StaticResource ContributionsConverter}}" Grid.RowSpan="2" Grid.Column="2" VerticalAlignment="Center"/>
</Grid>
</DataTemplate>
</Page.Resources>
</FrameworkElement.Resources>

<ScrollViewer Background="{StaticResource PageBackGround}" VerticalScrollBarVisibility="Hidden">
<StackPanel Margin="0,75,0,0">
<ScrollViewer VerticalScrollBarVisibility="Hidden">
<StackPanel>
<TextBlock Margin="15,20,15,0" FontSize="18" FontWeight="Bold" x:Uid="CurrentUser"/>
<Grid Margin="15,15,15,10" Width="Auto" HorizontalAlignment="Left">
<Grid Margin="15,15,15,10">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
Expand Down Expand Up @@ -83,35 +88,47 @@
<!--颜色主题-->
<StackPanel Margin="0 10">
<TextBlock Margin="15 0" FontSize="18" FontWeight="Bold" x:Uid="ColorTheme"/>
<ComboBox Margin="15 10 15 0" Width="300" DropDownClosed="ComboBox_DropDownClosed" x:Name="cboxColorTheme">
<ComboBox Margin="15 10 15 0" HorizontalAlignment="Stretch" DropDownClosed="ComboBox_DropDownClosed" x:Name="cboxColorTheme">
<ComboBoxItem x:Uid="LightColorTheme"/>
<ComboBoxItem x:Uid="DarkColorTheme"/>
<ComboBoxItem x:Uid="DefaultColorTheme"/>
</ComboBox>
</StackPanel>
<!--缓存管理-->
<StackPanel Margin="0,10">
<TextBlock Margin="15,0,15,0" FontSize="18" FontWeight="Bold" x:Uid="Cache"/>
<StackPanel Margin="15,10,15,0" Orientation="Horizontal">
<StackPanel Margin="15,10">
<TextBlock FontSize="18" FontWeight="Bold" x:Uid="Cache"/>
<StackPanel Margin="0 10 0 0" Orientation="Horizontal">
<TextBlock x:Uid="CacheSize"/>
<TextBlock x:Name="txtCacheSize" x:Uid="Calculating"/>
</StackPanel>
<Button Style="{StaticResource ButtonRevealStyle}" BorderThickness="1.5"
Margin="15,10,15,0" x:Uid="ClearCache"
Width="170" x:Name="btnClearCache" Click="btnClearCache_Click"/>
<Button Style="{StaticResource ButtonRevealStyle}"
BorderThickness="1.5" Margin="15,5,15,0" x:Uid="DeleteInvalid"
Width="170" x:Name="btnDelInvalid" Click="btnDelInvalid_Click"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="5"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Style="{StaticResource ButtonRevealStyle}" BorderThickness="1.5"
HorizontalAlignment="Stretch" x:Uid="ClearCache"
x:Name="btnClearCache" Click="btnClearCache_Click"/>
<Button Grid.Column="2" Style="{StaticResource ButtonRevealStyle}" BorderThickness="1.5"
HorizontalAlignment="Stretch" x:Uid="DeleteInvalid"
x:Name="btnDelInvalid" Click="btnDelInvalid_Click"/>
</Grid>
</StackPanel>
<!--版本信息-->
<StackPanel Margin="0,10">
<TextBlock Margin="15,0,15,0" FontSize="18" FontWeight="Bold" x:Uid="VersionInfo"/>
<TextBlock Margin="15,10,15,0" x:Name="txtVersion"/>
<TextBlock Margin="15,2,15,0" x:Name="txtPkgName"/>
<TextBlock Margin="15,2,15,0" x:Name="txtInsDate"/>
<StackPanel Orientation="Vertical" Margin="15,10,15,0">
<Button Style="{StaticResource ButtonRevealStyle}" BorderThickness="1.5" x:Name="btnGithub" Width="170" Height="Auto" Click="BtnGithub_Click">
<Grid Width="130">
<Grid Margin="15,10,15,0">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="5"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" HorizontalAlignment="Stretch" Style="{StaticResource ButtonRevealStyle}" BorderThickness="1.5" x:Name="btnGithub" Click="BtnGithub_Click">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="*"/>
Expand All @@ -120,8 +137,8 @@
<TextBlock Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10 0 0 0">GitHub Repo</TextBlock>
</Grid>
</Button>
<Button Margin="0 5 0 0" Style="{StaticResource ButtonRevealStyle}" BorderThickness="1.5" x:Name="btnQQGroup" Width="170" Height="Auto" Click="btnQQGroup_Click">
<Grid Width="130">
<Button Grid.Column="2" HorizontalAlignment="Stretch" Style="{StaticResource ButtonRevealStyle}" BorderThickness="1.5" x:Name="btnQQGroup" Click="btnQQGroup_Click">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="*"/>
Expand All @@ -130,20 +147,27 @@
<TextBlock Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10 0 0 0">QQ Community</TextBlock>
</Grid>
</Button>
</StackPanel>
</Grid>
</StackPanel>
<!--作者和参与者-->
<StackPanel Margin="0,10">
<TextBlock Margin="15,0,15,0" FontSize="18" FontWeight="Bold" x:Uid="Developers"/>
<TextBlock Margin="15,10,15,0" x:Uid="MainDeveloper"/>
<ListView Margin="15,10,0,0" x:Name="lstMainDev" SelectionMode="None" Width="365" HorizontalAlignment="Left"
<ListView Margin="15,10,0,0" x:Name="lstMainDev" SelectionMode="None"
ItemContainerStyle="{StaticResource contributorStyle}"
IsItemClickEnabled="True" ItemTemplate="{StaticResource contributorTemplate}" ItemClick="lstMainDev_ItemClick"/>
<TextBlock x:Name="txtContributors" Margin="15,10,5,0" x:Uid="Contributors"/>
<ProgressRing x:Name="progressLoadingContributors" Margin="15,10,5,0"
IsActive="False" Visibility="Collapsed" HorizontalAlignment="Left"/>
<ListView Margin="15,10,0,0" x:Name="lstContributors" SelectionMode="None" Width="365" Visibility="Collapsed" HorizontalAlignment="Left"
<ListView Margin="15,10,0,0" x:Name="lstContributors" SelectionMode="None" Visibility="Collapsed"
ItemContainerStyle="{StaticResource contributorStyle}"
IsItemClickEnabled="True" ItemTemplate="{StaticResource contributorTemplate}" ItemClick="lstMainDev_ItemClick"/>
</StackPanel>
<StackPanel.ChildrenTransitions>
<TransitionCollection>
<AddDeleteThemeTransition/>
</TransitionCollection>
</StackPanel.ChildrenTransitions>
</StackPanel>
</ScrollViewer>
</Page>
</ContentDialog>
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,38 @@ namespace PixivFSUWP
/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class SettingsPage : Page, IGoBackFlag
public sealed partial class SettingsDialog
{
public SettingsPage()
public SettingsDialog()
{
this.InitializeComponent();
_ = loadContentsAsync();
Title = GetResourceString("SettingsPagePlain");
PrimaryButtonText = GetResourceString("OKPlain");
}

private bool _backflag { get; set; } = false;

public void SetBackFlag(bool value)
{
_backflag = value;
}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
TheMainPage?.SelectNavPlaceholder(GetResourceString("SettingsPagePlain"));
}

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
if (!_backflag)
{
Data.Backstack.Default.Push(typeof(SettingsPage), null);
TheMainPage?.UpdateNavButtonState();
}
}
//private bool _backflag { get; set; } = false;

//public void SetBackFlag(bool value)
//{
// _backflag = value;
//}

//protected override void OnNavigatedTo(NavigationEventArgs e)
//{
// base.OnNavigatedTo(e);
// TheMainPage?.SelectNavPlaceholder(GetResourceString("SettingsPagePlain"));
//}

//protected override void OnNavigatedFrom(NavigationEventArgs e)
//{
// base.OnNavigatedFrom(e);
// if (!_backflag)
// {
// Data.Backstack.Default.Push(typeof(SettingsPage), null);
// TheMainPage?.UpdateNavButtonState();
// }
//}

async Task loadContentsAsync()
{
Expand Down