Links:
Listed on: Dmegs Web Directory

PHP video tutorials

phpmath.com
phpclasses.org
Canadian Mathematical Society
camel.math.ca

Algebra.com
Blogs:
rationalcode.com
Silverlight Playground

Technology:
silverlight.net
XNA Creators Club Online
php
asp.net


WCF and IIS 7.0

by Administrator 8. February 2010 04:54

Recently, I had a little headache while deploying a WCF service to a win 2k8 machine running IIS 7.0.

The trick is WCF should get registered by the following command:

 "%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r -y

To read more about Service Model Registration Tool, visit the following MSDN page:

http://msdn.microsoft.com/en-us/library/ms732012.aspx

Enjoy!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

.NET | Training

IEqualityComparer interface: How to remove objects with the same property values from a generic list.

by Administrator 16. November 2009 04:45

Problem description:

Any developer is familiar with the concept of removing duplicate numbers from a list or array. .NET 3.5 offers the new extension method “Distinct” in System.Linq namespace which can be used to remove all duplicate integers(or any value type) from a list of numbers. Here is an example:

List<int> listOfNumbers = new List<int>() { 1, 5, 4, 10, 1, 4 };
List<int> uniqueList = listOfNumbers.Distinct().ToList<int>();

Distinct method is great. is not it?

Now imagin a list of a domain objects for instance a list of User object where the User has the following signature:

class User
 {
    public string Username;                
 }

User u1 = new User() {Username="nima" };
User u2 = new User() { Username = "reza" };
User u3 = new User() { Username = "nima" };
User u4 = new User() { Username = "sanam" };
List<User> listOfUsers = new List<User>() { u1, u2, u3, u4 }; 

The goal is to remove duplicated User objects with the same Username. Although u1 and u3 have the same Username, from the framework point of view they
are not equal because they have different hash codes. So how can we use the Distinct method? Here is where the IEqualityComparer<T> inteface comes to account.
To define the concept of equality for complex objects, we can create a class (UserComparer) which implements the IEqualityComparer<T> interface where T is our complex business type (User here).
In UserComparer class, we will specify under which circumstance two User objects can be considered equal. This interface has two methods which we need to implement:

  1. Equals
  2. GetHashCode

The class implementation follows:

public class UserComparer : IEqualityComparer<User>
{
    public bool Equals(User x, User y)
    {
       return x.Username == y.Username;
    }
    public int GetHashCode(User obj)
    {
       return obj.Username.GetHashCode();
    }
}

Now in the client code we can use this syntax to remove the duplicate usernames from our list:
List<User> uniqueListOfUsers = listOfUsers.Distinct<User>(new UserComparer()).ToList<User>();

So uniqueListOfUsers will only contain User objects with reza, nima and sanam Usernames.

For a detailed information please visit
http://msdn.microsoft.com/en-us/library/ms132151.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , , , ,

.NET | Training

Visual Representation Of The Relativity Theory Online!

by Administrator 1. August 2009 14:35

Hi all,

Here, specificly I want to introduce one of my programs which visually represents the Relativity theory...

You enter the initial length, mass and time of the object and the speed...it calculates the length, mass and time in that speed with a downloadable visual representation.

you can try it here:
http://www.dreamstube.com/php/relativity/

enjoy and please let me know about your feedback.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

PHP | Physics

Image To HTML - Convert Image To Text - Convert Your Image To Pure HTML In Seconds!

by Administrator 31. July 2009 13:54

You can use this program to convert an Image to pure HTML. The generated HTML file can be downloaded as well.

I load the image in php and read it pixel by pixel and based on the pixel RGB value generate the appropriate HTML tag. To save the server bandwidth and cpu time, I limited the image type to GIF and Jpeg and the image dimentions to 400 by 300 pixels and the image size to 50KB.

You can try this cool application here. I hope you enjoy it.

PHP SWF Library - Flash & PHP integration

by Administrator 30. July 2009 07:43

If you are a flash/php programmer, you might be interested in this link:

http://us2.php.net/manual/en/book.swf.php

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Flash/ActionScript | PHP

Flash Gaming Tutorial - Collision Detection

by Administrator 30. July 2009 02:14

Collision detection is the most important concept in game development. It does not matter which programming language you are using for gaming. XNA, Flash or ... They all offer a method to detect collisions. You should be able to detect collisions and perform some logic to respond to it.

In this small tutorial I'm going to show you how to detect collisions in ActionScript. There are other ways to detect collisions in Flash / ActionScript but this one is the simplest one I believe.

