Random Technical Stuff RSS 2.0
 Wednesday, April 16, 2008

I have a Blackjack II and have really liked the phone so far (although I really want a Sony Xperia X1 when it releases).  Recently I mentioned to a couple of friends how much I liked the BJII and they went out and purchased them.  They liked them also, but wanted a home screen with smaller icons so they could better maximize their real estate. 

Here is the Windows Default Layout (notice that the mail/messaging notifications are below and it is necessary to scroll down to get them).

image

Here is the layout after I changed the home screen around a little bit.  I changed to smaller icons and moved around a few of the items so my mail/messaging is above the profile.

image

I have posted the new home screen here.  If you want to try it out, save it to the XML file to your device in the Application Data\Home directory then go into your settings and change the home screen to "Default with Small Icons". 

Warning, I have not taken the time (nor do I have the ability) to internationalize the XML file so if you are using a different language than US English you should open the XML file and change the name to be appropriate for you. 

Also, if you want to move things around in the home screen, it is quite easy.  Just open the XML file and reorder the <plugin> elements to match your liking.

16-Apr-2008 4:26 PM  #    Comments
Personal Technology

 Wednesday, April 02, 2008

I wanted to thank everyone that showed up for my presentation on Office Development with Visual Studio in both Denver and Phoenix.  I wanted to put together a follow up with code samples if you are interested in digging into the topic further.

  • The first demo that I did was a Word add-in that hooked into a set of web services.  I have a posting with a how to video about creating a Word add-in here (requires the Silverlight runtime).  The specific demo that I did in Denver wires up a Word Add-In to the Northwind database.  I have posted that code here - you will need to download and install the Northwind sample database and set the connection string to get it working.  The sample I used in Phoenix was slightly different and was dependent on services that were created in other sessions.  If you were in Phoenix and want to look at some working code go ahead and download the sample above.  It is pretty much the same as the demo I did in Phoenix but hooks into a database directly rather than consuming services.  I have posted the code I wrote in Phoenix here, but the code will not work without the services back end so it would be reference code only. I also showed how to lookup the Office Icons using the Office Developer Power Tools in Phoenix.
  • In the second demo I created an Outlook add-in with some ribbon customizations and an Outlook form region.  Because the code I used in both Denver in Phoenix was dependent on the other sessions I don't have a working add-in to post.  However, I have posted the code here for you to download if you want to just see the code. 
  • In my third demo I showed how you could use System.IO.Packaging to manipulate Word documents on the server without needing to actually run Word on the server.  In Denver I used a sample that is posted here and should just work because the data is encapsulated within the project.  I have also posted my demo from Phoenix here but again it is dependent on other services so the code would be for reference only.  If you are interested in this method of working with Office documents on the server, there is a good MSDN article about this.  I also use the Word Content Control Toolkit to show how arbitrary XML can be databound to Content Controls within Word.

Hopefully you enjoyed the session and found it worth your time.  If you found this session interesting, I would recommend exploring the Office Developer area of MSDN to drill into any of the topics we discussed during the session.

2-Apr-2008 8:29 AM  #    Comments


 Tuesday, March 25, 2008

Pretty much since the time I left the Denver Launch until now I have been on the road (I am blogging this from DIA right now as I head to Seattle).  I will update this with a few more things when I get a minute to breathe, but for those of you who were interested in some of the code/topics from the Office Developer session you can check out my posting from here where I used a number of the same or similar demos.  Be early next week I will expand this posting so it maps more closely to the session.

Thanks for coming out and we will see you an another event soon.

Update: I finally have a few minutes this morning and have finally put together a more detailed post about the session.  I also wanted to publicly thank Stephen Smith from Starz for spending a few minutes with us during the developer keynote to tell us how Visual Studio 2008, WPF, WCF, and WF have been essential for their video encoding and distribution project.

25-Mar-2008 4:14 PM  #    Comments


 Friday, February 01, 2008

Thanks to all of you who attended my presentation yesterday on Live Services and the Live API - hope you had as much fun as I did.  Here are my follow up links:

General

If you just want the presentation go here, but if you want to learn more about Windows Live development visit http://dev.live.com.  I showed off the the Windows Live Quick Apps (Contoso Bicycle Club, Cotoso University, Contoso ISV, and AdventureWorks Resort) can be found on CodePlex.  Also, if you are getting more serious about developing Live applications, you should consider taking a look at the Visual Studio Tools for Live.

