Friday, June 19, 2009

Wednesday, June 17, 2009

என் முதல் கவிதை (En mudal kavidai)

1.என்னை மறந்த என் உயிருக்கு ,
நான் மறைந்தால்தான் புரியும்,
என்னை பிரிந்தாய் என்று

இப்படிக்கு இறந்து
வாழும் உடல் ........(பினம்)


Enai maranda en uieruku,
Nan maraindal dan poorium,
Enai perindai endru.

Epadiku erandhu
vazhum udal........(penam)

_______________________

2. என் காதலை காயப்படுத்திய கள்ளி,
என் காதலி........

En Kadalai Kayapaduthiya Kalli
En Kadhali...................
_______________________

3. காதலிக்க தெரிந்த உனக்கு,
என்னை காப்பாற்ற தெரியவில்லை .
இப்படிக்கு கண்ணீருடன்
காதல்.............


Kadalika tharindha unaku,
Enai kapatra thariyavilai.
Epadiku kanerudan
kadhal.................

_______________________

4. உயிர் தோழி

துலைந்து போனாய் , தோழி யானாய்
துவண்டு நின்றேன் - நான்.

Uieer thozhi

Thulaindhu ponai, thozhi aanai
thuvandu nenran - naan.
_______________________

5. பிரிந்த உயிர்

முன்,.......
உயிரென நினைத்தேன்,
உணர்வுடன் கலந்தாய்.

மறந்து வாழ நினைதாய்,
மறக்க மணம் இல்லை.

மருத்து என்னை மறந்தாய்,
மறைந்து உன்னை மன்னித்தேன்.

பின்,.........
இணைந்து வாழ நினைதாய்,
இனைய உயிர் இல்லை.

கல்லறைக்கு வந்தாய்,
கண்ணீருடன் நின்றாய்.

கல்லுக்குள் இருந்தென்,
கல்மனதோடு சென்றாய்.


peerindha uier

Mun,.......
uierena nenaithan,
unarvudan kalandhai.

marandhu vazha nenaithai,
maraka manum ellai.

maruthu ennai marandhai,
maraindhu unnai mannithen.

pin,.........
enaindhu vazha nenaithai,
enaiya uier illai.

kallaraiku vandhai,
kanneerudan ninrai.

kallukkul irundhan,
kallmanadhodu sendrai.

Tuesday, June 16, 2009

XML Serialization and DeSerialization

Ref :- http://sharpertutorials.com/serialization/

// these lines do the actual serialization
XmlSerializer mySerializer = new XmlSerializer(typeof(myTestClass));
StreamWriter myWriter = new StreamWriter("c:/myTestClass.xml");
mySerializer.Serialize(myWriter, test);
myWriter.Close();

Output:-

version="1.0" encoding="utf-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>
Hello World>

>1234>
>
>qwerty>
>asdfgh>
>zxcvbn>
>123456>
>
>

//deserialization

myTestClass test;

XmlSerializer mySerializer = new XmlSerializer(typeof(myTestClass));
FileStream myFileStream = new FileStream("c:/mtTestClass.xml",FileMode.Open);

test = (myTestClass)mySerializer.Deserialize(myFileStream);

Sunday, June 14, 2009

XML parsing

commands in the visual studio command prompt

convert xml to XSD

D:\Test>xsd sample.xml


convert xsd to class file

D:\Test>xsd sample.xsd /classes

using these classes, assign values in the code and do xml serialization to get a orginal xml file

Thursday, May 28, 2009

check date is valid javascript

function isDate(dateStr) {
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
alert(”Please enter your birth date as dd/mm/yyyy. Your current selection reads: ” + dateStr);
return false;
}

day = matchArray[1]; // p@rse date into variables
month = matchArray[3];
year = matchArray[5];

if (month <> 12) { // check month range
alert(”Month must be between 1 and 12.”);
return false;
}

if (day <> 31) {
alert(”Day must be between 1 and 31.”);
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert(”Month “+month+” doesn`t have 31 days!”);
return false;
}

if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap)) {
alert(”February ” + year + ” doesn`t have ” + day + ” days!”);
return false;
}
}
return true; // date is valid
}

function checkForValidDate(){
var ddlVMonth = document.getElementById(”_ctl0_DropDownListMaanden”);
var ddlVDay = document.getElementById(”_ctl0_DropDownListDagen”);
var ddlVYear = document.getElementById(”_ctl0_DropDownListJaren”);

if (!isDate(ddlVDay.value + ‘/’ + ddlVMonth.value + ‘/’ + ddlVYear.value))
{ return(false); }

return(true);
}

