Building assembly and adding embedded resource at run-time - Scenario included - silverlight

EDIT: To better clarify the issue, I've included a scenario:
Scenario: There is an education institution that produces video tutorials. We were asked to provide a solution on how to protect the video files so as not to give access to the real video files to the users. The videos are published "offline" using DVD ROM.
Solution: We decided to embed the video files into the silverlight assembly and write a Silverlight OOB application that takes advantage of MediaElement control to play video content. This control accepts video resource of type Stream which makes it possible to use Application.GetResourceStream method to read the embedded resource as an stream and pass it to MediaElement.
Design: We need to write two applications:
One that accepts one or more video files from education institute operator and creates an assembly and embeds the video files into the assembly.
Another application that reads the contents of the newly-created assemblies and plays the video content using MediaElement control.
Problem:
How to generate a silverlight assembly and embed video resources to it "programmatically" using a C# windows app or Silverlight app? I wanted to use AssemblyBuilder class, but it does not contain Save method in silverlight.
Any help would be greatly appreciated.

Assuming you feel you need to embed your video in the way you described, rather than stream it, then you do not need to run the creation of modules on the Silverlight client.
Have the Silverlight app upload the Video to the matching Silverlight host
Now you have full access to the .Net stack and can create pretty much anything you need (including compiling projects or assemblies on the fly and using AssemblyBuilder).
If this does not cover your situation, please clarify the question further.

Related

Grab picture from web cam in WPF Application?

I am using web cam in WPF application. I am using Expression Encoder for video capture. for video capture I have created Job and its working properly. While I want to get picture with same resolution as video is. for this I am using ffmpeg to extract first frame from video. but quality of image is very low. the priority is that image quality should be best of attached web cam and resolution should be as much as video is.
Either we have any better option in Expression Encode for taking picture or kindly help me with any alternative.
You can have a look at this control:
The control provides the following functionalities:
Gets a list of available web camera devices on a system.
Displays a video stream from a web camera device.
Gets the current image being captured.
Requirements
The WPF version of the control is implemented using .NET Framework 4 Client Profile.
The control uses the VMR-9 renderer filter available since Windows XP SP2.
The control supports both x86 and x64 platform targets.
For some reason, accessing images from a web cam is far more complicated then it should be. While I have not used the Expression Encode application, I can provide you with two links to CodePlex, where you can find two different libraries that could help you to solve your problem. Please see the following pages:
WebCam Library for WinForm and WPF with C# and VB.NET
WPF MediaKit - For webcam, DVD and custom video support in WPF
Alternatively, if you're happy with using Expression Encode, then you could take a look at the following links:
Extracting still pictures from movie files, with C#
Extract frames from video files – The Code Project – Multimedia
I would recommend AForge.Net, it works flawless, free and licensed under LGPL v3 license, it also seems to work in both 32 and 64 bit.
The only drawback is that you need ~400 kb worth of dlls to get the webcam control.

large silverlight site (hundreds of pages)

When you surf a silverlight site, I believe it downloads the site to the client.
Excluding practicality, lets say your going to develop a large full silverlight site with nearly a thousand pages of static content.
Is there any way you can set the compiler to divide the silverlight app in small parts that will only download as a user attempts to access different areas of the huge site?
You need to use Managed Extensibility Framework (MEF) of Silverlight.
With it you can create small silverlight projects and load them when you need.
Here are some links:
3 Steps to MEF - Export, Import, Compose from silverlight.tv
When and Where to use MEF from silverlight.tv
Using MEF with Silverlight 4 for Extensibility from silverlight.net
To be more specific it downloads the XAP file to the client, which is the end product for your silverlight project.
(Input) Silverlight project -> (Output) one XAP File (containing the main assembly and its dependencies) compressed in a normal ZIP file, but ironically renamed to take XAP extension.
Yes, this is doable, see my answer HERE, you need the same methodology depending on the control (portion) you need upon a specified condition.

How to Convert TIFF to JPG Inside Silverlight, client side, using a control or a class/function?

