Web

Showing posts with label Web. Show all posts

As you all know that, the Out-Of-Browser (OOB) functionality in Silverlight is not a new feature. It is available since Silverlight 3. Microsoft added the trusted application behaviour in Silverlight 4 Beta. In addition to this, they introduced one more additional functionality called “Chromeless OOB WIndow” i.e. “Customized OOB Window” in Silverlight 4 RC (Release Candidate). In this article, I will guide you to create a simple customized OOB Window Application in Silverlight 4 RC. After the end of this tutorial, you will be able to create a Customized OOB Window in Silverlight 4 which will look similar to this.

 

Read the Complete Article @ DotNetFunda.com

Published by on under Silverlight | Web

Silverlight 4 Printing API Demo Silverlight 4 now supports printing functionality using the Printing APIs. Using the APIs, you can now print your whole application screen or a portion of the application. Also, you can customize the look while you printing your part/full application.

 

In this post, I will step you guys to the depth of the printing API. Don’t forget to share your thoughts. Suggestions are always welcome. This will help me to improve my articles.

 

Published by on under .Net | Silverlight

Microsoft has just released the Silverlight 4 RC with several changes in the Silverlight runtime & in the Silverlight tools. Though there are couple of changes since Silverlight 3 & since Silverlight 4 Beta but it supports most of the Silverlight 3 applications by using Quirks mode. In some cases your earlier application will break or behave differently.

In this post I will describe you both the breaking changes in Silverlight 4 since Silverlight 3 & Silverlight 4 Beta. But before going to the discussion on the breaking changes, let me tell you what is Quirks mode. Quirks mode is a behaviour by which your previous application will work on the new runtime. Simple example is that, if you have Silverlight 3 compiled application it will try to run in Silverlight 4 (some cases it will fail) using quirks mode but if you compile the same application in Silverlight 4 it will not use the quirks mode and through errors on the changes.

 

What’s new in Silverlight 4:

  • XAP Signing
  • Custom Chrome Window
  • WebCam/Mic Configuration Preview
  • Text position and Selection API
  • Pinned full screen mode on secondary display
  • Support for Private Browsing
  • RichTextBox XAML clipboard format
  • Elevated apps doesn’t have Sockets Security Restrictions
  • Support for querying printer page size and printable area
  • XmlnsPrefix & XmlnsDefinition attributes has been added

 

Breaking Changes since Silverlight 3:

So, lets start with describing the breaking changes in Silverlight 4 since Silverlight 3.

  • Mouse Wheel Support - Silverlight 4 controls (ListBox, TextBox, ComboBox, ScrollViewer, Calendar, DatePicker, DataGrid) now have support for Mouse Wheel.
  • Shared BitmapImage Source – Now Silverlight 4 will render the images properly if more than one Image controls are sharing the same BitmapImage source.
  • ImageBrush.ImageSource returns ImageSource – ImageBrush.ImageSource in Silverlight 4 now returns ImageSource instead of UriSource which could be WritableBitmap or BitmapImage.
  • Keyboard Navigation in TabControl – Keyboard navigation in TabControl was a feature in Silverlight 3 having an issue with the TabItem activation. Previously pressing Up Arrow activated the next TabItem and pressing Down Arrow activated the previous TabItem. In this release they fixed it to properly activate the TabItem. In Silverlight 4 if you press Up Arrow it will activate the previous TabItem & pressing Down Arrow will activate the next TabItem.
  • Automation focus in DataGridCell - DataGridCell now receives automation focus when currency changes in the DataGrid, rather than focusing on the other part of the DataGrid.
  • Hit Test while Toggling Full Screen Mode – While toggling full screen mode Silverlight 4 will now rerun hit testing. This allows controls that were under the mouse before toggling to update the MoouseEnter state if necessary.
  • Whitespace handling with Span tag – TextBlock and RichTextArea now accepts text content & creates implicit runs generating whitespaces between inlines separated by CRLF.
  • DisplayMemberPath & ItemTemplate recreates all containers – Silverlight 4 now recreates all containers by invalidating them while there is any change in DisplayMemberPath or in ItemTemplate properties of the ItemControl.
  • New XAML Parser – Silverlight 4 now includes all new XAML Parser along with the previous XAML Parser. As per the runtime version detected in the application manifest it will parse the XAML in the appropriate parser. Apart from that, it has now additional benefits like “Better XAML compatibility”, “Greater parsing correctness & consistency”, “Better feedback error mechanism”, “Performance improvement”.
  • Panels Clear() method calls InvalidateMeasure – If you call the Clear() method of the Silverlight 4 panel it will now explicitly call InvalidateMeasure.
  • Virtualizing Stack Panel now scrolls by 3 lines – Mouse Wheel scroll in Silverlight 4’s Virtualizing Stack Panel will scroll by three (3) lines instead of one (1) line.

 

