Monthly Archives: November 2008

TechED US and PDC in LA again!

So its already been announced that TechED US will be in LA (where I happen to live :)) in May, and PDC again in November.  Shannon and I couldn’t be happier.

I did here a lot of complaints though from people who feel like Downtown LA is kind of boring in the evenings.  And well – I can’t really argue there,  there isn’t that much going on. 

Three tips for those of you coming to either event in 2009:

 

1) Leave Downtown!  I know cabs are expensive – but the Metro line goes to Hollywood from very near the convention center.  Hollywood can be fun (if a little weird)

2) Go to Little Tokyo.   I tried to tell everyone I could that the thing to do in Downtown LA at night is to head to Little Tokyo – there are great places to eat, Karaoke, and good bars.  Check it out. http://maps.live.com/default.aspx?v=2&FORM=LMLTCC&cp=34.047006~-118.251085&style=r&lvl=15&tilt=-90&dir=0&alt=-1000&scene=33819618&phx=0&phy=0&phscl=1&encType=1  (Little Tokyo in the upper right corner)

3) See http://la.eater.com/archives/2008/11/19/plywood_tracking_la_live_restaurants_opening_soon.php.  This is all right next to the Convention Center, so by the time TechEd rolls around – there will be good massed produced fun to be had right downtown (I still recommend Little Tokyo for un-produced fun, but I do like the Yard House quite a bit :)).

SharePoint, Silverlight, and Virtual Earth

I’ve been doing a number of project lately for the SharePoint and SharePoint online teams.  Mostly around services and integrating SharePoint services with Silverlight.  One of these projects was pretty cool so we decided to put it up on CodePlex – http://www.codeplex.com/sharepointsilverligh  (yes I can spell Silverlight – CodePlex seems to not like long project names in its URIs ;-)).

The basic idea is a Silverlight control that coordinates data between a SharePoint List (using the SharePoint List Web Service) and the Virtual Earth map control in the browser.  You can point it at any list that has columns containing longitude and latitude data (it should be pretty easy to modify it to use addresses and do a query of Virtual Earth as well).  It can also be pointed at a Picture list, so the picture can show up on the pushpin "tooltip".  Enjoy and let me know what you think.

Controlling authentication with the WF 3.5 SendActivity

Someone emailed me a question about whether or not you can specify credentials when using the OOB SendActivity in WF 3.5 because they heard that you had to write a custom activity to accomplish this.  You do not have to write a custom activity.  While it is true that the SendActivity links to a named endpoint, and if you use the configuration file to configure your endpoint you can’t specify specific credentials (a username and password for example),  WF 3.5 has a OOB WorkflowRuntime Service named the ChannelManagerService.  The ChannelManagerService (which I described in my article on MSDN – here http://msdn.microsoft.com/en-us/library/cc626077.aspx)  allows you to pre-populate some or all of the endpoints you want the SendActivities running inside of your WorkflowRuntime to use.  So you definitely can programmatically configure an Endpoint that the SendActivity can use without having to write a custom activity.

Semi-short video on M – aka M is like an Onion

 

I spent some time the last few days recording a short screen cast on M.  You can view it here:

Intro to M (~ 39 minutes)

One thing I would say about M is that it may be different things to different people.  This video is just one example of what you might do with M.

I say in the title that "M is like an Onion" as an homage to Shrek (if you haven’t seen this movie look here – Ogres are like Onions

It isn’t because M smells, but because M has layers.  There is the whole "M".  You can split that up into MSchema, MGrammar, and MGraph.  Each part might be useful.  And any one of them has a number of different interesting scenarios.  

In this scenario my concept was "I’m a .NET developer, I create tables in a database to hold my application data, so how might I use M?".

IntelliPad (IPad): adding commands

Last week at the PDC was Oslo’s big coming out party.  If you haven’t heard Oslo is a new set of technologies from Microsoft relating to model-driven development.  The three main parts of Oslo are:

1) A language:  The M language is a language for writing stuff down.  You write down the things you need to drive your application.  The things could be application configuration data, or application specific data, or data which is actually your application.  How exactly you use M is largely up to you.  There is also MGrammar which I’ll be covering more in future posts.

2) A repository: There needs to be a place to hold all this data, so Oslo has a SQL Server 2008 database named the "Repository".  The Repository is full of models, both models that Microsoft has created, as well as models you might want to create.  Microsoft has created a large number of models that they think will be useful for us as developers.  Things like endpoints, service contracts, workflows, as well as other data our applications will need.  You can choose to put your models made in M into the Repository, or you can put your models into your own database.  The choice I think will largely be based on whether you want your models to be able interact with Microsoft’s models, and whether the Repository becomes your main application database.

