Thursday, November 3, 2011

Non intrusive shadow effect for translucent area

NeXXeuS asked a very interesting question. In WPF, you have DropShadowEffect which displays a shadow of a geometry/shape. But if the geometry/shape is translucent (0 < Opacity < 1),  then you can see the shadow through.

The question was posted on SO as:

Ques: I have a DropShadowEffect on a Rectangle with a fill that's slightly transparent. The problem is, the drop shadow also shows up inside the fill, which is what I don't want. Anyways to solve this? I tried this, but it doesn't work for me.

My answer:
This is very tricky. You need to customize the shadow effect for this. This solution gives the desired effect.
This is a sample Grid with yellow background. I've drawn two intersecting rectangles of 100x100 dimension on it. You may need to customize the size according to your need. One rectangle is gray rectangle (to show shadow), and the other is a red rectangle (the actual semi-transparent rectangle that you want to display). The shadow depth has been hard coded as 5 pixels here. Please customize it at:
  • RectangleGeometry Rect="5,5,100,100"
  • RectangleGeometry Rect="0,0,95,95"
So, the grid looks like:
   1:  <Grid Background="Yellow">
   2:      <!-- A rectangle for shadow -->
   3:      <Rectangle Fill="Gray" Width="100" Height="100" Opacity=".7">
   4:          <Rectangle.Clip>
   5:              <CombinedGeometry GeometryCombineMode="Exclude">
   6:                  <CombinedGeometry.Geometry1>
   7:                      <RectangleGeometry Rect="5,5,100,100"/>
   8:                  </CombinedGeometry.Geometry1>
   9:                  <CombinedGeometry.Geometry2>
  10:                      <RectangleGeometry Rect="0,0,95,95"/>
  11:                  </CombinedGeometry.Geometry2>
  12:              </CombinedGeometry>
  13:          </Rectangle.Clip>
  14:          <Rectangle.Effect>
  15:              <!-- For nice soft shadow effect -->
  16:              <BlurEffect Radius="5" />
  17:          </Rectangle.Effect>
  18:      </Rectangle>
  20:      <!-- Actual rectangle which is translucent -->
  21:      <Rectangle Fill="Red" Width="100" Height="100" Opacity=".6" >
  22:          <Rectangle.Clip>
  23:              <RectangleGeometry Rect="0,0,95,95"/>
  24:          </Rectangle.Clip>
  25:      </Rectangle>
  26:  </Grid>

Hope this is interesting to you as much as I had fun creating it! :)

Sunday, October 2, 2011

Communication, an IT industry perspective

Does anyone else in software development and sustenance field thinks that actual work, the real work which brings quality to a product, is done by fixing the bugs, and not just by reporting it?

A sustenance (or maintenance) team usually contains two essential parts - development and testing (technical names may vary.) The communication between these two small teams is crucial for customer satisfaction and not just personal financial gains, though its part of it. But then, who wants to get up and walk to the other team member and say, "Hey! I found this crazy bug here... can you fix it?" Very few.

Most of the teams think reaching out to other teams or projects is not their job. They rather shove it in management's behind - "Let them initiate a formal channel." If you work under the style where each team is divided to the extent that they cannot work together without the involvement of superiors, there is something wrong there. I was thinking of designing a flow chart for the problem identification, but it would defeat the purpose of this post. :) We need action to resolve the problem, not just identify and report it.

But in short, if you are not allowed to reach out to the teams and individuals, the problem may very well be in the style of working. The problem may be in the rules that govern the working environment. Locate the problem and find a way which works best to diffuse the problem. This, is troubleshooting.

Communication, even in its bare essential, is terrifyingly important. Its meant to be practiced, or suffer consequences.

Saturday, October 1, 2011

Visio 2010 64-bit bummer

Its so weird and irritating to know something doesn't work and has been documented already. Just that I did not search for it. How would anyone know if things will work or not?

You cannot use the ActiveX control of Visio 64 bit edition in your VS applications. I happen to run everything in 64 bit mode. x-(

Here is the info:

You cannot add the Microsoft Visio 14.0 drawing control to a Windows Form application in Visual Studio if you have the 64-bit version of Visio 2010 installed

Cause: These problems occur because the Visual Studio designer does not support 64-bit ActiveX controls and because the 64-bit version of Visio 2010 only works with the 64-bit version of the Microsoft Office Visio 14.0 drawing control. Therefore, the drawing control cannot be instantiated.

To work around this problem, follow these steps:
  1. Install the 32-bit version of Visio 2010 on a computer....

Ridiculous. Now, I've to undo the installation and install 32 bit version. Great! :(
Why is VS Designer not modified to support 64 bit ActiveX controls?

Even when I uninstalled 64 bit Visio, the 32 bit Viso won't install because of 64 bit Office installed on my machine. That means I've to uninstall whole 64 bit MS Office for just one VS Designer to work. WTH?!

Monday, January 3, 2011

Uno 1.3 at Softpedia

This is great news! My game Uno (ver 1.3) has been featured at Softpedia! Yay! :)
The link is here ->

It has been rated "Clean" for not containing any spyware/trojan/virus.

I feel motivated when I see people using my creations. I plan to release a better/faster version soon.