Breaking Changes since Silverlight 4 Beta:

If you were exploring Silverlight 4 Beta this section will be most important for you. There are some changes in both the runtime & tool since the beta release. So before starting with that please read the same carefully.

  • Removed TextSelection.CanInsert – TextSelection.CanInsert is now no longer available in Silverlight 4.
  • RichTextArea changed to RichTextBox – RichTextArea now renamed to RichTextBox.
  • RichTextBox.TextDecorations no longer exists – RichTextBox.TextDecoration is not available now. Instead of it you can use Inline.TextDecorations.
  • Default value to RichTextBox.TextWrapping – Silverlight 4 now has a default value of RichTextBox.TextWrapping to Wrap. If you don’t want to wrap your content you have to explicitly set it to NoWrap.
  • HtmlBrush renamed to WebBrowserBrush – In Silverlight 4 HtmlBrush now renamed to WebBrowserBrush.
  • COM Interoperability – COM Interoperability types are now moved to System.Runtime.InteropServices instead of System.Windows.Interop namespace.
  • WebCam/Output Protection Support – There has been a huge changes in the webcam/output protection support:
      • CanEnableHDCP renamed to CanEnableHdcp
      • CanEnableCGMSA renamed to CanEnableCgmsa
      • VGA, DVI, HDMI, LVDS, SDI, UDIExternal, UDIInternal also renamed to similar naming convention
      • VideoFormat.Height and VideoFormat.Width renamed to VideoFormat.PixelHeight and VideoFormat.PixelWidth respectively
      • AsyncCaptureImage call now changed to CaptureImageAsync
  • NotificationWindow – NotificationWindow.Visible property has been changed to NotificationWindow.Visibility
Published by on under .Net | News
Hi folks, as all of you know that Silverlight 4 is now going to come out as “Go-Live” license within a few months and also in the mean time there are some wishlist coming for Silverlight 5, hence I am writing this post to collect those most wanted features requested by the community. Please contribute your wishlist for Silverlight 5 here (as comment) and I will update that list regularly.
  • Sophisticated Authentication & Security (includes client certificates as credentials for web service call) - [Vote] – alexander.biskop
  • More encryption algorithm - [Vote] – alexander.biskop
  • More flexible way to do localization in DataForm/DataGrid - [Vote] – sladapter
  • Application patching functionality - [Vote] – Haathen
  • Better Local Messaging API - [Vote] – ksleung
  • Better drawing API - [Vote] – ksleung
  • Support for Report Viewer - [Vote] - mlonny
  • Real time printing support - [Vote] – ksleung
  • Support for iPod/iPhone - [Vote] - microsoft_kc
  • Android support - [Vote] – ksleung
  • Better 3D support like WPF - [Vote] - microsoft_kc
  • An embedded database component like SQL-CE that can be used in OOB mode - [Vote] – Joeyw
  • Better support for WritableBitmap - [Vote] – Joeyw
  • Vector Printing - [Vote] – Joeyw
  • Support for IObservable for databinding - [Vote] – Joeyw
  • Rich Text Editor which allows Word Wrapping around images or other elements - [Vote] - Erwin Beckers
  • BMP and GIF image support - [Vote] - Erwin Beckers
  • More advanced controls like Outlook Agenda/Calendar control - [Vote] - Erwin Beckers
  • Transparency Support in Out-Of-Browser Mode - [Vote] - microsoft_kc
  • Improved SaveFileDialog with DefaultName option - [Vote] - Neha
  • ChildWindow with NON-modal support - [Vote] - Amantha
  • Flash video playback - [Vote] - Erwin Beckers
  • A working webbrowser control in a non-out-of-browser scenario - [Vote] - Peter Gfader
  • Support tooltip better for transparent, init delay, show delay, tiling image brush - [Vote] - Anonymous
Your suggestions for Silverlight 5 feature requests are welcome to publish here. Cheers…
Also, you can post them & vote in Silverlight Uservoice.
Published by on under Silverlight | Web

I think this is now-a-days a common issue for all the developers who are currently exploring both Visual Studio 2010 RC and Silverlight 4 Beta. Microsoft has removed the bits of Silverlight in the RC version of Visual Studio 2010. To work with that lots of people are now asking the same question.

