コード例 #1
0
        //
        // GenerateImage
        //
        // Will generate the bitmap representing this text item
        //
        public Bitmap GenerateImage(string fileName, SlideShowImageSize imageSize, string templateDirectory)
        {
            int width  = SlideShow.slideShowImageWidths[(int)imageSize];
            int height = SlideShow.slideShowImageHeights[(int)imageSize];

            CompiledTextFeed compiledTextFeed = CompiledTextFeed.GetCompiledTextFeed(compiledTextFeedHash, compiledTextFeedGuid);

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.AppendChild(xmlDoc.CreateElement("textfeeditem"));
            ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "channeltitle", compiledTextFeed.Title);
            if (!String.IsNullOrEmpty(compiledTextFeed.LogoImageUrl))
            {
                ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "logoimg", compiledTextFeed.LogoImageUrl);
            }
            if (!String.IsNullOrEmpty(this.title))
            {
                ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "itemtitle", this.title);
            }
            if (!String.IsNullOrEmpty(this.description))
            {
                ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "itemdesc", this.description);
            }
            if (compiledTextFeed.RenderAd)
            {
                ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "adurl", Config.GetSetting("AdUrl"));
            }
            ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "width", width.ToString());
            ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "height", height.ToString());
            Bitmap bitmap = WebPageBitmap.LoadXsl(templateDirectory + "textfeeditem.xsl", xmlDoc, width, height);

            ImageUtil.SaveJpeg(fileName, bitmap, 100);

            return(bitmap);
        }
コード例 #2
0
        Random r = new Random(); // can be done centrally for the entire application
        //
        // GET: /Question/
        public ActionResult Index(String id)
        {
            String word = id;

            String[] titles = new String[] {
                "Can you guess what “" + word + "” means?",
                "Do you know what “" + word + "” means?",
                "What do you think “" + word + "” means?",
                "Do you really know what “" + word + "” is?",
                "What is “" + word + "”?"
            };
            String[] descriptions = new String[] {
                "Write your definition of the word “" + word + "” in a comment below. If you want to read more about it, or if you want to check your answer, click on the link to see the detailed description of the word.",
                "Write your interpretation of “" + word + "” in a comment if you want to test yourself. Open this link to see the answer."
            };

            ViewBag.Word        = word;
            ViewBag.Description = descriptions[r.Next(descriptions.Length)];
            ViewBag.Title       = titles[r.Next(titles.Length)];

            // todo: make sure name comes from dictionary (so doesn't contain funny characters
            WebPageBitmap.LoadBitmapSTA(word, Config.WebRoot);
            ViewBag.Image = Config.GetImagePath(word, ShareMode.Question);
            ViewBag.Url   = Request.Url.AbsoluteUri;                 // needs to be set same as actual URL, probably helps FB to know how to cache, can test at https://developers.facebook.com/tools/debug/

            ViewBag.Audio = "http://mapto.ko64eto.com/po-zodia.mp3"; // just a placeholder
            return(View());
        }
コード例 #3
0
        public ActionResult Test(String word)
        {
            Thread thread = new Thread(() => WebPageBitmap.InitBitmap("wtest4", ShareMode.Question, ""));

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();

            return(View());
        }
コード例 #4
0
        static void Main(string[] args)
        {
            WebPageBitmap webBitmap = new WebPageBitmap("http://google.com.pe", 800, 600, false, 10000);

            if (webBitmap.IsOk)
            {
                webBitmap.Fetch();
                Bitmap thumbnail = webBitmap.GetBitmap(800, 600);
                thumbnail.Save("captura.jpg", ImageFormat.Jpeg);
                thumbnail.Dispose();
            }
        }
コード例 #5
0
        //
        // FetchWebPageData
        //
        // Gets the web page image for the selected url,
        // then stores the page in the web page cache
        //
        static private void FetchWebPageData(string url, Guid compiledWebPageGuid)
        {
            try
            {
                string filename = ImageUtil.GetCompiledImageDirectory("WebPageFetchCache") + compiledWebPageGuid + ".jpg";

                Bitmap webPageBitmap = WebPageBitmap.Fetch(new Uri(url).AbsoluteUri, 800, 600);

                webPageBitmap.Save(filename, ImageFormat.Jpeg);
            }
            catch (Exception)
            {
            }
        }
コード例 #6
0
        //
        // GenerateImage
        //
        // This will generate an image for the weather data
        //
        private Bitmap GenerateImage(string fileName, string templateDirectory, string weatherImageDirectory, SlideShowImageSize imageSize)
        {
            int width  = SlideShow.slideShowImageWidths[(int)imageSize];
            int height = SlideShow.slideShowImageHeights[(int)imageSize];

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.AppendChild(xmlDoc.ImportNode(this.weatherData, true));
            ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "weatherimagedirectory", weatherImageDirectory);
            ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "adurl", Config.GetSetting("AdUrl"));
            ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "width", width.ToString());
            ImageUtil.AddXmlElement(xmlDoc.DocumentElement, "height", height.ToString());
            Bitmap bitmap = WebPageBitmap.LoadXsl(templateDirectory + "Weather.xsl", xmlDoc, width, height);

            ImageUtil.SaveJpeg(fileName, bitmap, 100);

            return(bitmap);
        }
コード例 #7
0
ファイル: Feed.cs プロジェクト: arnoldblinn/photo.misc
        public void AddWebPageItems(List <FeedItem> items, string url, DateTime dateContext)
        {
            List <string> imageSources = WebPageBitmap.LoadDocumentImages(url);

            if (imageSources != null)
            {
                foreach (string imageSource in imageSources)
                {
                    Bitmap bitmap = ImageUtil.LoadImageFromUrl(imageSource);
                    if (bitmap != null && bitmap.Height >= 640 && bitmap.Width >= 480)
                    {
                        FeedItem feedItem = new FeedItem();
                        feedItem.pubDate     = dateContext;
                        feedItem.imageUrl    = imageSource;
                        feedItem.imageWidth  = bitmap.Width;
                        feedItem.imageHeight = bitmap.Height;
                        items.Add(feedItem);
                    }
                }
            }
        }
コード例 #8
0
        Random r = new Random(); // can be done centrally for the entire application

        //
        // GET: /Definition/
        //[Route("def/{id}")]
        public ActionResult Index(String id = null)
        {
            String word = id;

            if (word == null)
            {
                word = "syzygy";
            }
            LookupResult result = DictLookup.Get(word);

            String def = result.Definition.First().Text;

            String[] titles = new String[] {
                "Definition of the word “" + word + "”",
                "This is what we mean by “" + word + "”",
                "“" + word + "” means...",
                "“" + word + "” has the meaning...",
                "When we use “" + word + "” we mean...",
                "What is “" + word + "”?",
                "What does “" + word + "” mean?"
            };
            String[] descriptions = new String[] {
                "“" + word + "” is " + def,
                word + " - " + def,
                "Definition: " + def
            };

            ViewBag.Word        = word;
            ViewBag.Description = descriptions[r.Next(descriptions.Length)];
            ViewBag.Title       = titles[r.Next(titles.Length)];

            // todo: make sure name comes from dictionary (so doesn't contain funny characters
            WebPageBitmap.LoadBitmapSTA(word, Config.WebRoot);

            ViewBag.Image = Config.GetImagePath(word, ShareMode.Definition);
            ViewBag.Url   = Request.Url.AbsoluteUri; // needs to be set same as actual URL, probably helps FB to know how to cache, can test at https://developers.facebook.com/tools/debug/

            //ViewBag.Audio = "http://mapto.ko64eto.com/po-zodia.mp3"; // just a placeholder
            return(View());
        }