Skip to content

Commit

Permalink
update ViewMdelLocator and so on
Browse files Browse the repository at this point in the history
  • Loading branch information
durow committed Oct 27, 2015
1 parent c83b855 commit 93d7455
Show file tree
Hide file tree
Showing 21 changed files with 349 additions and 149 deletions.
Binary file modified UWPDDD/Dlls/AyxMVVM.dll
Binary file not shown.
7 changes: 7 additions & 0 deletions UWPDDD/Domain/Model/ANote.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@


using Domain.Repository;

namespace Domain.Model
{
public sealed class ANote
Expand All @@ -10,5 +12,10 @@ public sealed class ANote
public string Title { get; set; }
public string Content { get; set; }
public ACategory Category { get; set; }

public void UpdateContent()
{
Content = Repositories.ANoteRepository.GetContent(ID);
}
}
}
1 change: 1 addition & 0 deletions UWPDDD/Domain/Repository/Common/IANoteRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ namespace Domain.Repository.Common
public interface IANoteRepository:IRepository<ANote>
{
ANote GetOne(int id);
string GetContent(int id);
}
}
5 changes: 5 additions & 0 deletions UWPDDD/Domain/Repository/Database/ANoteDataRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public IEnumerable<ANote> GetAll()
throw new NotImplementedException();
}

public string GetContent(int id)
{
throw new NotImplementedException();
}

public ANote GetOne(int id)
{
throw new NotImplementedException();
Expand Down
5 changes: 5 additions & 0 deletions UWPDDD/Domain/Repository/Mars/ANoteMarsRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public IEnumerable<ANote> GetAll()
throw new NotImplementedException();
}

public string GetContent(int id)
{
throw new NotImplementedException();
}

public ANote GetOne(int id)
{
throw new NotImplementedException();
Expand Down
5 changes: 5 additions & 0 deletions UWPDDD/Domain/Repository/WebService/ANoteWebRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public IEnumerable<ANote> GetAll()
throw new NotImplementedException();
}

public string GetContent(int id)
{
throw new NotImplementedException();
}

public ANote GetOne(int id)
{
throw new NotImplementedException();
Expand Down
13 changes: 13 additions & 0 deletions UWPDDD/Infrastructure/Database/ANoteData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ public IEnumerable<Dictionary<string,object>> GetAll()
}
}

public string GetContentByID(int id)
{
const string GETCONTENT_SQL = @"SELECT Content FROM ANote WHERE ID=?";
using (var statement = con.Prepare(GETCONTENT_SQL))
{
var result = statement.Step();
if (result == SQLiteResult.ROW)
return statement[0].ToString();
else
return string.Empty;
}
}