Say you have a bullet movie clip and an enemy movie clip and need to know if the bullet hits the enemy. To do so follow these steps:

  • Open a new Flash file (anything but ActionScript 3.0 file).
  • Draw your bullet. For simplicity I used the Oval tool from the toolbox to create it.
  • Select the bullet object you just made and press F8 to convert it to a movie clip.
  • Select the movie clip and press Ctrl + F3 to open the Properties panel. Type bulletInstance in the instanceName box.
  • Draw the enemy. I used the Rectangle tool to create a simple rectangle as my enemy.
  • Select the rectangle and press F8 to convert it to a movie clip.
  • Select the enemy movie clip and press Ctrl + F3 to open the Properties panel. Then Type enemyInstance in the instanceName box.
  • Now we have all the graphics to start ActionScripting. Select the bulletInstance and press F9 to open the Actions panel. Type the following script:
    • onClipEvent (enterFrame) {
       // Check if the bullet hit the enemy object.
       if (this.hitTest(_root.enemyInstance)) {
        // The bullet hit the enemy. Stop moving.
       } else {
        // The bullet has not hit the target yet. Keep moving the bullet.
        this._x += 10;
       }
      }
  • We are done. Run our simple game by pressing Ctrl + Enter and confirm that the bullet stops after reaching (hitting) the enemy.

hitTest function:
I used hitTest method to detect collisions. I called this fucntion on the bulletInstance movie clip (I used this because I'm adding scripts to the bulletInstance's Action panel). It takes the target movie clip as a parameter (here enemyInstance) and examins for collisions between those two.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , ,

Flash/ActionScript | Gaming | Training

Tutorial: Create a simple Flash & ActionScript based game

by Administrator 29. July 2009 05:43

In this tutorial, I'm going to show you how to create a simple shooting game in Flash. You can play this game here. The code is also downloadable here.

Please follow these steps to create your own game:

  • Open Adobe Flash and create a flash file. You can use any Flash edition you want for this tutorial. Just make sure you do not create an ActionScript 3.0 file.
  • Now we need a graphic to use as the target. We can create it from scratch (Vector) or can use a ready image. For simplicity, I used the following image (target.jpg). (You can also save it and use it in your game).

  • Import target.jpg to your flash movie. To do so press [ctrl + R] and select target.jpg and press OK.

  • Select the imported image and press F8 to convert it to a flash movie clip. Enter targetObject for the name and press Ok.

  • Now we have the targetObject movie clip added to the Flash library. Each movie clip need to have an instance name 
    to be able to get referd from ActionScript. Select the movie clip and press Ctrl + F3 to see the Property panel. Now enter 
    targetObjectInstance for the instance name.

  • Now we need create a custom + sign to replace the mouse pointer in the game. This will make the shooting
    more accurate. To do so follow these steps:
    • Select the Line tool from the toolBox and draw a line (about 100 pixel long)
    • Choose the selection tool, select the line you just created and press Crtl + G to convert it to a group.
    • Select the group and press Ctrl + D to duplicate it (Create another line object).
    • Now we need to rotate one of the lines for 90 degrees to create a +. To do so, select one of the lines and 
      press Ctrl + T to load the transfer panel.
    • Select the Rotate section and type 90 and press OK.
    • Select both lines and press Ctrl + K to load the Align panel. Press Align Horizental Center and Align 
      Vertical Center
      buttons on the first section (Align) and align our 2 lines to centre.
    • Now our + is ready. Select both lines and press F8. In the name section type customPointer and press 
      Ok.
    • Select the customPointer movie clip and press Ctrl + F3 to load the propery panel. Type 
      customPointerInstance for the Instance name and press Enter.
  • Now we have all the graphics we need to start programming our game. First we need to replace the mouse pointer with 
    customPointerInstance. To do so follow these steps:
    • Select customPointerInstance and press F9 to load the Actions panel. You can write ActionScription code for 
      your object in this panel.
    • Write the following code and close the panel:
      • onClipEvent (load) {
           Mouse.hide();// Hides the mouse pointer as soon as the movie clip is loaded.
          }
      •   onClipEvent (mouseMove) {
           // After each mouse move, The position of [customPointerInstance], this, will be updated base on 
          //the mouse pointer position. This way the custom pointer replaces the mouse pointer.
           this._x = _root._xmouse;
           this._y = _root._ymouse;
          }
    • Run the game by pressing Ctrl + Enter. Make sure the mouse pointer is changed.
  • Now lets make our targetObjectInstance object clickable. I want to increase the score each time the user hits
    the central white circle. To do so I'm going to create a button on top of the central circle and increase 
    the score (global varialble which we will define later). Follow these steps:
    • Double click on the targetObjectInstance to enter the movie clip editing mode. You can confirm that by 
      looking at the left top corver of the scene. Before double clicking on the targetObjectInstance, you just see [Scene1
      but now you should see targetObjectInstance as the following image shows.:
    • Select the Oval tool
    • Draw a circle exactly the same size as the central while circle. Select your circle and press F8. Choose 
      [button] from the drop down and click Enter.
    • Move your button over the targetObjectInstance]
    • Select the button and press F9. Type the following code in the Actions panel:
      • on (press) {
           _root.score += 1;//score is a global variable which holds the player's score!
          }
      •  
    • Close the Actions panel.
    • IMPORTANT: Click on Scene1 (top left corver) to return to the main scene.
    • New we need to define the [score] global variable. To do so:
      • Locate the timeline. You can toggle the timeline's visibility by pressing Ctrl + alt + T.
      • In the timeline, click on the first frame (which is the only frame) and press F9 to load the Actions 
        panel. Type the following line there:
        • _root.score = 0;
      • Close the Actions panel.
  • We need to show the player's score on the screen. To do so we will use a Text object from the toolbox:
    • Select the Text Tool from the toolbox and draw a text area on the top left corner of the scene as the following screen 
      suggests.Type something in it like score.
    • Choose the select tool and select the text you just added. Press Ctrl + F3 and change the drop down value 
      from Static Text to dynamic Text and type the global variable name (score) in the variable textbox. You can also increase the 
      font size of the Text area in this panel.
    • press Enter and close the property panel.
  • Lets move it! Now we just need to somehow start moving the target on the stage so players can start shooting.
    • Click on the targetObjectInstance and press F9. Type the following code in Actions panel
      • onClipEvent (load) {
           // Place the targetObjectInstance at the left side.
           this._x = 0;
           this._y = 100;
          }
      • onClipEvent (enterFrame) {
           if (_root.score == 10) {
            // If the score is 10, it should stop the game and shoe the "You Won!" message.
            _root.score = "You Won!";
           } else {
            // _root.directionFactor determines which side the target should move to.
            // If positive, the target moves to right else left.
            // _root.directionFactor determines which side the target should move to.
            // If positive, the target moves to right else left.
            if (this._x<=0) {
             _root.directionFactor = 1;
            } else if (this._x>=550) {
             _root.directionFactor = -1;
            }
            // Move the targetObjectInstance by changing its X property.  
            this._x += (_root.directionFactor*10);
           }
          }
      • Run the Flash movie by pressing ctrl + enter and make sire the target moves from left to right and returns.
      • It is possible that the custom mouse pointer hides behind the targetObjectInstance. To fix that stop the 
        animation then select the custom target object on the scene and select Bring To Front from Modify > Arrange menu.
  • We're done! You can now enjoy the game. Try to hit the target 10 times and you win the game.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

