tag:blogger.com,1999:blog-307218862024-03-05T21:19:38.491-08:00C#.Net Articlesby Thiagarajan.AThiaguhttp://www.blogger.com/profile/17888457107965047422noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-30721886.post-35403624703664087532009-11-03T07:47:00.000-08:002009-11-03T08:31:22.795-08:00Remote Desktop using C#.Net<div><strong>Overview:</strong><br />Remote Desktop Services is one of Microsoft Windows components to access a remote computer through network. Only the user interface of the application is presented at the client. Any input is redirected over to the remote computer over the network. At work we use Remote Desktop a great deal. It allows us to login to a remote server to perform health checks, deploy applications, troubleshoot problems, etc. We also use remote desktop often when we do WFH (work from home :)).<br /><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 229px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5399907119631265106" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzL4ZlUXm22FbPOjRl1B0-6_ghBWATtr5S7mCNBHliWj08HrsHTahcWlkrScPPAEofsjy1NZkcHDEXCtfczwXmeRVaqWd0ExCM3oTRa3CNlwdN9YYstAf2b4-cbvj7cVsH6GipKQ/s320/1.jpg" /><br />Why do we want to write a .Net application to do this when you have the MS Terminal Services client available from OS? Well, consider if you want to work on 3 different application servers at the same time and want to toggle between these 3 servers quite often. With the MSTSC, we will be running 3 different clients for the 3 servers and it is difficult to manage the working environment. In .Net you can develop an application with tab control to load remote desktop sessions in different tabs in one window.However, tab control is not in scope of this article. That gives me an idea for my next article :)<br /><br /><strong>Microsoft Terminal Services Control</strong><br /><br />We will be using AxMSTSCLib an ActiveX component in our program to connect to the remote computer. It's not that hard to build a remote desktop application in .Net.<br />Microsoft has a "Microsoft RDP client control" ActiveX control that we will be using in our application.<br /><br /><strong>This is how we do it</strong><br /><br />We will start by creating a windows application in the Visual Studio IDE.<br />Add reference to "Microsoft Terminal Services Control Type Library" from the COM tab. This will add MSTSCLib.dll to the project. </div><br /><br /><div><br /></div><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 262px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5399911881098170290" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgf_mhfg53iEpIglMYb1SHhGKZ8a4HxbmanMxGz0IK_P3Lv4HjdSfgg0sPKvQM48-Zr2sYFng1zBysxOESAG5h600nNd53-EJZTjO4lgIfazkgaFTVEvuU-XXR51-a28xG6ZHTT1w/s320/2.jpg" /><br /><div><br />To add MSTSC to the toolbox, right click the toolbox and select "Choose Items…". Now add "Microsoft Terminal Services control from the COM tab.<br /></div><br /><br /><div></div><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 260px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5399912149596016754" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_xcGNqKFsbd2aNidF_v61Ek_SAjReno2V-QcndxMQReLXqLsNdmqFBrlCPY1xtZmNd-UNmWvh0k5Bhzdb_Maqgriv5_02Xqt0wzhsnyJlYVz5Cz-_ZNMByj7jJXuQGTbK_qxN-Q/s320/3.jpg" /><br /><br /><div><br />Drag the newly added control from toolbox to the form.<br />Add 3 textbox and 2 button controls to the form. </div><div><br /></div><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 320px; DISPLAY: block; HEIGHT: 278px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5399912217717862354" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaysz3FErJxFYi8CX8jyaY0z6nOcju6_lMRn6tpBk-spzqRyzcRNhyphenhyphennGg7RwwI7KrLU4ZMqKwtVoNFE_u9ygJ8-771edovCBQfT8QvS7w0iG1xc-eNLKOFbw8FS8guGPhfoF_q-Q/s320/4.jpg" /><br /><strong>Connect Button - Click Event:</strong><br />Here is how we write the Connect button click event.<br /><br /><blockquote>rdp.Server = txtServer.Text;<br />rdp.UserName = txtUserName.Text;<br /><br />IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp.GetOcx();<br />secured.ClearTextPassword = txtPassword.Text;<br />rdp.Connect();</blockquote><br /><div><br />Now assign the properties (Server, UserName) of RDP control with the textbox values.<br />Here's how easy to login to remote machine. However there is one catch, there is no direct method in RDP control through which you can pass the username and password to login to the remote desktop.<br />Due to security reasons you have to implement an interface (IMsTscNonScriptable) to cast it separately.<br /><br /></div><blockquote>IMsTscNonScriptable secured = IMsTscNonScriptable)rdp.GetOcx();<br />secured.ClearTextPassword = txtPassword.Text;<br /></blockquote><br /><br /><div><strong>Disconnect Button - Click Event:</strong> </div><div><br />To disconnect from the remote desktop session, we just need to call the Disconnect() method.<br />Before disconnecting, we want to ensure that the connection is still available. We don't want to disconnect if it is already disconnected (very clever huhJ)<br /><br /></div><blockquote>if (rdp.Connected.ToString() == "1")<br />rdp.Disconnect();</blockquote><br /><br /><div>Check the full source code <a href="http://www.c-sharpcorner.com/UploadFile/thiagu304/remotedesktop10262009033113AM/remotedesktop.aspx?ArticleID=b55aa9a7-69ba-4ec3-90bf-6301d6ba0505">here</a>. Please leave your valuable comments and questions.<br />That's all folks! Happy Coding!</div>Thiaguhttp://www.blogger.com/profile/17888457107965047422noreply@blogger.com26tag:blogger.com,1999:blog-30721886.post-1169216701829647732007-01-19T06:24:00.000-08:002007-01-19T06:25:02.230-08:00Snap It! - How to take screen shot using .Net<big><big><small><small><span style="font-size:130%;"><big><span style="font-weight: bold;"><span style="font-size:100%;">Introduction</span></span></big><br /></span></small></small></big></big><br /><big><big><small><small>We all would have used snap shots (screen shots) to illustrate bugs or behavior or something that others could understand by seeing them. For taking snap shots we just hit the "Print Screen" key and copy it to Ms Paint and save it. Ever wondered how to programmatically take a snap shot? Then this article is for you.</small></small></big></big><br /><br /><div style="text-align: center;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/7529/2900/1600/610347/snapit1.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/7529/2900/400/570261/snapit1.jpg" alt="" border="0" /></a></div> <div style="text-align: center;"><big><big><small><small>Image-1 This is how the application looks</small></small></big></big><br /></div><big><big><small><small><br /><span style="font-size:130%;"><big><span style="font-weight: bold;"><span style="font-size:100%;">Scenario</span></span></big></span></small></small></big></big><big><big><small><small><span style="font-size:130%;"><br /><br /></span>Why do we need to take snapshots programmatically? Consider a scenario where you want to report some kind of behavior errors in an application. Human supervision is not possible when the occurrence of error is random. So we just code a program to take snap shots are regular intervals and store it as a image file. So that later you can use it.<br /></small></small></big></big><br /><span style="font-size:85%;"><span style="font-weight: bold;">GDI classes we need to know</span></span><big><big><small><small><br /><br />Lets see what we need to know before we do coding. We need to have a little knowledge about GDI and graphics classes. The <span style="font-weight: bold;">Graphics class</span> provides methods for drawing objects to the display device. A Graphics object is associated with a specific device context. This class is used as a canvas to draw images. In order to display anything in a window, you have to obtain a reference to the window's Graphics object.</small></small></big></big><br /><big><big><small><small><br />Next comes the Bitmap class. A Bitmap object is an object used to work with images defined by pixel data. A bitmap consists of the pixel data for a graphics image and its attributes.<br /><br /><span style="font-size:85%;"> <span style="font-weight: bold;">Getting Started</span></span></small></small></big></big><big><big><small><small><br /></small></small></big></big><br /><big><big><small><small>To use the GDI classes we need to include <span style="font-weight: bold;">System.Drawing.Imaging</span> namespace in the "using" section of the code. Go to the source view and add a string variable and a property to the class. This string variable is used in the property to store and retrieve the output file name.<br /><br /><small> <span style="font-size:85%;"><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="color: rgb(0, 153, 0);">// variable to store output file name</span></span><br /><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="color: rgb(51, 51, 255);">private string</span> strFilename;</span><br /><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > </span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="color: rgb(0, 153, 0);">// Property for storing and retrieving output file name</span></span><br /><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" ><span style="color: rgb(51, 51, 255);">public string</span> filename</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" ><br /> {</span> <span style="font-weight: bold;"><br /></span><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" ><span style="color: rgb(51, 51, 255);"> get</span>{<span style="color: rgb(51, 51, 255);">return</span> strFilename;}</span><br /><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="color: rgb(51, 51, 255);">set</span>{strFilename=<span style="color: rgb(51, 51, 255);">value</span>;}</span><br /><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" >}</span></span></small><br /></small></small></big></big><br /><big><big><small><small>In the design view, add a button and a savefiledialog to the form. Double click the button and go to the click event in the code view. Use the savefiledialog control to retrieve the output file name from the user. And store the file name in the variable strFilename using the property filename.<br /><br /><span style="font-size:85%;"><small style="font-weight: bold;"><span style="font-family:Courier New,Courier,monospace;"> <span style="color: rgb(0, 153, 0);"><span style="font-size:85%;">// Check user clicked OK button</span></span></span> <span style="font-size:85%;"><span style="color: rgb(0, 153, 0);font-family:Courier New,Courier,monospace;" ><br /> // Get the filename and put in the textbox and property</span> <span style="font-family:Courier New,Courier,monospace;"> <span style="color: rgb(51, 51, 255);">if</span>(saveFileDialog1.<span style="color: rgb(51, 51, 255);">ShowDialog()</span>!=DialogResult.Cancel)</span> <span style="font-family:Courier New,Courier,monospace;"><br /> {</span><br /><span style="font-family:Courier New,Courier,monospace;">filename=saveFileDialog1.FileName;</span><br /><span style="font-family:Courier New,Courier,monospace;"> }</span></span></small></span></small></small></big></big><big><big><small><small><span style="font-size:85%;"><br /></span></small></small></big></big><br /><big><big><small><small>Before taking the snap shot we hide our application because we don't want our application in the snap shot image. Sometimes even after hiding the application, the snap shot pictures our application, this is because the application takes few extra milliseconds to hide, so we </small></small></big></big>make our application to wait for some milliseconds.<br /><br /><span style="font-size:85%;"><span style="font-family:courier new,courier,mono;"><small style="font-weight: bold;"><span style="font-family:Courier New,Courier,monospace;"> <span style="font-size:85%;">this.<span style="color: rgb(51, 51, 255);">Hide</span>();</span></span> <span style="font-family:Courier New,Courier,monospace;"> </span> <span style="font-family:Courier New,Courier,monospace;"> <span style="color: rgb(0, 153, 0);"><span style="font-size:85%;"><br />// Slow the thread to hide the application before taking the snap</span></span></span> <span style="font-family:Courier New,Courier,monospace;"><span style="font-size:85%;"> Thread.<span style="color: rgb(51, 51, 255);">Sleep</span>(200);<br /><br /></span></span></small></span></span><span style="font-size:85%;"> <span style="font-weight: bold;">How to Snap It?</span></span><big><big><small><small><br /><br /></small></small></big></big><big><big><small><small>Now we create a Bitmap object to set the size of the screen. We use the width and height of the application screen to capture the snap shot. So the user can place our application screen on any area of the screen, move/resize to get the snap shot. To make the user more comfortable in selecting the snap shot area we make the application screen semi-transparent by setting the opacity of the form to 50%<br /><br /></small></small></big></big><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/7529/2900/1600/424390/snapit2.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/7529/2900/400/568918/snapit2.jpg" alt="" border="0" /></a> <div style="text-align: center;"><big><big><small><small><img style="width: 658px; height: 386px;" alt="Resizing the application" src="file:///C:/Documents%20and%20Settings/talagars/My%20Documents/Articles/snapit2.JPG" /></small></small></big></big><br /></div><div style="text-align: center;"><big><big><small><small>Image-2 Resizing and Moving the screen<br /></small></small></big></big></div><br /><big><big><small><small><br /><small style="font-weight: bold;"><span style="font-size:85%;"><span style="color: rgb(0, 153, 0);font-family:Courier New,Courier,monospace;" > // Setting the size of the screen for the bitmap</span> </span><span style="font-family:Courier New,Courier,monospace;"><span style="font-size:85%;"> Bitmap bmp= <span style="color: rgb(51, 51, 255);">new</span> Bitmap(this.Width,this.Height,PixelFormat.Format32bppArgb);</span></span></small></small></small></big></big><br /><big><big><small><small><small style="font-weight: bold;"><span style="font-family:Courier New,Courier,monospace;"><span style="font-size:85%;"><br /></span></span></small></small></small></big></big><big><big><small><small>A Graphics object is required to get the image bounds and create the actual picture. So we initialize a Graphics object and get the image bounds from the Bitmap that we have already created. CopyFromScreen method is used to get the snap shot from the screen. Based on the user selection of the file type in the savefiledialog box, we use different image formats to save the file using Bitmap.Save function.<br /><br /><span style="font-size:85%;"><small style="font-weight: bold; color: rgb(0, 153, 0);"><span style="font-family:Courier New,Courier,monospace;"> <span style="font-size:85%;"> // Saving file in the selected image format</span></span></small><br /><small><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="font-size:85%;">bmp.<span style="color: rgb(51, 51, 255);">Save</span>(filename,ImageFormat.Jpeg);</span></span></small><br /></span></small></small></big></big><br /><big><big><small><small><span style="font-size:85%;">After saving the picture we show the application back by using the following statement<br /><br /></span><small><span style="font-size:85%;"><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="color: rgb(0, 153, 0);">// Showing the application again</span></span> </span><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" ><span style="font-size:85%;"> this.<span style="color: rgb(51, 51, 255);">Show</span>();<br /><br /></span></span></small></small></small></big><span style="font-weight: bold;font-size:85%;" >Viewing the snap shot</span></big><br /><br />Now the screen is captured and the picture is saved. We need to view the snap shot. There is an option available to see how your snap shot has come up, just right after saving the file. We use Process class of System.Diagnostic namespace to view the image file.<br /><br /><small style="font-weight: bold;"> <span style="font-size:85%;"><span style="font-family:Courier New,Courier,monospace;"><span style="color: rgb(0, 153, 0);"> // Viewing the image</span><br /> Process pr= <span style="color: rgb(51, 51, 255);">new</span> Process();</span> <span style="font-family:Courier New,Courier,monospace;"> pr.StartInfo.FileName=filename;</span> </span><span style="font-family:Courier New,Courier,monospace;"><span style="font-size:85%;"> pr.Start();<br /><br /></span></span></small> <div style="text-align: center;"><span style="font-size:85%;"><small style="font-weight: bold;"><span style="font-family:Courier New,Courier,monospace;"><img style="width: 658px; height: 386px;" alt="Viewing the image" src="file:///C:/Documents%20and%20Settings/talagars/My%20Documents/Articles/snapit3.JPG" /></span></small></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/7529/2900/1600/148371/snapit3.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/7529/2900/400/140454/snapit3.jpg" alt="" border="0" /></a><span style="font-size:85%;"><small style="font-weight: bold;"><span style="font-family:Courier New,Courier,monospace;"><img style="width: 658px; height: 386px;" alt="Viewing the image" src="file:///C:/Documents%20and%20Settings/talagars/My%20Documents/Articles/snapit3.JPG" /></span></small><br /><small style="font-weight: bold;"><span style="font-family:Courier New,Courier,monospace;"></span></small></span></div> <div style="text-align: center;">Image -3 Viewing the saved image file<br /></div><small style="font-weight: bold;"><span style="font-family:Courier New,Courier,monospace;"><br /></span></small>When the Start method is executed the image file is opened in the respective application configured in the system.<br />Thats all folks.Thiaguhttp://www.blogger.com/profile/17888457107965047422noreply@blogger.com10tag:blogger.com,1999:blog-30721886.post-1168927315000039942007-01-15T21:50:00.000-08:002007-01-15T23:28:17.743-08:00File Splitter in .Net<big><big><span style="font-weight: bold;font-family:Times New Roman;" ><br /></span></big></big><br /><big><big><span style="font-weight: bold;font-family:Times New Roman;" ><small>Introduction<br /></small></span></big></big><br /><big><big><small><small><span style="font-family:Times New Roman;">I love to do utility programs in .Net. And this is one of them. As I was playing with JSplit (a free file splitter program), I wondered if I could do it in .Net. The framework supports file operations like reading files in bytes and creating them. It is indeed easy to do file operations in .Net</span> <big> <span style="font-weight: bold;font-family:Times New Roman;" >Basics on File operations<br /></span><small> <span style="font-family:Times New Roman;">The namespace </span><span style="font-weight: bold;font-family:Times New Roman;" >System.IO</span><span style="font-family:Times New Roman;"> provides classes for file operations. </span><span style="font-weight: bold;font-family:Times New Roman;" >StreamReader</span><span style="font-family:Times New Roman;"> is a class which provides methods to read a file in different modes. It allows the user to read file by number of characters, by line, by block and to the end of the file. There is another class </span><span style="font-weight: bold;font-family:Times New Roman;" >FileStream</span><span style="font-family:Times New Roman;"> which allows the user to read file by number of bytes. This is what we are going to use.</span></small></big></small></small></big></big><big><big><small><small><big><small><br /></small></big></small></small></big></big><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/7529/2900/1600/426378/FileSplitter.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/7529/2900/400/523201/FileSplitter.jpg" alt="" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/7529/2900/1600/909754/FileSplitter2.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/7529/2900/400/693033/FileSplitter2.jpg" alt="" border="0" /></a><big><big><small><small><big><small><br /><br /><big><span style="font-weight: bold;font-family:Times New Roman;" >Getting Started<br /></span></big></small></big></small></small></big></big><br /><big><big><small><small><big><small><big><small><span style="font-family:Times New Roman;">Lets begin by creating a windows application with a textbox, a numericupdown control, a label and three buttons.</span> <span style="font-family:Times New Roman;">Add a openfileDialog control and add some code to extract the filename from the dialog and to put it in the textbox when the browse button is clicked.</span><br /><small> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="color: rgb(51, 51, 255);">if</span>(openFileDialog1.ShowDialog()==DialogResult.OK)</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > {</span> <span style="font-family:Courier New,Courier,monospace;"><span style="font-weight: bold;"> txtFileName.Text=openFileDialog1.FileName;</span><br /><big> <span style="font-family:Times New Roman;">Now change the Maximum value of the numericupdown control to 1. Change the backcolor of the label to black and forecolor to green (to give a matrix screen effect)<br /><br />Set the text property of the buttons to "Calculate" and "Split".<br /></span></big></span></small></small></big></small></big></small></small></big></big><br /><big><big><small><small><big><small><big><small><small><span style="font-family:Courier New,Courier,monospace;"><big><span style="font-family:Times New Roman;">Include the namespaces System.IO and System.Text in the Using section.<br /><br /><big><span style="font-weight: bold;">Calculate Method<br /><br /></span><small>In Calculate method we are going to calculate the number of parts the file will be splitted based on the file size and the split size specified by the user.<br /></small></big></span></big></span></small></small></big></small></big></small></small></big></big><br /><big><big><small><small><big><small><big><small><small><span style="font-family:Courier New,Courier,monospace;"><big><span style="font-family:Times New Roman;"><big><small>Double click on the calculate button to go to the Click event. Now initialize the class FileStream by passing the filename from the textbox and specifying file mode and file access parameters.<br /><br /><small><span style="font-family:Courier New,Courier,monospace;"> <span style="font-weight: bold;">FileStream FR=<span style="color: rgb(51, 51, 255);">new</span> FileStream(txtFileName.Text,FileMode.Open, FileAccess.Read);</span></span></small><br /><br />The number of parts is caculated by dividing the file size (in bytes) and user selected split size. This is made to display in the label.<br /></small></big></span></big></span></small></small></big></small></big></small></small></big></big><br /><big><big><small><small><big><small><big><small><small><span style="font-family:Courier New,Courier,monospace;"><big><span style="font-family:Times New Roman;"><big><small><small><span style="font-family:Courier New,Courier,monospace;"> <span style="font-weight: bold;"><span style="color: rgb(51, 51, 255);">int</span> no_of_parts = Int32.Parse(FR.Length.ToString())/intByteSize;<br /> <span style="color: rgb(51, 51, 255);">int</span> intmod=Int32.Parse(FR.Length.ToString())%intByteSize;<br /> <br /> <span style="color: rgb(51, 204, 0);">//Include the remaining bytes</span><br /> <span style="color: rgb(51, 51, 255);">if</span>(intmod > 0)<br /> no_of_parts=no_of_parts+1;</span></span></small></small></big></span></big></span></small></small></big></small></big></small></small></big></big><br /><big><big><small><small><big><small><big><small><small><span style="font-family:Courier New,Courier,monospace;"><big><span style="font-family:Times New Roman;"><big><small><br /><big><span style="font-weight: bold;">Split Method</span></big><br /><br />In this method we are going to split the file in to user desired size and number of parts. We again use the FileStream class to read the file. But here we are going to read the file by number of bytes required for each part. So after reading a block of bytes required for a part we write it to a file by using FileStream but in the create file mode and write file access.<br /></small></big></span></big></span></small></small></big></small></big></small></small></big></big><br /><big><big><small><small><big><small><big><small><small><span style="font-family:Courier New,Courier,monospace;"><big><span style="font-family:Times New Roman;"><big><small><small><span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="color: rgb(51, 204, 0);">//Read the file by number of bytes and create part files</span></span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="color: rgb(51, 51, 255);">for</span>(<span style="color: rgb(51, 51, 255);">int</span> i=0;i<no_of_parts;i++)></no_of_parts;i++)></span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > {</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="color: rgb(51, 51, 255);">if</span>(intmod>0 && i==no_of_parts-1)</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > {</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > by=<span style="color: rgb(51, 51, 255);">new byte</span>[intmod];</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > FR.Read(by,0,intmod);</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > }</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > <span style="color: rgb(51, 51, 255);">else</span></span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > {</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > by=<span style="color: rgb(51, 51, 255);">new byte</span>[intByteSize];</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > FR.Read(by,0,intByteSize);</span> <span style="font-weight: bold;font-family:Courier New,Courier,monospace;" > }</span></small><br /><br />FileStream's WriteByte function is used to write the bytes to a file. Like this number of files are generated for the number of parts calculated. Each file is written with a dynamic name by appending some incrementing number to the file name.<br /></small></big></span></big></span></small></small></big></small></big></small></small></big></big><br /><big><big><small><small><big><small><big><small><small><span style="font-family:Courier New,Courier,monospace;"><big><span style="font-family:Times New Roman;"><big><small><small style="font-weight: bold;font-family:Courier New,Courier,monospace;"> <span style="color: rgb(51, 51, 255);">foreach</span>(<span style="color: rgb(51, 51, 255);">byte</span> b <span style="color: rgb(51, 51, 255);">in</span> by)<br /> {<br /> FW.WriteByte(b);<br /> }</small><br /><br /><big><span style="font-weight: bold;">Batch File<br /></span></big></small></big></span></big></span></small></small></big></small></big></small></small></big></big><br /><big><big><small><small><big><small><big><small><small><span style="font-family:Courier New,Courier,monospace;"><big><span style="font-family:Times New Roman;"><big><small><big><small>The significance of a file splitter is the ability to reunite the file without the actual splitter application. For this, we create a batch file in the split function to reunite the files and create the actual file. This batch file contains statements to combine the part files and generate the actual file.<br /><br /><small style="font-weight: bold;"><span style="font-family:Courier New,Courier,monospace;"> StringBuilder SB= <span style="color: rgb(51, 51, 255);">new</span> StringBuilder();</span> <span style="font-family:Courier New,Courier,monospace;"> SB.Append("Copy /b " + tempfilenames + " \"" + filename + "\"");</span> <span style="font-family:Courier New,Courier,monospace;"> SW.Write(SB.ToString());</span></small></small></big></small></big></span></big></span></small></small></big></small></big></small></small></big></big><big><big><small><small><big><small><big><small><small><span style="font-family:Courier New,Courier,monospace;"><big><span style="font-family:Times New Roman;"><big><small><big><small><br /><br />We use StringBuilder class to generate the statement for the batch file. The statement includes the command for uniting the files followed by the filenames. This command should be dynamically added to include the filenames. Now we write this statement to a file and save. The content of the batch file should look like the following statement.<br /><br /><small style="font-weight: bold;"><span style="font-family:Courier New,Courier,monospace;">Copy /b "test.pdf0" +"test.pdf1" +"test.pdf2" "test.pdf"<br /><br /></span></small></small></big></small></big></span></big></span></small></small></big></small></big></small></small></big></big><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/7529/2900/1600/50146/FileSplitter3.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/7529/2900/400/228842/FileSplitter3.jpg" alt="" border="0" /></a><br /><big><span style="font-weight: bold;"><br /><span style="font-family:Times New Roman;">Conclusion</span></span></big> <big><big><small><small><big><small><big><small><small><span style="font-family:Courier New,Courier,monospace;"><big><span style="font-family:Times New Roman;"><big><small><big><small><span style="font-family:Times New Roman;">While using file operations we should ensure that the file is closed after the read/write process. Thats all folks!<br /><span style="font-size:85%;"><a href="http://www.c-sharpcorner.com/UploadFile/thiagu304/FileSplitter01142007232713PM/FileSplitter.aspx?ArticleID=c4dd6dbf-09c9-4a42-861f-6ed94683360e">For further reading and code download</a></span><br /></span></small></big></small></big></span></big></span></small></small></big></small></big></small></small></big></big>Thiaguhttp://www.blogger.com/profile/17888457107965047422noreply@blogger.com1tag:blogger.com,1999:blog-30721886.post-1166710382188243492006-12-21T06:11:00.000-08:002007-01-15T23:33:06.780-08:00Find and Replace for multiline text<span style="font-size:100%;"><br /><br />Many of us would have used "Find and Replace" option available in our IDE and in many of the text editors. This functionality finds a single line of text given and replaces with the given text in the current document as well as in the files under a given folder. But how would you find and replace a multiline text? In this article I have tried to explain that.<br /><br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/7529/2900/1600/493568/FindnReplace.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/7529/2900/320/261470/FindnReplace.jpg" alt="" border="0" /></a><br /><span style="font-size:100%;">The project included in this article has a simple file reading operation. For the beginners first let me explain how to read files. You can skip this section if you are familiar with file operations.<br /><br /><span style="font-weight: bold;">File Operations</span><br /><br />The first step is to include the System.IO namespace in the using directive.<br /><br /></span><div style="margin-left: 40px;font-family:verdana;"><span style="font-size:100%;"><span style="color: rgb(51, 51, 255);">using</span> System.IO;<br /></span></div><span style="font-size:100%;"><br />System.IO namespace has <span style="font-weight: bold;">DirectoryInfo</span> class which is used for typical operations such as copying, moving, renaming, creating, deleting and enumerating through directories and sub-directories. Files under a specific directory can be found using this class.<br /><br />The following statement instantiates DirectoryInfo class with a folder path from the text box.<br /><br /></span><div style="margin-left: 40px;font-family:verdana;"><span style="font-size:100%;">DirectoryInfo DI= <span style="color: rgb(51, 51, 255);">new</span> DirectoryInfo(txtFolder.Text);<br /></span></div><span style="font-size:100%;"><br />To get the file information we use the following statement.<br /><br /></span><div style="margin-left: 40px;font-family:verdana;"><span style="font-size:100%;"><span style="color: rgb(51, 51, 255);">foreach</span>(FileInfo FI <span style="color: rgb(51, 51, 255);">in</span> DI.GetFiles())<br /></span></div><span style="font-size:100%;"><br />The GetFiles method of the DirectoryInfo class, returns an array of FileInfo object. The <span style="font-weight: bold;">FileInfo</span> class like DirectoryInfo has operations for reading, copying, moving, renaming, creating and deleting files.<br /><br />Now we use a StreamReader object to read the file.<br /><br /></span><div style="margin-left: 40px;font-family:verdana;"><span style="font-size:100%;">StreamReader SR= <span style="color: rgb(51, 51, 255);">new</span> StreamReader(FI.OpenRead());<br /></span></div><span style="font-size:100%;"><br />We use the following statement to read a line and assign it to a string variable.<br /><br /></span><div style="margin-left: 40px;font-family:verdana;"><span style="font-size:100%;">s=SR.ReadLine();<br /></span></div><span style="font-size:100%;"><br /><span style="font-weight: bold;">Search Operation</span><br /><br />We read each line and store it in a temporary variable appending a new line character ("\r\n") at the end of the line.<br />This will differentiate each line for searching multiline text.<br /><br /></span><div style="margin-left: 40px;font-family:verdana;"><span style="font-size:100%;">temp=temp+s+"\r\n";<br /></span></div><span style="font-size:100%;"><br />Now to search the string we use IndexOf() method in the temporary variable with the search text as parameter.<br /><br /></span><div style="margin-left: 40px;font-family:verdana;"><span style="font-size:100%;">pos=temp.IndexOf(txtFind.Text);<br /></span></div><span style="font-size:100%;"><br />The above statement returns the position of the search text.<br />We use a list box to record the number of files that matches the search text and the occurence of the first position.<br /><br /><span style="font-weight: bold;">Replace Operation</span><br /><span style="font-weight: bold;"><br /></span>For the replace functionality, we use Replace() method in the temporary variable with search string and string to replace as arguments.<br />temp=temp.Replace(txtFind.Text,txtReplace.Text);<br /><br />To reflect this change in the actual file, we need to write it to the file. So we use StreamWriter object to write to the file.<br /><br /></span><div style="margin-left: 40px;font-family:verdana;"><span style="font-size:100%;">StreamWriter SW= <span style="color: rgb(51, 51, 255);">new</span> StreamWriter(FI.OpenWrite());<br />SW.Write(temp);<br />SW.Close();<br /></span></div><span style="font-size:100%;">The source code for the project can be downloaded <a href="http://thiagarajan.alagarsamy.googlepages.com/FindnReplace.zip">here</a>.<br /><span style="font-size:85%;"><a href="http://www.c-sharpcorner.com/UploadFile/thiagu304/FindnReplace12222006022310AM/FindnReplace.aspx?ArticleID=b6ed7667-5de6-42e1-a5fb-80dae92457a0">For further reading and source code download</a></span><br />Thats all folks!!!</span>Thiaguhttp://www.blogger.com/profile/17888457107965047422noreply@blogger.com3tag:blogger.com,1999:blog-30721886.post-1163691639612492982006-11-16T07:14:00.000-08:002006-11-20T03:35:59.196-08:00Consuming a webservice from behind a proxy firewallI was trying to access a webservice from my office which is behind a proxy firewall, I was annoyed by seeing the following error message<br /><br />"<span style="COLOR: rgb(255,0,0)">- The request failed with HTTP status 407: Proxy Authentication Required</span>"<br /><br />I knew that it is something to do with the firewall proxy. So I googled my doubt and the error text but couldn't get a descent solution. Then I tried with the options in the command WSDL that we use to generate a proxy class (not to be confused with firewall proxy) for our webservice.<br /><br />I found the following options.<br /><br /><span style="FONT-WEIGHT: bold">/proxy:</span><br /><span style="FONT-WEIGHT: bold">/proxyusername:</span><br /><span style="FONT-WEIGHT: bold">/proxypassword:</span><br /><span style="FONT-WEIGHT: bold">/proxydomain:</span><br /><br />But I didn't know how to use these options (I should admit that I am not good at DOS). Then I googled these options and got some answers which I am going to share with you now.<br /><br />/proxy: is the url of the proxy server with the port number. For E.g., if your proxy server address is 255.255.255.255 and the port is 8001 then your proxy url is <a href="http://255.255.255.255:8001">http://255.255.255.255:8001</a><br /><br />/proxyusername: is the username of your proxy server and /proxypassword: is the password of your proxy server.<br /><br />/proxydomain: is the domain name of your server.<br /><br />So the WSDL command should be something like this.<br /><br /><span style="FONT-WEIGHT: bold">c:\WSDL /proxy:http://255.255.255.255:8001 </span><br /><span style="FONT-WEIGHT: bold">/proxyusername:uname</span><br /><span style="FONT-WEIGHT: bold">/proxypassword:pwd /proxydomain:lotus <a href="http://thiagu007.tk.105.webhostforasp.net/">http://thiagu007.tk.105.webhostforasp.net/</a></span><br /><span style="FONT-WEIGHT: bold">service1.asmx?wsdl</span><br /><br />The above command will download the proxy class file for the webservice.<br /><br />But this is not the end of the show. We need to consume the service. The first thing we need to do is compile the class to a dll.<br /><br /><span style="FONT-WEIGHT: bold">c:\csc.exe \t:library service1.cs</span><br /><br />Then create a windows application project in Visual Studio and add the dll as a reference. Now you can use the class that is available in the dll and create an instance of it. But calling the web method from the webservice will again display the same error.<br /><br />To resolve this you have to create a WebProxy. This is again the authenication information for firewall proxy.<br /><br />To instantiate the WebProxy class you need to include the namespace System.Net in the "using" part.<br /><br /><span style="COLOR: rgb(51,51,255)">using</span> System.Net;<br /><br />Now you can instantiate WebProxy class as follows,<br /><br /><span style="COLOR: rgb(0,153,0)">// Instantiate the WebProxy class</span><br />WebProxy myProxy = <span style="COLOR: rgb(51,51,255)">new</span> WebProxy(<a href="http://255.255.255.255:8001,true">http://255.255.255.255:8001,<span style="COLOR: rgb(51,51,255)">true</span></a>);<br />myProxy.Credentials = <span style="COLOR: rgb(51,51,255)">new</span> NetworkCredential("uname", "pwd", "lotus");<br /><br />Now, the proxy should be assigned to the Service class and the function can be called.<br /><br /><span style="COLOR: rgb(0,153,0)">// Instantiate the WebService class<br /></span>Service1 sr=<span style="COLOR: rgb(51,51,255)">new</span> Service1();<br />sr.Proxy =myProxy; <span style="COLOR: rgb(0,153,0)">// Set the proxy to the class</span><br />String str=sr.HelloWorld(); <span style="COLOR: rgb(0,153,0)">// Calling the web method</span><br /><br />This will call the method that is available in the webservice by authenticating the proxy server's credentials.<br /><br />Happy Coding :)Thiaguhttp://www.blogger.com/profile/17888457107965047422noreply@blogger.com3tag:blogger.com,1999:blog-30721886.post-1162815199369314842006-11-06T03:54:00.000-08:002006-11-06T04:16:24.976-08:00Dynamic Code CompilationWelcome to dynamic code compilation. This article throws light on how a code can be built dynamically, compiled and run. The scenario of dynamic code compilation may arise when you want an application to upgrade (or rewrite) another application.<br /> Lets jump in to coding. The namespaces that we are going to use in this project are<br /><ul><li> System.CodeDom</li><li> System.CodeDom.Compiler</li><li> Microsoft.CSharp</li></ul> The <b>System.CodeDom</b> namespace contains classes that can be used to represent the elements and structure of a source code document. The classes in this namespace can be used to model the structure of a source code document that can be output as source code in a supported language using the functionality provided by the <span class="linkTerms">System.CodeDom.Compiler</span> namespace.<br /><br /> The <b>Microsoft.CSharp</b> namespace contains classes that support compilation and code generation using the C# language.<br /><br />At first we need to instantiate the class CSharpCodeProvider. Then create a complier using CreateCompiler() function of CSharpCodeProvider class and assign to the interface ICodeCompiler.<br /><br /> <span style="font-family:courier new;">CSharpCodeProvider codeProvider = </span><span style="color: rgb(51, 51, 255);font-family:courier new;" >new</span><span style="font-family:courier new;"> CSharpCodeProvider();</span><br /><span style="font-family:courier new;"> ICodeCompiler icc = codeProvider.CreateCompiler();</span><br /><br />Then set the parameters for the compiler using CompilerParameters class. Set parameters like GenerateExecutable, OutputAssembly<br /><br /> <span style="font-family:courier new;">System.CodeDom.Compiler.CompilerParameters parameters = <span style="color: rgb(51, 51, 255);">new</span> CompilerParameters();</span><br /><span style="font-family:courier new;"> parameters.GenerateExecutable = <span style="color: rgb(51, 51, 255);">true</span>;</span><br /><span style="font-family:courier new;"> parameters.OutputAssembly = "Out.exe";</span><br /><br />Now declare a String variable and write the source code for the new application/program. Now instantiate CompilerResults class with compiler parameters and the source code as below.<br /><br /><span style="font-family:courier new;"> String sourcecode;</span><br /><span style="font-family:courier new;"> sourcecode="using System;namespace SampleApp{class Class1{[STAThread] static void Main(string[] args) { Console.WriteLine(\"I am born to live!\");Console.Read(); } }}";</span><br /><span style="font-family:courier new;"> CompilerResults results = icc.CompileAssemblyFromSource(parameters,sourcecode);<br /><br /><span style="font-family:georgia;">Now the code is compiled. If you want to run the compiled EXE, start the process by<br /><br /> Process.Start("Out.exe");<br /><br />Thats all folks!....<br />Happy coding<br /><br /></span></span>Thiaguhttp://www.blogger.com/profile/17888457107965047422noreply@blogger.com1tag:blogger.com,1999:blog-30721886.post-1152768337822131542006-07-12T22:25:00.000-07:002006-07-12T22:39:03.203-07:00Calling APIs, The .Net Way!<big><span style="font-weight: bold;">What is Windows API?</span></big><br /><br /><span style=""><span style="font-family:Verdana;">The Windows API is the name given by Microsoft to the core set of application programming interfaces available in the Microsoft Windows operating systems. It is designed for usage by C/C++ programs and is the most direct way to interact with a Windows system for software applications.</span><br /><br /><span style="font-family:Verdana;">The functionality provided by the Windows API can be grouped into various categories like Base Services, Graphics Device Interface, User Interface, Common Dialog Box Library, Common Control Library, Windows Shell, Network Services.</span></span><br /><big style="font-weight: bold;"><br />The .Net Way!</big><br /><br /><span style="font-family:Verdana;">Now we will see how to call an API function in .Net. As we all know that .Net supports Interop Services, its very easy to call an API function using the namespace "System.Runtime.InteropServices".<br /><br />Before going to the coding section, lets start with an example. Here I am going to use Windows API for hiding the mouse cursor and showing it back. For this purpose, I am going to use the API user32.ShowCursor function which is under the category User Interface.<br /><br />Let us start the coding by first including the namespace "System.Runtime.InteropServices". This namespace provides a wide variety of members that support COM interop and platform invoke services. </span><br /><br /><span style="color: rgb(51, 51, 255);"> using </span>System.Runtime.InteropServices;<br /><br /><span style=""><span style="font-family:Verdana;">Then comes the declaration part. Here we declare the API function that we are going to use. Here we have to specify the dll to which the function refers. In our case it is User32.dll.</span></span><br /><br /> [DllImport("user32.dll")]<br /> <span style="color: rgb(51, 51, 255);">static extern int</span> ShowCursor(<span style="color: rgb(51, 51, 255);">bool</span> bShow);<br /><br /><span style="font-family:Verdana;">The Statement DllImport is an attribute which you use to define platform invoke methods for accessing unmanaged APIs. This definition should be made inside the main class like other member functions and variables.</span><br /><br /><span style="font-family:Verdana;">The interesting part is calling the API function. It is very straight forward. Just use the following statement.</span><br /><br /> ShowCursor(<span style="color: rgb(51, 51, 255);">false</span>); <span style="color: rgb(153, 255, 153);"> <span style="color: rgb(93, 156, 93);">// Hide cursor</span></span><br /><br /> ShowCursor(<span style="color: rgb(51, 51, 255);">true</span>); <span style="color: rgb(93, 156, 93);">// Show cursor</span><br /><big><br /><span style="font-weight: bold;">Some Tips...<br /><br /></span><small> <span style=""><span style="font-family:Verdana;">For beginners, implementing APIs is a tough job. There is a quick reference website (</span><a style="font-family: Verdana;" href="http://www.pinvoke.net/">www.pinvoke.net</a><span style="font-family:Verdana;">) which provides the structure and sample code (sometimes)</span></span></small><span style=""><span style="font-weight: bold;font-family:Verdana;" > </span></span><small><span style=""><span style="font-family:Verdana;">for all the APIs. But first you need to know which API function is needed for your use. You can find it easily by searching in Google. Happy Coding!</span></span><br /><br /></small><small><small> </small><br /><br /></small><span style="font-weight: bold;"></span></big><small><br /><br /></small>Thiaguhttp://www.blogger.com/profile/17888457107965047422noreply@blogger.com1tag:blogger.com,1999:blog-30721886.post-1152277606652016482006-07-07T05:12:00.000-07:002007-01-02T21:02:05.150-08:00Excel Automation in .Net<span style="font-size:100%;"><span style="font-family:Verdana;">Excel Automation is a buzz word in both webapps and winapps. In the programming life (like Mr.Anderson neo) I guess almost every one could have come across this word. For others let me go further in detail. Excel Automation is automating some or all of the process involved in creating or updating excel worsheets.</span><span style="font-family:arial;"> </span><br /><br /><span style="font-family:Verdana;">The real life scenario of an excel automation can be a daily account maintenance where you have an excel sheet template with graphs and calculations already in place except the data. So you want the data to be pulled in from a database and written to the excel sheet. After this the template takes care of the data by manipulating for graph generation.</span><br /><br /><span style="font-family:Verdana;">For the above said scenario we can go for a simple console application in .Net. Why I didn't go for an ASP.Net web application? Because running a web application requires a browser to be opened and closed. This becomes tedious when you schedule the process using windows scheduler to occur in particular intervals. And running a console based application is quite easy.</span><br /><span style="font-family:Verdana;"><br /></span> <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/7529/2900/1600/362159/XL-file.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/7529/2900/320/885216/XL-file.jpg" alt="" border="0" /></a><br /><span style="font-family:Verdana;">Pardon me for beating around the bush. Now let us jump in to the good part (coding). For this automation process we need to follow the below steps</span><br /><br /><span style="font-family:Verdana;">1. Add a referrence to the Microsoft Excel object library COM component.</span><br /><span style="font-family:Verdana;">2. Add the namespace Excel</span><span style="font-family:arial;"> </span><span style="font-family:Verdana;"><br />3. Instantiate the class Excel.ApplicationClass as below</span><span style="font-family:arial;"> </span><br /><span style=";font-family:Courier New,Courier,monospace;font-size:85%;" ><br />Excel.Application xl=<span style="color: rgb(51, 51, 255);">new</span> Excel.ApplicationClass();</span></span> <p style="font-family:arial;"><span style="font-size:100%;"> 4. To open an excel file,</span></p> <p style="font-family:Courier New,Courier,monospace;"><span style="font-size:85%;"> Excel.Workbook wb=xl.Workbooks.Open(Environment.CurrentDirectory+"/SampleExcel.xls",0, <span style="color: rgb(51, 51, 255);">false</span>, 5, System.Reflection.Missing.Value, System.Reflection.Missing.Value, <span style="color: rgb(51, 51, 255);">false</span>, System.Reflection.Missing.Value, System.Reflection.Missing.Value,<span style="color: rgb(51, 51, 255);">true</span>, <span style="color: rgb(51, 51, 255);">false</span>, System.Reflection.Missing.Value, <span style="color: rgb(51, 51, 255);">false</span>, <span style="color: rgb(51, 51, 255);">false</span>, <span style="color: rgb(51, 51, 255);">false</span>); <span style="color: rgb(51, 204, 0);">//Open the excel sheet</span></span></p> <span style=";font-family:arial;font-size:100%;" ><span style="font-family:georgia;"> 5. To read cell(s) in the worksheet,</span><br /><br /><span style=";font-family:courier new;font-size:85%;" > Excel.Sheets xlsheets=wb.Sheets; </span><span style="color: rgb(51, 204, 0);font-family:courier new;font-size:85%;" >//Get the sheets from workbook</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" > Excel.Worksheet excelWorksheet = (Excel.Worksheet)xlsheets[1]; </span><span style="color: rgb(51, 204, 0);font-family:courier new;font-size:85%;" >//Select the first sheet</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" > Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("B4:FZ4",Type.Missing); </span><span style="color: rgb(51, 204, 0);font-family:courier new;font-size:85%;" >//Select a range of cells</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" > Excel.Range excelCell2 = (Excel.Range)excelWorksheet.get_Range("A5:A5",Type.Missing); </span> <span style="color: rgb(51, 204, 0);font-family:courier new;font-size:85%;" >//Select a single cell</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" > Console.WriteLine(excelCell2.Cells.Value2.ToString()); </span><span style="color: rgb(51, 204, 0);font-family:courier new;font-size:85%;" >//Print the value of the cell for a single cell selection</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" > System.Array myvalues = (System.Array)excelCell.Cells.Value2; </span><span style="color: rgb(51, 204, 0);font-family:courier new;font-size:85%;" >//Assign it to an array</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" > string[] strArray = ConvertToStringArray(myvalues); </span><span style="color: rgb(51, 204, 0);font-family:courier new;font-size:85%;" >//Convert array into String array</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" > foreach (string str in strArray)</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" > Console.WriteLine(" Text in Cell " + str); </span><span style="color: rgb(51, 204, 0);font-family:courier new;font-size:85%;" >//Loop through the array to print the values in the cell</span></span><span style="color: rgb(51, 204, 0);font-family:courier new;font-size:85%;" > </span><span style="font-size:100%;"><br /><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/x/blogger/7529/2900/1600/901185/XL-Automation.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/7529/2900/400/558822/XL-Automation.jpg" alt="" border="0" /></a><br /><span style="font-family:Verdana;"> 6. To save a value in a cell</span><br /><span style=";font-family:Courier New,Courier,monospace;font-size:85%;" > excelCell2.Cells.Value2="SampleText"; <span style="color: rgb(51, 204, 0);">//Assign a value to the cell</span></span><span style=";font-family:courier new;font-size:85%;" > </span><span style=";font-family:Courier New,Courier,monospace;font-size:85%;" > <br />wb.Save(); <span style="color: rgb(51, 204, 0);">//Save the workbook</span></span><br /></span><span style="font-size:100%;"><br /><span style="font-family:Verdana;"> 7. Finally Quit the Excel Application</span><br /><span style=";font-family:Courier New,Courier,monospace;font-size:85%;" > xl.Quit();</span><br /></span>Thiaguhttp://www.blogger.com/profile/17888457107965047422noreply@blogger.com1tag:blogger.com,1999:blog-30721886.post-1152172048032807192006-07-06T00:41:00.000-07:002006-07-12T06:30:30.953-07:00Passing Data Between Forms - WinForms<span style="font-size:85%;"><span style="font-family:verdana;">Some of you would have faced a scenario where you wanted to pass data from one form to another in WinForms. Honestly, I too had a similar problem (that’s why I am writing this article!).<br /><br />There are so many methods (How many? I don’t know) to pass data between forms in windows application. In this article let me take four important (easiest) ways of accomplishing this.<br /></span><br /><br /></span><ol style="margin-top: 0in;" type="1"><li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style=";font-family:verdana;font-size:85%;" >Using constructor </span></li><li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style=";font-family:verdana;font-size:85%;" >Using objects </span></li><li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style=";font-family:verdana;font-size:85%;" >Using properties </span></li><li class="MsoNormal" style="margin: 0in 0in 0pt;"><span style=";font-family:verdana;font-size:85%;" >Using delegates</span></li></ol><br /><br /><h2 class="MsoNormal" style="margin: 0in 0in 0pt;">The Constructor Approach</h2><br /><br /><span style="font-family:Times New Roman;"></span><p class="MsoNormal" style="margin: 0in 0in 0pt;"><o:p><span style="font-family:Times New Roman;"><strong><span style="font-family:Times New Roman;"></span></strong></span></o:p></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-family:Times New Roman;"><span style="font-family:Times New Roman;"></span></span><span style=";font-family:verdana;font-size:85%;" >This could be the easiest method of all. A method is invoked whenever you instantiate an object. This method is called a constructor. Code a constructor for form2 class with one string parameter. In the constructor assign the text to the label’s text property. Instantiate form2 class in form1’s button click event handler using the constructor with one string parameter and pass the textbox’s text to the constructor.<br /></span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><br /><br /></p><span style="font-family:Times New Roman;"><p class="MsoNormal" style="margin: 0in 0in 0pt;"><o:p><span style="font-family:Times New Roman;"></span></o:p></p></span><h2 class="MsoNormal" style="margin: 0in 0in 0pt;">The Object Approach</h2><br /><br /><span style="font-family:Times New Roman;"><span style="font-size:100%;"></span></span><p class="MsoNormal" style="margin: 0in 0in 0pt;"><o:p><span style="font-family:Times New Roman;"><span style="font-size:100%;"><strong><span style=";font-family:Times New Roman;font-size:100%;" ></span></strong></span></span></o:p></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-family:Times New Roman;"><span style="font-size:100%;"><span style="font-size:100%;"><span style="font-family:Times New Roman;"><span style="font-size:0;"><strong></strong></span></span></span></span></span><span style=";font-family:verdana;font-size:85%;" >Objects are reference types, and are created on the heap, using the keyword new. Here we are going to pass data using objects. The approach is simple; in form2 we are going to instantiate form1 class. Then instantiate form2 in the button click event handler of form1. After this we are going to pass form1 object to the form2 using form2’s form1 object. The last step is to invoke the form2 window by calling the form2’s show method. </span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style=";font-family:verdana;font-size:85%;" ><br /></span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><br /></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/7529/2900/1600/PassData.3.jpg"></a><img style="margin: 0px auto 10px; display: block; text-align: center;" alt="" src="http://photos1.blogger.com/blogger/7529/2900/320/PassData.3.jpg" border="0" /><br /><br /></p><h2 class="MsoNormal" style="margin: 0in 0in 0pt;">The Properties Approach</h2><br /><o:p></o:p><o:p></o:p><strong></strong><span style="font-family:Times New Roman;"></span><span style="font-size:78%;"><span style=";font-family:verdana;font-size:85%;" >Properties allow clients to access class state as if they were accessing member fields directly, while actually implementing that access through a class method. In this method we are going to add one property to each form. In form1 we are going to use one property for retrieving value from the textbox and in form2, one property to set the label’s text property. Then, in form1’s button click event handler we are going to instantiate form2 and use the form2’s property to set the label’s text.</span><br /><br /><br /></span><h2 class="MsoNormal" style="margin: 0in 0in 0pt;">The Delegates Approach</h2><br /><br /><o:p></o:p><span style="font-size:100%;"></span><o:p></o:p><span style="font-size:100%;"><strong></strong></span><span style=";font-family:Times New Roman;font-size:100%;" ></span><strong></strong><span style=";font-family:verdana;font-size:85%;" >Technically, a delegate is a reference type used to encapsulate a method with a specific signature and return type. You can encapsulate any matching method in that delegate. Here we are going to create a delegate with some signature and assign a function to the delegate to assign the text from textbox to label.</span> <p class="MsoNormal" style="margin: 0in 0in 0pt;"><br /><br /></p><h2 class="MsoNormal" style="margin: 0in 0in 0pt;">Winding up...</h2><br /><br /><span style="font-size:100%;"></span><span style="font-size:100%;"></span><p class="MsoNormal" style="margin: 0in 0in 0pt;" align="left"><span style=";font-family:verdana;font-size:85%;" >These four approaches are very simple in implementing data passing between forms. There are also other methods available in accomplishing the same. Source code for the methods I stated above is given at the top for download. It is time for you to put your thinking cap and find other ways of doing this. Happy Coding!!!</span><br /></p><p class="MsoNormal" style="margin: 0in 0in 0pt;" align="left"><br /><a href="http://www.codeproject.com/useritems/pass_data_between_forms.asp"><span style=";font-family:verdana;font-size:78%;" >For source code and further reading...</span></a><br /></p><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style=";font-family:'Times New Roman';font-size:12;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="font-size:0;"></span><span style="font-size:0;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="font-size:0;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="font-size:0;"></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;color:blue;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="color:blue;"></span><span style="color:blue;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style="font-size:0;"></span><span style=";font-family:'Courier New';font-size:10;" ></span><span style=";font-family:'Courier New';font-size:10;" ><span style=";font-family:'Courier New';font-size:10;" ><span style="font-size:0;"><pre class="MsoNormal" style="margin: 0in 0in 0pt;" lang="cs"><span style=";font-family:'Courier New';font-size:10;" ><span style="font-size:0;"><span style=";font-family:'Courier New';font-size:10;" ><span style="font-size:0;"><span style=";font-family:'Courier New';font-size:10;" ><span style="font-size:0;"><span style=";font-family:'Courier New';font-size:10;" ><span style="font-size:0;"><br /><br /><span style="color:blue;"><span style="color:blue;"><span style="color:blue;"><span style="font-size:0;"></span></span></span></span></span></span></span></span></span></span></span></span></pre></span></span></span>Thiaguhttp://www.blogger.com/profile/17888457107965047422noreply@blogger.com2