Tuesday, 15 May 2012

For c++ developers, DevC++ is an excellent free tool. to download the tool, please click the link down below

<iframe src="https://skydrive.live.com/embed?cid=E103DC75724AEE79&resid=E103DC75724AEE79%21119&authkey=AAZXYSyodESqUYs" width="98" height="120" frameborder="0" scrolling="no"></iframe>

Monday, 14 May 2012

What is SILVERLIGHT

What is Silverlight?

Heard and seen various advertisements on the web, still figuring out what is Microsoft Silverlight? A few of my blog readers requested me to give them an Introduction about Microsoft Silverlight, Thanks for coming forward and asking!! In a few minutes I will brief you’ll through it and would give out a simple Hello World application.

Microsoft Silverlight

Microsoft Silverlight History

 Microsoft introduced a new web technology back in 2007, which would create rich internet applications called Microsoft Silverlight. It was a competitor to Adobe’s Flash since developers would face difficulty in implementing Flash on their web pages. One of the main goals of Silverlight is to bridge the gap between Windows Application and Web Application as far as the User Interface (UI) is concerned. 

What is Silverlight and Why Silverlight?

Silverlight is approximately 6 MB, Client Side, browser plug-in which is used to enhance the User Interface of the Web Pages.
  • Silverlight supports cross-browser technology i.e. ability to use across multiple browsers eg. Internet Explorer, Mozilla Firefox, Google Chrome, and Safari
  • Silverlight supports cross-platform technology (ability to use across various platforms eg. Windows, MAC, Linux with Moonlight technology etc.)
  • Silverlight supports multiple devices (cross device technology) such as Desktops, Mobiles, 270p HDTV and more.
  • The main advantage of Silverlight is that it is free, easy to use, and fast!!
  • Large communities are available on the net for learning, rather than implementing Flash.
  • Supports .Net framework. A .Net developer can easily start programming in Silverlight using his preferred language such as C#, VB.
  • Transferring High Definition video files on the web is also supported by Silverlight.
Technically Speaking… 
Silverlight applications are developed using a text-based markup language called XAML (eXtensible Application Markup Language). XAML is a declarative markup language that you can use to define UI elements such as Rectangle, Line, Circle and various other shapes. Silverlight’s latest version is Silverlight 5 Beta.

Applications are written either completely in XAML or in combination of XAML and JavaScript with DOM (Document Object Model) to manipulate the user interface. It requires Silverlite.js file which you need to reference from the HTML page and an additional JavaScript file in order to declare the Silverlight Object. You can download the Silverlight.js from here  

Silverlight 2.0, Silverlight 3.0 and Silverlight 4.0 

Silverlight 2.0 fully supports .Net framework 3.5 and various ASP.Net controls such as TextBox, CheckBox, Radio Button, TabControl, DataGrid… It also provides Deep Zooming Facility using Mouse Scroll.

Silverlight 3.0 is an extension to 2.0 and it provides improved graphics capabilities, media management, and application development by Integrating with the Expression Blend tool (helps designers to design high quality videos and enhance graphics) provided by Microsoft. It also helps in Search Engine Optimization (SEO). 

Silverlight 4.0 is the current version which is used and it provides additional features such as Local Fonts, Printing, Webcam, and Microphone. 




Who can work on Silverlight?


You must know HTML, JavaScript, and CSS to work on Silverlight 1.0. To learn Silverlight 2.0 onwards, you must know ASP.Net (framework 3.5) and AJAX.
I have managed to write a simple Hello World code in Silverlight,HTML, and Javascript you can check out the follow link 


Download Hello World Code (Extract and Run the HelloWorld.html file) - RAR File
Download Hello World Code (Extract and Run the HelloWorld.html file) - ZIP File


Those who are using Firefox 3.6.3 might face issues as there is some browser problem. I tried to find out but there is no such plug-in check out this link Firefox 3.6.3 Issue as soon as I'll get their reply ill post it. 


You can play around with the colors and gradients used in the HelloWorld.xaml file to see different color effects and understand what each object does. I'll write a similar post and explain the different objects used in the JavaScript and XAML files.
Hi friends