Tuesday, May 19, 2009

Run Commands in Windows

Do you use the Run feature in Windows XP? For most, this feature remains unused (or rarely used). Why is that? Well, first off nearly all of the Run Commands Correspond to a particular Control Panel Item or a Utility, Tool or Task that can be accessed through Windows.

Here is the list of different Run command. To access go to run (Win + R )

  • Accessibility Controls : access.cpl
  • Accessibility Wizard : accwiz
  • Add Hardware Wizard : hdwwiz.cpl
  • Add/Remove Programs : appwiz.cpl
  • Administrative Tools control : admintools
  • Adobe Acrobat (if installed) : acrobat
  • Adobe Designer (if installed) : acrodist
  • Adobe Distiller (if installed) : acrodist
  • Adobe ImageReady (if installed) : imageready
  • Adobe Photoshop (if installed) : photoshop
  • Automatic Updates : wuaucpl.cpl
  • Bluetooth Transfer Wizard : fsquirt
  • Calculator : calc
  • Certificate Manager : certmgr.msc
  • Character Map : charmap
  • Check Disk Utility : chkdsk
  • Clipboard Viewer : clipbrd
  • Command Prompt : cmd
  • Component Services : dcomcnfg
  • Computer Management : compmgmt.msc
  • Control Panel : control
  • Date and Time Properties : timedate.cpl
  • DDE Shares : ddeshare
  • Device Manager : devmgmt.msc
  • Direct X Control Panel (If Installed)* : directx.cpl
  • Direct X Troubleshooter : dxdiag
  • Disk Cleanup Utility : cleanmgr
  • Disk Defragment : dfrg.msc
  • Disk Management : diskmgmt.msc
  • Disk Partition Manager : diskpart
  • Display Properties control : desktop
  • Display Properties : desk.cpl
  • Display Properties (w/Appearance Tab Preselected) control : color
  • Dr. Watson System Troubleshooting Utility : drwtsn32
  • Driver Verifier Utility : verifier
  • Event Viewer : eventvwr.msc
  • Files and Settings Transfer Tool : migwiz
  • File Signature Verification Tool : sigverif
  • Findfast : findfast.cpl
  • Firefox (if installed) : firefox
  • Folders Properties control : folders
  • Fonts control : fonts
  • Fonts Folder : fonts
  • Free Cell Card Game : freecell
  • Game Controllers : joy.cpl
  • Group Policy Editor (XP Prof) : gpedit.msc
  • Hearts Card Game : mshearts
  • Help and Support : helpctr
  • HyperTerminal : hypertrm
  • Iexpress Wizard : iexpress
  • Indexing Service : ciadv.msc
  • Internet Connection Wizard : icwconn1
  • Internet Explorer : iexplore
  • Internet Properties : inetcpl.cpl
  • Internet Setup Wizard : inetwiz
  • IP Configuration (Display Connection Configuration) : ipconfig /all
  • IP Configuration (Display DNS Cache Contents) : ipconfig /displaydns
  • IP Configuration (Delete DNS Cache Contents) : ipconfig /flushdns
  • IP Configuration (Release All Connections) : ipconfig /release
  • IP Configuration (Renew All Connections) : ipconfig /renew
  • IP Configuration (Refreshes DHCP & Re-Registers DNS) : ipconfig /registerdns
  • IP Configuration (Display DHCP Class ID) : ipconfig /showclassid
  • IP Configuration (Modifies DHCP Class ID) : ipconfig /setclassid
  • Java Control Panel (If Installed) : jpicpl32.cpl
  • Java Control Panel (If Installed) : javaws
  • Keyboard Properties control : keyboard
  • Local Security Settings : secpol.msc
  • Local Users and Groups : lusrmgr.msc
  • Logs You Out Of Windows : logoff
  • Malicious Software Removal Tool : mrt
  • Microsoft Access (if installed) : access.cpl
  • Microsoft Chat : winchat
  • Microsoft Excel (if installed) : excel
  • Microsoft Frontpage (if installed) : frontpg
  • Microsoft Movie Maker : moviemk
  • Microsoft Paint : mspaint
  • Microsoft Powerpoint (if installed) : powerpnt
  • Microsoft Word (if installed) : winword
  • Microsoft Syncronization Tool : mobsync
  • Minesweeper Game : winmine
  • Mouse Properties control : mouse
  • Mouse Properties : main.cpl
  • Nero (if installed) : nero
  • Netmeeting : conf
  • Network Connections control : netconnections
  • Network Connections : ncpa.cpl
  • Network Setup Wizard : netsetup.cpl
  • Notepad : notepad
  • Nview Desktop Manager (If Installed) : nvtuicpl.cpl
  • Object Packager : packager
  • ODBC Data Source Administrator : odbccp32.cpl
  • On Screen Keyboard : osk
  • Opens AC3 Filter (If Installed) : ac3filter.cpl
  • Outlook Express : msimn
  • Paint : pbrush
  • Password Properties : password.cpl
  • Performance Monitor : perfmon.msc
  • Performance Monitor : perfmon
  • Phone and Modem Options : telephon.cpl
  • Phone Dialer : dialer
  • Pinball Game : pinball
  • Power Configuration : powercfg.cpl
  • Printers and Faxes control : printers
  • Printers Folder : printers
  • Private Character Editor : eudcedit
  • Quicktime (If Installed) : QuickTime.cpl
  • Quicktime Player (if installed) : quicktimeplayer
  • Real Player (if installed) : realplay
  • Regional Settings : intl.cpl
  • Registry Editor : regedit
  • Registry Editor : regedit32
  • Remote Access Phonebook : rasphone
  • Remote Desktop : mstsc
  • Removable Storage : ntmsmgr.msc
  • Removable Storage Operator Requests : ntmsoprq.msc
  • Resultant Set of Policy (XP Prof) : rsop.msc
  • Scanners and Cameras : sticpl.cpl
  • Scheduled Tasks control : schedtasks
  • Security Center : wscui.cpl
  • Services : services.msc
  • Shared Folders : fsmgmt.msc
  • Shuts Down Windows : shutdown
  • Sounds and Audio : mmsys.cpl
  • Spider Solitare Card Game : spider
  • SQL Client Configuration : cliconfg
  • System Configuration Editor : sysedit
  • System Configuration Utility : msconfig
  • System File Checker Utility (Scan Immediately) : sfc /scannow
  • System File Checker Utility (Scan Once At Next Boot) : sfc /scanonce
  • System File Checker Utility (Scan On Every Boot) : sfc /scanboot
  • System File Checker Utility (Return to Default Setting) : sfc /revert
  • System File Checker Utility (Purge File Cache) : sfc /purgecache
  • System File Checker Utility (Set Cache Size to size x) : sfc /cachesize=x
  • System Information : msinfo32
  • System Properties : sysdm.cpl
  • Task Manager : taskmgr
  • TCP Tester : tcptest
  • Telnet Client : telnet
  • Tweak UI (if installed) : tweakui
  • User Account Management : nusrmgr.cpl
  • Utility Manager : utilman
  • Windows Address Book : wab
  • Windows Address Book Import Utility : wabmig
  • Windows Backup Utility (if installed) : ntbackup
  • Windows Explorer : explorer
  • Windows Firewall : firewall.cpl
  • Windows Magnifier : magnify
  • Windows Management Infrastructure : wmimgmt.msc
  • Windows Media Player : wmplayer
  • Windows Messenger : msmsgs
  • Windows Picture Import Wizard (need camera connected) : wiaacmgr
  • Windows System Security Tool : syskey
  • Windows Update Launches : wupdmgr
  • Windows Version (to show which version of windows) : winver
  • Windows XP Tour Wizard : tourstart
  • Wordpad : write