We are creating a client in Silverlight that will show a lot of TIFF images. Silverlight natively do not support TIFF. I need a control/class to convert tiff to jpg in runtime inside the Silverlight client. Any idea?
In Silverlight forum last friday I received this post:
Re: How to Convert TIFF to JPG Inside Silverlight, client side, using a control or a class/function?
12-18-2009 5:38 PM |
If you're willing to use a third-party library, check out ImageGear for Silverlight provided by Accusoft Pegasus. It's a 100% managed Silverlight toolkit (http://www.accusoft.com/ig-silverlight.htm), and runs entirely on the client. TIFF support is included (among lots of other formats).
Hope this helps,
Casey
I was successful displaying TIFFs in Silverlight. It's easy to port the free LibTiff.NET library to Silverlight, just 3-4 minor tweaks required.
The library itself is quite legacy-like and raw to use and one still needs to have some knowledge about the inner workings of the TIFF format in order to be able to extract the image data the way one needs it.
But it's doable and the bits and pieces can then be chiseled into a WriteableBitmap.
Not sure you are interested in solution by now, but we've just released LibTiff.Net 2.0 with Silverlight support, improved documentation and samples.
There is Silverlight Test Application in source package that shows how to create WriteableBitmap from TIFF images in Silverlight. Maybe it will help you or others.

how to add custom visualization to Media Element (Windows Media Player) in WPF

I just came across this requirement, could find this URL is of close match but the source downloaded is corrupted.
http://blogs.msdn.com/adam_nathan/archive/2005/10/24/using-com-interop-to-create-a-wpf-visualization-for-windows-media-player.aspx
Also how to add this visualization into Windows Media Player for playing audio files (like copying to proper folder for WMP 11 and change registry entries)
Any body else have the source code or other best way of doing this?
Thank you,
Sahridhayan
I too found the link you posted and could not download the code. I am trying to do the same thing and have posted a similar question here:
C# Com Interop with Windows Media Player Visualisation (With Sample Code)
I have provided code to demonstrate my progress. If I get no help I will just use C++ and interop to C# to perform my drawing (I'm not a C++ programmer and I want to use XNA for my effects).

Does Silverlight 3 have access to local file system, Open Excel, and print reports?

I was wondering if Silverlight 3 can be used to create line of business applications where I can use file import/export facilities, read an xls file and open Excel, use a report tool like Crsytal Reports or Reporting Services or.. is WPF needed?
I am new to Silverlight and WPF and want to decide if I can skip learning WPF. I know Silverlight is a subset of WPF but I just want to concentrate in one of the two.
Although Silverlight is sand-boxed and it isn't possible to open and save files to the local file system direcly, it is possible to get a stream to a local file.
There are the OpenFileDialog and SaveFileDialog classes. These classes make it possible to let the user select a file or location. They return only a stream to that file and do not give any information about the filesystem. This way it's possible to import and export to excel for example.
This example should be enough to get you going.
update:
in the meantime I did a small SilverBullet(tm) on the subject on my blog at http://www.timmykokke.com/
Silverlight 3 has quite limited file system access. Even though you can save a local file you cannot open it using the associated application directly from Silverlight. If you want the user to export and open an Excel file from a button click in Silverlight you will have to consider alternatives:
You can open a new browser window pointed at a URL on your webserver that generates an Excel file. If the server sets the correct content type and the client is properly configured the user will be prompted to open the file in Excel. This effectively moves your export code to the server.
You can embed an ActiveX control on the same page as the Silverlight control and using the browser object you can operate this ActiveX control from Silverlight. Given enough rights by the user the ActiveX control can do anything to the local computer including automating Excel.
No, but apparently SL4 does!
Local file access - Silverlight 4
No, but unlike Jimmy my guess is that it won't happen in a future.
If you need local system there are other technologies to use (e.g. local windows service which can communicate with silverlight app).
The reason why silverlight won't have local access in the nearest future is that Microsoft learned it's lesson with ActiveX.
No, as far as I know Silverlight 3 is still as sand-boxed as ever. This is becoming a bottleneck for developers though, so I'm sure it will be addressed in upcoming versions of Silverlight.
From what I know, SL3 doenst support to use COM application such as Word, Excel, etc.. but SL4 does. If your application is just gonna be used internally, WPF will be the best candidate for your project, but if you want it to be used from the external clients as well, then I reckon you can use SL4, then use OUT OF BROWSER, then it'll work really similar with WPF. Plus with SL4, you're able to interact with Excel, Word, etc... to do lots of things.
Cheers,
Brandon

Resources