SlickEdit 2008 Week 2

SlickEdit 2008 Week 2

Even though there's been no disposition on the macro issue -- and it IS a big issue to code up, I'm sure -- I'm trying to use SE2008 as much as possible to get a feel for it in general. There's differences, and there's goodness, some things you just find accidentally.

For instance, just now I was deleting characters using the backspace key, and was getting ready to type something uppercase, and whoa... shift-backspace puts characters back... cool... not sure if V7 did that or not... I'm guessing not since I just noticed it now :)

With the newer versions of Visual Studio, I find myself using SlickEdit differently than I did when it first came out. At first it was the only game in town for a good editor with intellisense, and all that, but then Visual Studio caught up in some respects, so SlickEdit becomes the "Pro From Dover", for me. I use it to fill in the blanks in areas that I feel the Visual Studio editor falls down, or for things that either wouldn't work in VS, or would be more trouble than they're worth.

One big thing I use Slick Edit for is searching across my system. I use the Find in Files function and point it at the root of my project, or sometimes I'll just point it at the base folder for ALL my projects and search for something in either the .aspx or .cs files. This still works great in SE2008, but the UI is a bit different.

I'm used to doing Alt-F5 to open the find box, type what I want, or accept what's there from the previous search, then hit Alt-U for Files/Buffers. Well, that changed a bit, because everything is on that one dialog, with tabs for Find in Files, Replace, and Replace in Files. So I have to retrain myself to hit the Find in Files tab.

In V7 the search results showed up in another window, and I had written a macro to pop that out for me to see it quickly.

In SE2008, the search results go to an 'Output' window that is docked at the bottom very similar to VS. I wasn't sure about that at first, since I'm used to it being full-screen, but found I could easily double-click the caption on it, and undock it to get it larger to use, then double-click it back to it's docked position. I like that... it keeps that window out of the chain of edit windows I have open.

On a similar subject, there is a File toolbar that puts up 'tabs' for all files open, also similar to Visual Studio. I'm still using it, we'll see how that goes. I'm not a big fan in VS of having to scroll through that list, and really like being able to hit Alt-B in SE to pop the a file list up, and that still works :)

So, no complaints today... just learning to use the new features.

Stay in the 'Light!

Twitter SLNews | Join me @ SilverlightCream | SL Web Articles | SL2 Web Articles | My Articles | My Tutorials | My Tooltips | My SL2 Articles | My SL2 ToolTips | SilverlightCream

I have arrived..

Just arrived to my new home in Seattle. The apartment Microsoft have provided is quite nice actually, roomy, warm and with a nice fast cable modem to cap it all off.

We spent some time prior to arriving in Seattle at Disneyland (Highly recommend folks avoid weekends - I should know better, but it was a schedule thing).

DisneyCalifornia 095

It was great to see Corey interact with all the Disney characters he's been watching on the idiot box for quite some time. The biggest hit for him was when he finally got to see Lightning McQueen (PIXAR).

He was grinning from ear to ear.

Next week I finally move into my new office at Redmond, and it's a nice hurdle to finally jump as there have been many delays to getting us here.

Next, writing a list of items to fill the new house, starting with Computer, TV and Microwave.

p.s

To all my fellow US Citizens what the heck is up with Corn Syrup being in everything. It's an evil ingredient and should be banned@!

50 New Silverlight Screencasts - Short and Snappy

I haven't seen these training videos receive nearly the coverage they deserve, so I wanted to try and "bump" them onto the radar.

Silverlight 2 Screencasts My erstwhile UK colleagues Mike Taulty and Mike Ormond have been hard at work over the last few weeks recording an amazing series of Silverlight 2 training screencasts. All free for the taking, these fifty videos provide a comprehensive guide to all matters Silverlight: from basic topics such as layout, controls, data binding, and styling to advanced topics like sockets, cross-domain requests, multi-threading and HTML interop. If even that's not enough, there are some great tips and tricks that go beyond the documentation: loading assemblies dynamically, embedding fonts and creating custom splash screens.

Many screencasts are too long or too ponderous - they don't suit the rapid-fire medium of the Internet. These are all short - mostly just a couple of minutes in length, and they're well edited to remove anything extraneous. Highly recommended - please produce some more, Mike and Mike!

Check them out here: http://www.silverlightscreencasts.com. Oh, and of course, you'll need Silverlight 2 Beta 1 to watch them!

Silverlight Cream for May 19, 2008 — #277

Koen Zwikstra with a Slideshow 2 Preview, Hanu Kommalapati continues with Silverlight for the Enterprise, Tim Binkley-Jones on Tags, and Tim Heuer with a SL Filckr Badge.