Monday, May 18, 2009

Abstract Class and interface

Ref :- http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx

What is an Abstract Class?

An abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.

What is an Interface?

An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn�t support multiple inheritance, interfaces are used to implement multiple inheritance.


Abstract Class Employee

using System;

namespace AbstractsANDInterfaces
{
///


/// Summary description for Employee.

///


public abstract class Employee
{
//we can have fields and properties


//in the Abstract class

protected String id;
protected String lname;
protected String fname;

//properties


public abstract String ID
{
get;
set;
}

public abstract String FirstName
{
get;
set;
}

public abstract String LastName
{
get;
set;
}
//completed methods


public String Update()
{
return "Employee " + id + " " +
lname + " " + fname +
" updated";
}
//completed methods


public String Add()
{
return "Employee " + id + " " +
lname + " " + fname +
" added";
}
//completed methods


public String Delete()
{
return "Employee " + id + " " +
lname + " " + fname +
" deleted";
}
//completed methods


public String Search()
{
return "Employee " + id + " " +
lname + " " + fname +
" found";
}

//abstract method that is different


//from Fulltime and Contractor

//therefore i keep it uncompleted and

//let each implementation

//complete it the way they calculate the wage.


public abstract String CalculateWage();

}
}

For remaining please refer the below link
http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx

