예제 #1
0
        private bool checkFilters(TradeMeItem item)
        {
            int value = 0;

            if (trackBar1.InvokeRequired)
            {
                trackBar1.Invoke(new MethodInvoker(() => value = trackBar1.Value));
            }
            else
            {
                value = trackBar1.Value;
            }

            //Price filter
            if (Convert.ToDouble(item.price.Substring(1, item.price.Length - 1)) > value)
            {
                return(false);
            }

            //Wrecking and damaged filters
            if (item.name.ToLower().Contains("wreck") || item.name.ToLower().Contains("broken") || item.name.ToLower().Contains("faulty") || item.name.ToLower().Contains("repairs") || item.name.ToLower().Contains("not working") || item.name.ToLower().Contains("parts"))
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     foreach (int i in listView1.SelectedIndices)
     {
         TradeMeItem remove = getItemByURL(items[i].url);
         fuckoff.Add(remove);
         items.Remove(remove);
     }
 }
예제 #3
0
        private void getTradeMeItemsFromURL(string url)
        {
            WebClient wc = new WebClient();

            wc.DownloadFile(url, "temp.htm");

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.Load("temp.htm");

            File.Delete("temp.htm");

            HtmlNodeCollection nodeCollection = doc.DocumentNode.SelectNodes("//ul[@id='ListViewList']//li[@class='listingCard']");
            int counter = 0;

            foreach (HtmlNode node in nodeCollection)
            {
                HtmlNode test        = node.SelectSingleNode(".//div[@class='listingImage']").SelectSingleNode(".//img");
                string   name        = test.GetAttributeValue("alt", "error");
                string   imagesource = test.GetAttributeValue("src", "noPhoto");

                if (imagesource.Contains("noPhoto"))
                {
                    imagesource = "http://www.trademe.co.nz/images/NewSearchCards/LVIcons/noPhoto_160x120.png";
                }

                backgroundWorker1.ReportProgress(1, new AsyncImage(counter, imagesource));

                string price = node.SelectSingleNode(".//div[@class='listingBidPrice']").InnerText;
                string time  = node.SelectSingleNode(".//div[@class='listingCloseDateTime']").InnerText;

                //div class="listingTitle"
                string path = node.SelectSingleNode(".//div[@class='listingTitle']").SelectSingleNode(".//a").GetAttributeValue("href", "null");
                path = path.Insert(0, "http://www.trademe.co.nz/");
                bool        shouldAdd = true;
                TradeMeItem newitem   = new TradeMeItem(path, name, price, time, counter++);

                if (checkFilters(newitem))
                {
                    foreach (TradeMeItem i in fuckoff)
                    {
                        if (i.Equals(newitem))
                        {
                            shouldAdd = false;
                        }
                    }
                    if (shouldAdd)
                    {
                        items.Add(newitem);
                    }
                }
            }
        }
예제 #4
0
        private bool checkFilters(TradeMeItem item)
        {
            int value = 0;
            if (trackBar1.InvokeRequired)
                trackBar1.Invoke(new MethodInvoker(() => value = trackBar1.Value));
            else
                value = trackBar1.Value;

            //Price filter
            if (Convert.ToDouble(item.price.Substring(1, item.price.Length - 1)) > value)
                return false;

            //Wrecking and damaged filters
            if (item.name.ToLower().Contains("wreck") || item.name.ToLower().Contains("broken") || item.name.ToLower().Contains("faulty") || item.name.ToLower().Contains("repairs") || item.name.ToLower().Contains("not working") || item.name.ToLower().Contains("parts"))
                return false;

            return true;
        }
예제 #5
0
 private void listView1_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
 {
     try
     {
         if (items.Count <= e.ItemIndex)
         {
             e.Item = new ListViewItem();
         }
         else
         {
             TradeMeItem  item     = items[e.ItemIndex];
             ListViewItem listitem = new ListViewItem("", item.imageindex);
             listitem.SubItems.Add(item.name);
             listitem.SubItems.Add(item.price);
             listitem.SubItems.Add(item.time);
             e.Item = listitem;
         }
     }
     catch
     {
         e.Item = new ListViewItem();
     }
 }
예제 #6
0
        private void getTradeMeItemsFromURL(string url)
        {
            WebClient wc = new WebClient();
            wc.DownloadFile(url, "temp.htm");

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.Load("temp.htm");

            File.Delete("temp.htm");

            HtmlNodeCollection nodeCollection = doc.DocumentNode.SelectNodes("//ul[@id='ListViewList']//li[@class='listingCard']");
            int counter = 0;
            foreach (HtmlNode node in nodeCollection)
            {
                HtmlNode test = node.SelectSingleNode(".//div[@class='listingImage']").SelectSingleNode(".//img");
                string name = test.GetAttributeValue("alt", "error");
                string imagesource = test.GetAttributeValue("src", "noPhoto");

                if (imagesource.Contains("noPhoto"))
                    imagesource = "http://www.trademe.co.nz/images/NewSearchCards/LVIcons/noPhoto_160x120.png";

                backgroundWorker1.ReportProgress(1, new AsyncImage(counter, imagesource));
                            
                string price = node.SelectSingleNode(".//div[@class='listingBidPrice']").InnerText;
                string time = node.SelectSingleNode(".//div[@class='listingCloseDateTime']").InnerText;

                //div class="listingTitle"
                string path = node.SelectSingleNode(".//div[@class='listingTitle']").SelectSingleNode(".//a").GetAttributeValue("href", "null");
                path = path.Insert(0, "http://www.trademe.co.nz/");
                bool shouldAdd = true;
                TradeMeItem newitem = new TradeMeItem(path, name, price, time, counter++);

                if (checkFilters(newitem))
                {
                    foreach (TradeMeItem i in fuckoff)
                    {
                        if (i.Equals(newitem))
                            shouldAdd = false;
                    }
                    if (shouldAdd)
                        items.Add(newitem);
                }

            }
        }