private void RightAfterLoaded(int threadId, int pageNo)
        {
            ThreadId = threadId;

            rightProgress.IsActive   = false;
            rightProgress.Visibility = Visibility.Collapsed;
            ReplyRefreshToFirstPageButton.IsEnabled = true;
            ReplyRefreshToLastPageButton.IsEnabled  = true;

            bool isShown = ReplyListService.CanShowButtonForLoadPrevReplyPage(threadId);

            if (isShown)
            {
                ReplyListView.HeaderTemplate = (DataTemplate)App.Current.Resources["ReplyListViewHeaderTemplate"];
            }
            else
            {
                ReplyListView.HeaderTemplate = null;
            }

            var cts = new CancellationTokenSource();
            var vm  = new SendThreadQuickReplyControlViewModel(cts, ThreadId, BeforeUpload, InsertFileCodeIntoContextTextBox, AfterUpload, SentFailed, SentSuccess);

            QuickReplyPanel.DataContext = vm;
        }
        public QuoteDetailPageViewModel(int postId, int threadId)
        {
            _ds       = new ReplyListService();
            _postId   = postId;
            _threadId = threadId;

            GetData();
        }
        public ReplyListViewForDefaultViewModel(CancellationTokenSource cts, int threadId, ListView replyListView, Action beforeLoad, Action <int, int> afterLoad, Action <int> listViewScroll)
        {
            _threadId       = threadId;
            _replyListView  = replyListView;
            _beforeLoad     = beforeLoad;
            _afterLoad      = afterLoad;
            _listViewScroll = listViewScroll;
            _ds             = new ReplyListService();

            AddToFavoritesCommand = new DelegateCommand();
            AddToFavoritesCommand.ExecuteAction = async(p) =>
            {
                await SendService.SendAddToFavoritesActionAsync(cts, threadId, _ds.GetThreadTitle(threadId));
            };

            RefreshReplyCommand = new DelegateCommand();
            RefreshReplyCommand.ExecuteAction = (p) =>
            {
                _ds.ClearReplyData(_threadId);
                LoadData(1);
            };

            LoadPrevPageDataCommand = new DelegateCommand();
            LoadPrevPageDataCommand.ExecuteAction = (p) =>
            {
                if (_startPageNo > 1)
                {
                    _ds.ClearReplyData(_threadId);
                    LoadData(_startPageNo - 1);
                }
            };

            LoadLastPageDataCommand = new DelegateCommand();
            LoadLastPageDataCommand.ExecuteAction = (p) =>
            {
                _ds.ClearReplyData(_threadId);
                LoadLastData(cts);
            };

            CopyUrlCommand = new DelegateCommand();
            CopyUrlCommand.ExecuteAction = (p) =>
            {
                string url         = $"http://www.hi-pda.com/forum/viewthread.php?tid={_threadId}";
                var    dataPackage = new DataPackage();
                dataPackage.SetText(url);
                Clipboard.SetContent(dataPackage);
            };

            OpenInBrowserCommand = new DelegateCommand();
            OpenInBrowserCommand.ExecuteAction = async(p) =>
            {
                var url = $"http://www.hi-pda.com/forum/viewthread.php?tid={_threadId}";
                Uri uri = new Uri(url, UriKind.Absolute);
                await Launcher.LaunchUriAsync(uri);
            };

            LoadData(_startPageNo);
        }
Esempio n. 4
0
        private async void OpenEditPostPanel(object sender, RoutedEventArgs e)
        {
            var data = (ReplyItemModel)((MenuFlyoutItem)e.OriginalSource).DataContext;

            if (data == null)
            {
                return;
            }

            var frame = Window.Current.Content as Frame;
            var mp    = frame.Content as MainPage;

            if (mp != null)
            {
                var cts      = new CancellationTokenSource();
                var editData = await ReplyListService.LoadContentForEditAsync(cts, data.PostId, data.ThreadId); // 先载入要修改的贴子的内容

                mp.OpenSendEditPostPanel(editData);
            }
        }
Esempio n. 5
0
        public ReplyListViewForSpecifiedPostViewModel(CancellationTokenSource cts, int postId, ListView replyListView, Action beforeLoad, Action <int, int> afterLoad, Action <int> listViewScroll)
        {
            _postId         = postId;
            _replyListView  = replyListView;
            _beforeLoad     = beforeLoad;
            _afterLoad      = afterLoad;
            _listViewScroll = listViewScroll;
            _ds             = new ReplyListService();

            AddToFavoritesCommand = new DelegateCommand();
            AddToFavoritesCommand.ExecuteAction = async(p) =>
            {
                await SendService.SendAddToFavoritesActionAsync(cts, _threadId, _ds.GetThreadTitle(_threadId));
            };

            RefreshReplyCommand = new DelegateCommand();
            RefreshReplyCommand.ExecuteAction = (p) =>
            {
                _ds.ClearReplyData(_threadId);
                LoadData(1);
            };

            LoadPrevPageDataCommand = new DelegateCommand();
            LoadPrevPageDataCommand.ExecuteAction = (p) =>
            {
                if (_startPageNo > 1)
                {
                    _ds.ClearReplyData(_threadId);
                    LoadData(_startPageNo - 1);
                }
            };

            LoadLastPageDataCommand = new DelegateCommand();
            LoadLastPageDataCommand.ExecuteAction = (p) =>
            {
                _ds.ClearReplyData(_threadId);
                LoadData(_ds.GetReplyMaxPageNo());
            };

            FirstLoad(cts);
        }