Friday, 7 October 2011

Waterfox Lite1.0

Waterfox lite 1.0:

                      Waterfox Lite1.0 is the lightweight web browser.This article explains its features and development.IE may not the most preferable, because of its compatibility and its appearance(less space for viewing web pages due to Add-ons).So ,it may be an unwanted application which you  always  do not want to run. To solve this issue, I have developed an application using Visual Studio 2010 which inherits the working nature of IE and presents IE in new style and new way.



Settings window

Overall design


Features of Waterfox:

1.It is Multi-tabbed and takes very low memory.
2.Extended from the internet Explorer.
3.Provides Screen to view the web pages,unlike IE.
4.URL suggestion Enabled
5.No Add-ons management (Inherits from IE)

Download Waterfox Lite1.0.exe
Download Project file

Friday, 1 July 2011

Screener- Capture Desktop as Image

SCREENER


                              This is the detailed article lets you to design Desktop application(Screener)  for capturing Desktop as Image just like Print Screen key .Before someday, i just tried to develop such application like this and search for code everywhere, But that was very large and difficult to understand. So, i want to develop my own and simple code that capture desktop .Finally i developed this simple coding.
Fig-Sample Form

Before Proceed, Try this....

1.Download Source Code
2.Download Installation File(Executable)

Design:

1.Open the Visual Studio
2.Goto File--->New Project
3.Expand   Visual C# Node
4.Select Windows Form Application
5.Name the Project
6. Design the Form as shown in Fig-Sample Form and add
   SaveFileDialog Control from Toolbox.

From Fig-Sample Form
Capture Screen Button ---> Capture Entire Screen.
Select Screen Button  ----> Lets you to select part of screen.
Tick Button                ----> Exit Application


7. Goto solution Explorer in Right side Visual Studio (If it is not
    Shown Press Ctrl+Alt+L
8. Right Click on Project Click Add-->  new item and Expand visual C# node and choose Windows Form
9. Click Add Button at Bottom, to Add to project.
10. Now, In Solution Explorer, Search for Form named "Form2" and Add SaveFileDialog
11. Set the Form2 Properties as shown below..

Fig; Form2 Propertie
Coding:
                      Main Concept behind this coding is to draw the rectangle on Screen and convert selected rectangle part as Bitmap image

1.Capture Entire Screen (In Form1)

//Behind Capture screen Button
    System.Threading.Thread.Sleep(250);// to hide this form1
    Rectangle r=  Screen.PrimaryScreen.Bounds;// Cature Entire Screen as Rectangle
    Bitmap target = new Bitmap(r.Width, r.Height);//Create bitmap blank Image with size
    using (Graphics g = Graphics.FromImage(target))
      {
    //Copyimage to bitmap
    g.CopyFromScreen(0,0,0, 0, new Size(screenSize.Width,screenSize.Height));                 
      }
                 
   //Save file to specified Location with file formate
    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
       target.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
     }
//Behind Select Screen Button
                         Form2 f2=new From2();                      
                         f2.Show();
              this.Hide();


2.Capture User Defined Screen (In Form 2)


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form2 : Form
    {
        Rectangle rect;
        Point start;
        Form1 f1 = new Form1();
        public Form2()
        {
//Initialize these Events
            InitializeComponent();
            this.Cursor = System.Windows.Forms.Cursors.Cross;
            this.MouseDown += new MouseEventHandler(mouse_Click);
            this.MouseUp += new MouseEventHandler(mouse_Up);
            this.MouseMove += new MouseEventHandler(mouse_Move);
            this.Paint += new PaintEventHandler(draw);

            this.DoubleBuffered = true; // For Avoid Flickering

       
        }

//Set mouse Click point as Starting Point
        private void mouse_Click(object sender, MouseEventArgs e)
        {
           start= new Point(e.X, e.Y);
  
        }
//Set the Co-ordinates for rectangle While cursor moving
        private void mouse_Move(object sender, MouseEventArgs e)
        {
               if (e.Button == MouseButtons.Left) //check Left mousebutton pressed
                {
              //Calculate height and width of rectangle
                int width = Math.Abs(start.X - Cursor.Position.X);
                int height = Math.Abs(start.Y - Cursor.Position.Y);

// Set the Co-ordinates of Rectangle As Per Mouse Move Direction

                if (Cursor.Position.X < start.X && Cursor.Position.Y<start.Y)
                {
                   rect = new Rectangle(Cursor.Position.X, Cursor.Position.Y, width, height);
                }
                else if (Cursor.Position.X < start.X && Cursor.Position.Y > start.Y)
                {
                   rect = new Rectangle(Cursor.Position.X, start.Y, width, height);

                }
                else if (Cursor.Position.X > start.X && Cursor.Position.Y > start.Y)
                {
                   rect = new Rectangle(start.X, start.Y, width, height);
                }
                else if (Cursor.Position.X > start.X && Cursor.Position.Y < start.Y)
                {
                   rect = new Rectangle(start.X, Cursor.Position.Y, width, height);
                   
                }
            }
              this.Invalidate(); //Draw single rectangle
               
         }

//Draw and display rectangle on Screen or Form2
        private void draw(object sender, PaintEventArgs e)
        {
          using (Pen pen = new Pen(Color.FloralWhite, 2))
            {
                e.Graphics.DrawRectangle(pen, rect);
                e.Graphics.FillRectangle(new SolidBrush(Color.FloralWhite), rect);
            }
        }

//Raised when user finished Screen slection

        private void mouse_Up(object sender, MouseEventArgs e)
        {
             Rectangle screenSize = rect;
             Bitmap target = new Bitmap(screenSize.Width, screenSize.Height);
        using (Graphics g = Graphics.FromImage(target))
        {

    g.CopyFromScreen(start,Point.Empty,new Size(screenSize.Width, screenSize.Height));

         }
        if (saveFileDialog1.ShowDialog() == DialogResult.OK)
        {
    target.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp);         
        }
             
              f1.Show();
              this.Hide();
  
        }
   

    }
}

