Beispiel #1
0
        public void GetSearchResults()
        {
            SearchContext searchContext = new SearchContext();

            searchContext.GetSearchResults(KeywordText,
                                           (invokeOp) =>
            {
                foreach (string imageURL in invokeOp.Value)
                {
                    ImageURLs.Add(imageURL);
                }
            },
                                           null);
        }
Beispiel #2
0
        public XElement toXMLElement()
        {
            XElement oElement = new XElement("Document");

            oElement.SetElementValue("Title", Title);
            oElement.SetElementValue("URL", URL);
            oElement.SetElementValue("Author", Author);
            oElement.SetElementValue("LastMod", LastModified);
            oElement.SetElementValue("Status", Status);
            XElement xURLS = new XElement("URLs");

            ImageURLs.ForEach(x => xURLS.Add(new XElement("ImgURL", x)));
            oElement.Add(xURLS);
            return(oElement);
        }
 private void LoadData()
 {
     try
     {
         imageIdentifiers = identifiers.ReadObject <ImageIdentifiers>();
     }
     catch
     {
         imageIdentifiers = new ImageIdentifiers();
     }
     try
     {
         skinInformation = skininfo.ReadObject <SkinInformation>();
     }
     catch
     {
         skinInformation = new SkinInformation();
     }
     try
     {
         imageUrls = urls.ReadObject <ImageURLs>();
     }
     catch
     {
         imageUrls = new ImageURLs();
     }
     if (skinInformation == null)
     {
         skinInformation = new SkinInformation();
     }
     if (imageIdentifiers == null)
     {
         imageIdentifiers = new ImageIdentifiers();
     }
     if (imageUrls == null)
     {
         imageUrls = new ImageURLs();
     }
 }
Beispiel #4
0
        public MemoryStream toPDF(Replaces oReplaces)
        {
            PdfDocument mDocument = new PdfDocument();
            Replace     ToValue   = null;

            using (WebClient wc = new WebClient())
            {
                string sImageUrl = ImageURLs.FirstOrDefault(x => oReplaces.Exists(y => x.Contains(y.ThisValue)));
                if (sImageUrl != null)
                {
                    MemoryStream ms = new MemoryStream(wc.DownloadData(sImageUrl));
                    foreach (Replace oRpl in oReplaces.Where(x => sImageUrl.Contains(x.ThisValue)))//.Select(y => sImageURL.Replace(y.ThisValue, y.WithThis)).ToList())
                    {
                        try
                        {
                            if (ms.Length != new MemoryStream(wc.DownloadData(sImageUrl.Replace(oRpl.ThisValue, oRpl.WithThis))).Length)
                            {
                                ToValue = oRpl;
                            }
                        }
                        catch
                        {
                            //nichts
                        }
                    }
                }
                if (ToValue != null)
                {
                    List <string> sNURLS = ImageURLs.Select(y => y.Replace(ToValue.ThisValue, ToValue.WithThis)).ToList();
                    ImageURLs = sNURLS;
                }
                foreach (string sImageURL in ImageURLs)
                {
                    try
                    {
                        PdfPage              page   = mDocument.AddPage();
                        XGraphics            gfx    = XGraphics.FromPdfPage(page);
                        System.Drawing.Image oImage = System.Drawing.Image.FromStream(new MemoryStream(wc.DownloadData(sImageURL)));


                        MemoryStream ms = new MemoryStream();
                        oImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                        oImage.Dispose();
                        XImage image = XImage.FromStream(ms);

                        double dProporcion = 1;
                        //rezise calcs
                        if (image.PixelWidth * dProporcion > page.Width)
                        {
                            dProporcion = page.Width / image.PixelWidth;
                        }
                        if (image.PixelHeight * dProporcion > page.Height)
                        {
                            dProporcion = page.Height / image.PixelHeight;
                        }
                        gfx.DrawImage(image, (page.Width - image.PixelWidth * dProporcion) / 2, (page.Height - image.PixelHeight * dProporcion) / 2, image.PixelWidth * dProporcion, image.PixelHeight * dProporcion);
                    }
                    catch
                    {
                        //do nothing, try next
                    }
                }
            }
            MemoryStream fs = new MemoryStream();

            mDocument.Save(fs, false);
            return(fs);
        }