Exemplo n.º 1
0
        private void autoSelectButton_Click(object sender, EventArgs e)
        {
            // get displaying items
            List <ImageRakerThumbnailListViewItem> displayingItems = new List <ImageRakerThumbnailListViewItem>();

            foreach (ListViewItem item in thumbnailListView.Items)
            {
                ImageRakerThumbnailListViewItem myitem = item.Tag as ImageRakerThumbnailListViewItem;
                displayingItems.Add(myitem);
            }

            bool ignoreSmall = !showSmallsCheckBox.Checked;

            ImageSelecter selecter = new ImageSelecter();
            Dictionary <string, string> selected = selecter.AutoSelect(imageItems.ToArray(), displayingItems.ToArray(), ignoreSmall);

            // select items
            originallyAutoSelectedImageItems.Clear();

            foreach (ListViewItem item in thumbnailListView.Items)
            {
                ImageRakerThumbnailListViewItem myitem = item.Tag as ImageRakerThumbnailListViewItem;

                if (selected.ContainsKey(myitem.ImageSource))
                {
                    item.Checked = true;

                    originallyAutoSelectedImageItems.Add(myitem);
                }
                else
                {
                    item.Checked = false;
                }
            }
        }
Exemplo n.º 2
0
        // returns num of images to save
        public int OnDocumentComplete(IHTMLDocument2 docRoot, ImageRakerDownloadForm.SaveCompleteDelegate saveCompleteDelegate)
        {
            if (docRoot != null)
            {
                // 프레임의 경우 여러 url으로 이루어져있으므로 우선 combined url을 구한다.
                int    numOfDocs   = 0;
                string combinedUrl = GetCombinedUrl(docRoot, out numOfDocs);

                Logger.Log("autosavemanager - doc complete - numofdocs: {0}, combined url: {1}", numOfDocs, combinedUrl);

                // check visited
                if (savedPages.ContainsKey(combinedUrl))
                {
                    // already visited, skip
                    Logger.Warn("already saved in this url: {0}", combinedUrl);

                    // 이미 방문한 경우...
                    saveCompleteDelegate(ImageRakerDownloadForm.SaveCompleteState.AlreadySaved, 0, 0, 0, 0, 0);

                    return(0);
                }

                savedPages.Add(combinedUrl, 0);

                ImgSrcExtractor extractor = new ImgSrcExtractor();
                extractor.Extract(docRoot);
                ImageRakerThumbnailListViewItem[] items = extractor.GetItems();

                ImageSelecter selecter = new ImageSelecter();
                Dictionary <string, string> selected = selecter.AutoSelect(items, items, true);                 // url, referer

                //List<UrlPair> urlpairs = new List<UrlPair>();
                urlPairs.Clear();

                // make url pair
                foreach (KeyValuePair <string, string> sel in selected)
                {
                    string url     = sel.Key;
                    string referer = sel.Value;

                    // check img url duplication
                    if (!savedUrls.ContainsKey(url))
                    {
                        urlPairs.Add(new UrlPair(url, referer));

                        savedUrls.Add(url, 0);
                    }
                }

                if (urlPairs.Count > 0)
                {
                    Logger.Info("auto save manager - starting ir downloadform...");

                    UsageReporter.Instance.FormLoadTime       = -1;
                    UsageReporter.Instance.SaveCountInSession = -1;

                    FilePathMaker.FileNameMakingMethod fileNameMakingMethod = FilePathMaker.GetFileNameMakingMethodFromConfig();

                    downloadForm = new ImageRakerDownloadForm(saveFolder, urlPairs,
                                                              fileNameMakingMethod, true, ImageRaker.SaveType.ByAuto);

//					downloadForm.TopMost = true;	// 사용할 수 없음.
                    downloadForm.WindowState = FormWindowState.Minimized;
//					downloadForm.Opacity = 0.65;
                    downloadForm.StartPosition = FormStartPosition.CenterScreen;
                    downloadForm.SaveComplete += saveCompleteDelegate;

                    downloadForm.Show();

                    Logger.Log("auto save complete asynchronously");

                    return(urlPairs.Count);
                }
                else
                {
                    Logger.Info("nothing to auto save!");

                    saveCompleteDelegate(ImageRakerDownloadForm.SaveCompleteState.NothingToSave, 0, 0, 0, 0, 0);

                    return(0);
                }
            }
            else
            {
                Logger.DLog("invalid doc!");
            }

            return(0);
        }