Virtual Earth

If you want to learn more about Virtual Earth visit the developer center and in particular the Virtual Earth Interactive SDK.  A great example of the usage of Virtual Earth are the radar maps on http://www.weather.com.  I showed off integrating in some GeoRSS feeds from MIT into a map and also showed a demo of a modified Club Site Starter Kit.

Live ID

The Live ID discussion was very lively and interesting.  I showed you the sample from the Live ID Client SDK and the Live ID Web SDK.

Live Contacts and Photos

Although we didn't do much in the way of demo we also talked a bit about Live Contacts and Live Photos.  There is a great blog posting you should visit if you are interested in Live Contacts.

Live Search

We also discussed the ability to add search to your site including the AJAX based client control and the ability to use the Interactive SDK to handle queries programmatically.

Live Messenger and Live Agents

One of the more interesting discussions we had was around Live Messenger and Live Agents.  I showed how to create a control you could drop onto a web page to embed IM communication purely through HTML.  I also showed some example agents that were pretty interesting.  If you would like to add them to your Live Messenger, search for the contact smarterchild@hotmail.com and encarta@botmetro.net.  As part of that discussion we also talked about Live Alerts.

Silverlight Streaming

I also did a quick demo that showed off embedding Silverlight Streaming applications into your web page.  There are instructions for packaging up your application for Silverlight Streaming, but I also recommend looking at the Expression Media Encoder if you are specifically looking at media.  I also really like the <iframe> method of embedding the application in your Silverlight applications in about any web page.

1-Feb-2008 4:07 PM  #    Comments
Events | Live

I recently put together a demo for The Big Event and I wanted to document how I developed this demo.  The Club Site Starter Kit is a free download for Visual Studio that comes with source code.  It contains the basics for a club site including Events, News, Photos, and Links.  In looking at the Events component, there is a locations function where a user can enter in an address for the event.  My goal was to extend the UI to provide a map view of the events in the system on the front page.

I based on lot of this work on a posting from Beth Massi which shows how to map some of the Northwind sample accounts in Virtual Earth using VB.NET which has some killer language features around XML.

To create a new Club Site, open Visual Studio and create a new website.  After you have installed the Club Site Starter Kit you will have a new project type under "My Templates".  If you create the site it will run right out of the box.  At this point you probably want to go into the ASP.NET configuration (under the Website menu) and create an administrator account.  The admin account will be required to actually update data on the site.

Now that we have the site up and running lets go through the modifications.

Extend the Database

The club site starter kit comes with a database that contains a table for locations.  I added two more fields to the database: lat and long both as varchar(50).  These fields will store the latitude and longitude associated with the address.

Get the Latitude and Longitude when creating or updating an address

One of the things that Beth discovered when putting together her sample was a website that will geocode (convert) an address to latitude and longitude using a Rest based web service.  The first step was to leverage this web service whenever a new or updated address is entered into the site on the locations.aspx page.  Since the page is bound to the database, I created two additional controls on the page that were hidden and held the latitude and longitude into both the insert and update views.  I also trapped the OnTextChanged event.

<asp:TextBox Text='<%# Bind("Address") %>' runat="server" ID="TextBox1" Rows="10" TextMode="MultiLine" Width="500px" Height="166px" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>

<asp:TextBox Text='<%# Bind("lat") %>' runat="server" ID="txtLat" Visible="false" />

<asp:TextBox Text='<%# Bind("long") %>' runat="server" ID="txtLong" Visible ="false" />

In the page server code I added the following C# that handles the OnTextChanged event

protected void TextBox1_TextChanged(object sender, EventArgs e)

  {

   TextBox lng = (TextBox)(FormView1.FindControl("txtLong"));

   TextBox lat = (TextBox)(FormView1.FindControl("txtLat"));

   TextBox address = (TextBox)(FormView1.FindControl("TextBox1"));

   var url = "http://geocoder.us/service/rest/?address=" + Server.UrlEncode(address.Text);

   XNamespace nsGeo = "http://www.w3.org/2003/01/geo/wgs84_pos#";

   XElement geo;

   try

   {

     geo = XElement.Load(url);

   }

   catch (Exception ex)

   {

     //in production put in some better exception handling

     throw ex;

   }

   lng.Text = geo.Element(nsGeo + "Point").Element(nsGeo + "long").Value;

   lat.Text = geo.Element(nsGeo + "Point").Element(nsGeo + "lat").Value;  

  }