public void Insert(string addDateTime,
string editDateTime,
string title,
Expand Down
10 changes: 10 additions & 0 deletions UWPDDD/UWPDDD/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
x:Class="UWPDDD.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:UWPDDD"
xmlns:vm="using:ViewModel"
RequestedTheme="Light">

<Application.Resources>
<vm:ViewModelLocator x:Key="VMLocator"/>
<Style TargetType="TextBlock" x:Key="SmallText">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="Foreground" Value="#FF787474"/>
</Style>
</Application.Resources>
</Application>
60 changes: 57 additions & 3 deletions UWPDDD/UWPDDD/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,65 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWPDDD"
xmlns:vm="using:ViewModel"
x:Name="Main"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
mc:Ignorable="d"
DataContext="{Binding NoteList, Source={StaticResource VMLocator}}">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<local:NoteListControl/>
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="#AAA4A4A4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button Content="菜单" Height="40" Background="Transparent"/>
<Button Content="新建" Height="40" Grid.Column="2" Background="Transparent"/>
<TextBlock Text="A-NoteBook" Grid.Column="1" VerticalAlignment="Center" FontFamily="微软雅黑" FontSize="24" FontWeight="Bold" TextAlignment="Center"/>
</Grid>
<AutoSuggestBox Grid.Row="1" Margin="20,7,20,5" Background="Transparent"
PlaceholderText="搜索标题" QueryIcon="Zoom" />
<ListView x:Name="NoteListView" Grid.Row="2" Padding="5,0,5,0"
ItemsSource="{Binding NoteList}"
SelectedItem="{Binding SelectedNote}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<Grid Margin="0,2,0,2" BorderBrush="LightGray" BorderThickness="2"
CornerRadius="5" Tapped="Grid_Tapped" Background="#AAF0ECEC">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Text="{Binding AddDateTime}"
FontSize="12" Margin="10,5,10,0"/>
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10,5,10,0"
VerticalAlignment="Center" TextAlignment="Right"
FontSize="12" Text="{Binding Category.Category}"/>
<Border Grid.Row="1" Grid.ColumnSpan="3" Margin="5,2,5,5"
BorderBrush="LightGray" BorderThickness="0,1,0,0">
<TextBlock Text="{Binding Title}" VerticalAlignment="Center"
FontFamily="微软雅黑" FontSize="16" Margin="5,10,5,10"/>
</Border>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Page>
10 changes: 10 additions & 0 deletions UWPDDD/UWPDDD/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using UWPDDD.View;
using ViewModel;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
Expand All @@ -22,9 +24,17 @@ namespace UWPDDD
/// </summary>
public sealed partial class MainPage : Page
{
NoteListViewModel VM { get;}

public MainPage()
{
this.InitializeComponent();
VM = DataContext as NoteListViewModel;
}

private void Grid_Tapped(object sender, TappedRoutedEventArgs e)
{
Frame.Navigate(typeof(NoteInfoPage),NoteListView.SelectedItem);
}
}
}
13 changes: 3 additions & 10 deletions UWPDDD/UWPDDD/View.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,8 @@
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="View\NoteInfoControl.xaml.cs">
<DependentUpon>NoteInfoControl.xaml</DependentUpon>
</Compile>
<Compile Include="View\NoteListControl.xaml.cs">
<DependentUpon>NoteListControl.xaml</DependentUpon>
<Compile Include="View\NoteInfoPage.xaml.cs">
<DependentUpon>NoteInfoPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down Expand Up @@ -135,11 +132,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="View\NoteInfoControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\NoteListControl.xaml">
<Page Include="View\NoteInfoPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
15 changes: 0 additions & 15 deletions UWPDDD/UWPDDD/View/NoteInfoControl.xaml

This file was deleted.

27 changes: 0 additions & 27 deletions UWPDDD/UWPDDD/View/NoteInfoControl.xaml.cs

This file was deleted.

61 changes: 61 additions & 0 deletions UWPDDD/UWPDDD/View/NoteInfoPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<Page
x:Class="UWPDDD.View.NoteInfoPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWPDDD.View"
xmlns:vm="using:ViewModel"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
DataContext="{Binding NoteInfo, Source={StaticResource VMLocator}}">
<Page.Resources>
<Style TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Height" Value="40"/>
</Style>
</Page.Resources>
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Background="#AAA4A4A4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button Content="返回" Click="{x:Bind VM.Back}"/>
<Button Content="删除" Grid.Column="2"/>
<Button Content="分享" Grid.Column="3"/>
</Grid>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical">
<TextBox Text="{Binding Note.Title}" Margin="0,10,0,0" Background="Transparent"
FontSize="18" BorderThickness="0" />
<Grid Padding="10,2,10,2" BorderThickness="0,1,0,1" BorderBrush="LightGray">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="添加时间:" Style="{StaticResource SmallText}" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Note.AddDateTime}" Grid.Column="1" Style="{StaticResource SmallText}"/>
<TextBlock Text="所属分类:" Grid.Column="3" Style="{StaticResource SmallText}"/>
<TextBlock Text="{Binding Note.Category.Category}" Margin="5" Style="{StaticResource SmallText}" Grid.Column="4"/>
</Grid>
<TextBox Text="{Binding Note.Content}" FontFamily="微软雅黑" FontSize="15"
TextWrapping="Wrap" AcceptsReturn="True"
BorderThickness="0" Margin="5"/>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<TextBlock Style="{StaticResource SmallText}" Text="最后编辑:"/>
<TextBlock Style="{StaticResource SmallText}" Text="{Binding Note.EditDateTime}" Margin="5,20,15,20"/>
</StackPanel>
</StackPanel>
</ScrollViewer>

</Grid>
</Page>
41 changes: 41 additions & 0 deletions UWPDDD/UWPDDD/View/NoteInfoPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Domain.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using ViewModel;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// “空白页”项模板在 http://go.microsoft.com/fwlink/?LinkId=234238 上提供

namespace UWPDDD.View
{
/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class NoteInfoPage : Page
{

public NoteInfoViewModel VM { get; }

public NoteInfoPage()
{
this.InitializeComponent();
VM = DataContext as NoteInfoViewModel;
}

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

0 comments on commit 93d7455

Please sign in to comment.