Today I found a link which is written in a different version. I thought to share this thru my blog which may help the fellow developers (who are keeping a eye to my blog posts) to explore both simultaneously. Here is the original link of the post: http://sorokoletov.com/2010/02/hate-2-wait-silverlight-4-beta-2-vs-2010-rc/

Use the below link to translate it in English: http://tinyurl.com/SL4inVS2010RC-en

If you follow the steps provided in that blog post, you can install the Silverlight 4 Beta in your Visual Studio 2010 RC environment & start working on it till Microsoft releases the RC version of Silverlight. Go ahead and enjoy.

Remember: WCF RIA Services doesn’t work with this hack. I strongly recommend you to work with Visual Studio 2010 Beta 2 & Silverlight 4 Beta.

Published by on under Silverlight | SilverlightTips

In this post I will discuss on how to create a Silverlight arrow. This will be beneficial for implementing Silverlight presentation where you can add some arrows to point to some blocks. This is simple enough to implement & will be beneficial for the beginners.

Create a Silverlight project. Now add a public class “Arrow” in it. Inside the Arrow.cs you have to add three lines (one is the base line, second is the left arrow head & the third is the right arrow head). Next you have to add those three lines inside a Panel.

Let’s start with creating the simple arrow in step-by-step process. First step is to create the base line of the arrow. Create a Line and set it’s (x1, y1) & (x2, y2). This will create the line.

private static Line CreateBaseLine(double startX, double startY, double length, Brush lineBrush, double thickness)
        {
            Line arrowLine = new Line();
            arrowLine.Stroke = lineBrush;
            arrowLine.StrokeThickness = thickness;
            arrowLine.X1 = startX;
            arrowLine.X2 = length;
            arrowLine.Y1 = startY;
            arrowLine.Y2 = startY;
            return arrowLine;
        }
Now lets create the left arrow head. The approach to it is same as creating the base line. Here only you have to pass the instance of the base line for calculating the (x1, y1).
private static Line CreateLeftArrowHead(Brush lineBrush, double thickness, Line arrowLine)
        {
            Line arrowLeft = new Line();
            arrowLeft.Stroke = lineBrush;
            arrowLeft.StrokeThickness = thickness;
            arrowLeft.X1 = arrowLine.X2 - 10.00;
            arrowLeft.X2 = arrowLine.X2;
            arrowLeft.Y1 = arrowLine.Y2 - 10.00;
            arrowLeft.Y2 = arrowLine.Y2;
            return arrowLeft;
        }
Creation of right arrow head is also similar to the one I mentioned for creating the left arrow head. The difference here is the y1.
private static Line CreateRightArrowHead(Brush lineBrush, double thickness, Line arrowLine)
        {
            Line arrowRight = new Line();
            arrowRight.Stroke = lineBrush;
            arrowRight.StrokeThickness = thickness;
            arrowRight.X1 = arrowLine.X2 - 10.00;
            arrowRight.X2 = arrowLine.X2;
            arrowRight.Y1 = arrowLine.Y2 + 10.00;
            arrowRight.Y2 = arrowLine.Y2;
            return arrowRight;
        }

Here instead of creating two separate methods for creating the two arrow heads you can just create only one method & pass the calculated (x1, y1) & (x2, y2). This is the simple approach mentioned here to give an idea to the beginner to create an arrow. It can be modified to implement some complex arrows like Horizontal, Vertical or even better Connected Arrows.

Download Sample Application: Silverlight Arrow Demo

Published by on under .Net | Silverlight

While surfing thru different forum I noticed that, lots of people are actually facing issues while trying to implement the drag and drop feature. The main problem arises while trying to drag from a ListBox to a panel like canvas. In this post, I will go thru the steps to demonstrate such feature.

Here I will use Telerik control to give out the demonstration. You can download the trial version of the dlls from Telerik Silverlight Control Page. I have implemented the demo using Silverlight 4 Beta 1. The same thing is also possible in earlier version of Silverlight. You can download Silverlight SDK from Silverlight Site. To develop apps in Silverlight 4 you must need Visual Studio 2010 Beta 2 which you can download from Microsoft site.

So, lets go for implementing the same. Create a Silverlight project. Lets create a ListBox and a Canvas inside the LayoutRoot:

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="150"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <ListBox x:Name="lstBox" Margin="10" Grid.Column="0"/>
    <Canvas x:Name="cnvDropBox" Background="Yellow" Margin="10" Grid.Column="1"/>
