Skip to content

Commit 65fe891

Browse files
committed
Add Page Navigation
1 parent 37a8f26 commit 65fe891

File tree

7 files changed

+162
-18
lines changed

7 files changed

+162
-18
lines changed

Flow.Launcher/Resources/Pages/WelcomePage1.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Title="WelcomePage1"
99
d:DesignHeight="450"
1010
d:DesignWidth="800"
11+
Background="#cecece"
1112
mc:Ignorable="d">
1213

1314
<ScrollViewer>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Page x:Class="Flow.Launcher.Resources.Pages.WelcomePage4"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800"
9+
Title="WelcomePage4">
10+
11+
<Grid>
12+
13+
</Grid>
14+
</Page>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace Flow.Launcher.Resources.Pages
17+
{
18+
/// <summary>
19+
/// WelcomePage4.xaml에 대한 상호 작용 논리
20+
/// </summary>
21+
public partial class WelcomePage4 : Page
22+
{
23+
public WelcomePage4()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Page x:Class="Flow.Launcher.Resources.Pages.WelcomePage5"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:Flow.Launcher.Resources.Pages"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800"
9+
Title="WelcomePage5">
10+
11+
<Grid>
12+
13+
</Grid>
14+
</Page>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace Flow.Launcher.Resources.Pages
17+
{
18+
/// <summary>
19+
/// WelcomePage5.xaml에 대한 상호 작용 논리
20+
/// </summary>
21+
public partial class WelcomePage5 : Page
22+
{
23+
public WelcomePage5()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

Flow.Launcher/WelcomeWindow.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
</Grid>
7474
</StackPanel>
7575
<!--#endregion-->
76-
<StackPanel Margin="26,12,26,0">
76+
<StackPanel Margin="0">
7777
<ui:Frame
7878
x:Name="ContentFrame"
7979
MinHeight="600"
@@ -93,18 +93,20 @@
9393
BorderThickness="0,1,0,0">
9494
<DockPanel>
9595
<Button
96+
x:Name="NextButton"
9697
Width="50"
9798
Height="50"
9899
Margin="10,5,28,5"
99-
Click="BackwardButton_Click"
100+
Click="ForwardButton_Click"
100101
Content="&#xe76c;"
101102
DockPanel.Dock="Right"
102103
FontFamily="/Resources/#Segoe Fluent Icons"
103104
FontSize="22" />
104105
<Button
106+
x:Name="BackButton"
105107
Width="50"
106108
Height="50"
107-
Click="ForwardButton_Click"
109+
Click="BackwardButton_Click"
108110
Content="&#xe76b;"
109111
DockPanel.Dock="Right"
110112
FontFamily="/Resources/#Segoe Fluent Icons"

Flow.Launcher/WelcomeWindow.xaml.cs

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Windows.Shapes;
1414
using ModernWpf.Media.Animation;
1515
using Page = ModernWpf.Controls.Page;
16+
using WelcomePages = Flow.Launcher.Resources.Pages;
1617

1718
namespace Flow.Launcher
1819
{
@@ -24,38 +25,94 @@ public partial class WelcomeWindow : Window
2425
public WelcomeWindow()
2526
{
2627
InitializeComponent();
27-
ContentFrame.Navigate(typeof(SamplePages.SamplePage1));
28+
//ContentFrame.Navigate(typeof(SamplePages.SamplePage1));
29+
ContentFrame.Navigate(typeof(WelcomePages.WelcomePage1));
30+
BackButton.IsEnabled = false;
2831
}
29-
30-
private void ForwardButton_Click(object sender, RoutedEventArgs e)
32+
private int page;
33+
private int MaxPage = 5;
34+
35+
/*public int Page
3136
{
32-
/*
33-
var pageToNavigateTo = ContentFrame.BackStackDepth % 2 == 1 ? typeof(SamplePages.SamplePage1) : typeof(SamplePages.SamplePage2);
37+
get { return this.page; }
38+
set
39+
{
40+
this.page = value;
41+
if (this.page == 1)
42+
{
43+
this.BackButton.IsEnabled = false;
44+
}
45+
else
46+
{
47+
this.BackButton.IsEnabled = true;
48+
};
49+
}
50+
}
51+
*/
3452

35-
if (_transitionInfo == null)
53+
private void ButtonDisabler()
54+
{
55+
if (page == 0)
3656
{
37-
// Default behavior, no transition set or used.
38-
ContentFrame.Navigate(pageToNavigateTo, null);
57+
BackButton.IsEnabled = false;
58+
NextButton.IsEnabled = true;
3959
}
40-
else
60+
else if (page == MaxPage - 1)
4161
{
42-
// Explicit transition info used.
43-
ContentFrame.Navigate(pageToNavigateTo, null, _transitionInfo);
62+
BackButton.IsEnabled = true;
63+
NextButton.IsEnabled = false;
64+
}
65+
else
66+
{
67+
BackButton.IsEnabled = true;
68+
NextButton.IsEnabled = true;
69+
}
70+
}
71+
private NavigationTransitionInfo _transitionInfo = new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight };
72+
73+
private static Type PageSelector(int a)
74+
{
75+
switch (a)
76+
{
77+
case 0:
78+
return typeof(WelcomePages.WelcomePage1);
79+
case 1:
80+
return typeof(WelcomePages.WelcomePage2);
81+
case 2:
82+
return typeof(WelcomePages.WelcomePage3);
83+
case 3:
84+
return typeof(WelcomePages.WelcomePage4);
85+
case 4:
86+
return typeof(WelcomePages.WelcomePage5);
87+
default:
88+
return typeof(WelcomePages.WelcomePage1);
4489
}
45-
*/
90+
}
91+
private void ForwardButton_Click(object sender, RoutedEventArgs e)
92+
{
93+
page = page + 1;
94+
ButtonDisabler();
95+
var pageToNavigateTo = PageSelector(page);
96+
ContentFrame.Navigate(pageToNavigateTo, null, _transitionInfo);
4697
}
4798

4899
private void BackwardButton_Click(object sender, RoutedEventArgs e)
49-
{/*
50-
if (ContentFrame.BackStackDepth > 0)
100+
{
101+
if (page > 0)
51102
{
103+
page = page - 1;
104+
ButtonDisabler();
52105
ContentFrame.GoBack();
53106
}
54-
*/
107+
else
108+
{
109+
BackButton.IsEnabled = false;
110+
}
55111
}
56112
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
57113
{
58114
Close();
59115
}
60116
}
61117
}
118+

0 commit comments

Comments
 (0)