Archive for November 2011

5

Nov

Unix commands

A cookie is used to store small piece of information on client machine.A cookie contains page-specific information that a web server sends to a client along with page output.Cookies are used for sending page specific information because HTTP is a stateless protocol and cannot indicate whether page request coming from the same or different client.You can use cookies to keep track of individual user who access a web page across HTTP connection.

Cookies are saved on the client computer.Cookies can be either temporary or persistent.Temporary cookies also know as session cookies,exist in the memory space of browser.When the browser is closed,all the session cookies added to the browser are lost.A persistent cookie is saved as a text file in the file system of the client computer.

Cookies enable you to store information about a client,session,or application.When a browser request a page,it sends the information in the cookie along with the request information.A web server reads the cookie and extracts its value.

//Creating a cookie
HttpCookie sampleCookie = new HttpCookie(“UserColorSetting”);
sampleCookie.Values.Add(“Background”, txtBackgroundColor.Text);
sampleCookie.Expires = #12/31/2010#; Response.Cookies.Add(sampleCookie);

//Getting a cookie value from the user’s computer
String sGetCookie;
sGetCookie = Request.Cookies(“UserColorSetting”)(“Background”).ToString();

Advantages of Cookies:

1.A cookie is stored on the client computer and can be read by the server after a request for a page is posted.Therefore,no server resource is involved in maintaining the cookie.

2.A cookie is a text based data structure that contains key-value pairs.Therefore ,it is easy to create and manipulate cookie.

3.A cookie can either expire when the browser ends or exist indefinitely on the client computer,subject to the expiration rules on the client.

Limitation of Cookies:

1.Cookies that are stored on client computers have a limited size.Most browsers allow cookie to have up to 4096 bytes in size.Therefore you cannot store a large amount of data in a cookie.

2.Users can temper with cookies because cookies are stored on client computer.

3.Users can disable cookies to prevent from being stored on the hard disk of their computer.If a user denies permission for cookies,an ASP.net web application cannot store cookies on client computer.

No tags Hide

User Control

you can create your own controls. You have two options. You can create:

  • User controls. User controls are containers into which you can put markup and Web server controls. You can then treat the user control as a unit and define properties and methods for it.
  • Custom controls. A custom control is a class that you write that derives from Control or WebControl.

User controls are substantially easier to create than custom controls, because you can reuse existing controls. They make it particularly easy to create controls with complex user interface elements.

User Control Structure


An ASP.NET Web user control is similar to a complete ASP.NET Web page (.aspx file), with both a user interface page and code. You create the user control in much the same way you create an ASP.NET page and then add the markup and child controls that you need. A user control can include code to manipulate its contents like a page can, including performing tasks such as data binding.
A user controls differs from an ASP.NET Web page in these ways:

  • The file name extension for the user control is .ascx.
  • Instead of an @ Page directive, the user control contains an @ Control directive that defines configuration and other properties.
  • User controls cannot run as stand-alone files. Instead, you must add them to ASP.NET pages, as you would any control.
  • The user control does not have html, body, or form elements in it. These elements must be in the hosting page.

To include a user control in a Web Forms page

1.In the containing ASP.NET Web page, create an @ Register directive that includes:

  • A TagPrefix attribute, which associates a prefix with the user control. This prefix will be included in opening tag of the user control element.
  • A TagName attribute, which associates a name with the user control. This name will be included in the opening tag of the user control element.
  • A Src attribute, which defines the virtual path to the user control file that you are including.

2.In the body of the Web page, declare the user control element inside the form element.
3.Optionally, if the user control exposes public properties, set the properties declaratively.
Example


<%@ Page Language=”VB” %>
<%@ Register TagPrefix=”uc” TagName=”Spinner”
Src=”~/Controls/Spinner.ascx” %>
<html>
<body>
<form runat=”server”>
<uc:Spinner id=”Spinner1″
runat=”server”
MinValue=”1″
MaxValue=”10″ />
</form>
</body>

No tags Hide

try to move image object on touch event in XNA game development.

step 1:

download and install windows phone 7.1 sdk from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27570

step-2 :

it create two project one is code project for xna game development and another for content or resource for project.

add ball image in content project and put set property buit action to compile.

step-3:

add following code in game1.cs

 

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace TestGame
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;

SpriteBatch objsprite;

Rectangle rectangle;
Texture2D texture;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = “Content”;
}

protected override void Initialize()
{

base.Initialize();
}

protected override void LoadContent()
{
objsprite = new SpriteBatch(GraphicsDevice);
texture = this.Content.Load<Texture2D>(“asset name of image”);// t is name asset name of image which u put in content project.
rectangle = new Rectangle(20, 100, 30, 50);
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back ==
ButtonState.Pressed)
this.Exit();
if (Mouse.GetState().LeftButton==ButtonState.Pressed)
{
rectangle.X = Mouse.GetState().X;
rectangle.Y = Mouse.GetState().Y;
}

if (Keyboard.GetState().IsKeyDown(Keys.Right))
{
rectangle.X += 3;
}
if (Keyboard.GetState().IsKeyDown(Keys.Left))
{
rectangle.X -= 3;
}
if (Keyboard.GetState().IsKeyDown(Keys.Up))
{
rectangle.Y += 3;
}
if (Keyboard.GetState().IsKeyDown(Keys.Down))
{
rectangle.Y -= 3;
}

base.Update(gameTime);
}

protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
objsprite.Begin();
objsprite.Draw(texture, rectangle, Color.White);
objsprite.End();
base.Draw(gameTime);
}

}
}

 

try this basic code and learn first step of game development in XNA for windows phone 7.

No tags Hide

« Previous

Managed by

MNP INFOTECH