</Grid>
Now in the code behind, we have to register the Drag and Drop events for the ListBox & Canvas. Use RadDragAndDropManager class to register the same. 
RadDragAndDropManager.AddDragInfoHandler(lstBox, OnDragInfo);
RadDragAndDropManager.AddDragQueryHandler(lstBox, OnDragQuery);
RadDragAndDropManager.AddDropInfoHandler(cnvDropBox, OnDropInfo);
RadDragAndDropManager.AddDropQueryHandler(cnvDropBox, OnDropQuery);

RadDragAndDropManager.SetAllowDrop(cnvDropBox, true);
The implementation of the events will be as below:
private void OnDragQuery(object sender, DragDropQueryEventArgs e)
{
    if (e.Options.Status == DragStatus.DragQuery)
    {
        var draggedListBoxItem = e.Options.Source as Image;
        e.Options.DragCue = draggedListBoxItem.Source;
        e.Options.Payload = draggedListBoxItem.Source;
    }

    e.QueryResult = true;
    e.Handled = true;
}
private void OnDragInfo(object sender, DragDropEventArgs e)
{
    if (e.Options.Status == DragStatus.DragComplete)
    {
        // comment this block if you are going to clone
        lstBox.Items.Remove(e.Options.Source);
    }
}
private void OnDropInfo(object sender, DragDropEventArgs e)
{
    var droppablePanel = e.Options.Destination;

    if (e.Options.Status == DragStatus.DropComplete && droppablePanel is Canvas)
    {
        FrameworkElement dragableControl = null;
        Point desiredPosition = new Point();
        Point currentDragPoint = e.Options.CurrentDragPoint;
        Point canvasPosition = cnvDropBox.TransformToVisual(null).Transform(new Point());

        if (e.Options.Source is Image)
        {
            // create the new instance & update the necessary properties
            // this step is require if you are going to make a clone
            Image tempDragableControl = e.Options.Source as Image;
            dragableControl = new Image() { Source = tempDragableControl.Source };
            cnvDropBox.Children.Add(dragableControl);
        }

        desiredPosition.X = currentDragPoint.X - canvasPosition.X;
        desiredPosition.Y = currentDragPoint.Y - canvasPosition.Y;
        dragableControl.SetValue(Canvas.LeftProperty, desiredPosition.X);
        dragableControl.SetValue(Canvas.TopProperty, desiredPosition.Y);
    }
}
private void OnDropQuery(object sender, DragDropQueryEventArgs e)
{
    var droppablePanel = e.Options.Destination;

    if (e.Options.Status == DragStatus.DropDestinationQuery && droppablePanel is Canvas)
    {
        e.QueryResult = true;
        e.Handled = true;
    }
}

As I am using Image inside the ListBoxItem, hence OnDragQuery I am setting the Source as an Image to the DragCue & PayLoad properties. OnDragInfo I am removing item from the ListBox. If you don’t want to remove the dragged image from the ListBox then just remove that line. OnDropInfo I am just placing the Image to the appropriate position which we will get as CurrentDragPoint in the DragDropEventArgs.

This is a sample demonstration. So, you have to explore it more to fulfil your requirement.

Download Sample Application:  Drag And Drop ListBoxItem to Canvas Demo

Published by on under .Net | Silverlight

In this post I will describe you another feature of Silverlight 4 “Access to external content”. Here I will show how to drag and drop some external images to my sample application. Earlier Silverlight 4 this feature was not available. There was no client file access permission. But in this new release they introduced this functionality by which you can implement the same.

To implement this feature you must need Silverlight 4, which is now available in Beta 1 version. You need Visual Studio 2010 Beta 2 which you can download freely from Microsoft site.

Now if your dev environment is ready then we can go further to implement the same. Excited so much to do it? Create a Silverlight project which will create “MainPage.xaml” for you. Inside the MainPage.xaml add a ScrollViewer containing a WrapPanel. Your ScrollViewer will have a fixed Height & Width where as your WrapPanel will be free size. This ensures that, if more components are added inside the WrapPanel it will automatically add a scrollbar to it. So, you can scroll through the child components. In this example I want to drop some external image files inside this panel. So, I will set the WrapPanel “AllowDrop” property to true. This will make the panel droppable.

On the Drop event handler of the wrap panel you will get the dropped files as data to the DropEventArgs which has an array of FileInfo. DataFormats.FileDrop sets the droppable permission to the panel.