3) A visual tool:  To view the models in the Repository they’ve create a visual tool named "Quadrant" (this is a code-name hence the quotes).  "Quadrant" is a tool for viewing models for those of you who are visual/spatial people.  Some people like text – so they have M.  Some people like drawings – so they Quadrant.  Quadrant is a highly customizable general purpose data viewing and editing tool.

Those are the three "main" pieces, but there are other pieces as well.  To create a great editing experience for M, the Oslo team built a tool called IntelliPad (or IPad) for short.  IPad is a customizable text editor that has support for the M language.  Here is a screenshot of IPad in action:

ipadwithm

In this picture I’m using M to generate "Reach SQL" which is SQL that isn’t limited to the Repository.  The test.m buffer is in "MMode" which means there are additional commands available that wouldn’t be available if I where editing any other kind of text file.  The other buffer is generated from the M in the test.m buffer, and I made this happen by going to the MMode menu and selecting "Reach SQL". 

If you want to see Repository SQL you can use the MMode menu and select "Repository SQL".

In this case I am beginning a model to represent a blog.  I’ve created an M type named BlogEntryType, and then an extent (the name for storage space in M) named BlogEntry.  You can see on the right that the M will generate a table named BlogEntry with the appropriate columns.  As Scott points out one of the nice features of this system for developers even if you aren’t using the Repository is that you will be able to check-in the m file to source control and doing all the usual source control type things on it.

That’s all a brief introduction to Oslo and IPad.  The purpose of this post (indicated by the title) is that IPad is super customizable.  When I was at the last Oslo "SDR" like event a few weeks ago, I asked for a feature in IPad – the "Open Folder in Windows Explorer" feature from Visual Studio 2008 which I find to be the most useful simple feature in Visual Studio I think for all time.

Chris Sells (who is a PM on Oslo) said "You add it".  Which is a very typical Chris response, but at least in this case it is possible since IPad’s whole system of commands is totally customizable.

Harry will happy that this is forcing me to learn about IronPython, although I have to admit I was able to make it work without much actual learning of the IronPython language.

Almost all of IPad’s commands are actually written in Python.  These commands are registered with IPad when IPad first starts, and the commands are implemented by manipulating the interface to IPad’s object model. 

The main command file is Commands.py which is in the Oslo install directory under BinIntellipadSettings.  It contains almost all of the standard mode commands.  To add a new command, all I had to do was add a new .py file to that directory.  IPad seems to search at least that directory for .py files and loads up all the commands found inside into the environment.

Each command has at least one IronPython function, which represents the "Execution" of method of the command.  This function is annotated with an "attribute" (which I think may be added by the IPad team, I can’t seem to find any reference to attribute support in IronPython – Harry?).

The Metadata.CommandExecuted "attribute" tells IPad this is a definition of a command.  It has three parameters,  the IPad object that should execute the command, the name of the command, and the keyboard shortcut (which is optional).  Here is my CommandExecuted function defintion from the MyCommands.py file I created in the settings directory:

import sys
import System
import Microsoft
import Common