From SilverlightCream.com:
Slideshow 2 preview
Koen Zwikstra gives us a preview of his Silverlight SlideShow upgraded to SL2. Check out the post for the feature list and some images.
Silverlight for the Enterprises - Application Partitioning
Hanu continues his Silverlight for the Enterprise series with this one on Application Partitioning... another detailed article...
Tag, you are not it
Tim Binkley-Jones takes off on an expose of SL2 tags and what can't be done, then shows you how to do it anyway... good stuff!
Silverlight Flickr Badge
Tim Heuer took on Joel Neubeck's flip screensaver and decided lashing it up to Flickr seemed like a good idea. Of course since it's hitting Flickr, I can't see it from here, but trust me, if it came from Tim and Joel, it's good :)

Stay in the 'Light!

Twitter SLNews | Join me @ SilverlightCream | SL Web Articles | SL2 Web Articles | My Articles | My Tutorials | My Tooltips | My SL2 Articles | My SL2 ToolTips | SilverlightCream

In Silverlight, Tags are just strings…

Tim Binkley-Jones sent in a Tip of the Day that custom attached properties make a superior choice to Tags because, in Silverlight, Tags can only be strings.

This is not what I've been saying, but he is right; I was wrong.

He provides this excellent blog entry in which he explains the problem and the solution: custom attached properties.

ParthianShot

His Parthian Shot: "A custom attached property is the tool of a Silverlight/WPF developer.  Not as clumsy or random as a Tag, but an elegant tool for a more civilized technology."

Ouch.

 

 

 

 

 

 

Quiet Please…Digging Into ADO.NET Data Services

Silverlight Logo

Now that .NET 3.5 SP1 and Visual Studio 2008 SP1 have been Beta'd, I've been spending a lot of time digging deep into the ADO.NET Data Services in that release. Because of this, i've been very quiet.  Look for this blog to get very loud in June after TechEd (no, I won't be there). 

I will be releasing a new version of my Silverlight Sample Site (www.silverlightdata.com) with ADO.NET Data Services and Forms Authenticaiton support in the next few weeks.  Keep your eye here!

© 2008 Shawn Wildermuth. All Rights Reserved.
Add Comment | digg this

Converting it to VB

Just to tie the previous two blog posts together, I copied the C# into Instant VB and here is what it spit out (line break added to fit)

Private Sub AnyPropertyCheckBox_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim isVisible As Nullable(Of Boolean) = Not AnyPropertyCheckBox.IsChecked
    For Each uie As UIElement In LayoutRoot.Children
        Dim cb As CheckBox = TryCast(uie, CheckBox)
        If cb IsNot Nothing Then
            If cb.Tag IsNot Nothing AndAlso cb.Tag.ToString().ToUpper() = "SEARCHCRITERIA" Then
                cb.Visibility = If(isVisible.GetValueOrDefault() = True, _
Visibility.Visible, Visibility.Collapsed) End If ' end if tag match End If ' end if check box Next uie ' end for each element End Sub ' end method

Blend, VS, Events and C#

From now until the summer I'll be working on videos, tutorials, presentations and blogging, but I'll also be writing Programming Silverlight 2 with Tim Heuer. Rather than convincing you that I'm continually hawking my book, I'd rather use the process of writing it as an opportunity to provide good, free, and I hope interesting material for this blog. (Write to me if I get the balance wrong!).

As an example, I ran into a bit of C# in what I'm writing in the first chapter that I thought made for an interesting example of how a Silverlight 2 programmer can? must? juggle the three principle technologies of (a) Visual Studio and (b) Blend and (c) a programming language of choice (which I can't quite understand why that wouldn't be C# or VB but I do know lots of folks disagree, and that in itself will make an interesting blog entry!)

So this blog entry may be of interest only for those of you who enjoy a bit of C#.

The context

This is early in the book and I'm laying out 9 checkboxes, used to designate search criteria. The first checkbox is "Any". If that is clicked the others are invisible,

 AnyCheckBox

If Any is unchecked, all the other criteria appear,

 AnyUnchecked

 

The book then goes on to show a number of things, including how to create the refining characteristics panels and how to overlay them, etc. etc. but the part I want to focus on here is a tiny detail: how you set the visibility flag on the check boxes. 

Here is the code I used.

private void AnyPropertyCheckBox_Click(object sender, RoutedEventArgs e)
{
    bool? isVisible = !AnyPropertyCheckBox.IsChecked;
    foreach (UIElement uie in LayoutRoot.Children)
    {
        CheckBox cb = uie as CheckBox;
        if (cb != null)
        {
            if (cb.Tag != null
                && cb.Tag.ToString().ToUpper() == "SEARCHCRITERIA")
            {
                cb.Visibility = isVisible == true ? 
                   Visibility.Visible : Visibility.Collapsed;
            }   // end if tag match
        }       // end if check box
    }           // end for each element
}               // end method

 

I'll walk through the entire method in just a second, but the key c# construct here is the use of the ternary operator (?:)

cb.Visibility = isVisible == true ? 
    Visibility.Visible : Visibility.Collapsed;

This operator (?:) is called ternary as it is the only operator that takes three parts. Here is how you read it (inside out).  First you evaluate the truth part  (isVisible==true).  This could have been written as

!AnyPropertyCheckBox.IsChecked == true

