Archive for May, 2013

Adding a glow in Silverlight with the DropShadowEffects class

I wanted to have a mouse-over effect for my Path – I mean, who doesn’t? Ladies love guys that can dynamically add Silverlight glow effects as much as they like guys that can use the ternary operator. So I’m going to tell you how to improve your love life.

First, the XAML. Notice the use of MouseEnter and MouseLeave events on my Path object:

    <Grid x:Name=”LayoutRoot” Background=”White”>
        <Path x:Name=”ScottPath” Stroke=”Black” Data=”M 20,100 C 10,300 300,-200 300,100″ MouseEnter=”Path_MouseEnter” MouseLeave=”Path_MouseLeave” />

Oh yeah, that’s right – I’m using a Bezier curve. This keeps getting better.

Now into the code behind we go. Before you enter the wonderful world of DropShadowEffects, you’ll need to add a reference to the right library:

using System.Windows.Media.Effects;

And away we go:

        private void Path_MouseEnter(object sender, MouseEventArgs e)
            DropShadowEffect dropShadow = new DropShadowEffect();
            dropShadow.BlurRadius = 10;
            dropShadow.Color = Colors.Purple;
            dropShadow.Direction = 0;
            dropShadow.Opacity = 1.0;
            dropShadow.ShadowDepth = 0;

            ((Path)sender).Effect = dropShadow;

        private void Path_MouseLeave(object sender, MouseEventArgs e)
            ((Path)sender).Effect = null;

What I have going on is that when the mouse hovers over the Path object, I create an instance of the magical DropShadowEffect class, set all the variables that make me feel happy and wonderful, and add the DropShadowEffect  to the Effect property of the Path object. And when the mouse leaves the path, I set the Path.Effect to null to get rid of the effect.

No worries, no fuss, just an awesome purple glow on your line.

Leave a comment

Displaying annoying error messages in JavaScript

The following code has no practical use. You have been warned.

Who hasn’t wanted to occasionally annoy users with a bunch of error messages? Well, here is an easy method using JavaScript to throw up a bunch of error messages to stop them from being productive. The code is easy to follow, but basically, I create an Array of error messages, then loop through them, generating a “confirm” box until either the user has exhausted all errors or gives up, clicks “No”, or leaves your site never to return:

    <script type=”text/javascript”>
        function GenerateMessages(count) {
            var messages = new Array(‘Are you sure’, ‘No, seriously, are you really sure?’, ‘Come on, this is a big decision. Think about it for minute. Still want to do it?’, ‘There is no shame is canceling. Are you really sure?’, ‘Would your mother approve of this decision?’, ‘No is an acceptable answer, just ask Nancy Reagan. Giving into peer pressure and saying Yes?’, ‘Last chance. You are going to go through with it, huh?’, ‘OK, I lied. This is your last chance. Super duper sure?’);

            for (var i = 0; i < count; i++) {
                var answer = confirm(messages[i]);

                if (!answer) {
                    alert(‘Good choice!’);

            window.location = ‘;;

Then call the script with a button onclick event:

<input type=”button” onclick=”GenerateMessages(8)” value=”Exit” />

Yes, I know, you can’t get that minute of your life back that you spent reading this post, but I appreciate the time.

Leave a comment

Optionally hiding columns in Reporting Services

One of these things is not like the other. My customer was intensely interested in Inspector Gadget, and had a SSRS report to tell them all about it. So we have the three main characters that were selected as the “Character” parameter, and this parameter was multi-select:

Inspector Gadget

There was a column that shouldn’t be visible when only Brain was selected, but should be visible if all characters were selected, or if Inspector Gadget and / or Penny were selected. I don’t know why, I just work here, living in the 80s. To toggle on the visibility, I wrote this little piece of code. If the count of the parameters is three (all characters were selected), then set the “Hidden” property to “False”. Otherwise, determine if “Brain” was one of the selected characters, and if it was, set the “Hidden” property to “True” (hiding the column):

=IIF(Parameters!Characters.Count = 3, False, IIF(Join(Parameters!Characters.Value,”,”).Contains(“Brain”), True, False))

As always, serving your Inspector Gadget / SSRS needs.

Leave a comment