Windows Phone I command you...

Today's Mobile Monday post provides a very cool looking toolset to help you develop Windows Phone applications, but also provide you the source for those same tools...

Windows Phone Commands for VS2010

The Windows Phone Commands is an open-source project built on top of. Microsoft Net 4.0, framework. This effort provides a powerful tool to assist the development phone for windows 7.1 as Isolate Storage Explorer (with copies of folders and files), Deployer, Build integrated, etc.

Pre-Requirements

What´s news in Version 1.2 :

  • Improvement UI
    • Auto Focus (one click over toolwindows)
    • Show explorer after copy
  • Welcome Screen
    • Splash screen
    • Information and link to site
  • Editor for manifest (WMAppManifest.xml) NEW!
    • Validate all fields and link
    • Allows you to select images by relative path
    • Allows you to select file Statup by relative path
  • Improvement Isolate Storage
    • Multi select /copy files NEW!
    • Improvement copy with create root folder
  • Improvement Build Integration (F5)
    • Show Status Debug NEW!
    • Detect selected Device over environment vs2010 NEW!

What's Windows Phone Commands can manage and do?

  • Connect from device or emulator
    • Monitors the connection
    • Show Device information
      • Plataform, build , version, avaliable memory, total memory, architeture
  • Manager installed applications
    • Launch, uninstall and explorer isolate storage files
  • Manager core applications
    • Launch blocked applications from emulator
      • Office, Calculator, alarm, calendar , etc
  • Manager blocked settings from emulator
    • Airplane Mode, Celullar Network, Wifi, etc
  • Deploy and update applications (xap files)
    • cache Title applications by productId
    • Rename Title when publish outside tool / vs2010
  • Build integrate (F5 Debug)
    • Cache title
    • Auto connect device (Real device -> emulator)

Isolate Storage explorer

  • Create and delete Folders
  • Copy files from desktop to device (Add Files)
  • Copy files and folder to desktop
  • Delete and rename file
  • Delete all files in folder
  • Show icons by extension files
    (bmp, png, gif, jpg, ppt, pptx,doc, docx. xls, xlsx, dll, exe, html, pdf, sdf)

image

image

imageimageimage

So that's the app, what you get if you install the Vsix, now let's look at the source. Remember, this project is extending Visual Studio, so you'll need to have the Visual Studio SDK installed or you'll get the "unsupported project" error.

Here are some snaps of the Solution

image

image

image

Everything you saw in the above screen shots, you can see the source for... How cool is that?

Let's take a peek at just one of the features, the reading of data from a Xap file (as seen in part in the Deploy/Update Phone Application screenshot above).

using System.IO;
using System.Linq;
using System.Xml.XPath;

namespace WindowsPhoneToolbox.Util
{
    public class XapFile
    {
        private readonly string _filePath;
        public string Guid { get; private set; }
        public string Title { get; private set; }
        public string Author { get; private set; }
        public string Genre { get; private set; }
        public string Version { get; private set; }
        public string Icon { get; private set; }

        public XapFile(string file)
        {
            if (!File.Exists(file))
                throw new FileNotFoundException(file);
            _filePath = file;
            ReadManifest();
        }

        private void ReadManifest()
        {
            using (var manifestStream = GetFileStreamFromXap(@"WMAppManifest.xml"))
            {
                var deployIsolateFile = new WpDeployApplication();

                var document = new XPathDocument(manifestStream);
                var navigator = document.CreateNavigator().SelectSingleNode("//App");

                if (navigator != null)
                {
                    Guid = navigator.GetAttribute("ProductID", string.Empty).Replace("{", "").Replace("}", "");
                    Title = navigator.GetAttribute("Title", string.Empty);
                    Author = navigator.GetAttribute("Author", string.Empty);
                    Genre = navigator.GetAttribute("Genre", string.Empty);
                    Version = navigator.GetAttribute("Version", string.Empty);
                    var selectSingleNode = navigator.SelectSingleNode("//App//IconPath");
                    if (selectSingleNode != null)
                        Icon = selectSingleNode.ToString();
                    deployIsolateFile.Guid = Guid;
                    deployIsolateFile.Title = Title;
                    deployIsolateFile.RenameTitle = string.Empty;
                    WpIsolateSaveData.Current.AddData(deployIsolateFile);
                }
            }
        }

        private Stream GetFileStreamFromXap(string file)
        {
            MemoryStream rv = null;
            using (var zip = ZipStorer.Open(_filePath, FileAccess.Read))
            {
                var entries = zip.ReadCentralDir();
                foreach (var entry in entries.Where(entry => Path.GetFileName(entry.FilenameInZip) == file))
                {
                    rv = new MemoryStream(2048);
                    zip.ExtractFile(entry, rv);
                    rv.Seek(0, SeekOrigin.Begin);
                }
            }
            return rv;
        }

    }

}

So if you're looking to see or write code that talks to Window Phone 7 or see a non-trivial Visual Studio extension written in C#/WPF then this project is just waiting for you to spelunk...

Tags:

Follow the Discussion

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.