How to create your Windows 8 Start Button with PowerShell

Before I go on, I have to say I find the Start Menu unnecessary.  There are already many ways to get to your Start Screen:

  • Throw mouse to lower-left corner (with the mouse)
  • Press the Windows key (on your keyboard)
  • Swipe in from the left edge (touch screen)
  • Press the Start button (any device with a hardware start button)

 

That said, Windows is still about choice.  And here's how you can add your own "Start Menu Button"

  1. Create a shortcut.
  2. Type in this:
    powershell.exe -Command "Add-Type -AssemblyName System.Windows.Forms; [Windows.Forms.SendKeys]::SendWait('^({ESC})')"

    (all in one line)
    This sends the Windows key (CTRL-ESC) via Powershell.
    image
  3. Configure the shortcut to run minimized
    image
  4. Change the Icon, I select this icon from the bootux.dll file %SystemRoot%\System32\bootux.dll) 
    image
    (All the icons are white, select them to see what they look like) 
  5. Drag the shortcut and pin it to the task bar, on the far left.
    image
  6. Now you have that familiar Start menu button back.  Click it and you'll get the Start Screen to pop up. 
    image

 

Notes

  • Does not appear to work in Windows RT, but if you have a Surface just hit that start hardware button

XML deserialization - cannot have child contents to be deserialized as an object

Element MyValue from namespace http://schemas.datacontract.org/2004/07/Services cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.

 

I was playing with DataContractSerializer, and getting this strange error when performing de-serialization (turning XML back into an object of type MyClass).

[DataContract]
public class MyClass
{
    [DataMember]
    public string MyName;

    [DataMember]
    public object MyValue;
}

 

The error message actually is pretty clear about what the issue is, but English is a sucky language.  Let me highlight what the error message is really saying:

Element MyValue from namespace http://schemas.datacontract.org/2004/07/Services cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.

Read it again:

Element MyValue cannot be deserialized as an object.

 

The deserializer was actually talking about the fact that it can't turn <MyValue>1</MyValue> back into an object of the type Object.

If you change your DataContract to

[DataContract]
public class MyClass
{
    [DataMember]
    public string MyName;

    [DataMember]
    public string MyValue;
}

 

Then the deserializer will be happy.

The SharePoint Pinterest-style Image Library

A picture is worth a thousand words.

 

In the latest version of spaspa.codeplex.com, I created a separate Knockout Template and bind the Images library (BaseTemplateID 851) to it.  Then I inserted a simple jQuery Plugin Wookmark https://github.com/GBKS/Wookmark-jQuery

The end result is that when we have pictures, they are displayed in an awesome layout.

As an added bonus, I'm calculating the thumbnail image from SharePoint, so instead of rendering:

http://spg-dev-jl/PublishingImages/wallpaper_08.jpg

image

Original: 78K

I'm rendering

http://spg-dev-jl/PublishingImages/_w/wallpaper_08_jpg.jpg

image

Thumbnail image generated by SharePoint.  Which is a far smaller file - 16k.

 

Next update, I'll try to resolve those pesky SharePoint users and get the correct user name and picture.  So we don't have Mr. Bill Gates staring back at us! ;-)

Test your C#: Generic overloaded constructors

I love languages.  Here's one for a language nut.

public class Response<T> {

    private T result;
    private string error;

    public Response(T result) { this.result = result; }
    public Response(string message) { this.error = message; }

}

 

You can use this generic class as a wrapper for returning data.

return new Response<int>(1000);

Or to return an abnormal result

return new Response<int>("Something has gone wrong");

 

Question 1

The fun part then, is what happens when you have this?

var result = new Response<string>("Is this a result or an error?");

What is result

 

Question 2


What about this:

public class Sample
{
    public static Response<T> GetSample<T>(T arg)
    {
        return new Response<T>(arg);
    }
}

and then:

var result = Sample.GetSample("Is this an error?");

What is result

SharePoint Saturday Adelaide update

 

Hope you enjoyed the session and all the wonderful sessions through out the day.

I hope I've also given you plenty of ideas on how you can mix and match a really rich set of the latest technology in your SharePoint environment. 

A summary link of all my related talks on REST, services and JavaScript technologies like jQuery and Knockout are on /rest/

A direct link to the solution that I used for the demo is at: https://static1.squarespace.com/static/5527bff2e4b0b430660b0d10/5527c30de4b030eeeef09715/5527c30ee4b030eeeef09b23/1316868647487/SPGSvcWp.zip

The PowerPoint presentation is at: https://static1.squarespace.com/static/5527bff2e4b0b430660b0d10/5527c30de4b030eeeef09715/5527c30ee4b030eeeef09b24/1335084544036/SharePoint+REST+and+jQuery5.pptx

Drop me a question if you want to ask me anything specific related to these topics and I'm more than willing to geek out!  Hope to see you guys again soon.

You can find me via

T: @johnnliu
E: john.liu at sharepointgurus.net

Or grab a business card from me throughout the day!