The above code encodes the address and calls the geocoder web service to obtain the latitude and longitude.  If you want to try out the service you can call it directly via your browser (for example http://geocoder.us/service/rest/?address=1600%20Pennsylvania%20Avenue%20NW%20Washington,%20DC%2020500 will give you the latitude and longitude of the White House). 

The last two lines extract the latitude and longitude from the resulting XML using LINQ to XML.  I find it much easier than trying to traverse the DOM but you can pull that information using traditional DOM code. 

One other point is that I would probably make is that this code would need to have some additional error processing when an invalid address is entered or if the geocoding service is not available.  Currently, if this particular geocoder service cannot convert the address the Club Site application will just leave these fields blank and the point will not show up on the map.  Also, this particular service isn't always as accurate as I would like (but it is free), I have had some points be off by a couple hundred yards.

Create a GeoRSS Feed

There are a couple of ways to integrate your custom data with Virtual Earth but I personally like the ability to integrate a GeoRSS feed.  If you want to find out more about programming against Virtual Earth check out the Interactive SDK.  Since I have the data stored in a database I created the feed using the following code:

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

 

 

 

public partial class GeoRSS : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        Response.ContentType = "text/xml";

        XElement geoRSS = GetGeoRSS();

        Response.Write(geoRSS.ToString());      

    }

 

    private XElement GetGeoRSS()

    {

        NorthwindDataContext db = new NorthwindDataContext();

 

        var events = from e in db.Events

                     select new { e.id, e.title, e.description, e.starttime, e.endtime, e.LocationDetail.address, e.LocationDetail.Location_title, e.LocationDetail.lat, e.LocationDetail.@long };

 

        XNamespace nsGeo = "http://www.w3.org/2003/01/geo/wgs84_pos#";

        XNamespace nsGeorss = "http://www.georss.org/georss";

        XNamespace nsGml = "http://www.opengis.net/gml";

 

        XElement xmlFeed = new XElement("rss",

            new XAttribute("version", 2.0),

            new XAttribute(XNamespace.Xmlns + "geo", nsGeo),

            new XAttribute(XNamespace.Xmlns + "georss", nsGeorss),

            new XAttribute(XNamespace.Xmlns + "gml", nsGml),

            new XElement("channel",

                new XElement("title", "Club Events Feed"),

                new XElement("link", Request.Url.AbsoluteUri),

                new XElement("description", "Events coming up...")

            )

        );

 

        XElement xmlChannel = xmlFeed.Element("channel");

        foreach (var row in events)

        {

            xmlChannel.Add(

                new XElement("item",

                    new XElement("title", row.title),

                    new XElement("link",

                        new XAttribute("rel", "via"),

                        new XAttribute("href", "http://localhost:1589/ClubWebSite1/Events_view.aspx?EventID=" + row.id.ToString())

                    ),

                    new XElement("description", row.description),

                    new XElement("content", (string)BuildContent(row.description, row.starttime, (DateTime)row.endtime, row.address, row.Location_title),

                    new XAttribute("type", "html")),

                    new XElement(nsGml + "Point",

                        new XElement(nsGml + "pos", row.lat + " " + row.@long)

                    )

                )

            );

        }

        return xmlFeed;

    }

 

    private string BuildContent(string description, DateTime starttime, DateTime endtime, string address, string locname)

    {

        string content;

        string when = starttime.ToLongDateString() + " " + starttime.ToShortTimeString() + " - " + endtime.ToShortTimeString();

        content = "<b>" + when + "</b><br/>" + locname + "<br>" + address + "<br/><br/>" + description;

        return content;

    }

}

 

Basically the above code uses LINQ to SQL to pull the data out of the database and LINQ to XML to format the XML output.  You can create the XML in any fashion that you would like as long as it conforms to the GeoRSS standard.  The other reason I like this approach is that I can also extend this approach to filter by all sorts of criteria via querystring (if I wanted to filter by date for example). 

The actual georss.aspx html code is below.  Notice that I am not caching any information (because I use this in demos).  In a real environment I would tune the cache a little differently.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GeoRSS.aspx.cs" Inherits="GeoRSS" %>

