Friday, May 26, 2006

OOP Project 2

Here I am again...
I took a break 4 a while & just thought about completing the post..
btw, I heard today that there is competition or sth like that for the projects & a friend confirmed that... I dunno, but maybe I will think of enrolling.. I dunno if its too late or wt.. 8-)

Anyway, back to the proj.. still I wanna show u 2 more things.. The print preview & the notification...

About the printpreview... sure u will wonder what's new in that.. actually I posted before a post here about "Multipages" printing.. I couldnt before support that in any application I made.. but this was solved.. mmm.. just make a function that returns bool to check ur current y ... & in case its true, make the e.HasMorePages = true;
//here is the imp part:
if((CurrentY > pageHeight - pageMarginBottom)&&(!pageLandscape))
return true;

Here comes the last thing in the proj that deserves watching..
Its a notification at the right side of the screen (as that of msn , yahoo.... ).. its idea is soooo simple, but the output looks nice..... now in order to make a notifier, we need to know the resolution of out screen in order to determine where will our form apear.. actually this can be solved easily with the function: Screen.GetWorkingArea(this) then with little math calculations & good use of timers to make the moving effect, u will get wt u need.. :)

I gtg now to complete studying a small part then go to sleep ISA.. :)

Exams are coming &.... Hope we all do well ISA.. :)

Friday, May 19, 2006

OOP Project 1

e7l.. the project has been delievered yesterday.. I won't talk in details about the delivery for many reasons.. the main is that I didn't do it for just taking marks + this has nth to do with wt that blog is made for + I wasn't happy with wt happened....

Talking about the project... Actually I didn't add more functionality to the project...(simply cause I wasn't convinced with the design they made & I didnt want to add any tables to it...), I did nth more than the requirments.... just some short reports at the main page (actually, it wasn't my idea.. Thanks for suggesting :) .. ) I was much concerned with the interface & making the other requirments so perfectly...

what are the new things I learnt from that project ?
- some GDI+
- Dealing with events handlers & delegates more flexible.
- Code reusability (make good use of wt others do instead of doing it from scratch) .
- Making good use of the controls & components of the .net to produce sth that looks good.

This is the Interface of the application... Hope its clear enough :) .. mmm.. There are buttons on the left for moving between forms.. I think buttons are more practical esp for things that are required a lot for the user (as making a reservation & checking rooms availbility).. I added some menus at then end cause almost All people told me "its better to make menus".. don't know y!! .. anyway.. I still don't like menus.. but maybe I can add both & the user have to choose (as many applications we use in daily life...)
BTW.. I used a class that was made by someone on code project to play sounds.. I used it in to make some effects for the mouse moving on the buttons + some few visual effects...


Here comes the most important form in the application & the most one that made me tired (esp as a functionality)...mmm... about the shape.. (simple use of GDI+)... & added some mouse event handlers to be able to move the form freely...

I'm now so tired.. I will go to sleep now..

To be continued ISA..

Monday, May 15, 2006

Changing Forms Shapes..

I decided to take some rest b4 studying so I thought of writing somthing useful here...

Sometimes we get bored from standard forms.. Learning GDI+ helps a lot in making cool shapes for forms.. Here, I'm not going to talk about how to use GDI+ to reshape ur forms (maybe I'll do next post).. I will talk now about a very simple way that can change the way ur form looks..

Let's begin..
First Design a nice picture for ur form...Here, I downloaded a pic from google images :) (I'm a programmer not a designer ;) )
After designing.. set the background of ur image to a unique colour that u will never use in ur form or in any font in ur application (simply cause anything having this colour will disappear)
ok.. that's the pic I chose & I set the background to dark grey...

Now, Go to ur form & set the background of ur form to this image...
& then u have to change some properties in ur form..
FormBorderStyle = None
Transparency Key = "colour u chose for ur pic background" (& this doesn't work in most cases due to sth related to screen colour quality.. I'll tell u how to manage that in the coming lines)

ok.. now done..
we have to add some things.. the Most imp thing is a button to close our application.. & this can be done easily by adding a button with mark "X" & in its action this.Close();
ok.. now ur form is almost ready..

now, if u run it, the transparency key doesn't here is a piece of code to make this thing work just fine.. but first don't forget to put ur pic beside the .exe

System.Drawing.Bitmap Img = new Bitmap("background.bmp");
this.BackgroundImage = Img;
this.TransparencyKey = Img.GetPixel(0,0);

I think the code is clear.. he sets the image to the form backgournd & gets the colour of the first pixel in ur image & set that to the transparency key...

Now, not finished yet.. :D .. there is still adding some Mouse event handlers so that u can move ur new form.. (I will leave u do that cause I have to go to study :D , its 11:00)

now I will just show u the final view of our form...

just remmeber that ur final form look depends on ur image quality...

Hope u enjoyed it..