Sunday, 26 June 2011

Play Football in Bed Room-XNA Game Studio

Fantastic Football-2D 

   
             It is a simple 2D game which renders images in gaming windows. To do this, take snap of your bed room and image file of football. 
You may wounder about the tittle itself why i have suited this tittle, it is all for attracting . However, this article guides you to how to develop your own games in  .NET Platform. if you have  experience in windows application and web based application (ASP.Net), you just need to learn little bit more to develop game. By my experience, Unlike windows based and web application, XNA does not provide user interface in Compile time (Form Designing phase) Because game is fully graphical dependent.Here,you need somewhat mathematical  knowledge in Trigonometric , Statistics and Game Logic.

Before starting, you have to prepare your system for game Development Environment by  installing  XNA game Studio.

What is XNA game Studio ?
      
                    XNA Game Studio and the XNA Framework are designed for cross-platform gaming scenarios with support for Windows Phone 7, Xbox 360, and Windows-based PCs. This allows you to target more platforms from the same code base. It also allows developers to focus game design for each platform on real device differences such as the device capabilities and experience, as opposed to writing with different frameworks for each targeted device.
  1. Download and Install XNA game studio from here
  2. Download Application File
  3. Download Project file 



Part I - Basic Settings:

  • As usual goto file--> New Project
  • Expand  visual C# Node, select XNA game studio and Name the Default Assemblies


             After creating a new project, you'll be presented with the code view of your game.



Part II - View of code:

             Some of the hard work has already been done for you. If you build and run your game now, the GraphicsDeviceManager will set up your screen size and render a blank screen. Your game will run and update all by itself. It's up to you to insert your own code to make the game more interesting.

Much of the code to start and run your game has already been written for you. You can insert your own code now.
These are the five methods allows you to code and run the game
  • The Initialize method is where you can initialize any assets that do not require a GraphicsDevice to be initialized.
  • The LoadContent method is where you load any necessary game assets such as models and textures.
  • The UnloadContent method is where any game assets can be released. Generally, no extra code is required here, as assets will be released automatically when they are no longer needed.
  • The Update loop is the best place to update your game logic: move objects around, take player input, decide the outcome of collisions between objects, and so on.
  • The Draw loop is the best place to render all of your objects and backgrounds on the screen.

  Part III - ADD Sprite

                    The next step is to add a graphic that can be drawn on the screen. Use a small graphics file, such as a small .bmp or .jpg file. Be creative—you can even make your own. You can even skip ahead a bit and make a sprite that "hides" parts that should not be seen (such as edges or corners) so that it looks even better.



  1. Make sure you can see the Solution Explorer for your project on the right side of the window. If you cannot see it, click the View menu, and then click Solution Explorer.
  2. Right-click the Content node, click Add, click Existing Item, and then browse to your graphic.
  3. If you can't see any files, make sure you change the Files of type selection box to read Texture Files
  4.  Click the graphic file, and then click Add.  
      5.  If the Properties window is not visible, press F4, or click the View menu, and then click
            Properties Window.

 Like above Add Bed Room  image file and football image to content folder.



Part IV -Update Code

