diff --git a/BoardSettingsPage.xaml.cs b/BoardSettingsPage.xaml.cs
index b8db37f..ef2b4db 100644
--- a/BoardSettingsPage.xaml.cs
+++ b/BoardSettingsPage.xaml.cs
@@ -26,9 +26,8 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
base.OnNavigatedTo(e);
// 恢复选择
- int[] modeMap = { 0, 1, 2, 2 };
ignoreSelection = true;
- Mode.SelectedIndex = modeMap[App.Service.BoardMode];
+ Mode.SelectedIndex = App.Service.BoardMode % 3;
}
private bool ignoreSelection = true; // 永远忽略第一次选择(由系统触发)
@@ -44,8 +43,7 @@ private void Mode_SelectionChanged(object sender, SelectionChangedEventArgs e)
ListPicker list = sender as ListPicker;
// 设置并保存模式
- int[] modeMap = { 0, 1, 3};
- int mode = modeMap[list.SelectedIndex];
+ int mode = list.SelectedIndex;
if (mode != App.Service.BoardMode)
{
diff --git a/MainPage.xaml b/MainPage.xaml
index 495a2c9..b3499ff 100644
--- a/MainPage.xaml
+++ b/MainPage.xaml
@@ -22,7 +22,7 @@
toolkit:TiltEffect.IsTiltEnabled="True">
-
diff --git a/MainPage.xaml.cs b/MainPage.xaml.cs
index 860ff4c..c9a4db3 100644
--- a/MainPage.xaml.cs
+++ b/MainPage.xaml.cs
@@ -15,6 +15,7 @@ namespace sbbs_client_wp7
{
using Sbbs;
using System.Collections.ObjectModel;
+ using System.Windows.Threading;
public partial class MainPage : PhoneApplicationPage
{
@@ -38,12 +39,25 @@ public MainPage()
}
// Load data for the ViewModel Items
+ private bool isFirstLoading = true;
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
- if (!App.ViewModel.IsDataLoaded)
+ // 启动时延迟2秒更新
+ if (isFirstLoading)
{
- LoadTopten();
- LoadFavorates();
+ isFirstLoading = false;
+
+ // 延迟两秒后开始刷新
+ DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(2) };
+ timer.Tick += delegate(object s, EventArgs arg)
+ {
+ App.ViewModel.IsDataLoaded = false; // 标记开始更新
+
+ LoadTopten();
+ LoadFavorates();
+ timer.Stop();
+ };
+ timer.Start();
}
}
diff --git a/PostPage.xaml.cs b/PostPage.xaml.cs
index 287f298..02cc216 100644
--- a/PostPage.xaml.cs
+++ b/PostPage.xaml.cs
@@ -52,7 +52,7 @@ 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)
+ App.Service.TopicPost(board, reid, TitleText.Text, ContentText.Text, delegate(TopicViewModel topic, bool success, string error)
{
viewModel.IsLoading = false;
if (!success)
@@ -66,7 +66,7 @@ private void Post_Click(object sender, EventArgs e)
App.ViewModel.CurrentBoard.NeedRefresh = true;
// 跳转到话题时直接在最后添加
else
- App.ViewModel.CurrentTopic.Topics.Add(topics[0]);
+ App.ViewModel.CurrentTopic.Topics.Add(topic);
NavigationService.GoBack();
}
diff --git a/Sbbs/Response.cs b/Sbbs/Response.cs
index 98293a0..df6bfcd 100644
--- a/Sbbs/Response.cs
+++ b/Sbbs/Response.cs
@@ -48,6 +48,22 @@ public ObservableCollection Root
}
}
+ // 返回单个主题
+ [DataContract]
+ public class TopicResponse : Response, IResponse
+ {
+ [DataMember(Name = "topic")]
+ public TopicViewModel topic;
+
+ public TopicViewModel Root
+ {
+ get
+ {
+ return topic;
+ }
+ }
+ }
+
// 返回版面集合
// 符合类型: 收藏夹
[DataContract]
diff --git a/Sbbs/Service.cs b/Sbbs/Service.cs
index 259fa89..a5ef4b5 100644
--- a/Sbbs/Service.cs
+++ b/Sbbs/Service.cs
@@ -87,14 +87,14 @@ public void Topic(string board, int id, int start, int limit, Action 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 });
+ wc.DownloadStringCompleted += DownloadedAndParse;
+ wc.DownloadStringAsync(uri, new ServiceArg() { Callback = callback });
}
// 下载完成后分析JSON数据然后调用回调函数
diff --git a/TopicPage.xaml b/TopicPage.xaml
index 47daf11..ba0978f 100644
--- a/TopicPage.xaml
+++ b/TopicPage.xaml
@@ -61,7 +61,8 @@
+ ScrollViewer.VerticalScrollBarVisibility="Disabled"
+ SelectionChanged="ListBox_SelectionChanged">