Flash/ActionScript | Gaming | Training

ASP.NET, Having items with different color in a ListBox or DropDownList

by Administrator 14. July 2009 02:41

One of my firends asked me "How can we change the text color for an individual item in a DropDownList or ListBox?". I thought it is a good idea to share the answer with you! The folowing image shows the dropDownList with the solution implemented. As you can see the First two items are red and the rest are black.

To implement it, follow these steps:

  1. Put a DropDownList control on your webform: <asp:DropDownList runat="server" Width="200" ID="lstAccounts" />
  2. On the Page_Load event handler add the following code
    1. // First items (Red)
      ListItem listItem1 = new ListItem("100000 (Active)", "100000");
      listItem1.Attributes.Add("style", "color: red;");
      lstAccounts.Items.Add(listItem1);
    2. // Second items (Red)
      ListItem listItem2 = new ListItem("100001 (Active)", "100000");
      listItem2.Attributes.Add("style", "color: red;");
      lstAccounts.Items.Add(listItem2);
    3. // Third items (Red)
      ListItem listItem3 = new ListItem("123456 (Active)", "100000");
      listItem3.Attributes.Add("style", "color: black;");
      lstAccounts.Items.Add(listItem3);
    4. // ...

You have also control over all attributes which are changable via CSS styles.

You can do the exact same thing with the ListBox object.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , ,

.NET | Training

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

Reza Salehi
Microsoft Certified Trainer

Microsoft Certified Professional Developer

Microsoft certiied Technology Specialist (ASP.NET 2.0)

About Me

My name is Reza Salehi. Since I remember I was interested in science and nature. I had a basic microscope and was exploring anything I could with it. I'm also an amateur astronomer.

I started programming about 11 years ago. I started with Flash 5.0 and Action Script 1.0 and continued with PHP, .NET, Silver light and XNA 3.0.

I like to use computers to demonstrate mathematical and physical concepts and develop games.

I currently work as a senior application developer in Toronto, Canada and also instruct programming related courses when I get a chance.

I'm a computer engineer and MCP (Microsoft Certified Professional) and earned my MCT (Microsoft Certified Trainer) certificate in 2008.

DreamsTube.com is a chance for me to share what I know with you and get feedbacks. I hope you enjoy reading my blog.

RecentComments

Comment RSS