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 13dff92 commit 517a09b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
3 changes: 2 additions & 1 deletion App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<local:BoolReverseConverter x:Key="BoolReverseConverter" />
<local:StampDateConverter x:Key="StampDateConverter" />
<local:LoadedOpacityConerter x:Key="LoadedOpacityConerter" />
<local:BoolAccentConverter x:Key="BoolAccentConverter" />

<!--RichTextBlock默认样式-->
<Style TargetType="RichTextBox">
Expand Down Expand Up @@ -50,7 +51,7 @@
<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}" TextWrapping="Wrap" Text="{Binding Title}"/>
<TextBlock Style="{StaticResource PhoneTextLargeStyle}" Foreground="{Binding Unread, Converter={StaticResource BoolAccentConverter}}" TextWrapping="Wrap" Text="{Binding Title}"/>
<Grid>
<TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{Binding Author}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 10 0">
Expand Down
3 changes: 3 additions & 0 deletions BoardPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ private void Topic_Selected(object sender, SelectionChangedEventArgs e)
(sender as ListBox).SelectedIndex = -1;
TopicViewModel topic = e.AddedItems[0] as TopicViewModel;

// 清除未读
topic.Unread = false;

this.NavigationService.Navigate(
new Uri("/TopicPage.xaml?board=" + topic.Board + "&id=" + topic.Id + "&title=" + HttpUtility.UrlEncode(topic.Title), UriKind.Relative));
}
Expand Down
2 changes: 1 addition & 1 deletion MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@
<local:Tile Title="版面分区"/>
<local:Tile Title="最近浏览"/>
<local:Tile Title="我的信箱" Visibility="{Binding IsLogin, Converter={StaticResource BoolVisibleConverter}}"/>
<local:Tile Title="设置"/>
<local:Tile Title="注册" Visibility="{Binding IsLogin, Converter={StaticResource BoolVisibleConverter}, ConverterParameter=True}"/>
<local:Tile Title="关于"/>
<local:Tile Title="退出" MouseLeftButtonUp="Logout_Click" Visibility="{Binding IsLogin, Converter={StaticResource BoolVisibleConverter}}"/>
</toolkit:WrapPanel>
</controls:PanoramaItem>
</controls:Panorama>
Expand Down
4 changes: 2 additions & 2 deletions SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

<!--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" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
<TextBlock x:Name="ApplicationTitle" Text="设置" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="虎踞龙蟠BBS" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>

<!--ContentPanel - place additional content here-->
Expand Down
6 changes: 3 additions & 3 deletions Tile.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
toolkit:TiltEffect.IsTiltEnabled="True"
mc:Ignorable="d"
d:DesignHeight="173" d:DesignWidth="173">
<Grid x:Name="LayoutRoot" Width="173" Height="173" Background="{StaticResource PhoneAccentBrush}">
d:DesignHeight="160" d:DesignWidth="160">

<Grid x:Name="LayoutRoot" Width="160" Height="160" Background="{StaticResource PhoneAccentBrush}">
<Image x:Name="TileImage"/>
<TextBlock x:Name="TileTitle" Text="未设定"
Foreground="White" FontSize="20"
Expand Down
20 changes: 16 additions & 4 deletions ValueConverters/BoolConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@

namespace sbbs_client_wp7
{
public class BoolVisibleConverter : IValueConverter
public class BoolAccentConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool visible = (bool)value;
visible = parameter == null ? visible : !visible;
bool reverse = parameter != null;
return ((bool)value ^ reverse) ? Application.Current.Resources["PhoneAccentBrush"] : Application.Current.Resources["PhoneForegroundBrush"];
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}

return visible ? Visibility.Visible : Visibility.Collapsed;
public class BoolVisibleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool reverse = parameter != null;
return ((bool)value ^ reverse) ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down

0 comments on commit 517a09b

Please sign in to comment.