Printing Support in avaible in Silverlight 4 now

9. August 2010

good news for developer's. Print can be done in Silverlight 4 through  PrintDocument class.

Example

 

PrintDocument doct = new PrintDocument();

    doct.PrintPage += (s, args)
    {   
        args.PageVisual = LayoutRoot;
    };

    doct.Print(docName);// print dialog box

By using this PrintDocument Class you can print entrie page or to print a specfic part of page.

 


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, SilverLight , ,

Encrypt & Decrypt your AJAX traffic -Microsoft Silverlight and Ajax.NET Professional

23. February 2010

Author: Aamir Hasan

It is possible to put an AJAX token. With Silverlight we get the System.Security.Cryptography name space on the client – before it was not very easy to encrypt a string without any plug-in (well, there are some implementations of Blowfish available in JavaScript).

Encrypt and Decrypt method given below,how to implement cryptography in Ajax.NET Professional. 

public override string Encrypt(string json)
{
    return Security.Encrypt(Security.GetHashKey("hans"), json);
}

public override string Decrypt(string jsoncrypt)
{
    return Security.Decrypt(Security.GetHashKey("hans"), jsoncrypt);
}

 

With Silverlight youre able to use the html bridge between JavaScript and managed .NET code. Youll find an example in the Silverlight Quickstarts. The Silverlight C# code looks likes this:

public override string ClientScript
    {
        get
        {
            return @"AjaxPro.cryptProvider = {
        encrypt : function(s) {
            var SLPlugin = document.getElementById(""Xaml1"");
            var strOut = SLPlugin.Content.SL_SMT.Encrypt(s);
            return strOut;
        },
        decrypt : function(s) {
            var SLPlugin = document.getElementById(""Xaml1"");
            var strOut = SLPlugin.Content.SL_SMT.Decrypt(s);
            return strOut;
        }
    };";
        }
    }

public class ScriptableManagedType
{
// Note: static methods are not allowed

[ScriptableMember]
public string Encrypt(string text)
{
return Security.Encrypt(Security.GetHashKey("hans"), text);
}

[ScriptableMember]
public string Decrypt(string text)
{
return Security.Decrypt(Security.GetHashKey("hans"), text);

client-side code youre able to encrypt strings in JavaScript with the help of System.Security. In the AjaxSecurityProvider created above you have to override the ClientScript property to let Ajax.NET Professional encrypt the JSON strings using Silverlight:

 

 

 



Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, asp.net , , ,

Capturing Web Camera and Microphone using Silver

4. February 2010

Author : Aamir Hasan

This is my first tutorial on silverlight.In this article i am going tell you how to utilize a user's web camera and microphone attached to their computer via the browser, to capturing audio and video.


First you have to add namespace in your cs file as given below

using System.Windows.Media;
using System.Windows.Media.Imaging;


ObservableCollection images adding images to it:

CaptureSource _captureSource;
ObservableCollection<WriteableBitmap> _images = new ObservableCollection<WriteableBitmap>();

Caturing the video


  

if (_captureSource != null)
{
_captureSource.Stop(); // stop whatever device may be capturing

// set the devices for the capture source
_captureSource.VideoCaptureDevice = (VideoCaptureDevice)VideoSources.SelectedItem;
_captureSource.AudioCaptureDevice = (AudioCaptureDevice)AudioSources.SelectedItem;

// create the brush
VideoBrush vidBrush = new VideoBrush();
vidBrush.SetSource(_captureSource);
WebcamCapture.Fill = vidBrush; // paint the brush on the rectangle

// request user permission and display the capture
if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
{
_captureSource.Start();
}
}

 

Create a Snapshot from the Video


When the capture process has started and a user clicks the Take Snapshot button, the appropriate command is invoked in the VM and the capture source’s AsyncCaptureImage method is invoked. I used the Dispatcher to make sure I operated on the UI thread because I wanted to not only grab the bitmap.


 

private void StopCapture_Click(object sender, RoutedEventArgs e)
{
if (_captureSource != null)
{
_captureSource.Stop();
}
}

private void TakeSnapshot_Click(object sender, RoutedEventArgs e)
{
if (_captureSource != null)
{
// capture the current frame and add it to our observable collection
_captureSource.AsyncCaptureImage((snapImage) =>
{
_images.Add(snapImage);
});
}
}


 


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, CSharp ,



User Name: Guest

Your Ip: 38.107.191.93
Time: