Monday, August 25, 2008

Introduction To WAP




Introduction:
Through this topic we will work together to understand Technology of Wireless Application Protocol (WAP), also we will take a fast tour about developing WAP Applications using ASP.net.

Technology Description:

Mobile Application :
When First Mobile arrived, it was only smart way for sending and receiving voice calls and after sometime for sending and receiving text messages. But now, it is become the most growing market for services and recreational purposes. It is also being used for accessing internet and multimedia world.

For this reason, a lot of developing and programming concepts changed to become compatible with mobile world, one of these concepts was WAP as a mobile alternative of WEB concepts for regular computers.

What is WAP ؟

From Wikipedia, WAP is an open international standard for application layer network communications in a wireless communication environment. Its main use is to enable access to the Internet (HTTP) from a mobile phone or PDA.

Sunday, August 24, 2008

Expression Blend



When WPF - the new .net technology- arrived, Microsoft try to provide some tools makes life easy to WPF Developers, one of this tools was Expression Blend, we will try to show some features about it in this topic.

Try to download it form Microsoft web site, then run it and choose new Project - WPF Application (*.exe):

You can now choose your name, folder and .net language you want.

Click View-Active Document View then click split view to show both code and design view:

Tuesday, June 17, 2008

IComparable Interface.



From The name, this Interface used for comparison. This is the implementation of this interface:

C#:

public interface IComparable
{
int CompareTo(object o);
}

vb.net:

Public Interface IComparable
Function CompareTo(ByVal o As Object) As Integer
End Interface

The result of this function is Integer; it returns 0 in similarity, -1 when the first one is smaller and 1 when larger .

Now we don't need to know who is larger, let’s assume that we have car class, something like that:

C#:

class Car
{

string Name;
int year;
}

vb.net:

Class Car
Private Name As String
Private year As Integer
End Class

Now we need to sort the cars depends on the creation year, our first step it to implement IComparable interface.

Thursday, June 5, 2008

FileSystemWatcher




FileSystemWatcher Class is very benefit when trying to monitor some files and inform user or program when any change occurs, all events are listed in NotifyFilters enum, this is the list of events can be handled by this:

public enum NotifyFilters {
Attributes, CreationTime, DirectoryName, FileName, LastAccess, LastWrite, Security, Size,
}

Now we need to declare functions to be called when some event occurred, this function will run through this delegate:


void MyNotificationHandler(object source, FileSystemEventArgs e)


Only rename event will run through this delegate:

void MyNotificationHandler(object source, RenamedEventArgs e)


Now we will start console application to monitor files, this application will run till user press q, this program will monitor all *.txt files in c:\ folder:


C#:


FileSystemWatcher watcher = new FileSystemWatcher();

// monitor files at:
watcher.Path = @"c:\";

// monitor files when
watcher.NotifyFilter = NotifyFilters.LastAccess NotifyFilters.LastWrite NotifyFilters.FileName NotifyFilters.DirectoryName;

// watch files of type
watcher.Filter = "*.txt";

// watch events:
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);

watcher.EnableRaisingEventys = true;

Console.WriteLine("Press 'q' to quit app.");

while (Console.Read() != 'q') ;

vb.net:


Dim watcher As New FileSystemWatcher()


' monitor files at:
watcher.Path = "c:\"

' monitor files when
watcher.NotifyFilter = NotifyFilters.LastAccess Or NotifyFilters.LastWrite Or NotifyFilters.FileName Or NotifyFilters.DirectoryName

' watch files of type
watcher.Filter = "*.txt"

' watch events:
AddHandler watcher.Created, AddressOf OnChanged
AddHandler watcher.Deleted, AddressOf OnChanged

watcher.EnableRaisingEvents = True

Console.WriteLine("Press 'q' to quit app.")

While Console.Read() <> "q"C

End While



As you seen, we call OnChanged function every event occurs, so we can implement this function to print this event and its time like that:


C#:


static void OnChanged(object source, FileSystemEventArgs e)

{

Console.WriteLine("File Changed, File Path: {0} , Change: {1}, DateTime: {2}", e.FullPath, e.ChangeType,DateTime.Now.ToString());

}

vb.net:


Private Shared Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs)

Console.WriteLine("File Changed, File Path: {0} , Change: {1}, DateTime: {2}", e.FullPath, e.ChangeType, DateTime.Now.ToString())

End Sub


Now, this is screen shot of application when delete .txt file and create it again.