diff options
author | Vitaly Takmazov | 2013-04-23 12:29:01 +0400 |
---|---|---|
committer | Vitaly Takmazov | 2013-04-23 12:29:01 +0400 |
commit | 83ea4b07788df8d5da9286372ca9bdf76b5513fd (patch) | |
tree | e040378ee339396c4d5703bc5c7190c22604a9e0 | |
parent | e7fb2a3794bc7fb3c6592312d2628d9d11eedf3b (diff) |
Move PostItem DataTemplate to Resources, add sample data to ThreadView, enable bitmap CacheMode, remove incomplete Validation
-rw-r--r-- | Juick/App.xaml | 19 | ||||
-rw-r--r-- | Juick/Controls/MessageList.xaml | 45 | ||||
-rw-r--r-- | Juick/DataTemplates/PostItemDataTemplate.xaml | 44 | ||||
-rw-r--r-- | Juick/Juick.csproj | 13 | ||||
-rw-r--r-- | Juick/LoginView.xaml | 3 | ||||
-rw-r--r-- | Juick/MainPage.xaml | 2 | ||||
-rw-r--r-- | Juick/NewPostView.xaml | 2 | ||||
-rw-r--r-- | Juick/SampleData/ThreadViewModelSampleData.xaml | 16 | ||||
-rw-r--r-- | Juick/ThreadView.xaml | 53 | ||||
-rw-r--r-- | Juick/ViewModels/LoginViewModel.cs | 5 | ||||
-rw-r--r-- | Juick/ViewModels/NewPostViewModel.cs | 28 |
11 files changed, 128 insertions, 102 deletions
diff --git a/Juick/App.xaml b/Juick/App.xaml index 0c60cc0..1b67f8c 100644 --- a/Juick/App.xaml +++ b/Juick/App.xaml @@ -1,20 +1,25 @@ -<Application
- x:Class="Juick.App"
+<Application
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:sys="clr-namespace:System;assembly=mscorlib">
+ xmlns:sys="clr-namespace:System;assembly=mscorlib"
+ x:Class="Juick.App"
+ >
- <!--Application Resources-->
<Application.Resources>
+ <ResourceDictionary>
+ <ResourceDictionary.MergedDictionaries>
+ <ResourceDictionary Source="DataTemplates/PostItemDataTemplate.xaml" />
+ </ResourceDictionary.MergedDictionaries>
+ </ResourceDictionary>
</Application.Resources>
<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
- <shell:PhoneApplicationService
- Launching="Application_Launching" Closing="Application_Closing"
- Activated="Application_Activated" Deactivated="Application_Deactivated"/>
+ <shell:PhoneApplicationService
+ Launching="Application_Launching" Closing="Application_Closing"
+ Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects>
</Application>
\ No newline at end of file diff --git a/Juick/Controls/MessageList.xaml b/Juick/Controls/MessageList.xaml index afa6c69..ac6db00 100644 --- a/Juick/Controls/MessageList.xaml +++ b/Juick/Controls/MessageList.xaml @@ -12,10 +12,10 @@ FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" d:DesignHeight="480" d:DesignWidth="480"> - + <Grid x:Name="LayoutRoot"> <toolkit:LongListSelector Margin="0, 0, -12, 0" - ItemsSource="{Binding Items}" IsFlatList="true"> + ItemsSource="{Binding Items}" IsFlatList="true" ItemTemplate="{StaticResource PostItemDataTemplate}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Link"> <bindings:InvokeDelegateCommandAction Command="{Binding LoadMessagesPageCommand}" @@ -25,46 +25,7 @@ <bindings:InvokeDelegateCommandAction Command="{Binding NavigateNextCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}"/> </i:EventTrigger> - </i:Interaction.Triggers> - <toolkit:LongListSelector.ItemTemplate> - <DataTemplate> - <Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="0 0 0 1"> - <Grid> - <Grid.ColumnDefinitions> - <ColumnDefinition Width="Auto" /> - <ColumnDefinition Width="*" /> - </Grid.ColumnDefinitions> - <Grid.RowDefinitions> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - </Grid.RowDefinitions> - <Image bindings:LowProfileImageLoader.UriSource="{Binding AvatarUri}" Grid.Row="0" Grid.Column="0" Margin="3" /> - <TextBlock Text="{Binding Username}" Grid.Row="0" Grid.Column="1" - Margin="5,0,5,5" VerticalAlignment="Top" - HorizontalAlignment="Left" - FontFamily="{StaticResource PhoneFontFamilySemiLight}" - FontSize="{StaticResource PhoneFontSizeLarge}" - Style="{StaticResource PhoneTextAccentStyle}" /> - <!--Style="{StaticResource PhoneTextNormalStyle}"--> - <usercontrols:HyperLinkRichTextBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" - TextWrapping="Wrap" HorizontalAlignment="Left" - Foreground="{StaticResource PhoneForegroundBrush}" - Margin="5,0,5,5" VerticalAlignment="Top" - IsReadOnly="True" Text="{Binding MessageText}" /> - <Image bindings:LowProfileImageLoader.UriSource="{Binding Attachment}" Grid.Row="2" Grid.Column="0" Margin="3" Grid.ColumnSpan="2" /> - <TextBlock Text="{Binding Status}" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" - Foreground="{StaticResource PhoneForegroundBrush}" - Style="{StaticResource PhoneTextAccentStyle}" - FontSize="{StaticResource PhoneFontSizeSmall}" - Margin="5,0,5,5" VerticalAlignment="Top" - TextWrapping="Wrap" HorizontalAlignment="Left"/> - </Grid> - </Border> - - </DataTemplate> - </toolkit:LongListSelector.ItemTemplate> + </i:Interaction.Triggers> </toolkit:LongListSelector> </Grid> </UserControl> diff --git a/Juick/DataTemplates/PostItemDataTemplate.xaml b/Juick/DataTemplates/PostItemDataTemplate.xaml new file mode 100644 index 0000000..285a5dc --- /dev/null +++ b/Juick/DataTemplates/PostItemDataTemplate.xaml @@ -0,0 +1,44 @@ +<ResourceDictionary + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:bindings="clr-namespace:Juick.Classes" + xmlns:usercontrols="clr-namespace:Juick.Controls" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > + + <DataTemplate x:Key="PostItemDataTemplate"> + <Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="0 0 0 1"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto" /> + <ColumnDefinition Width="*" /> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + </Grid.RowDefinitions> + <Image bindings:LowProfileImageLoader.UriSource="{Binding AvatarUri}" Grid.Row="0" Grid.Column="0" Margin="3" /> + <TextBlock Text="{Binding Username}" Grid.Row="0" Grid.Column="1" + Margin="5,0,5,5" VerticalAlignment="Top" + HorizontalAlignment="Left" + FontFamily="{StaticResource PhoneFontFamilySemiLight}" + FontSize="{StaticResource PhoneFontSizeLarge}" + Style="{StaticResource PhoneTextAccentStyle}" /> + <usercontrols:HyperLinkRichTextBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" + TextWrapping="Wrap" HorizontalAlignment="Left" + Foreground="{StaticResource PhoneForegroundBrush}" + Margin="5,0,5,5" VerticalAlignment="Top" + IsReadOnly="True" Text="{Binding MessageText}" /> + <Image bindings:LowProfileImageLoader.UriSource="{Binding Attachment}" Grid.Row="2" Grid.Column="0" Margin="3" + Grid.ColumnSpan="2" /> + <TextBlock Text="{Binding Status}" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" + Foreground="{StaticResource PhoneForegroundBrush}" + Style="{StaticResource PhoneTextAccentStyle}" + FontSize="{StaticResource PhoneFontSizeSmall}" + Margin="5,0,5,5" VerticalAlignment="Top" + TextWrapping="Wrap" HorizontalAlignment="Left"/> + </Grid> + </Border> + + </DataTemplate> +</ResourceDictionary>
\ No newline at end of file diff --git a/Juick/Juick.csproj b/Juick/Juick.csproj index 33fbd5c..9d7c770 100644 --- a/Juick/Juick.csproj +++ b/Juick/Juick.csproj @@ -27,6 +27,8 @@ <ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
+ <Utf8Output>true</Utf8Output>
+ <ExpressionBlendVersion>4.0.30816.0</ExpressionBlendVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -107,7 +109,6 @@ <Compile Include="ViewModels\PageViewModel.cs" />
<Compile Include="ViewModels\PostItem.cs" />
<Compile Include="ViewModels\ThreadViewModel.cs" />
- <Compile Include="ViewModels\Validation\DataViewModelBase.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" />
</ItemGroup>
<ItemGroup>
@@ -119,6 +120,10 @@ <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="DataTemplates\PostItemDataTemplate.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="LoginView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -190,6 +195,12 @@ <Content Include="Images\appbar.send.png" />
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
+ <ItemGroup>
+ <DesignData Include="SampleData\ThreadViewModelSampleData.xaml">
+ <Generator>MSBuild:MarkupCompilePass1</Generator>
+ </DesignData>
+ </ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
diff --git a/Juick/LoginView.xaml b/Juick/LoginView.xaml index 004580a..3e204a4 100644 --- a/Juick/LoginView.xaml +++ b/Juick/LoginView.xaml @@ -9,10 +9,9 @@ xmlns:viewModels="clr-namespace:Juick.ViewModels"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
- phoneshell:SystemTray.IsVisible="True">
+ phoneshell:SystemTray.IsVisible="True" CacheMode="BitmapCache">
<phone:PhoneApplicationPage.DataContext>
<viewModels:LoginViewModel />
</phone:PhoneApplicationPage.DataContext>
diff --git a/Juick/MainPage.xaml b/Juick/MainPage.xaml index 45e1ff9..306555c 100644 --- a/Juick/MainPage.xaml +++ b/Juick/MainPage.xaml @@ -13,7 +13,7 @@ FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
- phoneshell:SystemTray.IsVisible="True">
+ phoneshell:SystemTray.IsVisible="True" CacheMode="BitmapCache">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
diff --git a/Juick/NewPostView.xaml b/Juick/NewPostView.xaml index f3a911b..1ed01b5 100644 --- a/Juick/NewPostView.xaml +++ b/Juick/NewPostView.xaml @@ -11,7 +11,7 @@ Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
- shell:SystemTray.IsVisible="True">
+ shell:SystemTray.IsVisible="True" CacheMode="BitmapCache">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
diff --git a/Juick/SampleData/ThreadViewModelSampleData.xaml b/Juick/SampleData/ThreadViewModelSampleData.xaml new file mode 100644 index 0000000..784bee3 --- /dev/null +++ b/Juick/SampleData/ThreadViewModelSampleData.xaml @@ -0,0 +1,16 @@ +<Juick_ViewModels:ThreadViewModel xmlns:Juick_ViewModels="clr-namespace:Juick.ViewModels" Caption="#333333" Mid="86" RestUri="Augue vestibulum ligula senectus dolor"> + <Juick_ViewModels:ThreadViewModel.Items> + <Juick_ViewModels:PostItem MessageText="Integer vestibulum maecenas mauris duis" + MID="51" RID="29" Status="Quisque adipiscing parturient nam vestibulum" + Username="@ugnich" /> + <Juick_ViewModels:PostItem MessageText="Lorem Ipsum - это текст-рыба, часто используемый в печати и вэб-дизайне. Lorem Ipsum является стандартной рыбой для текстов на латинице с начала XVI века. В то время некий безымянный печатник создал большую коллекцию размеров и форм шрифтов, используя Lorem Ipsum для распечатки образцов. Lorem Ipsum не только успешно пережил без заметных изменений пять веков, но и перешагнул в электронный дизайн. Его популяризации в новое время послужили публикация листов Letraset с образцами Lorem Ipsum в 60-х годах и, в более недавнее время, программы электронной вёрстки типа Aldus PageMaker, в шаблонах которых используется Lorem Ipsum." MID="21" RID="57" Status="Est donec etiam consequat convallis" Username="@ugnich"/> + <Juick_ViewModels:PostItem MessageText="Nullam ante bibendum vivamus dictumst" MID="91" RID="43" Status="Eleifend adipiscing" Username="@ugnich"/> + <Juick_ViewModels:PostItem MessageText="Parturient aliquam facilisi fermentum aliquet" MID="42" RID="12" Status="Hac leo" Username="Blandit fusce fringilla habitasse auctor"/> + <Juick_ViewModels:PostItem MessageText="Faucibus mus hendrerit arcu" MID="84" RID="29" Status="Diam nec habitant" Username="Eget himenaeos inceptos"/> + <Juick_ViewModels:PostItem MessageText="Vestibulum imperdiet malesuada congue penatibus" MID="48" RID="26" Status="Elit porttitor" Username="Lorem enim interdum"/> + <Juick_ViewModels:PostItem MessageText="Commodo conubia vestibulum erat cursus" MID="14" RID="70" Status="Cubilia lobortis tincidunt" Username="Nascetur eros dictum lectus"/> + <Juick_ViewModels:PostItem MessageText="Non pharetra tristique per" MID="80" RID="43" Status="Ultricies morbi" Username="Libero dapibus nulla"/> + <Juick_ViewModels:PostItem MessageText="Proin adipiscing nibh placerat" MID="65" RID="52" Status="Venenatis sed sem nisi" Username="Vulputate curabitur parturient egestas sit"/> + <Juick_ViewModels:PostItem MessageText="Phasellus nisl" MID="55" RID="25" Status="Vel euismod" Username="Pulvinar sagittis"/> + </Juick_ViewModels:ThreadViewModel.Items> +</Juick_ViewModels:ThreadViewModel> diff --git a/Juick/ThreadView.xaml b/Juick/ThreadView.xaml index 14a6f75..d52a343 100644 --- a/Juick/ThreadView.xaml +++ b/Juick/ThreadView.xaml @@ -11,67 +11,30 @@ FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
- mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
- phoneshell:SystemTray.IsVisible="True">
+ mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
+ phoneshell:SystemTray.IsVisible="True" CacheMode="BitmapCache">
<!--LayoutRoot is the root grid where all page content is placed-->
- <Grid x:Name="LayoutRoot" Background="Transparent">
+ <Grid x:Name="LayoutRoot" Background="Transparent" d:DataContext="{d:DesignData /SampleData/ThreadViewModelSampleData.xaml}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
+ <RowDefinition/>
</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" Text="{Binding Caption}" Style="{StaticResource PhoneTextNormalStyle}"/>
+ <TextBlock x:Name="ApplicationTitle" Style="{StaticResource PhoneTextNormalStyle}" Text="{Binding Caption}"> </TextBlock>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
- <ListBox Margin="0,0,-12,0" ItemsSource="{Binding Items}" SelectionChanged="ListBox_SelectionChanged">
+ <ListBox Margin="0,0,-12,0" ItemsSource="{Binding Items}" SelectionChanged="ListBox_SelectionChanged" DataContext="{Binding}"
+ ItemTemplate="{StaticResource PostItemDataTemplate}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
</Style>
- </ListBox.ItemContainerStyle>
- <ListBox.ItemTemplate>
- <DataTemplate>
- <Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="0 0 0 1">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <!-- RowDefinition Height="Auto" / -->
- </Grid.RowDefinitions>
- <Image bindings:LowProfileImageLoader.UriSource="{Binding AvatarUri}" Grid.Row="0" Grid.Column="0" Margin="3" />
- <TextBlock Text="{Binding Username}" Grid.Row="0" Grid.Column="1"
- Margin="5,0,5,5" VerticalAlignment="Top"
- HorizontalAlignment="Left"
- FontFamily="{StaticResource PhoneFontFamilySemiLight}"
- FontSize="{StaticResource PhoneFontSizeLarge}"
- Style="{StaticResource PhoneTextAccentStyle}" />
- <!--Style="{StaticResource PhoneTextNormalStyle}"-->
- <controls:HyperLinkRichTextBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
- Foreground="{StaticResource PhoneForegroundBrush}"
- Margin="5,0,5,5" VerticalAlignment="Top"
- TextWrapping="Wrap" HorizontalAlignment="Left"
- IsReadOnly="True" Text="{Binding MessageText}" />
- <Image bindings:LowProfileImageLoader.UriSource="{Binding Attachment}" Grid.Row="2" Grid.Column="0" Margin="3" Grid.ColumnSpan="2" />
- <!-- TextBlock Text="{Binding Status}" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
- Foreground="{StaticResource PhoneForegroundBrush}"
- Style="{StaticResource PhoneTextAccentStyle}"
- FontSize="{StaticResource PhoneFontSizeSmall}"
- Margin="5,0,5,5" VerticalAlignment="Top"
- TextWrapping="Wrap" HorizontalAlignment="Left"/ -->
- </Grid>
- </Border>
- </DataTemplate>
- </ListBox.ItemTemplate>
+ </ListBox.ItemContainerStyle>
</ListBox>
</Grid>
</Grid>
diff --git a/Juick/ViewModels/LoginViewModel.cs b/Juick/ViewModels/LoginViewModel.cs index 95528fe..2bc5bda 100644 --- a/Juick/ViewModels/LoginViewModel.cs +++ b/Juick/ViewModels/LoginViewModel.cs @@ -2,12 +2,11 @@ using System.Net; using System.Windows; using Juick.Classes; -using Juick.ViewModels.Validation; using RestSharp; namespace Juick.ViewModels { - public class LoginViewModel : DataViewModelBase + public class LoginViewModel : ViewModelBase { private string _username; private string _password; @@ -64,7 +63,7 @@ namespace Juick.ViewModels } else { - AddError("Username", "Invalid username or password", false); + //AddError("Username", "Invalid username or password", false); } }); } diff --git a/Juick/ViewModels/NewPostViewModel.cs b/Juick/ViewModels/NewPostViewModel.cs new file mode 100644 index 0000000..3c28cc7 --- /dev/null +++ b/Juick/ViewModels/NewPostViewModel.cs @@ -0,0 +1,28 @@ +using System; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Ink; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace Juick.ViewModels +{ + public class NewPostViewModel : ViewModelBase + { + public PostItem ReplyTo { get; set; } + + public PostItem Draft { get; set; } + + public BitmapImage Attachment { get; set; } + + public NewPostViewModel(PostItem replyTo) + { + ReplyTo = replyTo; + } + } +} |