@Metadata.CommandExecuted('{Microsoft.Intellipad}BufferView', '{Microsoft.Intellipad}OpenExplorerAtBuffer', 'Ctrl+B')
def OpenExplorerAtBufferExecute(target, sender, args):
    from System.Diagnostics import Process
    from System.IO import Path, File
    exists = False
    file = sender.Buffer.Uri.AbsolutePath
    exists = File.Exists(file)
    if exists:
        Process.Start(Path.GetDirectoryName(file))

 

The first argument of the CommandExecuted can either be (as far as I can tell so far) the BufferView object which represents the current buffer, or the HostWindow object which seems to represent IPad itself.  OpenExplorerAtBuffer is the name I gave this command, and Ctrl+B is the keyboard short cut.  The code is pretty easy, I just find the path of the buffer and if it exists (since a buffer in IPad might not have been saved yet) I just call Process.Start at the directory to open explorer.

Each command can optionally have a function that IPad will call to find out if the command should even be available at a particular time, so I added that one as well:

@Metadata.CommandCanExecute('{Microsoft.Intellipad}BufferView', '{Microsoft.Intellipad}OpenExplorerAtBuffer')
def CanOpenExplorerAtBuffer(target, sender, args):
    from System.IO import Path, File
    file = sender.Buffer.Uri.AbsolutePath
    args.CanExecute = File.Exists(file)

 

The "CommandCanExecute" function just checks to see if the file exists and returns the args.CanExecute as true or false, if true the command is active, if false the command is not. 

The next step was to add my command to a menu, since I tend to be a mouse/keyboard developer (sometimes I use the mouse at odd times – just the way my hands work I guess).  To add a command to IPad at all times,  I edited the MenuBar.xcml file which is in the IntellipadSettingsVisualStudio folder, and drives the default menu (other IPad "Modes" can have additional menu items merged, as the MMode mode does with the MMode menu).  I added a new item under the File menu:

 

<act:Exports
      xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
      xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
      xmlns:act='clr-namespace:System.ComponentModel.Activation;assembly=Activation'
      xmlns:mis='clr-namespace:Microsoft.Intellipad.Shell;assembly=Microsoft.Intellipad.Framework'
      xmlns:mi='clr-namespace:Microsoft.Intellipad;assembly=Microsoft.Intellipad.Core'
      xmlns:mih='clr-namespace:Microsoft.Intellipad.Host;assembly=Microsoft.Intellipad.Core'
      >
  <act:Export Name='{}{Microsoft.Intellipad}MenuBar' xmlns:mti='Microsoft.Intellipad' >
        <Menu>
            <Menu.Resources>
                <mi:FileNameConverter x:Key='fileNameConverter' />
                <mi:ModeToMenuItemConverter x:Key='modeToMenuItemConverter' />
            </Menu.Resources>
            <MenuItem Header='_File'>
                <MenuItem Header='_New' Command='{mis:NamedCommand Name=mti:New}' />
                <MenuItem Header='_Open' Command='{mis:NamedCommand Name=mti:Open}' />
                <MenuItem Header='Open _Project' Command='{mis:NamedCommand Name=mti:OpenProject}' />
                <MenuItem Header='_Save' Command='{mis:NamedCommand Name=mti:Save}' />
                <MenuItem Header='Save _As' Command='{mis:NamedCommand Name=mti:SaveAs}' />
                <MenuItem Header='_Close Buffer' Command='{mis:NamedCommand Name=mti:CloseBuffer}' />
                  <MenuItem Header='Open _Buffer Folder In Explorer'
                   Command='{mis:NamedCommand Name=mti:OpenExplorerAtBuffer}' />
                <Separator />
<!-- rest of file omitted-->
</act:Exports>

 

So adding the command allowed me to to Ctrl+B from any buffer and get the windows explorer folder of the current buffer to open.  Changing the MenuBar.xcml file enabled me to get the menu item on the File Menu:

menu

 

All in all I find IPad to be a really interesting and powerful text editor – but being able to customize the menus and commands with such ease I think is just another example of the cool work the Oslo team is doing for us as developers.