<%Response.Expires = -1; %>

Modify the Home Page to Include the Map

At this point the heavy lifting is complete.  Now all that is left is to actually place the map on the home page and bind it to the GeoRSS feed that we created.  The one difficulty in this example is that the Club Site Starter Kit uses master pages and content pages.  This causes two issues in that we cannot easily trap the <body> tag OnLoad event and we have to programmatically inject script into the <head> secion.

I added the following C# code to inject the include script for the map control into the <head> section of the page:

    protected void Page_Load(object sender, EventArgs e)

    {

        Page.ClientScript.RegisterClientScriptInclude("VEScript", "http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6");

    }

Then I added the map to the appropriate portion of the page.  You can see that I added a <br> tag with an OnLoad event to trigger the map load.

<br onload="GetMap();" />

<div id="myMap" style="position:relative; width:446px ; height:400px"/>

Finally, I added a script for the GetMap event to render the map and wire it up to the GeoRSS feed.

<script type="text/javascript">

   var map = null;

   self.setTimeout("GetMap()", 1);  

   function GetMap()

   {

      map = new VEMap('myMap');

      map.SetDashboardSize(VEDashboardSize.Small);        

      map.LoadMap();

      var layer = new VEShapeLayer();

      var veLayerSpec = new VEShapeSourceSpecification(VEDataType.GeoRSS, "georss.aspx", layer);

      map.ImportShapeLayerData(veLayerSpec, null);

   }

</script>

The one thing I had to add that you won't find in the Interactive SDK is the self.setTimeout call.  This forces this function to load after the entire body is done rendering.

Here is the final result:

image

1-Feb-2008 2:53 PM  #    Comments
Live

 Tuesday, January 08, 2008

My team and I have been putting together an event that should be a lot of fun.  From Tim Heuer's blog:

miss the days of devdays?  me too.  my team is trying to bring a little of that spark back!  joe shirey on my team has organized a full-day of developer and architect goodness.  we'll be hosting two events, one in the phoenix, arizona metro area and one in the denver, colorado metro area.  here's the gist:

 

keynote: microsoft patterns and practices is being shipped in to talk about what they've produced and the logic behind it!

 

developer track:

    • exposing and consuming data using the microsoft stack (rob bagby): take a look at the ado.net entity framework, linq and the ado.net data services (project 'astoria').
    • office as a developer platform (tim heuer): didn't know you could easily write office applications using managed code?  let me show you how easy it is and what visual studio 2008 has done to enable this and make it even easier.
    • what is new in visual basic 9 (beth massi): that's right.  beth massi -- if you are a vb'er, you've no doubt heard the name from the vb team.  we convinced her that she needed to be a part of this and she agreed!  come learn from beth all the new goodness that is VB9: xml literals, object initializers, anonymous types, extension methods, lambda expressions and some wicked intellisense improvements!

architect track:

    • why user experience matters: face it, developers are not good at defining user interfaces and thus it is often an aspect that is left out.  let's discuss the reason this needs to change and how attention to the user experience affects application adoption.
    • agile development at microsoft: the team from patterns and practices will discuss how they have fully adopted agile methods in their development team and their learnings over the years.
    • the Windows Live platform: think windows live is just virtual earth?  think again!  come hear about the services available to you as service-based building blocks that microsoft has exposed for your use!

this is going to be a great day and a must-see event.  it is completely free to attend.  come hang out with us.  we will also have a couple of surprises throughout the day and some fun stuff to show as well.

 

register for your event today:

 

PHOENIX 29 JAN REGISTER HERE

 

DENVER 31 JAN REGISTER HERE

 

do not miss out on this opportunity to hear from some locals as well as some people we are dragging out from redmond and the product teams!

8-Jan-2008 5:42 PM  #    Comments
Events

 Friday, December 21, 2007

Thanks to all of you who attended the Phoenix MSDN Power Series Event on 12/20.  The slides will be posted via MSDN Events and I will provide links to them once they are live.  A couple of other items for those of you that attended.

