Perfil de BenSpacecatazBlogListas Herramientas Ayuda

Spacecataz

Appreciating and adapting in the pre-singularity world.
29 abril

Animated Transitions in MVVM with WPF (my attempt)

I've been filling my brain with all kinds of data and discussions surrounding the MVVM model lately. I really like the pattern, but there is a particular piece of the puzzle that's been bugging me. I spend a lot of time developing demos in WPF that use a lot of advanced graphics techniques. Every single change to the UI needs to happen smoothly, and that means a lot of animation and transitions. When I look at my code and try to think about how I would move more logic out of the view and either into XAML or into the ViewModel, this is an area that is most often the sticking point.

Well, after being inspired by Josh Smith's post about that very subject, I took my own crack at this. My primary motivation was finding something that would work for transitioning items in and out of itemscontrols as well as single child content controls. I also wanted to avoid adding code to the view. Josh was sticking with current "production-ready" code, but since my apps are often just demos anyway, I decided to go ahead and use the Blend3 Behavior goodness.

The idea is this: If you apply one of my Behaviors to a content control, and the content is of type ITranstionItem, then the behavior will apply a transition when the value changes. If you apply the behavior to a datatemplate to be used in an itemscontrol, those items will transition in and out when they are added/removed. The behaviors are meant to be stackable too. I built two behaviors (or actually I guess they're actions), one just fades items in and out, the other applies storyboards defined in the view and assigned at design time.

So even though this is very rough, I decided to show some details here. I don’t really like what I named things, and for some reason I did everything with properties and monitoring for PropertyChanged events instead of custom events (I did a lot of iterating on the fly) but I decided to stop here and step back. There's probably memory leaks and obvious improvement to be made.

Here's the interface. The viewmodels I want to support transitioning will implement this (or extend the abstract class below).
public interface ITransitionItem : INotifyPropertyChanged
{
    bool TransitionEnabled { get; set; }
    bool IsNew { get; set; }
    bool IsOld { get; set; }
    bool IsReadyToRemove { get; set; }
}

I also created an abstract class implementation for the properties and one reusable method called DelaySet. This is where I should probably change things to use more custom events rather than properties.
protected bool DelaySet(object currentValue, Action applyValue)
{
    var tItem = currentValue as ITransitionItem;
    if (tItem != null &&
        !tItem.IsNew &&
        !tItem.IsReadyToRemove &&
        !tItem.IsOld)
    {
        tItem.IsOld = true;
        PropertyChangedEventHandler handler = null;
        handler = new PropertyChangedEventHandler(delegate(object s, PropertyChangedEventArgs ev)
        {
            if (tItem != null && tItem.IsReadyToRemove)
            {
                tItem.PropertyChanged -= handler;
                applyValue.Invoke();
            }
        });
        tItem.PropertyChanged += handler;
        return true;
    }
    else
        return false;
}

Then here is a view and viewmodel using the fade action:
<ContentPresenter Content="{Binding Path=Content, NotifyOnTargetUpdated=true}"
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="TargetUpdated" >
            <PersonalMVVMSampleApp_Behaviors:Fade_InAndOut_TransitionAction />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</ContentPresenter>

public class ApplicationViewModel : TransitionItem
{...
  public ITransitionItem Content
  {
    get { return _content; }
    set 
    {
        if (!DelaySet(_content, () => Content = value))
        {
            _content = value;
            OnPropertyChanged("Content");
        }
    }
  }

The code for items controls is even simpler because no special code is needed in the viewmodel. It's handled by a custom version of ObservableCollection:
public class TransitioningObservableCollection<T> : ObservableCollection<T> where T : ITransitionItem
{
    protected override void RemoveItem(int index)
    {
        var toRemove = this[index];
        if (toRemove.IsReadyToRemove)
            base.RemoveItem(index);
        else if (!toRemove.TransitionEnabled)
            base.RemoveItem(index);
        else
        {
            toRemove.IsOld = true;
            toRemove.PropertyChanged += new PropertyChangedEventHandler(delegate(object s, PropertyChangedEventArgs e)
            {
                if (toRemove.IsReadyToRemove) Remove(toRemove);
            });
        }
    }
}

I won't post the details of the behaviors here, but basically they attach and look for a transiton item to listen to, then apply the transtions when appropriate. (i'll make the source code available soon)

This is meant to get me on the road to something reusable, but I welcome suggestions for how to improve this, or you can just tell me that this is a crazy way to handle this issue and you'll probably be right.




12 enero

Microsoft's REC

I see Microsoft has announced their Retail Experience Center (REC). I've been there, and I can definitely say they've built something really cool. In fact, they've included so much detail it's actually kind of surreal. You can easily forget you're not in a real store. Right down to the giant mural of a parking lot that's behind the sliding glass doors. Anyway, if you have the means, I recommend checking it out.

Also, Avanade's retail demo is installed on their Microsoft Surface, and you can catch a glimpse of it in the video (it also appears in one of the gallery images). So that's cool to see! :)
05 enero