FileInfo[] droppedFiles = e.Data.GetData(DataFormats.FileDrop) as FileInfo[];
Now for each dropped file you can check whether it is a supported image file. If so, proceed further to add it to the wrap panel. See the sample code:
void imageContainer_Drop(object sender, DragEventArgs e)
{
    FileInfo[] droppedFiles = e.Data.GetData(DataFormats.FileDrop) as FileInfo[];

    foreach (FileInfo droppedFile in droppedFiles)
    {
        if (IsSupportedImageFile(droppedFile.Extension))
        {
            Border imagePlaceHolder = new Border()
            {
                Child = CreateImage(droppedFile),
                Background = transparentColor,
                Margin = new Thickness(10.0),
                Cursor = Cursors.Hand,
            }; 
            
            ToolTipService.SetToolTip(imagePlaceHolder, droppedFile.Name);

            imagePlaceHolder.MouseEnter += imagePlaceHolder_MouseEnter;
            imagePlaceHolder.MouseLeave += imagePlaceHolder_MouseLeave;

            imageContainer.Children.Add(imagePlaceHolder);
        }
    }
}
Here IsSupportedImageFile() method takes the extension of the dropped file as a parameter which will check whether it is a valid image format. I used .jpg & .png for the demonstration which actually uses switch case. The CreateImage() method creates an object of the image from the FileStream of the dropped file.
private Image CreateImage(FileInfo droppedFile)
{
    using (FileStream fileStream = droppedFile.OpenRead())
    {
        BitmapImage bitmapImage = new BitmapImage();
        bitmapImage.SetSource(fileStream);

        return new Image() { Source = bitmapImage, Width = 100, Margin = new Thickness(5.0) };
    }
}

Now after writing this code, your application will be ready to get external file droppable inside it. Run your application & drop some jpg/png files from your image directory to your browser i.e. Silverlight application. You will see that the dropped images are automatically added inside your panel. This is a good example of accessing external files droppable inside your web application. Download the sample solution & implement what you want to do.

So what next? I think from the above example you will get the idea of what we can achieve from this. Anyway you can implement file upload utility by just dragging & dropping inside the web application just like Skydrive. You can also drop text files to read the file instead of browsing & uploading to the server. And more… Go ahead & enjoy programming with Silverlight 4.

Download Sample Application:   Silverlight 4 Drag-N-Drop External Image

Published by on under .Net | Silverlight

Silverlight 4 has now support for Mouse Wheel. From now onwards you can use mouse wheel event to trigger on mouse wheel rotation. Until the release of Silverlight 4 Beta 1 you had to write JavaScript code & a huge lines of code in C#. Now just forget about those lines. Your code will be clean.

If you want to use the clean coding for mouse wheel, you have to just register & implement the said event in your code. Apart from the MouseLeftButtonDown / MouseLeftButtonUp / MouseRightButtonDown / MouseRightButtonUp / MouseEnter / MouseLeave events there you will find another event called MouseWheel. This event is responsible for clean up your code to implement the feature. You can also override the OnMouseWheel event in your main control.

See the below code:

protected override void OnMouseWheel(MouseWheelEventArgs e)
{
    base.OnMouseWheel(e);

    txbMouseWheelValue.Text = string.Format("Mouse Wheel Value: {0}", e.Delta);

    if (e.Delta > 0)
        rotateBrdWheeler.Angle += 10;
    else
        rotateBrdWheeler.Angle -= 10;
}

Here when the mouse wheel event is registered, it will set e.Delta as the output of mouse wheel rotation. You can check whether the value is positive / negative & depending on that you can decide your own logic. In the demo app I am rotating a Rectangle by 10 degree depending on the sign of delta. You can do your own logic there.

It’s so easy. So, go ahead & clean your code (only supports in Silverlight 4). Enjoy the new feature. Cheers…  :)

Download Sample Application:   Silverlight 4 Mouse Wheel Demo Solution

Published by on under .Net | Silverlight

In my previous posts I discussed about “How to work with Notification API?” & “How to Capture Video from Default Webcam?”. In this post I will describe about the another cool new feature (“How to use the all new Right Click Context Menu?”) of Silverlight 4.

Silverlight 4 has now support for right click. You can now register the event “MouseRightButtonDown” & “MouseRightButtonUp” to any FrameworkElement. Hence, no need to use JavaScript to disable the right click option. If you want to disable the right click option then just implement those events with:

e.Handled = true;

Now if you want to implement a Context Menu on right click, create the Popup Context menu & position it to proper location. The following code will create the context menu:

