A new release of Microsoft All-In-One Code Framework is available on May 6th. The blog introduces 14 new code samples in the release.

Download address: http://1code.codeplex.com/releases/view/65772

Alternatively, you can download the code samples using Sample Browser v3. The new Sample Browser gives you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about new releases.

If it’s the first time that you hear about Microsoft All-In-One Code Framework, please read this Microsoft News Center article, or watch the introduction video on Microsoft Showcase, or read the introduction on our homepage http://1code.codeplex.com/.


New ASP.NET Code Samples

CSASPNETDragItemInListView, VBASPNETDragItemInListView

C# version: http://code.msdn.microsoft.com/CSASPNETDragItemInListView-09a18768
VB version: http://code.msdn.microsoft.com/VBASPNETDragItemInListView-5c361870

The project illustrates how to drag and drop items in ListView using JQuery. This code-sample includes two ListView controls, user can drag, sort and move items from one controls to another. This sample can be used in many areas. For example, you can create an application of online shopping, users can drag and drop the goods from shopping list to their shopping chart, and it will give users better feelings with your application.

CSASPNETEmbedLanguageInUrl, VBASPNETEmbedLanguageInUrl

C# version: http://code.msdn.microsoft.com/Embed-language-code-in-URL-9d79559b
VB version: http://code.msdn.microsoft.com/VBASPNETEmbedLanguageInUrl-de9c06ad

The ASP.NET code sample demonstrates embedding language in URL of a webpage. For example, http://domain/en-us/ShowMe.aspx. The page displays localized content according to the language code in URL.  The code sample use url-routing and resource files to localize the content of web page. 

CSASPNETStripHtmlCode, VBASPNETStripHtmlCode

C# version: http://code.msdn.microsoft.com/CSASPNETStripHtmlCode-3e9b3547
VB version: http://code.msdn.microsoft.com/VBASPNETStripHtmlCode-eeb8b400

The project illustrates how to strip and parse Html code. As the web pages are always include much useful information such as title, text, images, links, tables, etc. Sometimes we need strip the key words or resources from a web page, so this code-sample can help us finish the work in regular expression.

CSASPNETSaveWebpageToImage, VBASPNETSaveWebpageToImage

C# version: http://code.msdn.microsoft.com/CSASPNETSaveWebpageToImage-5299048d
VB version: http://code.msdn.microsoft.com/VBASPNETSaveWebpageToImage-27f87026

The project illustrates how to save the webpage as an image. The code-sample creates a WebBrowser to retrieve the target webpage's html code and uses are WebBrowser.DrawToBitmap method convert the html code to .bmp image. In this code-sample, users can set the image's width, height and browser's width, height, generate an appropriate image.


New Windows Workflow Foundation Code Samples


Download: http://code.msdn.microsoft.com/CSWF4ServiceHostFactory-4e9f4a56

By using WorkflowServiceHost class, we can create a WF4 service host in code. The advantage of using WorkflowServiceHost is that we can add our own workflow extensions, tracking participant and persistence store provider. So problem is: can use our own WorkflowServiceHost in IIS7 like we did in the console application? This sample is for answering this question.


Download: http://code.msdn.microsoft.com/VBWF4CustomSequenceActivity-cd65cb4c

Generally, we use the built in Sequence activity to build a sequence workflow. Sequence activity is a composite activity. this sample demonstrated creating an customized composite activity: MySequenceActivity. and also its activity designer so that you can use it in a workflow designer. If you are going to create your own WF4 activity, you can use this sample as a reference.


New Windows General Code Samples

CSCheckProcessType, VBCheckProcessType

C# version: http://code.msdn.microsoft.com/CSCheckProcessType-62b7f649
VB version: http://code.msdn.microsoft.com/VBCheckProcessType-1fbafcf1

The code sample demonstrates how to identify the process type in run time, including whether this process is a 64bit process, a managed process, a .NET 4.0 process, a WPF process or a process with console window.

  • To determine whether a process is a 64bit process on x64 OS, we can use the Windows API IsWow64Process Function
  • To determine whether a process is a managed process, we can check whether the .Net Runtime Execution engine MSCOREE.dll is loaded.
  • To determine whether a process is a managed process, we can check whether the CLR.dll is loaded. Before .Net 4.0, the workstation CLR runtime is called MSCORWKS.DLL. In .Net 4.0, this DLL is replaced by CLR.dll. 
  • To determine whether a process is a WPF process, we can check whether the PresentationCore.dll is loaded.
  • To determine whether a process is a console process, we can check whether the target process has a console window with the GetConsoleMode API.

NOTE: This sample application must run on Windows Vista or later versions because it uses the EnumProcessModulesEx function to enumerate the loaded modules in a process, and the function is only available on these Windows versions.

New Office Open XML Code Samples

CSManipulateImagesInWordDocument, VBManipulateImagesInWordDocument

C# version: http://code.msdn.microsoft.com/CSManipulateImagesInWordDoc-312da7ef
VB version: http://code.msdn.microsoft.com/VBManipulateImagesInWordDoc-79ddae01

The code sample demonstrates how to list, export, delete, and replace images in an Office Word document using Office Open XML SDK.


If you have any suggestions for the code samples, please email us: onecode@microsoft.com.