Now Initialize these variables...


        Texture2D mytex,bgr,mou; //these varible for background,football and Cursor
       
        Vector2 sposition = Vector2.Zero;
        Vector2 text = new Vector2(680, 10);
        Vector2 gameover = new Vector2(200, 200);
        Vector2 gameover1 = new Vector2(230, 250);
        Vector2 spriteSpeed = new Vector2(0f, 10f);
        Vector2 mpos = Vector2.Zero;

        Vector2 origin;
        Vector2 screenpos;
        float RotationAngle;

        GraphicsDevice device;
        MouseState mouseStateCurrent;
        SpriteFont fnt,gover;


Update  "protected override void LoadContent() " method by adding...

            device = graphics.GraphicsDevice;
            spriteBatch = new SpriteBatch(GraphicsDevice);
            mytex = Content.Load<Texture2D>("fb");
            bgr = Content.Load <Texture2D>( "bg");
            mou = Content.Load<Texture2D>("pon");
            fnt = Content.Load<SpriteFont>("Arial");
            gover = Content.Load<SpriteFont>("over");


            Viewport viewport = graphics.GraphicsDevice.Viewport;
            origin.X = mytex.Width / 2;
            origin.Y = mytex.Height / 2;
            screenpos.X = viewport.Width / 2;
            screenpos.Y = viewport.Height / 2;


update "protected override void Draw(GameTime gameTime)" by adding..

            int screenWidth;
            int screenHeight;

            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            // TODO: Add your drawing code here
            spriteBatch.Begin();
           
            screenWidth = device.PresentationParameters.BackBufferWidth;
            screenHeight = device.PresentationParameters.BackBufferHeight;
            Rectangle screenRectangle = new Rectangle(0,0, screenWidth, screenHeight);
            spriteBatch.Draw(bgr, screenRectangle, Color.White);

            spriteBatch.Draw(mytex, sposition,null,    
            Color.White,RotationAngle,origin,0.5f,SpriteEffects.FlipHorizontally,1f);
            spriteBatch.Draw(mou,mpos,Color.White);
            spriteBatch.DrawString(fnt, "Score:"+i.ToString(),text,Color.YellowGreen);
            if(staus==true)
            {
                spriteBatch.DrawString(gover,"Game Over", gameover,Color.YellowGreen);
                spriteBatch.DrawString(fnt, "Score:" + i.ToString()+"\n Click Ball for
                   New Game\n Developed by Muthukumar", gameover1, Color.YellowGreen);
                spriteSpeed = new Vector2(0f, 0f);
         
            }
            spriteBatch.End();

            base.Draw(gameTime);


Update " protected override void Update(GameTime gameTime)" method by..
                 
                       This is the right place to show your mathematical talents and game logic...


            mpos.X = mouseStateCurrent.X;
            mpos.Y = mouseStateCurrent.Y;
            RotationAngle +=(float) gameTime.ElapsedGameTime.TotalSeconds*5;
            float circle = MathHelper.Pi * 2;
            RotationAngle = RotationAngle % circle;
            int MaxX =
                graphics.GraphicsDevice.Viewport.Width - mytex.Width;
            int MinX = 0;
            int MaxY =
                graphics.GraphicsDevice.Viewport.Height - mytex.Height;
            int MinY = 0;
            mouseStateCurrent = Mouse.GetState();
           
            if (mouseStateCurrent.LeftButton == ButtonState.Pressed)
            {
                if (staus == true)
                {
                    staus = false;
                    i = 0;
                }

                if (Math.Abs(sposition.Y - mouseStateCurrent.Y) <50 &&
                              Math.Abs(sposition.X - mouseStateCurrent.X) < 50)
                {
                                     
                    spriteSpeed = new Vector2(mouseStateCurrent.Y-100,
                                                       mouseStateCurrent.X-100);
                    sposition -=
                   spriteSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds * 1;
                    i++;
                  
                }


            }
            else
            {
                sposition -=
              spriteSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds * 2;
            }
          
            // Check for bounce.
            if (sposition.X > MaxX+50)
            {
                spriteSpeed.X *= -1;
                sposition.X = MaxX;
                i+=5;
            }

            else if (sposition.X < MinX)
            {
                spriteSpeed.X *= -1;
                sposition.X = MinX;
                i++;
            }

            if (sposition.Y > MaxY+75)
            {
                spriteSpeed.Y *= -1;
                sposition.Y = MaxY;
                i++;
                staus = true;
            }

            else if (sposition.Y < MinY)
            {
                spriteSpeed.Y *= -1;
                sposition.Y = MinY;
                i++;
            }
        

            base.Update(gameTime);



PART V:
  • Build and run your game.
now foot ball starts moving in your bed room

Preview of game:






Enjoy the game..............

Post your Valuable Comments.........