Add Page Navigation

This commit is contained in:
DB p 2021-12-01 00:44:02 +09:00
parent 37a8f26a74
commit 65fe8917f1
7 changed files with 164 additions and 20 deletions

View file

@ -8,6 +8,7 @@
Title="WelcomePage1" Title="WelcomePage1"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800" d:DesignWidth="800"
Background="#cecece"
mc:Ignorable="d"> mc:Ignorable="d">
<ScrollViewer> <ScrollViewer>

View file

@ -0,0 +1,14 @@
<Page x:Class="Flow.Launcher.Resources.Pages.WelcomePage4"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="WelcomePage4">
<Grid>
</Grid>
</Page>

View file

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Flow.Launcher.Resources.Pages
{
/// <summary>
/// WelcomePage4.xaml에 대한 상호 작용 논리
/// </summary>
public partial class WelcomePage4 : Page
{
public WelcomePage4()
{
InitializeComponent();
}
}
}

View file

@ -0,0 +1,14 @@
<Page x:Class="Flow.Launcher.Resources.Pages.WelcomePage5"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="WelcomePage5">
<Grid>
</Grid>
</Page>

View file

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Flow.Launcher.Resources.Pages
{
/// <summary>
/// WelcomePage5.xaml에 대한 상호 작용 논리
/// </summary>
public partial class WelcomePage5 : Page
{
public WelcomePage5()
{
InitializeComponent();
}
}
}

View file

@ -73,7 +73,7 @@
</Grid> </Grid>
</StackPanel> </StackPanel>
<!--#endregion--> <!--#endregion-->
<StackPanel Margin="26,12,26,0"> <StackPanel Margin="0">
<ui:Frame <ui:Frame
x:Name="ContentFrame" x:Name="ContentFrame"
MinHeight="600" MinHeight="600"
@ -93,18 +93,20 @@
BorderThickness="0,1,0,0"> BorderThickness="0,1,0,0">
<DockPanel> <DockPanel>
<Button <Button
x:Name="NextButton"
Width="50" Width="50"
Height="50" Height="50"
Margin="10,5,28,5" Margin="10,5,28,5"
Click="BackwardButton_Click" Click="ForwardButton_Click"
Content="&#xe76c;" Content="&#xe76c;"
DockPanel.Dock="Right" DockPanel.Dock="Right"
FontFamily="/Resources/#Segoe Fluent Icons" FontFamily="/Resources/#Segoe Fluent Icons"
FontSize="22" /> FontSize="22" />
<Button <Button
x:Name="BackButton"
Width="50" Width="50"
Height="50" Height="50"
Click="ForwardButton_Click" Click="BackwardButton_Click"
Content="&#xe76b;" Content="&#xe76b;"
DockPanel.Dock="Right" DockPanel.Dock="Right"
FontFamily="/Resources/#Segoe Fluent Icons" FontFamily="/Resources/#Segoe Fluent Icons"

View file

@ -13,6 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using ModernWpf.Media.Animation; using ModernWpf.Media.Animation;
using Page = ModernWpf.Controls.Page; using Page = ModernWpf.Controls.Page;
using WelcomePages = Flow.Launcher.Resources.Pages;
namespace Flow.Launcher namespace Flow.Launcher
{ {
@ -24,34 +25,89 @@ namespace Flow.Launcher
public WelcomeWindow() public WelcomeWindow()
{ {
InitializeComponent(); InitializeComponent();
ContentFrame.Navigate(typeof(SamplePages.SamplePage1)); //ContentFrame.Navigate(typeof(SamplePages.SamplePage1));
ContentFrame.Navigate(typeof(WelcomePages.WelcomePage1));
BackButton.IsEnabled = false;
} }
private int page;
private int MaxPage = 5;
private void ForwardButton_Click(object sender, RoutedEventArgs e) /*public int Page
{ {
/* get { return this.page; }
var pageToNavigateTo = ContentFrame.BackStackDepth % 2 == 1 ? typeof(SamplePages.SamplePage1) : typeof(SamplePages.SamplePage2); set
if (_transitionInfo == null)
{ {
// Default behavior, no transition set or used. this.page = value;
ContentFrame.Navigate(pageToNavigateTo, null); if (this.page == 1)
{
this.BackButton.IsEnabled = false;
}
else
{
this.BackButton.IsEnabled = true;
};
}
}
*/
private void ButtonDisabler()
{
if (page == 0)
{
BackButton.IsEnabled = false;
NextButton.IsEnabled = true;
}
else if (page == MaxPage - 1)
{
BackButton.IsEnabled = true;
NextButton.IsEnabled = false;
} }
else else
{ {
// Explicit transition info used. BackButton.IsEnabled = true;
ContentFrame.Navigate(pageToNavigateTo, null, _transitionInfo); NextButton.IsEnabled = true;
} }
*/ }
private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight };
private static Type PageSelector(int a)
{
switch (a)
{
case 0:
return typeof(WelcomePages.WelcomePage1);
case 1:
return typeof(WelcomePages.WelcomePage2);
case 2:
return typeof(WelcomePages.WelcomePage3);
case 3:
return typeof(WelcomePages.WelcomePage4);
case 4:
return typeof(WelcomePages.WelcomePage5);
default:
return typeof(WelcomePages.WelcomePage1);
}
}
private void ForwardButton_Click(object sender, RoutedEventArgs e)
{
page = page + 1;
ButtonDisabler();
var pageToNavigateTo = PageSelector(page);
ContentFrame.Navigate(pageToNavigateTo, null, _transitionInfo);
} }
private void BackwardButton_Click(object sender, RoutedEventArgs e) private void BackwardButton_Click(object sender, RoutedEventArgs e)
{/* {
if (ContentFrame.BackStackDepth > 0) if (page > 0)
{ {
page = page - 1;
ButtonDisabler();
ContentFrame.GoBack(); ContentFrame.GoBack();
} }
*/ else
{
BackButton.IsEnabled = false;
}
} }
private void BtnCancel_OnClick(object sender, RoutedEventArgs e) private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
{ {
@ -59,3 +115,4 @@ namespace Flow.Launcher
} }
} }
} }