Skip to content

Commit

Permalink
优化各项显示
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Mar 4, 2012
1 parent 517a09b commit be35ae6
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 11 deletions.
2 changes: 1 addition & 1 deletion App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<Grid Margin="0 0 0 10">
<Rectangle Fill="{Binding Leaf, Converter={StaticResource LeafBrushConverter}}" Width="8" HorizontalAlignment="Left"/>
<StackPanel Orientation="Vertical" Margin="4 0 0 0">
<TextBlock Style="{StaticResource PhoneTextLargeStyle}" Text="{Binding EnglishName}"/>
<TextBlock Style="{StaticResource PhoneTextLargeStyle}" Foreground="{Binding Unread, Converter={StaticResource BoolAccentConverter}}" Text="{Binding EnglishName}"/>
<TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{Binding Description}"/>
</StackPanel>
</Grid>
Expand Down
5 changes: 5 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ private void Application_Activated(object sender, ActivatedEventArgs e)
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
// Ensure that required application state is persisted here.
if (ViewModel.FavoratesDirectory.First != null)
LocalCache.Set<ObservableCollection<BoardViewModel>>("Favorates", ViewModel.FavoratesDirectory.First.Value);
else
LocalCache.Set<ObservableCollection<BoardViewModel>>("Favorates", ViewModel.FavoratesItems);
LocalCache.Set<ObservableCollection<TopicViewModel>>("Topten", ViewModel.ToptenItems);
}

// Code to execute when the application is closing (eg, user hit Back)
Expand Down
13 changes: 6 additions & 7 deletions BoardPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@

<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Description}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="{Binding EnglishName}" Margin="9,-7,0,0" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding Description}" Margin="0" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="{Binding EnglishName}" Margin="0,-7,0,0" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
</StackPanel>

<!--ContentPanel - place additional content here-->
Expand All @@ -75,13 +75,12 @@
</Grid>

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="False">
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton Click="NewPost_Click" IconUri="/Images/new.png" Text="发帖"/>
<shell:ApplicationBarIconButton Click="Refresh_Click" IconUri="/Images/refresh.png" Text="刷新"/>
<!--<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>-->
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Click="Settings_Click" Text="版面设置"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

Expand Down
5 changes: 5 additions & 0 deletions BoardPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ private void NewPost_Click(object sender, EventArgs e)
NavigationService.Navigate(new Uri("/PostPage.xaml?board=" + App.ViewModel.CurrentBoard.EnglishName, UriKind.Relative));
}

private void Settings_Click(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/BoardSettingsPage.xaml", UriKind.Relative));
}

private void LoadMore_Click(object sender, RoutedEventArgs e)
{
App.ViewModel.CurrentBoard.IsLoaded = false;
Expand Down
66 changes: 66 additions & 0 deletions BoardSettingsPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<phone:PhoneApplicationPage
x:Class="sbbs_client_wp7.BoardSettingsPage"
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:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys ="clr-namespace:System;assembly=mscorlib"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
toolkit:TiltEffect.IsTiltEnabled="True"
shell:SystemTray.Opacity="0"
shell:SystemTray.IsVisible="True">

<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">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Margin="0" Text="虎踞龙蟠BBS" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="版面设置" Margin="0,-7,0,0" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
</StackPanel>

<!--ContentPanel - place additional content here-->
<ScrollViewer Grid.Row="1">
<StackPanel>
<toolkit:ListPicker SelectionChanged="Mode_SelectionChanged" x:Name="Mode" Header="版面模式">
<sys:String>普通模式</sys:String>
<sys:String>主题模式</sys:String>
<sys:String>论坛模式</sys:String>
</toolkit:ListPicker>
</StackPanel>
</ScrollViewer>
</Grid>

</phone:PhoneApplicationPage>
51 changes: 51 additions & 0 deletions BoardSettingsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace sbbs_client_wp7
{
public partial class BoardSettingsPage : PhoneApplicationPage
{
public BoardSettingsPage()
{
InitializeComponent();
}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);

// 恢复选择
int[] modeMap = { 0, 1, 2, 2 };
Mode.SelectedIndex = modeMap[App.Service.BoardMode];
}

private void Mode_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListPicker list = sender as ListPicker;

// 设置并保存模式
int[] modeMap = { 0, 1, 3};
int mode = modeMap[list.SelectedIndex];

if (mode != App.Service.BoardMode)
{
App.Service.BoardMode = mode;
LocalCache.Set<int>("BoardMode", App.Service.BoardMode);

// 刷新版面以生效
App.ViewModel.CurrentBoard.NeedRefresh = true;
}
}
}
}
Binary file added Images/cancel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion Sbbs/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class Service
// 用户认证Token
public string Token { get; set; }