private Popup CreateContextMenu(Point currentMousePosition)
{
    Popup popup = new Popup();
    Grid popupGrid = new Grid();
    Canvas popupCanvas = new Canvas();

    popup.Child = popupGrid;
    popupCanvas.MouseLeftButtonDown += (sender, e) => { HidePopup(); };
    popupCanvas.MouseRightButtonDown += (sender, e) => { e.Handled = true; HidePopup(); };
    popupCanvas.Background = new SolidColorBrush(Colors.Transparent);
    popupGrid.Children.Add(popupCanvas);
    popupGrid.Children.Add(CreateContextMenuItems(currentMousePosition));

    popupGrid.Width = Application.Current.Host.Content.ActualWidth;
    popupGrid.Height = Application.Current.Host.Content.ActualHeight;
    popupCanvas.Width = popupGrid.Width;
    popupCanvas.Height = popupGrid.Height;

    return popup;
}
CreateContextMenuItems() will add some context menu items, on click it will show which menu item has been cllicked by you. Upto this I only talked about the creation of the customized context menu. Now we have to show it on right click inside the Silverlight application. In my example, I added a Border control which has the right click event registered. Now check the below implemented code which will be responsible for showing the context menu:
void brdRightClickZone_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
    txbMessage.Text = "Right Clicked";
    Point currentMousePosition = e.GetPosition(LayoutRoot);
    ShowPopup(currentMousePosition);
}

private void btnRightClick_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
    e.Handled = true;
}

On right mouse down, I am setting the e.Handled = true. This ensures that, this will not show up the default Silverlight context menu & the right mouse up implementation will popup the customized context menu at the current mouse position.

What next? Download the sample application created by me & implement your own logic to create the customized context menu which will open on right click on your silverlight application.

Download Sample Application:  Silverlight 4 Right Click Context Menu Demo

Published by on under .Net | Silverlight

Silverlight Notification API is a new feature introduced in Silverlight 4 Beta 1. If you are developing your application using Silverlight & want to show some notification message like Outlook to the user, then you can use this. Remember that, this feature only works out of browser.

To develop Silverlight 4 application you must need Visual Studio 2010 Beta 2 which you can download from the Microsoft site. If you are using Visual Studio 2008 then you can install Visual Studio 2010 side by side too. After you installed the studio, just go with the installation of the “Silverlight 4 Tools for Visual Studio 2010”.

After you setup your development environment create a new Silverlight 4 application using Visual Studio 2010. This will automatically create a page “MainPage.xaml” for you. Add two buttons in your XAML. One is to install the Silverlight application as out of browser & another is to show the notification.

<Button x:Name="btnInstall" Width="150" Height="20" Content="Install OOB" Margin="5"/>
<Button x:Name="btnShowNotification" Width="150" Height="20" Content="Show Notification" Margin="5"/>

For implementing the Silverlight out of browser feature follow my earlier post: “How can you implement Silverlight 3 Out-Of-Browser feature?” Now go to the code behind file “MainPage.xaml.cs” & implement the click event for those. On page load, if it is running out of browser then create the notification window instance:

// Initialize a new instance of Notification Window
notificationWindow = new NotificationWindow();
notificationWindow.Height = 50.0;
notificationWindow.Width = 300.0;
Create your custom notification panel either using XAML or code behind. You can go for a nice looking UserControl. Here for example I will use a TextBlock inside a Border to show a simple message.
Border border = new Border()
{
    Background = new SolidColorBrush(Colors.Gray),
    Height = notificationWindow.Height,
    Width = notificationWindow.Width,
    Child = new TextBlock()
    {
        Text = "This is a Custom Notification from Silverlight 4",
        Foreground = new SolidColorBrush(Colors.White)
    }
};
Now, on “Show Notification” button click event check for whether it is running out of browser. If so, assign the notification panel you created to the content of the notification window instance & call the show method of the notification window. Here you have to pass the duration of the visibility of the notification in milliseconds.
notificationWindow.Content = border; // add the custom notification panel
notificationWindow.Show(2000); // show the notification
Now run your application & click on the “Install OOB” button. This will install the Silverlight application and open the desktop version of it. Click the “Show Notification” button to show the notification at the right bottom corner of your desktop.

Download Sample Solution:   Silverlight 4 Notification API Demo


Published by on under .Net | Silverlight

Silverlight 4 Beta 1 has been released by Microsoft on 18th November 2009. There are lots of goodies came up with the release of the new version. Among them, most of all are requested by the developers & users of Silverlight. In this post I will demonstrate one of the new feature “Accessing Default Webcam using Silverlight 4”.

To create a Silverlight 4 application you need “Visual Studio 2010 Beta 2”. Download it from the Microsoft site. Then install the “Silverlight Tools 4 for Visual Studio 2010 Beta 2”. After successful installation, create a Silverlight 4 Application project.

