-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
392 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<phone:PhoneApplicationPage | ||
x:Class="sbbs_client_wp7.MailboxPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" | ||
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" | ||
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" | ||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
FontFamily="{StaticResource PhoneFontFamilyNormal}" | ||
FontSize="{StaticResource PhoneFontSizeNormal}" | ||
Foreground="{StaticResource PhoneForegroundBrush}" | ||
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait" | ||
mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480" | ||
toolkit:TiltEffect.IsTiltEnabled="True" | ||
shell:SystemTray.Opacity="{Binding IsLoading, Converter={StaticResource LoadedOpacityConerter}, ConverterParameter=true}" | ||
shell:SystemTray.IsVisible="True"> | ||
|
||
<phone:PhoneApplicationPage.Resources> | ||
<DataTemplate x:Key="MailDataTemplate"> | ||
<Grid Margin="0 0 0 10"> | ||
<Rectangle Fill="{StaticResource PhoneAccentBrush}" Width="8" HorizontalAlignment="Left"/> | ||
<StackPanel Orientation="Vertical" Margin="4 0 0 0"> | ||
<TextBlock Style="{StaticResource PhoneTextLargeStyle}" Foreground="{Binding Unread, Converter={StaticResource BoolAccentConverter}}" TextWrapping="Wrap" Text="{Binding Title}"/> | ||
<Grid> | ||
<TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{Binding Author}"/> | ||
<TextBlock HorizontalAlignment="Right" Text="{Binding Time, Converter={StaticResource StampDateConverter}}"/> | ||
</Grid> | ||
</StackPanel> | ||
</Grid> | ||
</DataTemplate> | ||
</phone:PhoneApplicationPage.Resources> | ||
|
||
<shell:SystemTray.ProgressIndicator> | ||
<shell:ProgressIndicator Text="载入中..." | ||
IsVisible="{Binding IsLoading}" | ||
IsIndeterminate="{Binding IsLoading}"/> | ||
</shell:SystemTray.ProgressIndicator> | ||
|
||
<toolkit:TransitionService.NavigationInTransition> | ||
<toolkit:NavigationInTransition> | ||
<toolkit:NavigationInTransition.Backward> | ||
<toolkit:TurnstileTransition Mode="BackwardIn"/> | ||
</toolkit:NavigationInTransition.Backward> | ||
<toolkit:NavigationInTransition.Forward> | ||
<toolkit:TurnstileTransition Mode="ForwardIn"/> | ||
</toolkit:NavigationInTransition.Forward> | ||
</toolkit:NavigationInTransition> | ||
</toolkit:TransitionService.NavigationInTransition> | ||
<toolkit:TransitionService.NavigationOutTransition> | ||
<toolkit:NavigationOutTransition> | ||
<toolkit:NavigationOutTransition.Backward> | ||
<toolkit:TurnstileTransition Mode="BackwardOut"/> | ||
</toolkit:NavigationOutTransition.Backward> | ||
<toolkit:NavigationOutTransition.Forward> | ||
<toolkit:TurnstileTransition Mode="ForwardOut"/> | ||
</toolkit:NavigationOutTransition.Forward> | ||
</toolkit:NavigationOutTransition> | ||
</toolkit:TransitionService.NavigationOutTransition> | ||
|
||
<!--LayoutRoot is the root grid where all page content is placed--> | ||
<Grid x:Name="LayoutRoot" Background="Transparent"> | ||
<!--Pivot Control--> | ||
<controls:Pivot LoadedPivotItem="Pivot_LoadedPivotItem" x:Name="MailboxPivot" Title="虎踞龙蟠BBS"> | ||
<controls:PivotItem Header="收件箱"> | ||
<ListBox ItemsSource="{Binding InboxItems}" ItemTemplate="{StaticResource MailDataTemplate}" | ||
SelectionChanged="Mail_Selected"> | ||
<ListBox.ItemContainerStyle> | ||
<Style TargetType="ListBoxItem"> | ||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> | ||
</Style> | ||
</ListBox.ItemContainerStyle> | ||
</ListBox> | ||
</controls:PivotItem> | ||
|
||
<controls:PivotItem Header="发件箱"> | ||
<ListBox ItemsSource="{Binding SentItems}" ItemTemplate="{StaticResource MailDataTemplate}" | ||
SelectionChanged="Mail_Selected"> | ||
<ListBox.ItemContainerStyle> | ||
<Style TargetType="ListBoxItem"> | ||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> | ||
</Style> | ||
</ListBox.ItemContainerStyle> | ||
</ListBox> | ||
</controls:PivotItem> | ||
|
||
<controls:PivotItem Header="垃圾箱"> | ||
<ListBox ItemsSource="{Binding DeletedItems}" ItemTemplate="{StaticResource MailDataTemplate}" | ||
SelectionChanged="Mail_Selected"> | ||
<ListBox.ItemContainerStyle> | ||
<Style TargetType="ListBoxItem"> | ||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> | ||
</Style> | ||
</ListBox.ItemContainerStyle> | ||
</ListBox> | ||
</controls:PivotItem> | ||
</controls:Pivot> | ||
</Grid> | ||
|
||
<phone:PhoneApplicationPage.ApplicationBar> | ||
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True"> | ||
<shell:ApplicationBarIconButton IconUri="/Images/new.png" Text="新建"/> | ||
<shell:ApplicationBarIconButton Click="Refresh_Click" IconUri="/Images/refresh.png" Text="刷新"/> | ||
</shell:ApplicationBar> | ||
</phone:PhoneApplicationPage.ApplicationBar> | ||
|
||
</phone:PhoneApplicationPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Windows; | ||
using System.Windows.Navigation; | ||
using System.Windows.Controls; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using Microsoft.Phone.Controls; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace sbbs_client_wp7 | ||
{ | ||
using Sbbs; | ||
|
||
public partial class MailboxPage : PhoneApplicationPage | ||
{ | ||
// 每页显示多少邮件 | ||
const int pageSize = 10; | ||
// 当前页数 | ||
int currentPage = 0; | ||
|
||
// 载入进度 | ||
private bool[] isLoading = { false, false, false }; | ||
private void SetLoading() | ||
{ | ||
App.ViewModel.Mailbox.IsLoading = isLoading[0] | isLoading[1] | isLoading[2]; | ||
} | ||
|
||
public MailboxPage() | ||
{ | ||
InitializeComponent(); | ||
|
||
if (App.ViewModel.Mailbox == null) | ||
App.ViewModel.Mailbox = new MailboxViewModel(); | ||
DataContext = App.ViewModel.Mailbox; | ||
} | ||
|
||
// 进入页面时根据参数切换到指定的页面 | ||
protected override void OnNavigatedTo(NavigationEventArgs e) | ||
{ | ||
base.OnNavigatedTo(e); | ||
|
||
if (NavigationContext.QueryString.ContainsKey("type")) | ||
{ | ||
int type = int.Parse(NavigationContext.QueryString["type"]); | ||
MailboxPivot.SelectedIndex = type; | ||
} | ||
} | ||
|
||
// 直到切换到页面时才只刷新必要的页面 | ||
private void Pivot_LoadedPivotItem(object sender, PivotItemEventArgs e) | ||
{ | ||
int type = (sender as Pivot).SelectedIndex; | ||
switch (type) | ||
{ | ||
case 0: | ||
if (App.ViewModel.Mailbox.InboxItems != null) | ||
return; | ||
break; | ||
case 1: | ||
if (App.ViewModel.Mailbox.SentItems != null) | ||
return; | ||
break; | ||
case 2: | ||
if (App.ViewModel.Mailbox.DeletedItems != null) | ||
return; | ||
break; | ||
} | ||
LoadMailbox(type); | ||
} | ||
|
||
// 选中邮件 | ||
private void Mail_Selected(object sender, SelectionChangedEventArgs e) | ||
{ | ||
if (e.AddedItems.Count == 1) | ||
{ | ||
// 清除选择,否则同样的项目无法点击第二次 | ||
(sender as ListBox).SelectedIndex = -1; | ||
} | ||
} | ||
|
||
// 加载指定的信箱 | ||
private void LoadMailbox(int type) | ||
{ | ||
isLoading[type] = true; | ||
SetLoading(); | ||
App.Service.MailBox(type, currentPage * pageSize, pageSize, delegate(ObservableCollection<TopicViewModel> mails, bool success, string error) | ||
{ | ||
isLoading[type] = false; | ||
SetLoading(); | ||
|
||
if (mails != null) | ||
{ | ||
switch (type) | ||
{ | ||
case 0: | ||
App.ViewModel.Mailbox.InboxItems = mails; | ||
break; | ||
case 1: | ||
App.ViewModel.Mailbox.SentItems = mails; | ||
break; | ||
case 2: | ||
App.ViewModel.Mailbox.DeletedItems = mails; | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
|
||
// 刷新按钮 | ||
private void Refresh_Click(object sender, EventArgs e) | ||
{ | ||
LoadMailbox(MailboxPivot.SelectedIndex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.