How to get XML to TextBlocks and an Image - c#

So I have a Windows Phone C# application in which I want to get a google weather api xml file located here: http://www.google.com/ig/api?weather=[insert zip code here] and get the current weather info. Well I want to display the image located in the xml file and I want to, based on the image, display a background image. How would I do that?
Also, I don't want to use a listbox for it because it won't let me resize the image to full screen.

You are asking rather a lot in your question, so here are some pointers rather than a complete answer.
Use Linq to XML to analyse the returned XML, using the XDocument.Parse method
Locate the images using Linq to XML, doc.Descendants("icon") will find all the icon elements, you can then iterate over them and extract the data attribute.
Create an ImageBrush for your background, setting its source to the URL of the image you require. There are numerous blog posts / SO questions that show you how to handle images in code-behind. For example:
How do you set Image.Source in Silverlight(Code behind)
This should get you started. If you get stuck on something specific, come back and ask a specific question.

Related

Getting actual content from RSS feed

Here for example there is a link for ABC news which gives various RSS feeds to consume.
http://rss.cnn.com/rss/edition.rss`
Using this feeds in Windows 8 store app, I am able to read it using built in SyndicationClient class. However, it gives only title and few summary text for the news story/article and not all content. Now I want to have all content i.e. Text and Image. I saw many news reader app for Windows store and they are doing it pretty much easily when I tap on any story and it gives me actual content right there.
Any idea how to accomplish this? Do I need some sort of html parser here?
You can have a look at News, News Bento app for example. I want to achieve something similar.
Here are the images from the app:
This is extracted text and images from the news article:
This is the view when you click on "View Original Article". I know that view below is using webview control. But I want how to extract data like image above.
Well, answer is readablity. More here as well:
https://github.com/scottksmith95/CSharp.Readability
It took me lot of time to find out this stuff but it is exactly what I wanted.

Retrieving images from MS Access database and display under <img> form

I save my images in the database as an OLE Object Data type.How can an image from the database displayed in the tag? Is it also in the 'src' attribute?
In other answer you have been pointed to article explains how to show image in data grid. In general I see here two questions, how to extract an image from the database and how to show it in tag. The article from Andras Toth answer covers both questions. But if you are not going to use grids, you should provide url to the image in tag. Here you can read how to implement generic handler shows an image stored in the database, so you can add url to the image to any tag. Solution depends on your needs.

Display thumbnails for images in articles

So I have this website where users can post articles, each article containing at least one photo. What I want to do is when I display the list of articles on the website I want to also show a thumbnail next to the articles name.
Here comes the tricky part: the images are not hosted on my server, are simply links hosted on some image-hosting website. Another problem is that I don't know where the images appear in the post (they could be at the beginning, at the end or in the middle of the article).
What would be the best approach to create a thumbnail system in this case?
I was thinking maybe I could do this: every time an article is posted or edited and stored into the database I could scan the entire articles for images links and store the first link in a separate value in the database (this could be kind of slow though).
Also once I have those values stored and I have to display a thumbnail the only way to do so will be by showing the full image resized to the thumbnail size (that means the user has to download multiple full-size images to see the articles list with thumbnails).
Is there any better approach? (you can see the technologies used in the tags)
Create a thumbnails task that runs in the background after an article has been published.
Find image tags in the article HTML using regular expression.
Get those images and create and thumbnail that you save locally in a folder in your server.
Protect that folder/location against hotlinking.
Use those local pictures as thumbnails
Use HtmlAgilityPack as a starter to get to the images from the image host.
Use an ASP.NET handler to generate the thumbnails. That way, you won't have to store anything locally, the thumbnails images will only exist in memory, making hotlinking impossible

ctrl-v image into richtextbox in sharepoint

I'm trying to ctrl-v an image into a RichTextBox in SharePoint using C#. So far, I've had no luck in successfully doing so. The image appears as a white space or as a broken image.
I know there is the option of using the clipboard or converting formats, but I'm not too sure how to do that (I've heard I need to convert clipboard image to a certain format before inserting it). Moreover, I want to check to see if anyone has tried to do something similar with success first.
Thanks.
Chris
This is not possible out of the box, you can however use RadEditor for sharepoint from telerik, it's free (the lite version) and allows for uploading of images while you are editing a page. Mind, you still need to upload the image first, then you can include it in the text using a url.
See this post for more info.

Is there a way to replace a text in a PDF file with itextsharp?

I'm using itextsharp to generate the PDFs, but I need to change some text dynamically.
I know that it's possible to change if there's any AcroField, but my PDF doen's have any of it. It just has some pure texts and I need to change some of them.
Does anyone know how to do it?
Actually, I have a blog post on how to do it! But like IanGilham said, it depends on whether you have control over the original PDF. The basic idea is you setup a form on the page and replace the form fields with the text you want. (You can style the form so it doesn't look like a form)
If you don't have control over the PDF, let me know how to do it!
Here is a link to the full post:
Using a template to programmatically create PDFs with C# and iTextSharp
I haven't used itextsharp, but I have been using PDFNet SDK to explore the content of a large pile of PDFs for localisation over the last few weeks.
I would say that what you require is absolutely achievable, but how difficult it is will depend entirely on how much control you have over the quality of the files. In my case, the files can be constructed from any combination of images, text in any random order, tables, forms, paths, single pixel graphics and scanned pages, some of which are composed from hundreds of smaller images. Let's just say we're having fun with it.
In the PDFTron way of doing things, you would have to implement a viewer (sample available), and add some code over a text selection. Given the complexities of the format, it may be necessary to implement a simple editor in a secondary dialog with the ability to expand the selection to the next line (or whatever other fundamental object is used to make up text). The string could then be edited and applied by copying the entire page of the document into a new page, replacing the selected elements with your new string. You would probably have to do some mathematics to get this to work well though, as just about everything in PDF is located on the page by means of an affine transform.
Good luck. I'm sure there are people on here with some experience of itextsharp and PDF in general.
This question comes up from time to time on the mailing list. The same answer is given time and time again - NO. See this thread for the official answer from the person who created iText.
This question should be a FAQ on the itextsharp tag wiki.

Categories