Beispiel #1
0
        private async Task RefreshItaList()
        {
            var client = new My2chClient();

            try
            {
                var categories = await client.GetItaList();

                var store   = new StoreToFiles();
                var changed = await store.AddOrUpdateCategories(categories);

                if (changed.Count > 0)
                {
                    string changedText = "";
                    foreach (var ita in changed)
                    {
                        changedText += (ita.Name + ", ");
                    }
                    var dialog = new MessageDialog(changedText, "以下の板のURLが変更されました。");
                    await dialog.ShowAsync();
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message, "板一覧の取得中にエラーが発生しました。");
                await dialog.ShowAsync();
            }
        }
Beispiel #2
0
        public async void Init(int count)
        {
            var store = new StoreToFiles();

            thread.MidokuCount = 0;
            await store.AddOrUpdateThreadInformation(thread);

            try
            {
                store.LoadPosts(thread);
                await Task.Delay(100);

                ScrollToCurrentOffset();
            }
            catch (Exception ex)
            {
                if (count > 10)
                {
                    var message = new MessageDialog(ex.Message, "スレッドの読み込み中にエラーが発生しました。");
                    await message.ShowAsync();
                }
                else
                {
                    var random = new Random();
                    await Task.Delay(random.Next(1, 5) * 100);

                    Init(++count);
                }
            }
        }
Beispiel #3
0
        public async Task ReloadPostList()
        {
            var store  = new StoreToFiles();
            var client = new My2chClient();

            try
            {
                var tmpThread = await store.AddOrUpdateThreadInformation(Thread);

                var posts = await client.GetFullPostList(tmpThread);

                posts = await store.AddPosts(posts, tmpThread);

                tmpThread.Posts = posts;
                Thread          = tmpThread;
                await Task.Delay(300);

                ScrollToCurrentOffset();
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message, "スレッドの取得中にエラーが発生しました。");
                await dialog.ShowAsync();
            }
        }
        public HistoryThreadsFlipModel(FlipView MainFlip)
        {
            this.MainFlip = MainFlip;
            threadList    = new ObservableCollection <Thread>();
            Role          = ItaListPageViewModel.FlipRole.ThreadList;
            var store = new StoreToFiles();

            store.LoadThreads(threadList);
        }
        private void DeleteThreadFile(object sender, RoutedEventArgs e)
        {
            var flip   = MainFlip.SelectedItem as HistoryPagePostsFlipModel;
            var thread = flip.thread;
            var store  = new StoreToFiles();

            store.DeleteThread(thread);

            viewModel            = new HistoryPageViewModel(MainFlip);
            MainGrid.DataContext = viewModel;
        }
Beispiel #6
0
        public void ScrollToCurrentOffset()
        {
            var container    = MainFlip.ContainerFromItem(this);
            var scrollViewer = FindChildrenObjectByType <ScrollViewer>(container);

            var store  = new StoreToFiles();
            var offset = store.LoadOffset(thread);

            scrollViewer.ScrollToVerticalOffset(offset);
            this.MainFlip.SelectionChanged += MainFlip_SelectionChanged;

            //scrollViewer.ViewChanged += ScrollViewer_ViewChanged;
        }
Beispiel #7
0
        public void ScrollToCurrentOffset()
        {
            MainFlip.GetBindingExpression(FlipView.ItemsSourceProperty).UpdateSource();
            var container    = MainFlip.ContainerFromItem(this);
            var scrollViewer = FindChildrenObjectByType <ScrollViewer>(container);

            var store  = new StoreToFiles();
            var offset = store.LoadOffset(Thread);

            scrollViewer.ScrollToVerticalOffset(offset);
            this.MainFlip.SelectionChanged += MainFlip_SelectionChanged;

            //scrollViewer.ViewChanged += ScrollViewer_ViewChanged;
        }
