Wednesday, May 09, 2007

Watched Spider Man 3 on IMAX

Spider Man 3 was released 3rd of May 2007. I had a chance to watch it in Melbourne IMAX theater. This was my first IMAX experience. I feel great to watch Spider Man on its release day.

It was a great movie experience. The speciality in IMAX is it is having very large screen and also the sounds system is also complicated and powerful. The screen is made out of tiny holes so that sound can come through the screen. When you watch you will feel as if you are in the movie. I think the experience is worth the extra money spent.
If you would like to know more about IMAX, pay a visit to their site www.IMAX.com.

Adding and Auto Sizing the background image of a MDI Form in .NET

Some months back I faced a problem of resizing an image on one of my tablet PC device applications. The image was on a Multiple Document Interface (MDI) form. Recently only I remembered this and did some research on this, and thought that better to put an entry.
People who have tried should be knowing that we cannot simply add an image to a form and make it automatically re size when the form changes it's size.
In a normal form we can put a picture box and make it fill the entire screen and can set the image properties to always stretch the image. This will re size the background image when ever you re size the form.
But in MDI forms this is not possible. Whatever control you put on a MDI form will appear on top of all other controls, hiding even the child forms that are open. I have found two elegant methods which can be used.

Method 1 -
Insert the following code into the MDI form code. Here we are using Paint event of the MDI form.

Private Sub frmMDI_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Always the MDI form will be the last control in the control collection. The following will take the MDI forms reference so we can access the properties of it.
Dim varControl As Control = Me.Controls(Me.Controls.Count - 1)
' Loading the background image required to place on the MDI.
Dim varImage As Image = Image.FromFile("E:\Projects\Tablet\Arjuna\Images\Background-Landsc.jpg")
' Resize the image and assign it to the MDI form background.
varControl.BackgroundImage = New Bitmap(varImage, Me.Width, Me.Height)
End Sub


Method 2 -
Insert the following code into the MDI form code. Here we are using Resize event of the MDI form.

Private Sub frmMDI_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
' Loading the background image required to place on the MDI.
Dim varImage As Image = Image.FromFile("E:\Projects\Tablet\Arjuna\Images\Background-Landsc.jpg")
' If there are no space, no point of drawing so exit the sub procedure.
If Me.ClientSize.Width = 0 OrElse Me.ClientSize.Height <= Me.StatusBar1.Height Then Exit Sub
' Creating the bitmap image which is used as the background image.
Dim varBitmap As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height - Me.StatusBar1.Height, Imaging.PixelFormat.Format24bppRgb)
' Getting the drawing surface of the bitmap (varBitmap).
Dim varGraphics As Graphics = Graphics.FromImage(varBitmap)
' Sets the interpolation mode of the graphics object. Interpolation mode determines how intermediate values between two endpoints are calculated
varGraphics.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
' Draw the image on the bitmap.
varGraphics.DrawImage(varImage, 0, 0, varBitmap.Width, varBitmap.Height)
' Assign the bitmap as the background image of the MDI form.
Me.BackgroundImage = varBitmap
End Sub

If you don't have a status bar in your MDI form just remove the codes that are coloured Magenta.

Method 1 does have some problems like, it is visible when the background image re sizes and also I found that if you make the form small sometimes the background image will not be re sized.
So I prefer Method 2.

Wednesday, May 02, 2007

Silverlight is here

Microsoft has released a plug-in for delivering next generation media experiences and rich interactive applications for web. This is a cross-browser, cross-platform plug-in which facilities the WPFs' rich look and feel.
Silverlight was formerly known as WPF/E.
Besides me telling you about Silverlight go to Microsoft and see for your self, you also can find some nice samples done.

http://www.microsoft.com/silverlight

Tuesday, May 01, 2007

Debugging Stored Procedures

I know that all of you might have tried debugging Stored Procedures (SPs). But I know there are also people who are searching how to do this so I thought I needs to put an article on how to do this.

Please note that to dubug SPs you need to use an account which is a member of sysadmin role.

1.) SQL Server 2005
When you install SQL Server 2005 it will install SQL Server Business Intelliegnce Development Studio. You can use this or Visual Studio to debug SPs.

Start any prefered application from the above two and go to View menu and click on Server Explorer (or press Ctrl + Alt + S) to display the Server Explorer.

Now create a connection to the database where the SP you want to debug is located (Right click on Data Connections and click Add Connection...).

When the connection is added to the list expand the list and browse to the Stored Procedures and right click on the SP which you want to debug and select Step Into Stored Procedure. Now if the SP is requiring any parameters a dialog box will be displayed to enter the values. After entering them click Ok to run into the SP.

After you were taken into the debug mode you can use the same keys to debug SPs as if you are debugging application code (Step Into - F11, Step Over - F10, Step Out - Shift + F11).
If you like to use the Debug toolbar activate it by Clicking on View -> Toolbars -> Debug.

If you want to know what the buttons does, just hover on top of the tool so a helpful tooltip will appear. If you need more information press on the help tool which is the right most tool with a yellow question mark.

Also remember that all the additional features are also available for you to use (as if the Immediate Window) while debugging.


2.) SQL Server 2000
In SQL Server 2000 you have to use the SQL Query Analyzer to debug SPs.
Start SQL Query Analyzer and click on Tools -> Object Browser -> Show/Hide (or F8) to display the Object Browser if it is not already shown.

Now expand the database where the required SP is located and right click on the SP which you needs to debug inside Stored Procedures node.

Click on the Debug... to start the debugging, if the SP requires any values for its parameters a window will pop up to enter the values. After entering the values click on Execute.

When debugging starts you can use the available controls or shortcut keys (Step Into - F11, Step Over - F10, Step Out - Shift + F11, Run to Cursor - Ctrl + F10) to debug through the SP.



If you want to know what the buttons does, just hover on top of the tool so a helpful tool tip will appear. If you need more information press on the help tool which is the right most tool with a yellow question mark.