diff --git a/App.xaml b/App.xaml
index fae545e..c764cf1 100644
--- a/App.xaml
+++ b/App.xaml
@@ -70,11 +70,7 @@
-
-
-
-
-
+
diff --git a/BoardPage.xaml b/BoardPage.xaml
index 81029cc..3a3c601 100644
--- a/BoardPage.xaml
+++ b/BoardPage.xaml
@@ -76,7 +76,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PostPage.xaml.cs b/PostPage.xaml.cs
new file mode 100644
index 0000000..287f298
--- /dev/null
+++ b/PostPage.xaml.cs
@@ -0,0 +1,76 @@
+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.Collections.ObjectModel;
+using Microsoft.Phone.Controls;
+
+namespace sbbs_client_wp7
+{
+ using Sbbs;
+
+ public partial class PostPage : PhoneApplicationPage
+ {
+ private string board;
+ private int reid = 0;
+ private LoadingViewModel viewModel = new LoadingViewModel();
+
+ public PostPage()
+ {
+ InitializeComponent();
+
+ DataContext = viewModel;
+ }
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ base.OnNavigatedTo(e);
+
+ if (this.NavigationContext.QueryString.ContainsKey("reid"))
+ {
+ string title = this.NavigationContext.QueryString["title"];
+ if (title.Length > 3 && title.Substring(0, 3) == "Re:")
+ TitleText.Text = title;
+ else
+ TitleText.Text = "Re: " + title;
+
+ TypeTitle.Text = "回复";
+ Board.Text = board = this.NavigationContext.QueryString["board"];
+ reid = int.Parse(this.NavigationContext.QueryString["reid"]);
+ }
+ else
+ {
+ TypeTitle.Text = "发帖";
+ Board.Text = board = this.NavigationContext.QueryString["board"];
+ }
+ }
+
+ private void Post_Click(object sender, EventArgs e)
+ {
+ viewModel.IsLoading = true;
+
+ App.Service.TopicPost(board, reid, TitleText.Text, ContentText.Text, delegate(ObservableCollection topics, bool success, string error)
+ {
+ viewModel.IsLoading = false;
+ if (!success)
+ MessageBox.Show("网络错误");
+ else if (error != null)
+ MessageBox.Show(error);
+ else
+ {
+ // 跳转到版面时标记刷新
+ if (reid == 0)
+ App.ViewModel.CurrentBoard.NeedRefresh = true;
+ // 跳转到话题时直接在最后添加
+ else
+ App.ViewModel.CurrentTopic.Topics.Add(topics[0]);
+
+ NavigationService.GoBack();
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/Sbbs/Response.cs b/Sbbs/Response.cs
index 19631ba..98293a0 100644
--- a/Sbbs/Response.cs
+++ b/Sbbs/Response.cs
@@ -32,7 +32,7 @@ public class Response
}
// 返回主题集合
- // 符合类型: 十大
+ // 符合类型: 十大,版面
[DataContract]
public class TopicsResponse : Response, IResponse>
{
diff --git a/Sbbs/Service.cs b/Sbbs/Service.cs
index ebd9489..925a4a5 100644
--- a/Sbbs/Service.cs
+++ b/Sbbs/Service.cs
@@ -78,6 +78,17 @@ public void Topic(string board, int id, int start, int limit, Action() { Callback = callback });
}
+ // 发帖
+ public void TopicPost(string board, int reid, string title, string content, Action callback)
+ {
+ WebClient wc = new WebClient();
+ Uri uri = new Uri(apiBase + "topic/post" + apiPost + "?type=2&token=" + HttpUtility.UrlEncode(Token) + "&board=" + board + "&reid=" + reid
+ + "&title=" + HttpUtility.UrlEncode(title) + "&content=" + HttpUtility.UrlEncode(content));
+
+ wc.DownloadStringCompleted += DownloadedAndParse;
+ wc.DownloadStringAsync(uri, new ServiceArg() { Callback = callback });
+ }
+
// 下载完成后分析JSON数据然后调用回调函数
// C为返回类型,比如TopicCollection
// R为JSON的Response类型
diff --git a/SettingsPage.xaml b/SettingsPage.xaml
new file mode 100644
index 0000000..2ec01dc
--- /dev/null
+++ b/SettingsPage.xaml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SettingsPage.xaml.cs b/SettingsPage.xaml.cs
new file mode 100644
index 0000000..916620e
--- /dev/null
+++ b/SettingsPage.xaml.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+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 SettingsPage : PhoneApplicationPage
+ {
+ public SettingsPage()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/TopicPage.xaml b/TopicPage.xaml
index 3fb2afd..3866b27 100644
--- a/TopicPage.xaml
+++ b/TopicPage.xaml
@@ -73,7 +73,7 @@
-
+
diff --git a/TopicPage.xaml.cs b/TopicPage.xaml.cs
index a0c2295..848bac2 100644
--- a/TopicPage.xaml.cs
+++ b/TopicPage.xaml.cs
@@ -87,6 +87,12 @@ private void Refresh_Click(object sender, EventArgs e)
LoadTopics();
}
+ private void Reply_Click(object sender, EventArgs e)
+ {
+ NavigationService.Navigate(new Uri("/PostPage.xaml?title=" + HttpUtility.UrlEncode(App.ViewModel.CurrentTopic.Title) + "&board=" + App.ViewModel.CurrentTopic.Board
+ + "&reid=" + App.ViewModel.CurrentTopic.Id, UriKind.Relative));
+ }
+
private void LoadTopics()
{
App.ViewModel.CurrentTopic.IsLoaded = false;
diff --git a/ValueConverters/LoadedOpacityConverter.cs b/ValueConverters/LoadedOpacityConverter.cs
index d162d1b..997cbcb 100644
--- a/ValueConverters/LoadedOpacityConverter.cs
+++ b/ValueConverters/LoadedOpacityConverter.cs
@@ -17,7 +17,8 @@ public class LoadedOpacityConerter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- return (bool)value ? 0 : 0.5;
+ bool reverse = parameter != null;
+ return ((bool)value ^ reverse)? 0 : 0.5;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
diff --git a/ValueConverters/StampDateConverter.cs b/ValueConverters/StampDateConverter.cs
index b29ee20..bf2b093 100644
--- a/ValueConverters/StampDateConverter.cs
+++ b/ValueConverters/StampDateConverter.cs
@@ -19,14 +19,14 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
{
DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, 0);
date = date.AddSeconds((int)value).ToLocalTime();
- DateTime now = new DateTime();
+ DateTime now = DateTime.Now;
if (date.Year == now.Year && date.Month == now.Month && date.Day == now.Day)
return date.ToString("HH:mm", culture);
else if (date.Year == now.Year)
return date.ToString("MM月d日 HH:mm", culture);
else
- return date.ToString("yyyy MM月d日", culture);
+ return date.ToString("yyyy年MM月d日", culture);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
diff --git a/ViewModels/CurrentBoardViewModel.cs b/ViewModels/CurrentBoardViewModel.cs
index 0a3b81c..5d135a4 100644
--- a/ViewModels/CurrentBoardViewModel.cs
+++ b/ViewModels/CurrentBoardViewModel.cs
@@ -19,6 +19,9 @@ public class CurrentBoardViewModel : INotifyPropertyChanged
private bool isLoaded;
private ObservableCollection topics;
+ // 全局变量,用于标记跳转到版面时是否需要刷新
+ public bool NeedRefresh { get; set; }
+
public string EnglishName
{
get
diff --git a/ViewModels/LoadingViewModel.cs b/ViewModels/LoadingViewModel.cs
new file mode 100644
index 0000000..6dc3630
--- /dev/null
+++ b/ViewModels/LoadingViewModel.cs
@@ -0,0 +1,37 @@
+using System;
+using System.ComponentModel;
+using System.Collections.ObjectModel;
+
+namespace sbbs_client_wp7
+{
+ public class LoadingViewModel : INotifyPropertyChanged
+ {
+ private bool isLoading;
+
+ public bool IsLoading
+ {
+ get
+ {
+ return isLoading;
+ }
+ set
+ {
+ if (isLoading != value)
+ {
+ isLoading = value;
+ NotifyPropertyChanged("IsLoading");
+ }
+ }
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ private void NotifyPropertyChanged(String propertyName)
+ {
+ PropertyChangedEventHandler handler = PropertyChanged;
+ if (null != handler)
+ {
+ handler(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+ }
+}
diff --git a/sbbs-client-wp7.csproj b/sbbs-client-wp7.csproj
index f81180d..4c695a3 100644
--- a/sbbs-client-wp7.csproj
+++ b/sbbs-client-wp7.csproj
@@ -80,10 +80,16 @@
+
+ PostPage.xaml
+
+
+ SettingsPage.xaml
+
Tile.xaml
@@ -100,6 +106,7 @@
+
@@ -130,6 +137,14 @@
MSBuild:Compile
Designer
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -152,9 +167,12 @@
PreserveNewest
+
+
+