Financial Planning on Microsoft Surface from Avanade and Accenture

We've finished another Surface demo and that means I get to embarras myself in another video. Hopefully you're too distacted by how amazing the app is to notice my performance. I had a lot of fun developing this one, and while I'm sure everyone will have their own positive and negative reactions, I think we produced something that showcases several good ideas in a short amount of time. So I'm happy. Please let me know if you have thoughts or questions. I'm happy to discuss.
 
 
31 agosto

The Big Drive

I just finished a drive from St. Paul to Seattle. 2.5 days, 1800 miles, lots of fun, 1 perspective shift. I have a new position at the same company, but now it makes more sense for me to work out of our headquarters in Seattle, so here I am. Technically, I could have flown. It would have taken about 6-7 hours total, and would have put me here in time to enjoy a beautiful august weekend. The company is paying for relocation, so whether I drove or had my car shipped was totally up to me and made no financial difference. So why did I drive?

It was a rather an easy decision to make, even though I put on a show of going back and forth about it for a couple weeks. Really though, I knew I wanted to drive the first time I thought of it, but it’s only in doing it, that I understood why. The fact that I hadn’t ever been in Montana, Wyoming, or Idaho was something I thought should change. I’m also planning to sell my car shortly, now that I don’t need it to get to work or the gym, so I thought it would be good to enjoy it while I have it. But the real reason turned out to be perspective. I needed to MOVE, not just pop over to Seattle like I’ve done at least a dozen times before. I wanted to feel the very sobering reality that I was leaving my home state indefinitely for the first time. I wanted to feel the weight of leaving behind friends and family. Not that I’m a masochist, understand; it just seemed like flying here would be like cheating somehow.

The fact is that Seattle IS 1600 miles from St Paul (the extra 200 miles I drove was for a very worthwhile detour to Yellowstone national park), and one tends to underestimate the enormity of that distance when they routinely cover the round trip twice a week and sometimes 10 times in a single month. The incredible speed at which you travel while 30k feet above the earth should evoke its own kind of awe, but for someone who didn’t grow up taking road trips, I suspected these distances were somewhat lost on me. I was right.

For example, yesterday I spent over 11 hours driving; saw the sunrise and the sunset from the car, and stopped only occasionally to stretch my legs and remind my senses that the world isn’t perpetually speeding by at 80 mph. When I started the day I was in Montana and I ended it in….wait for it….Montana! And still a good 150 miles from the western border! Granted, I spent some of the day taking a detour a bit south which took me through a corner of Wyoming, but generally I was heading west the whole day. I averaged 60 miles an hour according to my car’s computer, and filled my tank a couple times. That’s distance!

And here’s the most important thing about it: every mile along the way, every mountain pass or 10 mile straight-away that begs you to see if you can get your car past 130mph, I was aware (at least subconsciously) that it brought me further away from my old home and closer to my new one. That limbo time, during which I thought of myself as a homeless wanderer (I should have learned kung-fu first) was therapy for the mind. Or at least I hope it was, because it didn’t do much for my back.

I will take possession of my new apartment tomorrow, and in so doing, complete a journey. Moving to a new city is not a breakthrough for mankind, I realize, but this is a journey that has been a long time coming for me, and I feel it is (if you’ll permit the cliché) a beginning as much as an end. Only one reader of this will remember directly, but I once stood on a dock in Greece telling someone, who was at the time a relative stranger, about how I wanted my life to be bigger. It was something I hadn’t thought of in those terms before that moment, but it was very true. So what better path to a bigger life than a big city, some big sky, and a big drive?

The Drive's Flickr Set

10 julio

iPhone 2.0 vs. Windows Mobile - A Back and Forth Conversation

I decided that the only way I can express my decision making process, which has led me to NOT buy a new iPhone tomorrow, is to externalize the conversation taking place in my head. So here ya go:

 

WM Owner

