Thursday 6 February 2014

Write text on a image C#

 Write text on an image c# code:



 FileStream fs = new FileStream(@"d:\certificate.jpg", FileMode.Open, FileAccess.Read);
            System.Drawing.Image image = System.Drawing.Image.FromStream(fs);
            fs.Close();

            Bitmap b = new Bitmap(image);
            Graphics graphics = Graphics.FromImage(b);


            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;

            SizeF s = graphics.MeasureString("[The Employee Name]", new Font("Thaoma", 70, FontStyle.Bold));
            RectangleF rectf = new RectangleF(950, 1450, 1200, 150);
            float fontScale = Math.Max(s.Width / rectf.Width, s.Height / rectf.Height);

            // graphics.DrawString("[The Employee Name]", new Font("Thaoma", 70, FontStyle.Bold), Brushes.Black, 1000, 1450, sf);

            using (Font font = new Font("Thaoma", 70 / fontScale, GraphicsUnit.Point))
            {
                //Employee Name
                graphics.DrawString("[The Employee Name]", new Font("Thaoma", 70, FontStyle.Bold), Brushes.Black, rectf, sf);

            }
            graphics.DrawString("01/01/2014", new Font("Thaoma", 45), Brushes.Black, 1200, 2100);//Date
            graphics.DrawString("My Office", new Font("Thaoma", 45), Brushes.Black, 1200, 2300);//Held at

            b.Save(@"d:\certificate1.jpg", image.RawFormat);

            image.Dispose();
            b.Dispose();
:) Enjoy

Friday 20 December 2013

How to calculate the total number of created objects for a particular class in C#/C++?

How do you calculate the total number of created objects for a particular class in C#/C++?


This could be one of the question to in any technical interview. So what is the solution??

suppose think that you have a class abc.

class abc
{
  int x=10;
  Console.WriteLine(a);
}

now if you create the object of the class:
abc a1=new abc();
abc a2=new abc();

now the total number of objects are 2. But how do you calculate it programatically??
Below is the solution:

class mainClass
    {
        static void Main(string[] args)
        {
            abc a1 = new abc();
            abc a2 = new abc();
            abc a3 = new abc();
            abc a4 = new abc();
            abc a5 = new abc();
            abc a6 = new abc();
            Console.WriteLine(abc.count);

        }
    }
    class abc
    {
        public static int count = 0;
        public abc()
        {
            count++;
        }
    }
Output:
6

Hope it helped you :)

Saturday 2 November 2013

how to select nth row in sql server without using row_number() and without using order by?

how to select nth row in sql server without using row_number() and without using order by??
Also without using cursors.(cursor can be one of the solution, but it decreases the performance when there are lacs of records.)

 

 

Solution:

 

declare @NewId bigint,@NewFname varchar(20),@NewLname varchar(20),@NewSalary money   select top 5 @NewId =eid,@NewFname = fname @NewLname=lname,@NewSalary=salary from Tbl_Emp_Detail   select @NewId ,@NewFname,@NewLname,@NewSalary

 

OR

declare @NewId bigint   select top 5 @NewId=eid from Tbl_Emp_Deatail   select * from Tbl_Emp_Detail where eid=@NewId

 

 

Here replace top 5 by top 'n' 

view my answer in codeproject.com

thank you :)

Saturday 6 July 2013

Seminar Topics for Computer Science/ Information Science 2013


1. ICAPTCHA: The next generation of captcha designed to defend against 3rd party human attacks
2. Skinput: Appropriating the skin as an interactive canvas
3. Analysis of the handover latency components in Mobile IPv6
4. Tesla Touch: Electrovibration for touch surfaces
5. Brain tumors: An engineering perspective
6. An ant colony optimization Algorithm for Multiple Traveling Salesman Problem
7. Smart card security;technology and adoption
8. Web based tunneling
9. Driver fatigue detection using drowsy eye detection.
10. Intelligent personal assistant for time and task management
11. A medical mirror for non contact health monitoring
12. Web Testing: Tool, Challenges and Methods
13. Intel Multi-CORE processors, Quad core
14. MAgeLan- AMulti-Agent system for monitoring a hyper encyclopedia
15. Innovative way of internet voting: Secure Online Vote
16. Cloud computing and its application in the world of networking
17. Securing Bluetooth connections
18. Mobile Cloud Computing (download MCC ieee paper here)
19. 3D password: Asecure authentication
20. Virtual Keyboard
21. SQL Injection: A hazard to Web apps
22. Green Computing
23. 5G- the future network
24. Graphical password for authentication
25. Speaker Recognition
26. USB to USB data transfer without PC
27. Mobile based remote database access using web services
28. Rainbow technology decidedly Nurtures Storage Trends
29. Mobile Number Portability (MNP): Challenges and Solutions


Saturday 11 May 2013

Remove Pendrive Shortcut Virus without Antivirus

Have messed up with the problem where your pendrive has only shortcuts of all the folders or 

you can see only one shortcut of your pendrive and there is no data when you open your pendrive , even though it shows the memory occupied,  when you see its properties ???

Then here is the solution for this virus without having an Antivirus.. :)
Step 1:
 Download Autorun Exterminator

Extract ithe zipped file, double click on "AutorunExterminator" then Plug your pendrive now.
This will remove the autorun.inf files from drives.

Step2:
Click on "Start">Run >type cmd and click on OK.

Here I assume your pen drive letter as F: 

Enter this command.

attrib -h -r -s /s /d f:\*.*

You can copy the above command.  Right-click in the Command Prompt and paste it. 

Note : Don't forget to replace the letter f with your pen drive letter. 

Now press "Enter". That’s it!!!!
Now check for your files and folder in Pen Drive.

If there are any Shortcut folders, just delete them. you wont loose any data.

:)