Welcome to Windows Workflow Foundation (WF)
Top Tasks :

WF Team Bloggers

Browse by Tags

All Tags » Misc   (RSS)

  • .NET 3.5 Beta Exams

    Trika dropped me an email asking me to point out the nice fact that if you're interested in taking a beta certification exam for WPF, WCF or WF, they've extended the deadline out a few weeks.  This means you can take a beta version of the test (FOR FREE), and if you pass it counts as if you passed the actual test, but you can get an early jump on the certification train this way. Check it out here . Read More...
  • Visual Studio Tip : AutoFormat Your Code

    Has this ever happened to you? You find some code on the Net so you copy and paste it into a source file within Visual Studio and notice that all the formatting is somehow messed up. For example. some lines might be indented while others are not.

    To have Visual Studio fix it all up nice and tidy for you, select the text, hold CTRL and hit K followed by F (CTRL+K-F). What I usually do is do a CTRL-A to select all text then do the CTRL+K-F combo. Voila!

  • Musings for 2008 Resolutions

    It seems to be the thing to note a few things one will try to do better in the new year.  What follows are my resolutions that are related to things at work. Work with Outlook shut off - let me focus on the task at hand Work with minimal internet induced interruption - see note above :-) Find interesting WF content to blog about until I can talk more about the work going on for Oslo Ask a lot more questions of you, what your experience is with the WF designer, and what we can do to make that better Learn F# - I enjoyed the brief excursion into Lisp while an undergrad, I would like to get back into thinking in a functional way Work to improve my speaking skills - I've been happy with my performance at the conferences I have spoken at, but I haven't really done anything to try to take that to the next level.  A corollary: Deliver at least one "non-traditional" presentation - I (and many people in the audiences) see a million and a half "bludgeoned by bullet point" presentations a year.  I'd like to try something different (a good example of this is Larry Lessig's talk at TED this past spring (deeper sidenote, a great collection of interesting speakers and speaking styles are present at the TED podcast.  I always make sure to have a few of those on my Zune to watch on the bus)) See you all at PDC :-) Read More...
  • C# WebCam User Control Source

    Some people have asked if they could take a look at the source for the WebCam Vista Sidebar gadget. After a little bit of cleaning up, I'm posting it now for you to take a look at. Here are some things worth mentioning:

    1. Uses the DirectShow.NET library

    2. I found some source in VB.NET and used that as a baseline (performed the conversion and cleaned up stuff that really wasn't needed)

    3. I am in no way a DirectX/DirectShow expert. Any questions sent my way will likely result in a blank stare back at you :-) (though fwiw, I do pick up things quickly and might be able to at least get you started on the correct path)

    4. If you look at the source, you might think "I thought this was a Vista Sidebar Gadget. Where is the gadget source?" That's the easy part. At the bottom of this post is a link to my .NET Gadget Creator application that I wrote (with instructions on how to use it with the WebCam control). That application will allow you to take any .NET UserControl and convert it into a Vista Sidebar Gadget. Just compile the WebCamControl2 control, and use the .NET Gadget Creator to create an instant Vista Sidebar gadget.

    5. You may receive an error when you run the provided test application saying something along the lines of "invalid argument". This is a known issue and is happens when more than one application tries to access the same camera. I haven't looked into fixing this so if someone wants to take a stab at it, clue me in on how to fix it.

    When looking through the source (there isn't that much to it) pay attention to the 2 primary methods. The first is the GetInterfaces method which creates all the necessary DirectShow interfaces and then creates the connection between DirectShow and your UserControl window (events are passed to the control via Window messages).

    The FindCaptureDevice method enumerates through your devices looking for the 1st video device it finds that provides an input (FilterCategory.InputDevice). This is done by creating a device class enumerator. Currently, the source will just grab the first device that it sees. If anyone is interested in knowing how to present the user with a list of all input devices, I can write some code to do that as well. Just let me know.

      103 UCOMIEnumMoniker classEnum = null;

      104 UCOMIMoniker[] moniker = new UCOMIMoniker[1];

      105 object source = null;

      106 

      107 ICreateDevEnum devEnum = (ICreateDevEnum)(new CreateDevEnum());

      108 int hr = devEnum.CreateClassEnumerator(FilterCategory.VideoInputDevice, out classEnum, CDef.None);

      109 DsError.ThrowExceptionForHR(hr);

      110 Marshal.ReleaseComObject(devEnum);

    Once the class enumerator is created, I just grab the first one that was found (assuming one was found) and bind it to an IBaseFilter object which I then return.

      117 int none = 0;

      118 

      119 if (classEnum.Next(moniker.Length, moniker, out none) == 0)

      120 {

      121     Guid iid = typeof(IBaseFilter).GUID;

      122     moniker[0].BindToObject(null, null, ref iid, out source);

      123 }

      124 else

      125 {

      126     throw new ApplicationException("Unable to access video capture device!");

      127 }

      128 

      129 Marshal.ReleaseComObject(moniker[0]);

      130 Marshal.ReleaseComObject(classEnum);

      131 

      132 return (IBaseFilter)source;

    Once the video input device is found and we have our base filter, we associate it with an ICaptureGraphBuilder2 object by telling it render a video stream through the preview pin of the input device(line 68 below of the CaptureVideo method).

    .cf { font-family: consolas; font-size: 10pt; color: black; background: white; font-weight: bold; } .cl { margin: 0px; } .cln { color: #2b91af; font-weight: normal; } .cb1 { color: blue; font-weight: normal; } .cb2 { color: #010001; font-weight: normal; } .cb3 { color: #2b91af; font-weight: normal; } .cb4 { color: green; font-weight: normal; } .cb5 { font-weight: normal; } .cb6 { color: #a31515; font-weight: normal; }

       51 private void CaptureVideo()

       52 {

       53     int hr = 0;

       54     IBaseFilter sourceFilter = null;

       55     try

       56     {

       57         // create the necessary DirectShow interfaces

       58         GetInterfaces();

       59 

       60         hr = this.captureGraphBuilder.SetFiltergraph(this.graphBuilder);

       61         DsError.ThrowExceptionForHR(hr);

       62 

       63         sourceFilter = FindCaptureDevice();

       64 

       65         hr = this.graphBuilder.AddFilter(sourceFilter, "WebCamControl Video");

       66         DsError.ThrowExceptionForHR(hr);

       67 

       68         hr = this.captureGraphBuilder.RenderStream(PinCategory.Preview, MediaType.Video, sourceFilter, null, null);

       69         Debug.WriteLine(DsError.GetErrorText(hr));

       70         DsError.ThrowExceptionForHR(hr);

       71 

       72         Marshal.ReleaseComObject(sourceFilter);

       73 

       74         SetupVideoWindow();

       75 

       76         hr = this.mediaControl.Run();

       77         DsError.ThrowExceptionForHR(hr);

       78 

       79         this.CurrentState = PlayState.Running;

       80     }

       81     catch (Exception ex)

       82     {

       83         MessageBox.Show("An unrecoverable error has occurred.\r\n" + ex.ToString());

       84     }

       85 }

    Now, if you want to use that control in the Vista Sidebar, just download and install the following application:

    When you launch the application and click Next it will ask you to add .NET assemblies. Click the Add button, navigate to the WebCamTest or WebCamControl2 bin directory and select the WebCamControl2.dll AND the DirectShowLib.dll assemblies as shown below.

    image

    Click Next twice to get to the "Select UserControl to Embed". Select the WebCamControl2.WebCamControl2 type and click Next. The next screen allows you to enter the information about the gadget. I provided an icon for you in the WebCamTest base directory. After you fill in the information, keep clicking Next and the gadget will be built for you. Go into the output directory you specified and you'll see the .gadget file. Simply double click on this and if all goes well, you should be looking at your webcam in the Vista Sidebar. Also, since you used the .NET Gadget Creator application, your gadget will uninstall successfully even while it is running (see .NET Sidebar Gadget Creator Update #2 for more information).

    Without further ado, here's the link to the WebCamControl source code.

    image

  • New & Improved NHL Schedule Importer for Outlook

    Ok, I redid the whole application (since I lost the source code) and added some new features as well. The previous application utilized XML which required you to actually get the NHL schedule in XML format somehow (I used Excel). Needless to say, it was a long and complicated process.

    This new version utilizes good old fashioned screen-scraping to get the job done. Here are some key features that I've added:

    1. Location field will tell if the stations the game is on for national and local (both away and home team) markets

    2. The body for each appointment when you open it up in Outlook contains links to each teams website as well as links to subscribe to that team's RSS feed (see screenshot below)

    3. ** Here's the cool feature ** After you ran the application and import your team's schedule, you can run the application at a later date and it will not create duplicate entries. In fact, if you run it a second time, it will add the game's final score and a link to show the recap of that game (again, see screenshot).

    4. You know have the ability to add an outlook reminder or not for each game

    5. UI is prettier. When you select a team from the drop down list, it will fetch that team's logo from the web and full team name (see screenshot).

    6. Internally everything is different. It would have been easy to allow you to select a year (e.g. 2008-2009) but I'll wait to add that. In any case, whenever a new NHL schedule is created, it's a trivial change to get the application to work with it.

    *NOTE* I tested this using Vista and Outlook 2007. If you have any issues when importing your team(s) schedule(s), let me know. It helps if you can send a screenshot or any error messages word for word. For developer types who know what a call stack is, send that as well if you can.

    Here's some screenshots followed by the link to download the application (complete with installer)

    importing

    appointment

    Download Here

     col GO AVS!!! col

  • Use for the WebCam Sidebar Gadget

    Someone asked "Why would I want a WebCam Sidebar Gadget to display my webcam in realtime"?

    Good question. Answer: So you are prepared when the maiger strikes again!

    maiger_sneek

    It's Friday. What can I say.

  • Fourth of July Vista Sidebar

    I found a screensaver that plays nicely with my Vista ScreenSaver Sidebar gadget. Just in time for the 4th of July!

     First, go get the ScreenSaver gadget and install it to your sidebar: http://gallery.live.com/liveItemDetail.aspx?li=e321409b-231a-4da0-905c-0580c732223e&bt=1&pl=1

    Next, go grab the SkyRocket ScreenSaver and install it to your C:\Windows\System32 directory: http://www.fileplanet.com/164987/160000/fileinfo/Skyrocket-Screensaver-%5BFREEWARE%5D

     Open the configuration options for the Sidebar gadget and select SkyRocket. Here's a screenshot for ya:

  • My St. Patrick's Day Dash Results and Healthier Lifestyle Update

    I, like many other people in the Seattle area, ran the St. Patrick's Day Dash yesterday. For those that don't know, I was a formerly heavy guy (see my I'm not half the man I used to be post). Last year I ran the race I was 30 pounds heavier than I am now and the year before that I was 35 pounds heavier than that. This year I ran the course in 25:21 which was more than 3:30 less than I ran it last year. I ended up getting 853rd out of 7409 people (only counting those that wore a timing chip). I can't say I'm not pleased since I shaved so much time off last year's result, but I know that if I would have hopped off the treadmill and hit the road just a few more times before the race I could have done much better.

    Anyway, for those that ran it, the results are up (and the web interface is much nicer this year I must say). 

    Link to Online Race Results | Race Details

    Again, I have to thank Microsoft for providing the 20/20 Lifestyle program to help obese people (like I used to be) lose weight and transition into a healthier lifestyle. One of those perks that is worth more than money can buy. I lost 65 pounds but the cool thing is, I finished the program last May and to this day, I haven't put on a single pound. I've lost more body fat (I'm at 18% right now, down from about 37%) and gained more muscle. Now time to start training for my first triathlon this summer (and maybe a few more 5k and 10k's as well).

  • My Screen Saver Vista Sidebar Gadget

     For some reason, I'm drawn to creating things that are just cool while not altogether useful (see my Animated Activity Designer post, though one could argue that it may in fact be useful). To that end, I decided to create a Vista Sidebar gadget that displays a screen saver of your choosing. Vista has some good screen savers that it shipped with and I've embedded screen savers before (in fact, I show how to do it in one of my books).

    So go ahead and grab it from the Windows Live Gallery (link below). If enough people clamor and beg, I will post the source code. Here's a quick rundown of what I did:

    1. Create a .NET User Control
    2. Embed a screen saver in the user control whenever the ScreenSaverPath property is set (and the control is visible)
    3. Create the HTML page for the sidebar (sidebar controls use Javascript and HTML in case you didn't know already)
    4. Embed the UserControl in the HTML page (using COM interop naturally)
    5. Create a settings page that also uses COM Interop. The settings page calls a .NET component that I wrote that simply returns a collection of screen saver paths on the local system.
    6. Create the installation in Javascript. I had to get some help for this one. Basically, I do what regasm does by using the WSHShell object to set registry entries. I found some code on the Internet to help.

    Here's a screenshot of it in action using the Ribbons screensaver:

    Here's the link:

    Screen Saver Vista Sidebar Gadget

  • I'm not half the man I used to be...

    I'm about 3/4 what I used to be. I recently finished the 20/20 weight management program of which Microsoft pays a large portion of. I started the Monday before Thanksgiving (why oh why did I not start after Thanksgiving) and just recently finished at the end of May. It was a 27 week program consisting of trainer sessions, a personal dietician, psychologist, small group meetings and regular doctor visits. I started at 262 pounds and wittled down to a fit 198 pounds (that's 64 pounds!). In that time I ran a race, climbed a mountain and pushed myself to run 11.6 miles one sunny Saturday.

    The cool thing is, I refused to see a lot of my family and friends during the time waiting instead to surprise them on Memorial Day. In fact, all I told them was that I have an announcement to make and want to meet them at my mothers house in Long Beach, WA. The look on everyone's face was priceless.

    I also decided to throw together a video (and by "throw together" I literally mean it. The quality isn't that great). I just finished uploading it to iFilm. Take a look if you're interested.

    http://www.ifilm.com/ifilmdetail/2732350

    Feel free to comment/email and I'll provide more details on what I went through.

Copyright © 2006 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us