Saturday, January 30, 2010

I know what you read on dzone last summer

You should know that depending upon how CSS is coloring your links; I can figure out that what are the links you visited already.
This is a nice hack, many people use it for knowing user interests e.g
  • What social networking site you use.
  • What banking site you use.
  • And many more what you can think of.
I have created a hack to show all popular links from dzone, I am sorting the links based what you have read already. Before you read further Check This, (will not work in IE8)

Here is how you can inspect CSS color of a link in your browser


document.write('<style>');
document.write('
#linkID:visited {color: #FF0000;}");
document.write('
</style>');

/* quickly add and remove the link from the DOM with enough time to save the visible computed color. */
document.body.appendChild(link);
var color = document.defaultView.getComputedStyle(
link,null).getPropertyValue("color");
document.body.removeChild(link);

/* check to see if the link has been visited if the computed color is red */
if (
color == "rgb(255, 0, 0)") {

/*visited do something*/

}
else {

/*not visited, do something else*/

}




Read More about How I brought All Dzone links on 1 page

Read More About How This CSS hack works?

Read Rest of My Hacks


Thursday, January 28, 2010

Understanding C#.net Border-less Form, when you maximize it

Hi There,
Have you ever created, a borderless window in C#.net?
There is problem with borderless window, if you maximize it, it goes FullScreen (over the taskbar).

Here is an analyis of how to achieve maximized borderless window.




If  you first set the border(anything other than FormBorderStyle.None) for the window and then set WindowState to maximize, You will get a standard maximized window, you can make it border-less there after.





private void btMaximize_Click(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;

if (this.WindowState != FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Maximized;
}
else
{
this.WindowState = FormWindowState.Normal;

}

this.FormBorderStyle = FormBorderStyle.None;
}





If you maximize a window after making it borderless it goes beyond the task-bar. You will get complete full-screen.



private void btFullscreen_Click(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
if (this.WindowState != FormWindowState.Maximized)
{

this.WindowState = FormWindowState.Maximized;
}
else
{
this.WindowState = FormWindowState.Normal;
}

}





Sunday, January 17, 2010

Hacking Google maps AJAX API to use in C#.Net

Hi,
As you know “Google Maps API” is available only for AJAX developers. Using it in C#.net is not possible. One of the great things about Google maps API is it gives you turn by turn direction almost anywhere on earth. I wanted to exploit this feature of turn by turn navigation on my mobile, that too offline, because when i go to remote places its highly probable that i will not be having connectivity on my phone. Or connectivity will be so poor that using maps is highly impractical.

So I have created a pair of application.
1. A Desktop app to retrieve turn by turn navigation data + static images.
2. A Mobile app to read this data and to give me turn by turn navigation on phone (offline).

Certainly this is something not allowed in TOU of Google, so i cannot release this app commercially.

How to Mix AJAX and C#.net??
1. I created a web page (html+JavaScript), which dumps the direction info data in DOM.
2.In C#.Net Form, I kept a web-browser control, which loads this page.
3.When page is loaded, using webBrowser1.Document.GetElementById stuff I extracted the direction info.
4.Then I downloaded Static Images using "Google Static Maps API", & hacked to get the latitude and longitude positions on the static images. see code for detail.


How I exported data on mobile??
1. Serialized whole object in an XML file, including direction info and static images.
2. De-serialized on mobile to get that data back.


Source Code
http://code.google.com/p/pocketnavigator/


Screen-shot Of Mobile Version.



Demo of Desktop App (6 minute).

Thanks, Feel free to ask question, & share on twitter + digg & blah blah.