Ok, I've decided to stick with my HTC Touch Cruise (substitute any of the latest wm phones with 3G and GPS).

iPhone 3G Owner

But how can you think WM is still a better choice when the new iPhone is so great?

WM
I know, I have to keep reminding myself of the reasons. Let's do this though. You start telling me the things you love about the iPhone that you think are either unique to it, or better than WM. And I will respond with something that is unique or better on WM; OR demonstrate equivalent functionality on WM, and see how far we get. And I'm not just going to list features for features sake; these are things that really matter to me

iPhone
Alright. Let's start with mobile web browsing. Web pages are displayed like they are on a desktop.

WM
Yeah but opera 9.5 on wm does the same thing as safari now. It has all the same benefits. The only thing it can't do is the multi-touch pinch, so just to even us up, I'll throw in the obvious wm advantage that it can be used with any carrier world-wide and supports more radio bands.

iPhone
Fair enough. So how about the great multi-media ipod functionality? It plays videos beautifully.

WM
I'll give you that it's better overall at multi-media, although I can play xvid torrents natively on mine with minimal slowdown, while those have to be converted for the iPhone. Also I can play audio over bluetooth and expand my storage with the SDHC card reader.

iPhone
The iPhone is great for texting with its threaded display and smart keyboard.

WM
Actually I have threaded txting now too, and I can copy/paste things into my txts/emails from any other program on the phone. I also have a 3rd party keyboard that incorporates all of the smarts of the iPhone keyboard, plus the ability to choose your layout and customize other useful options.

iPhone
I love google maps on the iPhone. And now I have gps.

WM
Yeah I have the same google maps program with gps, and I also have MS live search which includes turn-by-turn gps support via the internet. It even does rerouting when you deviate from course. And it supports voice commands.

iPhone
The gesture-based UI is great.

WM
I'll give you that it's nice, although multi-touch is probably underutilized. HTC phones do gestures now though too. All lists are flick-able. I can flip through pictures and emails. There is a program launcher that is all gesture based. And I can even zoom in on areas of pictures by drawing little circles instead of doing the pinch.

iPhone
Email support is great, and now supports exchange push.

WM
That's great, but obviously WM has that too. Also, it implements ALL exchange features. The iPhone is missing tasks and flagged emails, which are extremely useful to me.

iPhone
How about how you can browse itunes and buy/download music directly over wifi?

WM
Good one. Although I have an app that will auto-download podcasts over the 3g network, which I find more useful than buying songs. I also have apps for twitter and flickr uploading, all running in the background, which I understand you can't do with 3rd party apps on the iPhone as they can't stay resident.

iPhone
Honestly, when it comes down to it, the iPhone is all about the overall amazingly fast and beautiful user experience.

WM
You win on ux and speed, I can't deny that. It takes a lot to overcome this one for me. Here's a few things I haven't mentioned yet: OfficeCommunicatorMobile for corporate IM and true freedom from the office; decent 3mp camera with auto-geotagging; windows remote desktop, for tweaking my home server from the road; laptop tethering to the internet via Bluetooth; spare batteries; Skype.

   

01 julio

Surface Video Available

I promised in my last post that we would put up a video of the Avanade/Accenture Surface demo, and it's finally here. Just took a bit longer than expected.
So enjoy, and try not to be too hard on the poor actors, they aren't professionals. :)

  

technorati tags:, , ,

11 marzo

Avanade and Accenture's Surface Demo!

Avanade put out a press release today announcing a Microsoft Surface demo that aims to "enhance the retail experience". This happens to be the application I've been working on for the past few months at Avanade headquarters in Seattle and I'm really excited to see it hit the light of day.

There should be a video available soon, but basically this application helps you shop for products by making it easy to compare them to each other, and see how they will work in your home. For instance, you can draw your living room blueprint-style, placing all your existing furniture and equipment, and then try out a new TV to see how well it will fit. Then you can resize the TV on the fly to pick the best one for your room. It's a bit hard to explain how well that works, but when the video is available you'll see it's pretty cool. :) There are also additional aspects to the application involving making product suggestions and helping with connecting up your equipment. It's all really good stuff that I would personally love to see adopted by retailers in the near future.