// 默认版面模式
public int BoardMode { get; set; }

// 登录换取Token
public void Login(string username, string password, Action<string, bool, string> callback)
{
Expand Down Expand Up @@ -60,9 +63,14 @@ public void Favorates(Action<BoardCollection, bool, string> callback)

// 获取版面
public void Board(string board, int start, int limit, Action<TopicCollection, bool, string> callback)
{
Board(board, BoardMode, start, limit, callback);
}

public void Board(string board, int mode, int start, int limit, Action<TopicCollection, bool, string> callback)
{
WebClient wc = new WebClient();
Uri uri = new Uri(apiBase + "board/" + board + apiPost + "?token=" + HttpUtility.UrlEncode(Token) + "&start=" + start + "&limit=" + limit);
Uri uri = new Uri(apiBase + "board/" + board + apiPost + "?token=" + HttpUtility.UrlEncode(Token) + "&start=" + start + "&limit=" + limit + "&mode=" + mode);

wc.DownloadStringCompleted += DownloadedAndParse<TopicCollection, TopicsResponse>;
wc.DownloadStringAsync(uri, new ServiceArg<TopicCollection>() { Callback = callback });
Expand Down
6 changes: 4 additions & 2 deletions TopicPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@

<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Board}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="{Binding Title}" TextWrapping="Wrap" Margin="9,-7,0,0" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding Board}" Margin="0" Style="{StaticResource PhoneTextNormalStyle}"/>
<ScrollViewer VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Visible">
<TextBlock x:Name="PageTitle" Text="{Binding Title}" Margin="0,-7,0,0" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
</ScrollViewer>
</StackPanel>

<ScrollViewer Grid.Row="1" Margin="12,0,12,0">
Expand Down
1 change: 1 addition & 0 deletions ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public MainViewModel()
{
// 载入保存的设置
App.Service.Token = LocalCache.Get<string>("Token");
App.Service.BoardMode = LocalCache.Get<int>("BoardMode", 3);

// 初始化
CurrentBoard = new CurrentBoardViewModel();
Expand Down
9 changes: 9 additions & 0 deletions sbbs-client-wp7.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
<Compile Include="BoardPage.xaml.cs">
<DependentUpon>BoardPage.xaml</DependentUpon>
</Compile>
<Compile Include="BoardSettingsPage.xaml.cs">
<DependentUpon>BoardSettingsPage.xaml</DependentUpon>
</Compile>
<Compile Include="DynamicOrientationChanges\AnimateOrientationChangesFrame.cs" />
<Compile Include="DynamicOrientationChanges\FadeOrientationChangesFrame.cs" />
<Compile Include="DynamicOrientationChanges\HybridOrientationChangesFrame.cs" />
Expand Down Expand Up @@ -117,6 +120,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="BoardSettingsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="LoginPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -169,9 +176,11 @@
<Resource Include="PanoramaBackground.png" />
<Content Include="Images\addcomment.png" />
<Content Include="Images\attach.png" />
<Resource Include="Images\cancel.png" />
<Content Include="Images\circle.png" />
<Content Include="Images\new.png" />
<Content Include="Images\refresh.png" />
<Resource Include="Images\save.png" />
<Content Include="Images\send.text.png" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
Expand Down

0 comments on commit be35ae6

Please sign in to comment.