Beispiel #1
0
        private void imageDownloadBtn_Click(object sender, RoutedEventArgs e)
        {
            ChanCatalogThread cct = threadLst.SelectedValue as ChanCatalogThread;

            string path = string.IsNullOrEmpty(Properties.Settings.Default.RootFolder) ? "DUMP" : Properties.Settings.Default.RootFolder;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string allPath = Path.Combine(path, "[ALL]");

            if (!Directory.Exists(allPath))
            {
                Directory.CreateDirectory(allPath);
            }

            string topicPath = Path.Combine(path, string.Format("{0}-{1}", cct.BoardSlug, cct.ThreadId));

            if (!Directory.Exists(topicPath))
            {
                Directory.CreateDirectory(topicPath);
            }


            List <Task> tl = new List <Task>();

            foreach (ChanPostFile item in imageLst.SelectedItems)
            {
                string itemPath = Path.Combine(allPath, string.Format("{0}{1}", item.MD5String, item.Extension));

                if (!File.Exists(itemPath))
                {
                    using (WebClient wc = new WebClient())
                    {
                        var dlTask = wc.DownloadFileTaskAsync(item.Uri, itemPath);
                        tl.Add(dlTask);
                    }
                }

                string linkPath = Path.Combine(topicPath, string.Format("{0}{1}", item.Name, item.Extension));

                if (!File.Exists(linkPath))
                {
                    InteropHelper.CreateHardLink(linkPath, itemPath, IntPtr.Zero);
                }
            }

            Task.WhenAll(tl).ContinueWith((t) =>
            {
                Dispatcher.Invoke(() =>
                {
                    MessageBox.Show("COMPLETE");
                });
            });
        }
Beispiel #2
0
        private void threadLst_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ChanCatalogThread chanThread = threadLst.SelectedValue as ChanCatalogThread;

            if (chanBoard == null)
            {
                return;
            }

            Frame.Navigate(typeof(imagesPage), new Tuple <BaseChan, ChanBoard, ChanCatalogThread>(chanSite, chanBoard, chanThread));
        }
Beispiel #3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var navData = e.Parameter as Tuple <BaseChan, ChanBoard, ChanCatalogThread>;

            chanSite   = navData.Item1;
            chanBoard  = navData.Item2;
            chanThread = navData.Item3;

            if (chanSite != null)
            {
                var src = await chanSite.GetPostsForTheadAsync(chanBoard.UrlSlug, (int)chanThread.ThreadId);

                imageLst.ItemsSource = src.Where(m => m.Files != null).SelectMany(m => m.Files);
            }
        }
Beispiel #4
0
        private void threadLst_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            BaseChan          bc  = siteLst.SelectedValue as BaseChan;
            ChanBoard         cb  = boardLst.SelectedValue as ChanBoard;
            ChanCatalogThread cct = threadLst.SelectedValue as ChanCatalogThread;

            if (bc == null || cb == null || cct == null)
            {
                return;
            }

            imageLst.ItemsSource = null;

            LoadingBlock.Visibility = Visibility.Visible;


            Task t = new Task(async() =>
            {
                var posts = await bc.GetPostsForTheadAsync(cct.BoardSlug, (int)cct.ThreadId);

                if (posts == null || posts.Count() == 0)
                {
                    return;
                }


                await Dispatcher.InvokeAsync(() =>
                {
                    imageLst.ItemsSource = posts.Where(m => m.Files != null).SelectMany(m => m.Files);
                    if (imageLst.Items.Count > 0)
                    {
                        imageLst.ScrollIntoView(imageLst.Items[0]);
                    }

                    (controlTabs.Items[3] as TabItem).Visibility = Visibility.Visible;
                    controlTabs.SelectedIndex = 3;

                    LoadingBlock.Visibility = Visibility.Hidden;
                    updateBreadCrumbs(bc.DisplayName, cb.Title, string.Format("{0} - {1}", cct.ThreadId, cct.SubjectSafe));
                });
            });

            t.Start();
        }