Once you done with the project creation, Visual Studio will open the MainPage.xaml for you. Add a Rectangle & three Buttons inside the Grid. The Rectangle will responsible for the Video output from your VideoCaptureDevice & buttons will be responsible for the interaction with the device. After adding the same your XAML will look like this:

   <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel HorizontalAlignment="Center">
            <Rectangle x:Name="rectWebCamView" Width="500" Height="400"/>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <Button x:Name="btnCaptureDevice" Content="Capture Device" Margin="5"/>
                <Button x:Name="btnPlayCapture" Content="Start Capture" Margin="5"/>
                <Button x:Name="btnStopCapture" Content="Stop Capture" Margin="5"/>
            </StackPanel>
        </StackPanel>
    </Grid>

Now, go to the code behind file (MainPage.xaml.cs) & create an instance of CaptureSource. Then call TryCaptureDevice() to initiate the Video Capture. This first get the default Video Capture device & assign it to the VideoBrush instance of the rectangle. Remember that, this will ask the user to grant permission to the user device & upon successful only it will start the device.

        private void TryCaptureDevice()
        {
            // Get the default video capture device
            VideoCaptureDevice videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

            if (videoCaptureDevice == null)
            {
                // Default video capture device is not setup
                btnPlayCapture.IsEnabled = false;
                btnStopCapture.IsEnabled = false;
                btnCaptureDevice.IsEnabled = true;

                MessageBox.Show("You don't have any default capture device");
            }
            else
            {
                btnPlayCapture.IsEnabled = false;
                btnStopCapture.IsEnabled = false;

                // Set the Capture Source to the VideoBrush of the rectangle
                VideoBrush videoBrush = new VideoBrush();
                videoBrush.SetSource(captureSource);
                rectWebCamView.Fill = videoBrush;

                // Check if the Silverlight has already access to the device or grant access from the user
                if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
                {
                    btnPlayCapture.IsEnabled = true;
                    btnStopCapture.IsEnabled = false;
                    btnCaptureDevice.IsEnabled = false;
                }
            }
        }

Download Sample Solution:   Silverlight 4 Webcam Demo

Published by on under .Net | Silverlight

Silverlight 3 came up with Out Of Browser support. Using that feature one can install the application just like a standalone windows application. Hence no need to open the browser to run the Silverlight application. Today for the first time I gone thru the APIs & created a sample application. Here I will discuss about the same to give you a demonstration. It is quite easy to implement.

Create a Silverlight application using Visual Studio 2008. This will automatically create “MainPage.xaml”. Now open the MainPage.xaml & add the following lines inside the LayoutRoot Grid:

<StackPanel Margin="20" HorizontalAlignment="Center">
<
TextBlock Text="Silverlight Out Of Browser Demo Application"
FontSize="20" HorizontalAlignment="Center"/>
<
Button x:Name="btnInstall" Content="Install as Out Of Browser Application"
Width="300" Height="20" Margin="20"/>
</StackPanel>

Read the Complete Article @ DotNetFunda.com

Published by on under .Net | Silverlight

Microsoft has just released it’s October 2009 release of Silverlight 3 Toolkit. You can download it from: Silverlight 3 Toolkit October 2009 Installer. Also have a look into the sample application at: Silverlight 3 Toolkit Sample Application

Silverlight 3 Toolkit has now full design time supports for Visual Studio 2010. Charting tool has been changed. They now introduced ISeries interface as the base interface for all the Series & StylePalette now renamed to Palette. So, those who are using StylePalette just make those changes in your code. You can now customize the LegendItem very easily. Silverlight team now added the support to Themes for Accordion, DataForm, DataPager, GridSplitter & ChildWindow. Added support for Drag & Drop functionality for some common items like ListBox, TreeView, DataGrid and Charting tools. Moreover the mousewheel support has been now added to navigate the GlobalCalendar & TimePicker controls.

Have a look into those latest features of Silverlight 3 Toolkit. In real scenarios those are really very awesome features. Though it is their 5th release of Silverlight Toolkit, hope they will come up with lots of required controls in the future versions.

Published by on under .Net | News
Microsoft released Silverlight 3 on 10th July 2009 as per the schedule. You can download the SDK, Visual Studio Tools & Blend from the following location:
Silverlight 3 came with the following features:
  • Out of Browser support
  • Network status check
  • Pixel Shader Effects
  • Bitmap APIs
  • Runtime themeing support
  • Enhanced control skinning
  • Support for System Colors
  • Bitmap Caching
  • Perspective 3D view
  • GPU hardware acceleration
  • Text animation
  • H.264 support
  • RAW audio/video support
  • Save File Dialogue
  • Wrap Panel, View Box, Dock Panel
  • Support for local fonts
  • Binary XML
  • Component caching & Scene caching
