Friday, September 24, 2010
Windows Presentation Foundation
THE EVOLUTION OF WINDOWS GRAPHICS
It’s hard to appreciate how dramatic WPF is without realizing that Windows developers have been using essentially the same display technology for more than 15 years. A standard Windows application relies on two well-worn parts of the Windows operating system to create its user interface:
* User32. This provides the familiar Windows look and feel for elements such as windows, buttons, text boxes, and so on.
* GDI/GDI+. This provides drawing support for rendering shapes, text, and images at the cost of additional complexity (and often lackluster performance).
Over the years, both technologies have been refined, and the APIs that developers use to interact with them have changed dramatically. But whether you’re crafting an application with .NET and Windows Forms or lingering in the past with Visual Basic 6 or MFC-based C++ code, behind the scenes the same parts of the Windows operating system are at work. Newer frameworks simply deliver better wrappers for interacting with User32 and GDI/GDI+. They can provide improvements in efficiency, reduce complexity, and add prebaked features so you don’t have to code them yourself; but they can’t remove the fundamental limitations of a system component that was designed more than a decade ago.
DIRECTX: THE NEW GRAPHICS ENGINE
Microsoft created one way around the limitations of the User32 and GDI/GDI+ libraries: DirectX. Over the years since it was first introduced (shortly after Windows 95), DirectX has matured. It’s now an integral part of Windows, with support for all modern video cards. But because of its raw complexity, DirectX was almost never used in traditional types of Windows applications (such as business software).
WPF changes all this. In WPF, the underlying graphics technology isn’t GDI/GDI+. Instead, it’s DirectX. Remarkably, WPF applications use DirectX no matter what type of user interface you create. That means that whether you’re designing complex three-dimensional graphics (DirectX’s forte) or just drawing buttons and plain text, all the drawing work travels through the DirectX pipeline. As a result, even the most mundane business applications can use rich effects such as transparency and anti-aliasing. You also benefit from hardware acceleration, which simply means DirectX hands off as much work as possible to the graphics processing unit (GPU), which is the dedicated processor on the video card.
THE NEW THINGS WPF BRINGS IN
* A web-like layout model
* A rich drawing model
* A rich text model
* Animation as a first-class programming concept
* Support for audio and video media
* Styles and templates
* Commands
* Declarative user interface
* Page based applications
RESOLUTION INDEPENDENCE
Traditional Windows applications are bound by certain assumptions about resolution. Developers usually assume a standard monitor resolution (such as 1024 by 768 pixels), design their windows with that in mind, and try to ensure reasonable resizing behavior for smaller and larger dimensions. The problem is that the user interface in traditional Windows applications isn’t scalable. As a result, if you use a high monitor resolution that crams pixels in more densely, your application windows become smaller and more difficult to read. This is particularly a problem with newer monitors that have high pixel densities and run at correspondingly high resolutions. For example, it’s common to find consumer monitors (particularly on laptops) that have pixel densities of 120 dpi or 144 dpi (dots per inch), rather than the more traditional 96 dpi. At their native resolution, these displays pack the pixels in much more tightly, creating eye-squinting small controls and text.
Ideally, applications would use higher pixel densities to show more detail. For example, a high resolution monitor could display similarly sized toolbar icons but use the extra pixels to render sharper graphics. That way, you could keep the same basic layout but offer increased clarity and detail. For a variety of reasons, this solution hasn’t been possible in the past. Although you can resize graphical content that’s drawn with GDI/GDI+, User32 (which generates the visuals for common controls) doesn’t support true scaling.
WPF doesn’t suffer from this problem because it renders all user interface elements itself, from simple shapes to common controls such as buttons. As a result, if you create a button that’s 1 inch wide on your computer monitor, it can remain 1 inch wide on a high-resolution monitor—WPF will simply render it in greater detail and with more pixels.
This is the big picture, but it glosses over a few details. Most importantly, you need to realize that WPF bases its scaling on the system DPI setting, not the DPI of your physical display device. This makes perfect sense—after all, if you’re displaying your application on a 100-inch projector, you’re probably standing several feet back and expecting to see a jumbo-size version of your windows. You don’t want WPF to suddenly scale down your application to “normal” size. Similarly, if you’re using a laptop with a high-resolution display, you probably expect to have slightly smaller windows—it’s the price you pay to fit all your information onto a smaller screen. Furthermore, different users have different preferences. Some want richer detail, while others prefer to cram in more content. So, how does WPF determine how big an application window should be? The short answer is that WPF uses the system DPI setting when it calculates sizes. But to understand how this really works, it helps to take a closer look at the WPF measurement system.
WPF UNITS
A WPF window and all the elements inside it are measured using device-independent units. A single device-independent unit is defined as 1/96 of an inch. To understand what this means in practice, you’ll need to consider an example.
Imagine that you create a small button in WPF that’s 96 by 96 units in size. If you’re using the standard Windows DPI setting (96 dpi), each device-independent unit corresponds to one real, physical pixel. That’s because WPF uses this calculation:
[Physical Unit Size] = [Device-Independent Unit Size] × [System DPI]
= 1/96 inch × 96 dpi
= 1 pixel
Essentially, WPF assumes it takes 96 pixels to make an inch because Windows tells it that through the system DPI setting. However, the reality depends on your display device.
THE ARCHITECTURE OF WPF
WPF uses a multilayered architecture. At the top, your application interacts with a high-level set of services that are completely written in managed C# code. The actual work of translating .NET objects into Direct3D textures and triangles happens behind the scenes, using a lower-level unmanaged component called milcore.dll. Milcore.dll is implemented in unmanaged code because it needs tight integration with Direct3D and because it’s extremely performance-sensitive.
* PresentationFramework.dll: This holds the top-level WPF types, including those that represent windows, panels, and other types of controls. It also implements higher-level programming abstractions such as styles. Most of the classes you’ll use directly come from this assembly.
* PresentationCore.dll: This holds base types, such as UIElement and Visual, from which all shapes and controls derive. If you don’t need the full window and control abstraction layer, you can drop down to this level and still take advantage of WPF’s rendering engine.
* WindowsBase.dll: This holds even more basic ingredients that have the potential to be reused outside of WPF, such as DispatcherObject and DependencyObject, which introduces the plumbing for dependency properties.
* milcore.dll: This is the core of the WPF rendering system and the foundation of the Media Integration Layer (MIL). Its composition engine translates visual elements into the triangle and textures that Direct3D expects. Although milcore.dll is considered part of WPF, it’s also an essential system component for Windows Vista and Windows 7. In fact, the Desktop Window Manager (DWM) uses milcore.dll to render the desktop.
THE LAST WORD
WPF is the beginning of the future of Windows development. In time, it will become a system like User32 and GDI/GDI+, on top of which more enhancements and higher-level features are added. Eventually, WPF will allow you to design applications that would be impossible (or at least thoroughly impractical) using Windows Forms.
Monday, August 30, 2010
Monday, February 8, 2010
MY NAME IS KHAN REVIEW BY TARAN ADARSH
* The first: B.C. and A.D. are designations used to label years in the Julian and Gregorian calendars. There's a third designation now - 9/11. Post September 11, the world stands divided. Terrorist outfits continue to strike in the name of religion and the common man, not even remotely associated with these groups, is bearing the brunt. The world is not a safe place anymore.
* The second statement: There're two sets of people in this world - the good and the bad. No matter how strong the evil forces are, good always triumphs.
MY NAME IS KHAN mirrors the era we live in. Not a day goes by when you haven't heard/read/watched news of terror attacks and innocents being killed. We live in turbulent times. Also, the movie states - and states very strongly, without mincing words - Not all Muslims are terrorists.
Karan Johar's cinema got more real from KABHI ALVIDA NAA KEHNA onwards. In MY NAME IS KHAN, the storyteller attempts to make a social statement and succeeds completely. At the same time, it takes no sides. If the protagonist says 'My name is Khan and I am not a terrorist', it also exposes those who misadvise the youth with inflammatory and rabble-rousing speeches.
Karan's take on the issue deserves the highest praise, since a subject like this is difficult to attempt. Final word? MY NAME IS KHAN is Karan, SRK and Kajol's best outing to date. Do I need to add anything more?
Rizvan Khan [Shah Rukh Khan moves to San Francisco and lives with his brother [Jimmy Shergill] and sister-in-law [Sonya Jehan]. Rizvan, who has Asperger's syndrome, falls in love with Mandira [Kajol]. Despite protests from his brother, they get married and start a small business together. They are happy until September 11, when attitudes towards Muslims undergo a sea-change.
When tragedy strikes, Mandira is devastated and they split. Rizvan is confused and upset that the love of his life has left him. To win her back, he embarks on a touching and inspiring journey across America.
Let me alert you. The story unfolds feverishly from the very start itself. So if you miss a scene or two, chances are you would've missed some vital links in the story. The fact is, there's too much happening in the first half. Although the narrative tends to get leisurely-paced at times, the wheels continue to move from one episode to another.
A number of sequences are endearing. For instance, the romance between SRK and Kajol is subtle, yet charming. But it's SRK's relationship with Kajol and their kid that's one of the best parts of the movie. Your heart bleeds when an accident occurs and their lives are torn apart. Kajol's outburst - first, when her son meets with a catastrophe and second, when she confronts SRK - are truly shattering.
MY NAME IS KHAN's strength lies in the fact that you root for Khan all through. At the same time, you are weighed down when he's in a vulnerable situation, especially when he's labelled a terrorist and thrown behind bars. You don't realize it, but the fact is that you, as a spectator, have already got entwined in Rizvan and Mandira's lives.
There's a slight hitch in the second hour, when SRK returns to Georgia to save a hurricane-ravaged hamlet. Also, the media exercise tends to add to the length of the film. Nonetheless, it's a minor hiccup that doesn't rob the film of its punch.
There's just one word to illustrate Karan's direction - exemplary. One of the finest storytellers of our generation, he deserves brownie points for deviating from 'Karan Johar brand of cinema' and attempting a film that knocks on your heart and stimulates your mind. With MY NAME IS KHAN, Karan takes rapid strides as a storyteller.
Shibani Bathija's screenplay is truly arresting. Shibani and Niranjan Iyengar's dialogues are noteworthy and many a times, applaud-worthy. Ravi K. Chandran's cinematography is awe-inspiring. Shankar-Ehsaan-Loy's music gels well with the nature of the film.
When a film stars two of the finest talents of the country, you expect nothing but the best. SRK, well, how does one describe his performance? To state that this is his best work so far would be cutting short the praise he truly deserves. In fact, no amount of praise can do sufficient justice to his portrayal of Rizvan Khan, who has Asperger's syndrome. His latest work is several notches above anything he has done before. The only compliment that I can think of is, SRK has a new screen-name now. Raj is passe, Rizvan it is.
Kajol is pure dynamite and casting her for this character was the most appropriate decision. No other actress could've matched SRK in histrionics the way Kajol has. In fact, SRK and Kajol compliment each other wonderfully well and this film only proves it yet again. It's a powerhouse performance from this supremely talented actress.
The film boasts of a number of capable actors, but the ones who leave a rock-solid impact are - in this order - Zarina Wahab, Sonya Jehan, Jimmy Shergill, Arjun Mathur, Parvin Dabas and Arif Zakaria. Sugandha Garg is confident. Navneet Nishan supports well. Vinay Pathak leaves a mark in a brief role. Tanay Chheda [young SRK] and Yuvaan Makaar [SRK and Kajol's son Sameer] are excellent. The American actors, especially the kid who plays Sameer's friend, deserves mention.
On the whole, MY NAME IS KHAN is a fascinating love story, has an angle of religion and a world-shaking incident as a backdrop. It not only entertains, but also mesmerises, enthrals and captivates the viewer in those 2.40 hours. At the same time, a film like MY NAME IS KHAN is sure to have a far-reaching influence due to its noble theme. I strongly advocate, don't miss this one!
Saturday, February 6, 2010
The Disease Rizwan Khan(SRK) has in My Name Is Khan
Asperger Syndrome
Asperger syndrome is an autism spectrum disorder, and people with it therefore show significant difficulties in social interaction, along with restricted and repetitive patterns of behavior and interests. It differs from other autism spectrum disorders by its relative preservation of linguistic and cognitive development. Although not required for diagnosis, physical clumsiness and atypical use of language are frequently reported.
Asperger syndrome is also called Asperger's syndrome, Asperger (or Asperger's) disorder, or just Asperger's; it is named after the Austrian pediatrician Hans Asperger who, in 1944, described children in his practice who lacked nonverbal communication skills, demonstrated limited empathy with their peers, and were physically clumsy Fifty years later, it was standardized as a diagnosis, but many questions remain about aspects of the disorder. For example, there is lingering doubt about whether it is distinct from high-functioning autism (HFA); partly because of this, its prevalence is not firmly established. The exact cause is unknown, although research supports the likelihood of a genetic basis; brain imaging techniques have not identified a clear common pathology.
There is no single treatment, and the effectiveness of particular interventions is supported by only limited data. Intervention is aimed at improving symptoms and function. The mainstay of management is behavioral therapy, focusing on specific deficits to address poor communication skills, obsessive or repetitive routines, and physical clumsiness. Most individuals improve over time, but difficulties with communication, social adjustment and independent living continue into adulthood Some researchers and people with Asperger's have advocated a shift in attitudes toward the view that it is a difference, rather than a disability that must be treated or cured.
Sunday, January 31, 2010
A simplre Problem with prime numbers
Question: Suppose p is a prime number......p is a factor of ab.....p doesn't divide a then prove that p is a factor of b.
Solution 1: Manual Solution
Since P is factor of ab....so we can write..
ab = k.P here k is positive integer---------(1)
Now P is not a factor of a
Lets us assume x belong to R such that a+x is divided by P
So we can write m.P = (a+x) where m is positive integer ------------(2)
so a = m.P - x
Put in first
(m.P-x)(b) = k.P
m.P.b - bx = k.P
from here GCD(P.b , b) = P
Hence P is also a factor of b
Solution 2: Bezout's theorem
Suppose p does not divide a, then gcd(p,a) =1.
Then by Bezout's theorem we can find integers m and n such that pm+an =1.
Multiply by b to obtain pmb + abn = b
Both summands on LHS are divisible by p and hence LHS is divisible by p. Which means RHS=b is divisible by p.
Monday, January 18, 2010
My SMS Collection
While walking down d street, I heard an old man say "I've been in love wid d same woman 4 almost 50 years now." I was touched until I heard him say "I wish she knew."
If u drop me I will break.If u hold me I will shake.If u need me I will hurry.If u dnt call me I'll worry.If u hurt me I will cry but if u leave me I'll die
I may b innocent 2 knw wat luv is,I may not show it 2u.I may not luv u d way it shld b,but Im alwys willng 2 luv u d way I undrstnd it!
*Nobody's Right Till Smbody's Wrong Nobody's Weak Til Smbody's Strong Nobody's Lucky Til Luv Comes Along Nobody's Lonely Til Smbody's Gone
If i reach 4 ur hand Wil u hold it? If i hold out my arms Wil u hug me? If i go 4 ur lips Wil u kiss me? If i capture ur heart Wil u Luv me?
I wrote on d doorof my heart:"Please Do Not Enter.."Love came with a smile and said:" Sorry I Am Illiterate..."
Silly Thing About"LOVE"Whn U Get 'Little', U want More Whn U Get More, U Desire More Bt Whn U Loose It, U Realize Even Little Was Enough
I think of u, U too think of me.. But the differnce is, when I think of u, I send u message.. U think of me after recieving my message!
If i Give u Dozen Roses n u Ask y ther r no thorns?I wud just smile & show my bleeding hAnds & sAy i took them Away so thAt u Won't Get hurt.
There is only a thread gap b/w love and friendship.. Stealing heart with permission is friendship!! Stealing heart without permission is love!!!
"You can''t make someone love u, all u can do is be someone who can be loved, d rest is up 2 d person to realize ur worth"
**A cute Frndship poem: Monsoon rain or Summer heat, Ur d reason Y i breath, Tell me frnd wat is so sweet? Is that u or ur heart that beat.
When d situation gets u dwn, remembr there's some1 in heaven who loves u & watches over u.& there is someone on earth who cares 4 u. I DO!
U may not love me like I love U..U may not care for me like I care for U..ButIf U ever need me, I will alwys be around for U.
Can i say i love you today? if not, can i ask u again tomorrow? and the day after that? Because i'll be loving u every single day of my life
I am a paper, u can write urfeelings, scribble ur anger,use me to absorb ur tear,don't throw me after use,bcoz when u feel cold. I'll burn..
The Most touching Lines SAid by a Lover while breAkup.."Out of all ur lies"You said to me.I LOVE YOUwas my favourAte