From a development perspective, this was a really fun app to work on. This is essentially a big WPF app that is touch-enabled using the Surface SDK. Our team didn't start with much WPF experience, so we had that learning curve to deal with on top of learning the nuances of the Surface device itself. To Microsoft's credit, it really wasn't too tough. Even in this early stage the devices are stable and easy to work with, and the SDK is well designed. The whole approach to designing applications for Surface is still evolving inside Microsoft, and probably our biggest challenge was trying to figure out which design principles we could work into this application and to what extent we could define our own. There were quite a few iterations of the design, and I must say I'm pretty impressed with what we were able to produce in just a couple months (we started in December).

So take a look at the pics (that's me in the first one on the left!), and be on the lookout for a video. I know this isn't exactly a blog people are reading for development posts (or reading at all actually) but feel free to ask questions in the comments or send me email to seraph.ben+surface@gmail.com. I still have a ton to learn about WPF and Surface, but I'm happy to share the knowledge I've gained so far!

Update: The video is now available.

technorati tags:, , ,


23 febrero

Seattle and Skiing

I've been working in Seattle for the past few months, basically since I got back from New Zealand actually. It's been great to work out of the company headquarters for a while, and I'm getting a chance to work on some really cool tech (although I'm not actually allowed to say what yet). I grabbed a corporate apartment here and have spent only two weekends at home in 2008 so far, so I've definitely had a chance to get to know the city. Let's just say it's an unquestionable upgrade weatherwise from MN winters. :)
The last two weekends have been the most dramatic examples of this. Not only do I get to enjoy 50's and sun in February, but if you drive for two hours there are two totally decent mountains waiting for you. Last weekend I hit Steven's pass, and I just got back from Crystal Mountain a few hours ago. These aren't quite Colorado or Utah quality, but they get the job done admirably, and the views certainly don't disappoint. There's nothing like skiing to the edge and seeing the glory of something as huge as Mt Rainier spread out before you.
 

Mt Rainier
08 octubre

Travel Update

Since the last time I posted here I've spent a month in India (August; for work) and I'm in the middle of a month in New Zealand and Australia! Big things, and I have really not had much of an urge to blog about them for whatever reason, but I've been uploading lots of pics and so I highly recommend, if you really care about what I'm up to, subscribing to my flickr feed. (www.flickr.com/photos/seraph).

I didn't upload much for India pics until I got back, but I've been pretty good with getting one cameraphone pic up everyday from NZ. Unfortunately, that will have come to an end today as I jumped in the spa with my new Nokia n73 in my pocket! So that's a bummer, although I didn't lose much since I didn't even buy the phone (won it right before I left the US in a raffle :) SO, I will have to start just uploading whenever I can get a net connection. The phone charges were starting to add up anyway.


I don't really have the time to go into much pontificating on the NZ trip yet, but it's amazing so far. Sandy and I have 7 days here nearly complete already and we've had great luck at every turn (we're on the south island for the whole trip). Our glacier walk had sun instead of hail, and our trip on milford sound last night included dolphins, penguins, kayaking, a bit of rain AND sun, so we're having a blast. The big thrills are even yet to come! I have to say, even if you didn't do a trip on the water in milford sound, just the drive down is absolutely breathtaking. I swear, driving along yesterday, with a new epically beautiful landscape around every bend, I actually started to lose the ability to ooh and ahhh, I just gaped. We're in Te Anua on the south island tonight, and are about to head to a glow worm cave trip that sounds interesting. I've just uploaded a bunch of pics to flickr with a bit of commentary. Check out my australia/nz set here.

25 abril

Beverly Warns Photography

I just remembered something I wanted to mention about my recent Hawaiian trip; while on the big island, I made my first significant art purchase ever. I picked up a limited print of Beverly Warns' "Cliffs of Kalapana". I should say that the reason I've never bought any art before is not because I've never seen stuff I like, but just because I've never found something I could not live without. I always have a conversation with myself about how (especially with photography) I can find things just as good or better on Flickr for free, and there is no need to spend good money on a permanent print of something when I am constantly amazed at what I can paint across my computer screen any time I please.
 
Well Beverly's infrared shots of Hawaii so completely blew me away that I could not leave without at least ONE of them. The difficulty was actually choosing with one! It's not just that they are well executed, but it's the fact that the technique reveals details and beauty that you wouldn't even get if you were standing there in person. It's stunning work and I'm grateful to have found it.
 
Seraph321
Xbox Live GamerCard
Rep:
5/5 estrellas
Marca:
9160
Zona:
Recreation
Guitar Hero 5GhostbustersScene It? BOS!Banjo Kazooie: N&BHalo 3: ODST

FriendFeed

Cargando...Cargando...

Latest Links

Cargando...Cargando...