Beispiel #8
0
        public async void ReloadThreadList()
        {
            var client = new My2chClient();
            var store  = new StoreToFiles();

            try
            {
                await client.GetThreadList(Ita, ThreadList);
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message, "スレッド一覧の取得中にエラーが発生しました。");
                await dialog.ShowAsync();
            }
        }
Beispiel #9
0
 private async void MainFlip_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (MainFlip.Items.Count == 4)
     {
         var container    = MainFlip.ContainerFromItem(this);
         var scrollViewer = FindChildrenObjectByType <ScrollViewer>(container);
         if (scrollViewer != null)
         {
             var store  = new StoreToFiles();
             var offset = (float)scrollViewer.VerticalOffset;
             Thread.CurrentOffset = offset;
             await store.UpdateCurrentOffset(Thread);
         }
     }
 }
Beispiel #10
0
        public async Task Refresh()
        {
            var client = new My2chClient();

            try
            {
                var newPosts = await client.GetFullPostList(thread);

                var store = new StoreToFiles();
                var posts = await store.AddPosts(newPosts, thread);
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message, "スレッドの取得中にエラーが発生しました。");
                await dialog.ShowAsync();
            }
        }
Beispiel #11
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.NavigationMode != NavigationMode.Back)
            {
                viewModel = new ItaListPageViewModel(MainFlip);
                var categoryFlip = new CategoryFlipModel(MainFlip);
                viewModel.FlipList.Add(categoryFlip);

                var store      = new StoreToFiles();
                var categories = await store.LoadCategories();

                var list = new ObservableCollection <Category>();
                if (categories == null || categories.Count == 0)
                {
                    var client = new My2chClient();
                    try
                    {
                        var getcategory = await client.GetItaList();

                        await store.AddCategories(getcategory);
                    }
                    catch (Exception ex)
                    {
                        var message = new MessageDialog("板一覧を取得するため、インターネットに接続できる状態で起動してください。", "初回起動ですか");
                        await message.ShowAsync();

                        return;
                    }
                }

                foreach (var category in categories)
                {
                    list.Add(category);
                }
                categoryFlip.CategoryList = list;

                MainGrid.DataContext = viewModel;
            }
        }
Beispiel #12
0
 private async void MainFlip_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (MainFlip.Items.Count == 2)
     {
         var container    = MainFlip.ContainerFromItem(this);
         var scrollViewer = FindChildrenObjectByType <ScrollViewer>(container);
         var store        = new StoreToFiles();
         if (scrollViewer != null)
         {
             var offset = (float)scrollViewer.VerticalOffset;
             thread.CurrentOffset = offset;
             try
             {
                 await store.UpdateCurrentOffset(thread);
             }
             catch (Exception ex)
             {
                 //ここでの例外はおそらく同時に複数のタスクが更新しようとしているだけ
             }
         }
     }
 }
        public async Task Refresh()
        {
            var store  = new StoreToFiles();
            var client = new My2chClient();

            foreach (var thread in threadList)
            {
                try
                {
                    var posts = await client.GetFullPostList(thread);

                    await store.AddPostsWithMidokuCount(posts, thread);
                }
                catch (Exception ex)
                {
                    var dialog = new MessageDialog(thread.Name + ": " + ex.Message, "スレッドの更新に失敗しました。");
                    await dialog.ShowAsync();
                }
            }

            store.LoadThreads(threadList);
        }
Beispiel #14
0
        private async void RefreshItaListButton(object sender, RoutedEventArgs e)
        {
            var button = sender as AppBarButton;

            button.IsEnabled = false;

            await RefreshItaList();

            var store      = new StoreToFiles();
            var categories = await store.LoadCategories();

            var cateFlip = MainFlip.Items[0] as CategoryFlipModel;

            cateFlip.CategoryList.Clear();

            foreach (var category in categories)
            {
                cateFlip.CategoryList.Add(category);
            }

            button.IsEnabled = true;
        }
Beispiel #15
0
        private void ReloadItalist()
        {
            var store = new StoreToFiles();

            this.Category.Itas = store.LoadItas(this.Category);
        }