or

AnyPropertyCheckBox != IsChecked

To simplify I used an interim nullable boolean variable.

In any case, if the truth part evaluates true, then whatever is on the left side of the colon (in this case Visibility.Visible) is assigned as the result of the expression, otherwise, whatever is on the right side is assigned.

I admit, it is a construct only a former C programmer can love.

Note that the code I used  is exactly the same as writing

private void AnyPropertyCheckBox_Click(object sender, RoutedEventArgs e)
{
    bool? isVisible = !AnyPropertyCheckBox.IsChecked;
    foreach (UIElement uie in LayoutRoot.Children)
    {
        CheckBox cb = uie as CheckBox;
        if (cb != null)
        {
            if (cb.Tag != null
                && cb.Tag.ToString().ToUpper() == "SEARCHCRITERIA")
            {
               if ( isVisible == true )
               {
                   cb.Visibility = Visibility.Visible;
                }
                else
                {
                   cb.Visibility =  Visibility.Collapsed;
                }
            }   // end if tag match
        }       // end if check box
    }           // end for each element
}               // end method

 

So, as promised, here is the line by line walk through

// Declare isVisible to be a nullable boolean variable
// (it can have three values: true, false or null
// If AnyPropertyCheckBox's property IsChecked is true, assign false
// otherwise assign true.  This is dangerous code as the property could
// be null, and in retrospect I'd rewrite this as
// bool? isVisible = ! (AnyPropertyCheckBox.IsChecked == true);
// which would assign false if the property is true or null
bool? isVisible = !AnyPropertyCheckBox.IsChecked;

Next we iterate through all the children of LayoutRoot which is a grid that contains all the UIElements on the page

foreach (UIElement uie in LayoutRoot.Children)
{
     // code to explain here
}

Within that loop we'll grab each element and cast it to type Checkbox. The cast will either work or return null. If it does not return null, we'll ask the temporary check box if its tag is null. If not, then we have a check box with a tag and we can see if that tag, when turned to a string matches the tag we're looking for

// try casting to a checkBox
CheckBox cb = uie as CheckBox;

// if the cast is not null, it really was a check box
if (cb != null)
{
    // see if the tag is null and if not if the tag as a string
    // matches what we're looking for
    if (cb.Tag != null
        && cb.Tag.ToString().ToUpper() == "SEARCHCRITERIA")
    {
        // code here
    }   
}       

Note that the test for the tag not being null and then turning the tag into a string is accomplished in a single if statement. That is safe if you get the order right and use the && symbol between the two expressions, because they will short circuit. That is, because both must be true, if the first is false, the second will never evaluate (which is a good thing, because if the first is false, then the Tag is null and trying to call ToString on it would throw an exception).

Finally, inside the if statement is the ternary operator where we set the visibility.

Not bad, but not obvious if you're not comfortable with a bit of C#.

Silverlight Cream for May 16, 2008 — #276

Joel Neubeck back with more flipping tiles, BradleyB on VSLive Orlando Presentation, Shawn Wildermuth on Uploading, John Evdemon on User Context, and Dan Wahlin on DotNetRocks!

From SilverlightCream.com:
Silverlight Flipping Tiles Animation
Joel Neubeck wasn't satisfied with me sitting and clicking his flipping animation from the last time I posted about it... this time he has an entire page of auto-flips! Since I don't have an iPhone, I'm not familiar with this, but it's dang cool... and what's cooler, is he has the source on the page :)
VS Live Orlando "Introduction to Silverlight programming"
BradleyB did a VSLive show in Orlando and has posted all his "Introduction to Silverlight Programming" materials on his blog... definitely worth a look!
Uploading and Silverlight
I was going to try to break these out, but Shawn describes them so good, I'll leave it. He has two great links to Uploading blog posts in this small post of his... check out both!
Getting User Context in Silverlight 2
John Evdemon has a nicely done article about getting User info in SL2. We've seen some of this, so bonus... we can compare and get even better info... never can have too much source code to look at!
Dan Wahlin on Silverlight 2.0 and WPF
Dan Wahlin joins the DNR folks at DevConnections and puts on a SL2 and WPF show in a way that only Carl and Richard can do! ... good drive-home material!

Stay in the 'Light!

Twitter SLNews | Join me @ SilverlightCream | SL Web Articles | SL2 Web Articles | My Articles | My Tutorials | My Tooltips | My SL2 Articles | My SL2 ToolTips | SilverlightCream

San Francisco Silverlight Tour Stop (May 28th) Only Has Five Seats Left!

URL: http://www.silverlight-tour.com

Silverlight Logo

For the upcoming San Francisco stop of the Silverlight Tour starting May 28th, there are only five seats left.  If you want to spend days with me discovering Silverlight 2, Beta 1, your time is running out.

You can see a full outline of the three day course here:

http://silverlight-tour.com/outline.aspx

© 2008 Shawn Wildermuth. All Rights Reserved.
Add Comment | digg this