Here I am placing a code to convert tiff image to pdf file. Some time we need to convert the

tiff image to pdf file according to the client need .There are a few for .NET including
iTextSharp
, PDFsharp and PDF Clown. I used iTextSharp because it has a sample that was
showing how to create a PDF file from a multipage TIFF image
// creation of the document with a certain size and certain margins
iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.

PageSize.A4, 0, 0, 0, 0);
// creation of the different writers
iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(docu

ment, new System.IO.FileStream(Server.MapPath("~/PDF/Output.pdf"), System.IO.Fil

eMode.Create));
// load the tiff image and count the total pages
System.Drawing.Bitmap bm = new System.Drawing.Bitmap(Server.MapPath("~/Folder

Location/file.tif"));

int total = bm.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);

document.Open();

iTextSharp.text.pdf.PdfContentByte cb = writer.DirectContent;

for (int k = 0; k < total; ++k)

{

bm.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, k);

iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bm, System.Drawin

g.Imaging.ImageFormat.Bmp);



// scale the image to fit in the page
img.ScalePercent(72f / img.DpiX * 100);

img.SetAbsolutePosition(0, 0);

cb.AddImage(img);

document.NewPage();

}

document.Close();

File upload


In this article, I will discuss how you can create your own File Upload feature in a Silverlight

application.


Step 1:

First, create a Silverlight Web application in Visual Studio 2008. You will see your default


Page.xaml.


Step 2:

On Create Page.xaml, change your code by adding following Panel, Button, and TextBlock


controls.

On buttin click event handler, I write code to call the OpenFileDialog that allows us to browse files

and gives us the selected file name. Here is the code.


public void

Button_Click(object sender, RoutedEventArgs e)


{


OpenFileDialog

dlg = new OpenFileDialog();


dlg.Multiselect =

false;


dlg.Filter =

"All files (*.*)|*.*|PNG Images (*.png)|*.png";


bool

? retval = dlg.ShowDialog();


if

(retval != null && retval == true)


{

UploadFile(dlg.File.Name, dlg.File.OpenRead());

StatusText.Text = dlg.File.Name;

}


else


{

StatusText.Text =

"No file selected...";


}

}

As you can see from the above code, I call a method UploadFile by passing the selected file name

from the OpenFileDialog.

The

UploadFile method looks like following. In this code, I use a WebClient class and a PushData


method.


private

void UploadFile(string fileName, Stream data)


{


UriBuilder

ub = new UriBuilder("http://localhost:3840/receiver.ashx");


ub.Query = string.Format(

"filename={0}", fileName);


WebClient

c = new WebClient();


c.OpenWriteCompleted += (sender, e) =>

{

PushData(data, e.Result);

e.Result.Close();

data.Close();

};

c.OpenWriteAsync(ub.Uri);

}




private void PushData(

Stream input, Stream output)


{

byte[] buffer = new byte[4096];

int bytesRead;

while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)

{

output.Write(buffer, 0, bytesRead);

}

}


Step 3:

Add a new Generic Handler receiver.ashx.


Now let's add a class. Right click on the project and Add a new item by selecting Generic Handler in

the right side templates as shown below.

And add the following code on the coe behind:

<%@

WebHandler Language="C#" Class="receiver" %>


using System;

using System.Web;

using System.IO;

public class

receiver : IHttpHandler {


public void ProcessRequest (

HttpContext context) {


string filename = context.Request.QueryString[

"filename"].ToString();


using (

FileStream fs = File.Create(context.Server.MapPath("~/App_Data/" + filename)))


{

SaveFile(context.Request.InputStream, fs);

}

}

private void SaveFile(

Stream stream, FileStream fs)


{

byte[] buffer = new byte[4096];

int bytesRead;

while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0)

{

fs.Write(buffer, 0, bytesRead);

}

}

public bool IsReusable {

get {

return false;

}

}

}


Step 4:

Build and Run


That's all. You are done. Now just build and run your project.