Published by on under .Net | Silverlight
Azure service platform is a cloud computing platform hosted in Microsoft data centers. This provides operating system & different set of development service which the developers can use to build their own web applications or enhance them directly in that platform. Without purchasing any upfront technology, developers can create their applications more quickly & easily in the cloud. They only need working knowledge in .Net Framework & Visual Studio Environment. Azure service currently supports native languages. In future it will support many more including Microsoft & Non-Microsoft languages. Once the coding is done, the developer can build & host the application in the cloud, so that end user will be able to run it over the internet.
Azure platform consists of Windows Azure, which is an Operating System to provide on demand computing, storage and management of cloud applications. In short, Windows Azure is an Operating System for the cloud computing platform designed for utility computing. It provides facilities to write, host or manage applications & store data on demand. The service layer consists of different services like: Live Service, .Net Service, SQL Service etc. which provides building blocks within the platform for the developers.
image
Published by on under Web |

Cloud computing is a dynamic style of computing in which virtualized resources are provided as a service over the internet. The users of cloud computing need not to worry about the capital expenditure and maintenance cost of hardware and software resources. They have to pay only what they are using. This can be of two types. User can either pay the provider based on the resources consumed during the time period or a time based subscription.

Published by on under Web |

Microsoft provides a tool named “MakeCert.exe” which helps us to create a temporary SSL Certificate for development environment. This tool comes with Visual Studio & also with Windows SDK. If you installed Visual Studio, you can find it in this location: “C:\Program Files\Microsoft Visual Studio <VERSION>\SmartDevices\SDK\SDKTools”. If you installed Windows SDK, you will get it here: “C:\Program Files\Microsoft SDKs\Windows\<VERSION>\Bin”.

Now open Command Console (“cmd.exe”) & change your current directory to one of the location specified above. Type the following in Command Prompt & hit enter:

makecert -b 01/01/2009 -e 01/01/2020 -n "CN=Developers" -pe -r -sk "Microsoft Cryptographic Provider" -ss "Microsoft Cryptographic Store" c:\developerCertificate.cer

This will create a test certificate (valid from 01/01/2009 to 01/01/2020) named “developerCertificate.cer” in your ‘C’ drive, which you can use for development environment. You can change the validity period by changing the begindate (-b) & expirydate (-e). You can also change all the parameters specified above.

Here is the list of the parameters mentioned above:

Parameter Description
-b Begin Date
-e Expiry Date
-n Certificate Subject Name
-pe Mark Generated Private Key as Exportable
-r Configures MakeCert to create a self-signed root certificate
-sk Subject’s Key Container Name
-ss Subject’s Certificate Store Name
Published by on under Web |

Silverlight 3, though it is in beta stage, but it came up with lots of new features. Some of them are mentioned below:

  • Silverlight 3 now supports H.264 video formats & AAC audio formats. Now it also supports RAW audio/video pipeline
  • It now supports GPU Acceleration by adding a parameter (EnableGPUAcceleration = "true") in the Silverlight object
  • It now supports 3D functionalities. You can now add Perspective view to the element level
  • Various Effects has been introduced in Silverlight 3 using Pixel Shader API (e.g. Blur, DropShadow etc)
  • Various Animations (like: bouncing, transition) are now part of the Silverlight 3
  • A user can start a Silverlight out-of-browser "application" either by right-clicking on the Silverlight element or by clicking on a button within the application itself
  • Silverlight now supports custom dialogs. By using the SaveFileDialog you can now write contents outside the sandbox
  • It now supports local messaging across multiple silverlight plugins
  • XAP compression has been improved
  • Lots of new controls (like: DockPanel, WrapPanel, Label, ViewBox, TreeView, ExpanderControl, AutoCompleteBox) were added in this version. New controls in the Silverlight Toolkit are also available
  • DataPagination has been added in Silverlight 3
  • Using NavigationFramework you can now navigate to different view of the application. You can now integrate the browser back/forward functionalities with this framework
  • Binding of elements are now available by which you can update the UI without any code. Data validation in binding is also available in this release
  • AssemblyCaching is now available by which you can download the external assemblies only once & later you can use them from the cache. This will improve the application load time during next load
  • In Silverlight 3 Network monitoring API has been introduced, by which you can check whether the application is connected to the network or not
  • Now binary XML format is also supported in addition to the text XML which will improve the performance in the messaging area

Cheers :)

Published by on under Silverlight | Web