How can I access windows file preview icons from my WPF application - wpf

I got a bunch of Pictures and Videos in a directory and needs to be displayed in the WPF application, I am thinking about displaying the Win7 Large Icon itself as the preview image. Because that will save me the work of grabbing an appropriate frame from the video file since Windows is doing that job pretty well already.
Any code snippet to access this Shell Icon image data?

When using the Windows API Code Pack, you can do:
XAML
<Image x:Name="img" />
C#
img.Source = ShellFile.FromFilePath(#"C:\path\to\file.ext").Thumbnail.BitmapSource;
This requires adding the Microsoft-WindowsAPICodePack-Shell package and the appropriate namespaces.

Related

Set default xaml window background image in dll

I am currently developing a default WPF control Kit.
But I am stuck with using the correct kind of uri in xaml.
What I have is an image wich should be used as the background for the non-client area of my window.
To make the default controls available very easy I want to put everything in a dll.
Other apps can quickly reference that dll and get access to the style.
The problem is, that my image is not showing up when using the dll style in an app.
My image (/Resources/WindowBackground.jpg) is set to Resource and I am using the following xaml:
<Image Grid.ColumnSpan="99" Grid.RowSpan="99">
<Image.OpacityMask>
<ImageBrush ImageSource="pack://application:,,,/Resources/WindowBackground.jpg"/>
</Image.OpacityMask>
</Image>
I also tried:
<Image Grid.ColumnSpan="99" Grid.RowSpan="99" Source="/Resources/WindowBackground.jpg"/>
Both write the following into the output (Couple times):
..."System.IO.IOException" in PresentationFramework.dll...
I also tried lots of other uris wich sometimes lead to XamlParseExeptions and other not so nice stuff.
Thank you for any hints :D
You can find your answer in the Pack URIs in WPF page on MSDN. For your particular situation, you can use the following syntax to reference your resource image file:
pack://application:,,,/ReferencedAssembly;component/Resources/WindowBackground.‌​jpg
From the linked page:
The following example shows the pack URI for a XAML resource file that is located in a subfolder of the referenced assembly's project folder.
pack://application:,,,/ReferencedAssembly;component/Subfolder/ResourceFile.xaml
Note: The type of resource file here is irrelevant.

Way to use WPF Image without attaching image at runtime

I know how to attach an image to a XAML <Image> via VB.net runtime code. How would I do this the normal old way. (Attach the image within the IDE without using any code)
Before WPF one would browse for the image (in the Visual Studio IDE) it would somehow place it in the project and it would work.
Now I do this same thing, I can see the image in my Visual Studio IDE but during runtime the image appears blank.
How would I use the VS IDE to correctly browse for the image so it will display at runtime? Perhaps im doing something wrong a bit of help or any guidance would be awesome
I suppose you have a folder in your project which contains your image files, in that case something similar to <Image Source="/WpfApplication1/component;ImagesFolder/ImageName.png" /> would do the trick.
If you're looking for a non-code way, when you click on tag, you can browse for imported files from Source Property from Properties panel

Is it possible to bind a local file to an Image control in Silverlight using XAML?

I'm writing an OOB app using Silverlight 5 and I want to be able to bind files from the local file system to an Image control, something like
<Image Source="e:/user_data/sprites1.png" Stretch="Uniform"/>
Is this possible? If so how can I do it?
If it runs from desktop than yes, you can configure permissions in the project but if it runs from web browser, than absolutely it is not possible to access files from any folder on file system.
Here it is:
http://blogs.silverlight.net/blogs/msnow/archive/2010/04/20/tip-of-the-day-112-how-to-configure-your-silverlight-app-to-run-in-elevated-trust-mode.aspx

Show pdf inside silverlight application. PDF to XAML

I need to create silverlight application where customer will see some pdf files.
PDF files have to be inside silverlight control and not rendered as images (customer wants to select text)
For this purposes i need some free libriaries or code to convert pdf file to xaml (or just open pdf so i can convert it to xaml).
Which library can read pdf and help me to convert data to xaml?
Can I read somehow pdf file and write custom convertation tool?
I saw iTextSharp. Is this library can read pdf and help me with my issue?
I will be thankfull for any ideas or links.
I make use of the Acrobat Reader plugin to do the displaying for me. It does require a different method depending on whether your application is running inside or outside the browser (I check if the application is running inside the browser and change the means of display accordingly). If running inside the browser, I overlay the application with an IFrame, as I describe in this article: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-6.aspx. Otherwise, I use the WebBrowser control. I have a control which does this all for you in the source code that accompanies my book, which is downloadable from the Apress website here: http://www.apress.com/9781430272076/.
Hope this helps...
Chris

Using Visual Studio Image Library PNGs in a Windows Form app

My question is about the Visual Studio Image Library that comes with VS2008. In the _Common Elements\Annotations folder, there are PNGs with multiple sizes and I was wondering what the intended use of these is. Is there an standard way to implement these images, e.g. in a Windows Forms status bar?
Here are three of the PNGs as an example:
The suggested usage is to basically copy/paste the sized image you want into a new image file. Then simply use that as an icon or image in your controls as you see fit. All of the PNGs already have a transparent background, so it should be really easy to copy/paste.

Resources