Tuesday, April 21, 2009

ResizeImage From source path to destination path

public void ResizeImage(string sourFilePath, int MaxSideSize, string destFilePath)
{
System.Drawing.Image imgInput = System.Drawing.Image.FromFile(sourFilePath);
int intNewWidth;
int intNewHeight;

//Determine image format
ImageFormat fmtImageFormat = imgInput.RawFormat;

//get image original width and height
int intOldWidth = imgInput.Width;
int intOldHeight = imgInput.Height;

//determine if landscape or portrait
int intMaxSide;

if (intOldWidth >= intOldHeight)
{
intMaxSide = intOldWidth;
}
else
{
intMaxSide = intOldHeight;
}
if (intMaxSide > MaxSideSize)
{
//set new width and height
double dblCoef = MaxSideSize / (double)intMaxSide;
intNewWidth = Convert.ToInt32(dblCoef * intOldWidth);
intNewHeight = Convert.ToInt32(dblCoef * intOldHeight);
}
else
{
intNewWidth = intOldWidth;
intNewHeight = intOldHeight;
}
//create new bitmap
Bitmap bmpResized = new Bitmap(imgInput, intNewWidth, intNewHeight);

bmpResized.Save(destFilePath, ImageFormat.Jpeg);
}

Extract Zip file

using java.util;
using java.util.zip;
using java.io;

private void Extract(string zipFileNamePath, string destinationPath)
{
ZipFile zipfile = new ZipFile(zipFileNamePath);
List zipFiles = GetZipFiles(zipfile);

foreach (ZipEntry zipFile in zipFiles)
{
if (!zipFile.isDirectory())
{
InputStream s = zipfile.getInputStream(zipFile);
try
{
Directory.CreateDirectory(destinationPath + "\\");
FileOutputStream dest = new FileOutputStream(Path.Combine(destinationPath + "\\", Path.GetFileName(zipFile.getName())));
try
{
int len = 0;
sbyte[] buffer = new sbyte[8000];
while ((len = s.read(buffer)) >= 0)
{
dest.write(buffer, 0, len);
}
}
catch (Exception ex)
{
dest.close();
s.close();
}
finally
{
dest.close();
}
dest.close();
}
catch (Exception ex)
{
s.close();
}
finally
{
s.close();
}
s.close();
}
}
zipfile.close();
}

Wednesday, January 7, 2009

Switch ON and OFF the monitor

How to turn off your monitor via code?
This is an important question at least to me , because I use my computer for long time daily and frequently turn on and off the screen as a way to save energy and power .
I hate to make that by using the monitor button(off/on) , because I hear sound from the monitor feel me that the screen may damage .
So I will inform you here , How to turn off your monitor via code ( C# ) ?

I will code that depending in API called SendMessage function it’s useful to handle monitor states - the display is going to low power, the display is being shut off and the display is turned on .

Syntax :
LRESULT SendMessage( HWND hWnd, UINT Msg,WPARAM wParam, LPARAM lParam );


Parameters:
  • # HWnd (first paramter)
    Handle to the window whose window procedure will receive the message. If you don't want to bother creating a window to send the message to, you can send the message to all top level windows (HWND_BROADCAST) or you can use GetDesktopWindow function sending the message to the desktop window.
  • # Msg (second paramter)
    Specifies the message to be sent (WM_SYSCOMMAND).
  • # wParam(Third paramter)
    Specifies additional message-specific information (SC_MONITORPOWER).
  • # LParam (last paramter)
    * 1 - the display is going to low power.
    * 2 - the display is being shut off.
    * –1 - the display is being turned on (undocumented value).

Start the coding now :

First of all you should use
using System.Runtime.InteropServices; //to DllImport

public int WM_SYSCOMMAND = 0x0112;
public int SC_MONITORPOWER = 0xF170; //Using the system pre-defined MSDN constants that can be used by the SendMessage() function .


[DllImport("user32.dll")]
private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
//To call a DLL function from C#, you must provide this declaration .


private void button1_Click(object sender, System.EventArgs e)
{

SendMessage( this.Handle.ToInt32() , WM_SYSCOMMAND , SC_MONITORPOWER ,2 );//DLL function
}

Ref:- http://fci-h.blogspot.com/2007/03/turn-off-your-monitor-via-code-c.html