Office as a Platform Session

  • If you want to know more about server side generation of documents, there is a good article on MSDN about it.  I have also posted the code I used in the demo here.  To get it to work, you will want to unzip the contents to a directory and open it using the "Open Web Site..." functionality in VS.NET.  This demo should work in both VS.NET 2005 and 2008 as long as you have installed .NET Fx 3.0.  I also had a question about what reference you need to add if you want to use System.IO.Packaging in your solutions - it is WindowsBase.
  • If you are interested in the part of the talk where I modified Word 2007, you can check out my video on an earlier posting to see the walkthru.  I have also posted my demo code that wires up the UI to a database here.  If you download that code, you will need to have the Northwind sample database installed (it doesn't come with SQL 2005 samples) and you will need to modify the app.config file to point to the appropriate server.  Also, you will need Word 2007 and VS.NET 2008 since I used Linq to perform the database interactions.  The sample Word document is enclosed in the zip file.
  • In both of my demos, I used Word Content Controls to bind the data to the document.  If you are interested in building out your own Word Documents with bound content controls, I recommend downloading and installing the Word Content Control Toolkit. This tool enables quick drag and drop to wire up your custom XML to your content controls in Word.

Software + Services

  • If you want to know more about what Microsoft is doing in the Software + Services arena you can check out the website.
  • Benny who did part of the presentation has a nice writeup here.

The Windows Live Platform

  • As I mentioned in my presentation, you can find out just about anything about the Windows Live Platform from a developer perspective at http://dev.live.com.  If you are curious about the licensing model, select the topic you are interested in, and then select the Terms of Use.

I hope that you found at least one or two nuggets of information during the day and as always, please feel free to contact me if you want to provide me more detailed feedback.

21-Dec-2007 3:52 PM  #    Comments
Events

 Tuesday, December 18, 2007

Just a public thanks to Daren May of EMC for the fantastic presentation on Software Factories yesterday.  I thought Daren covered a lot of ground in a very short time but was able to convey why software factories are valuable and how to get started using them.  He also made me wish I had a British accent so I could sound more intelligent.  I will be posting his presentation here later today.

A couple of links of interest from the session.

Again, thanks to all that made it out yesterday for the session.

UPDATE:

  • The Webguide website mentioned above was down the last couple of days - it appears to be up now.
  • Daren passed along his materials from the presentation, the following links will take you to:
18-Dec-2007 9:36 AM  #    Comments
Events

 Friday, December 07, 2007

If you are like me you spend much of your time in the Office suite of applications, but as a developer or architect I used to rarely think about incorporating Office into my solutions.  I guess I spent too much time debugging Excel macros or struggling with the plumbing when I first starting playing with the Visual Studio Tools for Office (VSTO).  It seemed like more work that it was worth.  This was a shame because Office has some great advantages as a compliment to custom application development.

With the latest release of Office 2007 and Visual Studio 2008 the plumbing for extending the UI around Office applications has drastically improved.  I created the attached video (no audio on this one)  to show a quick example (7:34 to be exact) of how to create a Word add in.  In this example I take the following steps:

  • Create a new Word Add-In project
  • Add a Ribbon item to extend the Ribbon UI in Word
  • Modify the custom ribbon to name things friendly and add a toggle button
  • Add a User Control to hold my UI for my Task Pane
  • Modify the Add-In code to attach the user control to Word and create methods to show and hide the custom task pane
  • Write code behind the ribbon toggle button that calls the show and hide methods for the task pane
  • Run the application to show the extended ribbon user interface and how clicking on the custom toggle button shows and hides my user control
  • Adding some winforms controls to the user control and wiring them up to pull and push content from my user control to the document
  • Running the application again to show the user control in action reading content from the document and writing content back to the document

This is a fairly simplistic example, but enough to get started.  I have written some other demos that hook up the user control to a SQL Server database to populate form letters from customer data.  If you are interested in learning more, I'd suggest checking out the VSTO on MSDN.  One other thing - VSTO used to be a separate product that you needed to purchase on top of Visual Studio.  With VS 2008 Professional, VSTO is included right in the box.

Double click the video once it starts to see it full screen.  You can double click again on the full screen to go back to regular view.  If you are reading this in an RSS reader, you most likely need to go to the site to see the video.

 

This video was published via Silverlight Streaming

7-Dec-2007 6:05 PM  #    Comments
Office | Office Apps

Archive
<April 2008>
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910
About the Author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Joe Shirey
All Content © 2008, Joe Shirey