Wishing a very happy and blessed New Year to you in advance!
A new release of Microsoft All-In-One Code Framework is available on December 29th. We expect that its 11 new code samples covering typical programming scenarios in Windows Phone 7, ASP.NET, WPF, Windows Shell, and WDK would ease your development in the coming New Year.
You can download the code samples using Sample Browser or Sample Browser Visual Studio extension. They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about sample updates.
If it is the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on Microsoft Showcase, or read the introduction on our homepage http://1code.codeplex.com/.
Story Creator Sample Application for Windows Phone 7 (CSWP7AzureVideoStory)
Developed by Yi-Lun Luo – a sample writer of Microsoft All-In-One Code Framework, CSWP7AzureVideoStory is a big sample application combing many hot technologies such as Windows Phone 7, Windows Azure, HTML5.
This sample solution is a story creator for Windows Phone 7. You can use it to create photo stories on your phone, and send the stories to a Windows Azure service to encode them into videos. The Windows Azure Service includes a REST service built with WCF Web API, a simple HTML5 browser client that allows you to see encoded videos, and a native component encodes videos using WIC and Media Foundation.
While individual pieces of technologies are very interesting, the true power comes when the platforms are combined. We know most developers need to work with the combined platform rather than individual technologies. So we hope this sample solution will be helpful to you.
Using Direct2D for Server-Side Rendering with ASP.NET (CSD2DServerSideRendering)
Download: http://code.msdn.microsoft.com/CSD2DServerSideRendering-2d099ab6 Developed by Greg Binkerd – Microsoft Senior Escalation Engineer
Some server applications need to render images and send back the generated bitmaps to users connected through web clients. For example, ASP.NET web applications that needs to generate user profile picture on the fly. We observed that many developers choose to use GDI+ and System.Drawing to generate those images, but actually GDI+ and System.Drawing are not supported in a service or web application. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions (see the “Caution” section in http://msdn.microsoft.com/en-us/library/system.drawing.aspx).
Direct2D is the appropriate technology for rendering images to a bitmap on disk in a service context. Direct2D is completely supported in the context of a service. This is a C# ASP.NET sample which demonstrates how to render a Direct2D scene to an image file on disk. It demonstrates how to create a Direct2D bitmap based on image data in memory, draw Direct2D objects, such as an Ellipse and a Rectangle, and it also demonstrates how to use DirectWrite to render text. The sample uses the Direct2D and DirectWrite assemblies from the Windows API Code Pack for Microsoft .NET Framework. These provide developers access to Direct2D and DirectWrite from managed code.
For more information on DirectWrite, see the MSDN DirectWrite documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/dd368038(v=vs.85).aspx
For more information on the Windows API Code Pack for Microsoft .NET Framework, see: http://archive.msdn.microsoft.com/WindowsAPICodePack
Maintain ASP.NET TreeView State (CS/VBASPNETMaintainTreeViewState)
Downloads C# version: http://code.msdn.microsoft.com/CSASPNETMaintainTreeViewSta-c7673683 VB version: http://code.msdn.microsoft.com/VBASPNETMaintainTreeViewSta-01591ffc Developed by Arwind Gao – Microsoft All-In-One Code Framework Sample Writer
The code-sample illustrates how to maintain TreeView's state across postbacks. The web application use session store the TreeView nodes' status and restore them in the next postback event. This interesting function can be used as the signs of the navigator bar.
Client templating with jQuery and JSON (CS/VBASPNETClientTemplateJQueryJSON)
Downloads C# version: http://code.msdn.microsoft.com/Client-templating-with-0c85db68 VB version: http://code.msdn.microsoft.com/VBASPNETClientTemplateJQuer-fac556f6 Developed by Arwind Gao – Microsoft All-In-One Code Framework Sample Writer
This project illustrates how to display a tabular data to users based on some inputs in ASP.NET application. We will see how this can be addressed with JQuery and JSON to build a tabular data display in web page. Here we use JQuery plug-in JTemplate to make it easy.
WPF ListBox Validation (CSWPFListBoxValidation)
Download: http://code.msdn.microsoft.com/CSWPFListBoxValidation-a3023d06 Developed by Jon Burchel – Microsoft Senior Escalation Engineer
The sample demonstrates how to add validation to a ListBox, overriding the control to contain a ValidationListener property, which can be bound to provide validation using built in validation UI features in WPF.
To run the sample, simply open in Visual Studio 2010 and run it. It contains a ListBox, which was overridden to include a property called ValidationListener, which is used to bind the ListBox to a property used for validation, and a validation rule. The validation property is simply a text field added to the Window, in which error text is written if the ListBox is found having no selected items. Of course the rule could be more complex as necessary, but this demonstrates the approach. When the form first displays, no items are selected, so it is not valid. Validation UI displays a red outline around it, and another label control is also validated using the same criteria, and is outlined in red as well, and displays the validation error message. Selecting any items validates the control. Removing all selections will again invalidate the control.
Search and Highlight Keywords in TextBlock (CS/VBWPFSearchAndHighlightTextBlockControl)
Downloads C# version: http://code.msdn.microsoft.com/CSWPFSearchAndHighlightText-3b5e207a VB version: http://code.msdn.microsoft.com/VBWPFSearchAndHighlightText-f9f2fe58 Developed by Jason Wang – Microsoft All-In-One Code Framework Sample Developer
The WPF code sample demonstrates how to search and highlight keywords in a TextBlock control. The sample includes a custom user control "SearchableTextControl" and its search method is used to demonstrate how to highlight keywords using System.Windows.Documents.Run and System.Windows.Documents.Incline.
Print an image using ShellExecute (CSShellPrintImageWithShellExecute)
Download: http://code.msdn.microsoft.com/CSShellPrintImageWithShellE-adda9973 Developed by Jon Burchel – Microsoft Senior Escalation Engineer
The sample demonstrates how to print an image using ShellExecute to invoke ImageView_PrintTo, equivalent to right clicking on an image and printing. Using the printto verb with ShellExecute may have unpredictable effects since this may be configured differently on different operating systems. The approach demonstrated here invokes ImageView directly with the correct parameters to directly print an image to the default printer.
To run the sample, simply open in Visual Studio 2010 and run it. It simply prompts the user to select any image file, using the OpenFileDialog, and then uses ShellExecute to launch ImageView_PrintTo, exposed in shimgvw.dll, with rundll32.exe, and providing the necessary parameters to this function. This is more reliable than trying to use the Shell printto verb, which may or may not be configured for a particular file type, and so may not work for images.
Enumerating and locating specific attach storage devices. (CppStorageEnum)
Download: http://code.msdn.microsoft.com/CppStorageEnum-90ad5fa9 Developed by Bart Bartel – Microsoft Senior Escalation Engineer
The code sample demonstrates the use of DeviceIoControl and SetupDiGetClassDevs in the everyday operations of enumerating and locating specific attach storage devices. To run this sample, you need to install the Windows Driver Kit (WDK). After building the sample successfully, just press Ctrl + F5 to run it. Then you may see something like this:
In closing, I want to take opportunity to wish you and your family my best wishes for this Holiday Season. The Holiday season is always a special time when we can spend time with our family and friends. I wish all of you the very best for the upcoming New Year!
Thank YOU for your support of Microsoft All-In-One Code Framework!