Posts
40
Comments
79
Trackbacks
0
October 2010 Entries
Announcement: NEW FREE Code Sample Request Service from Microsoft All-In-One Code Framework

 

 

 

Today, the Microsoft All-In-One Code Framework team announces a NEW, FREE code sample request service. This service is a proactive way for our developer community to obtain code samples for certain programming tasks directly from Microsoft. We want to alleviate the frustration felt by developers.

Developers are encouraged to submit code sample requests dealing with any Microsoft development technologies to our site. At the same time, developers can now vote for newly submitted or existing code sample topics. Here’s the exciting part! Microsoft engineers will then pick the requests with the highest number of votes and provide the code samples. It’s all FREE!

 

Feedback

This is a new service from our team. We encourage our developer community to share your feedback with us so that we can continuously improve what we offer to you.

 

 

Guideline

 

How do I request a code sample from the Microsoft All-In-One Code Framework team?

 

Step 1: Visit the All-In-One Code Framework sample request portal http://1code.codeplex.com/workitem/list/basic and sign in with your CodePlex account.
Note: If you don’t have an account, you will be required to register for CodePlex.



Step 2: Once you are signed in with your CodePlex account, we encourage you to begin by searching for existing code sample requests to avoid any duplication with other developer requests.

search.png

 

 

If you find a relevant code sample topic that has already been submitted, you can add your comments to the request and vote for it. The code sample requests with the highest number of votes have the strongest chance to be turned into code samples by Microsoft.

vote.png

 

Step 3: If you cannot find any relevant sample request in the portal, please click the Create New Item button. Fill out the form to submit a sample request.

submit.png

 

In the Description, please tell us the purpose of the sample. Why do you think that it is necessary to create this code sample?

For example: Do you see other developers asking about the same topic? Does the topic currently lack code samples and documentation?

After you complete the form, please select Email me when someone comments or the status changes checkbox, and Save it.

You will be notified about any updates to the request.

 

How do Microsoft engineers determine the eligibility of a code sample topic?

Microsoft engineers will pick the requests with the highest number of votes. Then, they’ll evaluate the sample topic to see if it is appropriate for a code sample. Finally, Microsoft engineers will create the code sample and share it in All-In-One Code Framework.

 

Posted On Thursday, October 28, 2010 12:31 AM | Feedback (1)
All-In-One Code Framework Survey Result in September

At the beginning of September, we launched All-In-One Code Framework Customer Polling Survey. 62 customers filled out the survey in September, and provided lots of constructive suggestions. Thanks to all of you who shared your invaluable feedback! The project can become better and better because of you. Please continue to input your comments.

Here is a summary of feedback that we collected in September, and the project team's follow-up action.

------------------------

The top five areas that the customers expect to see more code samples:

  • ASP.NET
  • .NET – native Interop
  • Data Platform (ADO.NET, Entity Framework, etc)
  • Windows Forms
  • Silverlight

Feedback of the organization of code samples

"I guess the organizing of the source codes into relevant groups would help better in getting started with a new technology."

In the current All-In-One Code Framework, we do not organize code samples in folders of different technologies (e.g. \Silverlight\<all silverlight samples>). All samples are parellelly in the Visual Studio 2008 and Visual Studio 2010 folders. 

\Visual Studio 2010
                All-In-One Windows Shell Samples.sln      The solution file for all Windows Shell samples
                CppShellExtInfotipHandler.sln
                CSShellExtInfotipHandler.sln
                \Debug                                                                All samples output to this folder in the Debug build
                \Release                                                             All samples output to this folder in the Release build
                \CppShellExtInfotipHandler
                    FileInfotipExt.h
                    ReadMe.txt
                \CSShellExtInfotipHandler
                    FileInfotipExt.cs
                    ReadMe.txt

The reasons for this directory layout are that

  • It avoids the trouble caused by cross-tech samples. Some samples may belong to multiple techs. If we have sub-folders of techs, it’s difficult to decide where to place those cross-tech samples. It is bad to duplicate the sample in the sub-folders of different techs.
  • The layout makes it possible to redirect all samples’ output (exe/dll) to a uniform folder (Debug/Release). This facilitates the tests and mutual references of samples.

The above directory layout can be regarded as the "physical layout" of the code samples. We try to group the code samples by technology in "logical layout". You can find a VS solution file named "All-In-One <Tech Name> Samples.sln" for each technology. The future releases of the sample browser will also display samples by technology.

Do you think that this sample organization makes sense?

Feedback of the discoverability of the code samples

"Have a web page when I can ""search"" the samples"

This is a golden idea! I'd like to take this opportunity to introduce our vision of the project, in which there is a similar sample search idea.

The project team is going to start a very interesting initiative to help developers search and use the code samples more easily. The team plans to move the centralized code samples to the cloud, provide a code search and sample download web service, and integrate the service with Visual Studio through a Visual Studio add-in. In this way, developers can instantly search code in IDE, and download samples on demand, instead of downloading the entire package. 

Do you like this idea? Please let us know your thoughts by leaving a message in the Comments.

Feedback of the project release

"Rather than downloading, installing, and deleting language samples whch I care nothing about; why not offer the downloads by specific language, C#, C++, VB.  And if I already have the and All-in-one browser installed, why not offer just the newest or updated samples, again by language, for download. I always delete superfluous files."

I think that the vision in the above picture may address this concern. It would allow you to download samples on demand, instead of downloading the entire package every time. Implementing the vision would cost some months. As a short-term solution, we will provide language-specific download packages from the next release.

Feedback of the sample browser

We received some crash reports of the sample browser. For example, the application may crash with the 'Object reference not set to an instance of the object' exception. Thanks for the reports! We are aware of these problems now. The team is heads-down and working hard on the second version of the browser.

Feedback of the code sample documentations

"Specify more clear and succint the necessary steps into achieving some goal."

One of our goals is to provide detailed and clear sample documentations. Please specifically tell us which sample should improve its documentation, and we will improve it in no time.

Other Feedback

Some customers feedback that there are a few incomplete code samples in the release. We are sorry about it. These code samples were checked in by mistake, and will be removed before the next release of the project.

"You might consider including a testing harness and/or test cases built in to the examples to promote consistent and thourogh testing (of course using MS tools). "

Sounds a great idea! As this would impact all existing code samples, I would like to first learn whether many people are expecting this change. Please share your thoughts in the Comments.

"if we can, we would like to receive a email introduce the project created soon and we like when there's a new project is created. just a little like codeproject but we can only send the selected type project by the custom when that type has been created a new one."

 

Nice idea! In the long run, we can provide newsletter of code samples. In the short term, I'm thinking about twittering or blogging each new sample. Customers can be notified by following the twitter or by registering the blog RSS feed. Is it fine to you?

Posted On Thursday, October 14, 2010 9:13 AM | Feedback (1)
Microsoft All-In-One Code Framework New Samples Updated on 2010-10-10

Microsoft All-In-One Code Framework is updated on 2010-10-10.

 

Download address: http://1code.codeplex.com/releases/view/53729#DownloadId=156489

 

If it’s the first time that you hear about Microsoft All-In-One Code Framework, please read the introduction on our homepage http://1code.codeplex.com/,  and this Port25 article http://port25.technet.com/archive/2010/01/18/the-all-in-one-code-framework.aspx. 

 

Windows Shell Extension New Samples

In the September release of All-In-One Code Framework, we gave an introduction of writing Windows Shell extension in .NET Framework 4, and demonstrated a "skeleton" Context Menu Handler. In this release, you can find the code samples of Windows Shell drag-and-drop handlers. An infotip handler is a shell extension handler that provides pop-up text when the user hovers the mouse pointer over the object. It is the most flexible way to customize infotips. The alternative way is to specify either a fixed string or a list of certain file properties to be displayed (See the Infotip Customization section in http://msdn.microsoft.com/en-us/library/cc144067.aspx)

CSShellExtInfotipHandler:   Shell infotip handler (C#) 
VBShellExtInfotipHandler:   Shell infotip handler (VB.NET)
CppShellExtInfotipHandler: Shell infotip handler (C++)
CppShellExtDragDropHandler: Shell drag-and-drop handler (C++).

 

ASP.NET New Samples

 

CSASPNETImagePreviewExtender,VBASPNETImagePreviewExtender

Microsoft Ajax extender controls enhance the client capabilities of standard ASP.NET Web server controls. We can target standard Web server controls such as TextBox controls, Button controls, and Panel controls by using one or more extender controls to provide a richer user experience in the browser. For example, to let users confirm before they submit a form to the server, we can use an extender control that adds client functionality to a Button control.

Some programmers in the ASP.NET community asked how to create a custom ASP.NET Ajax Extender control, just like these controls in the AjaxControlToolkit. In this sample, we illustrated how to create that kind of control step by step. The sample, ASPNETImagePreviewExtender make Image server control as target, and it will show the image as a thumbnail by default and when user clicks the image it will automatically show the full image from client side without postback.

 

CSASPNETAJAXHTMLEditorExtender

HTMLEditor is an AJAX server control in the AjaxControlToolkit package. It allow us to input data with HTML format. That’s a very complicated control and always a lot of people want to find a way to add a custom toolbar control to the HTMLEditor and realize some custom feature. In this sample, I create a custom toolbar control step by step to realize a feature that make a <H1></H1> tag surround the selected string.

 

CSASPNETAddControlDynamically, VBASPNETAddControlDynamically

This sample illustrates how to dynamically add controls in ASP.NET pages. For  the reason that HTTP is a stateless protocol, it’s hard to know when the controls have been created and whether the controls have been changed. However, we can use ViewState to store these information in the page and when the next time the page posts back, we can re-create these controls according to the ViewState values.

 

CSASPNETBingMaps

This sample shows the way to use the Bing Maps API map in an ASP.NET page. Sometime we need to embed a map in our ASP.NET pages to locate a place and show the surroundings around the place. To achieve this task, Bing Maps API provide a map control which is  by no means weak than Google Map. And it can be easily set the location, zoom level, display mode and other properties by few code.

 

CSASPNETAutoComplete

This sample demonstrates how to use AutoComplete Control in Ajax Control Toolkit. AutoComplete can be attached to any TextBox control, and will associate that control with a popup panel to display words that begin with the prefix typed into the textbox.

 

CSASPNETTheme

Sometime we need different web page experience for different visitors, The CSASPNETTheme populate how to set page output with themes.

 

Office New Samples

 

CSOfficeRibbonAccessibility, VBOfficeRibbonAccessibility

These two samples show how to use the Microsoft Active Accessibility API to do Office 2010 Ribbon UI automation.  The program define a custom form, which shows the whole structure of the ribbon in three layers. The tab contains multiple groups. The group contains multiple controls. It also shows how to invoke an control’s functionality as well.

 

Windows Base New Samples

 

CSProcessWatcher, VBProcessWatcher

Sometimes we need to monitor the creation, deletion and modification events of the specific process in .Net application. Is there any simple way to achieve this except the sophisticated and unsupported way such as hooking APIs? This sample shows a fairly simple solution -- using WMI to monitor process creation, deletion and modification events. You can be programmatically notified when a certain process is started or stopped.

CppPlatformDetector, CSPlatformDetector, VBPlatformDetector

The code samples demonstrate the following tasks related to platform detection:

1. Detect the name of the current operating system. (e.g. "Microsoft Windows 7 Enterprise")
2. Detect the version of the current operating system.  (e.g. "Microsoft Windows NT 6.1.7600.0")
3. Determine whether the current operating system is a 64-bit operating system.
4. Determine whether the current process is a 64-bit process.
5. Determine whether an arbitrary process running on the system is 64-bit.

 

WPF New Samples

 

VBWPFMVVMPractice

The sample demonstrates how to implement the MVVM pattern in a WPF application  through a small game.

 

If you have any suggestions, questions, or feedback about this release, please feel free to email us: onecode@microsoft.com

Posted On Tuesday, October 12, 2010 10:23 PM | Feedback (0)
Writing Windows Shell Extension with .NET 4 - Part 2

Sample download

In Part 1 of the series, we gave an introduction of writing Windows Shell extension in .NET Framework 4, and demonstrated a "skeleton" Context Menu Handler.

This article introduces the sample: Infotip Handler.

CSShellExtInfotipHandler:   Shell infotip handler (C#) 
VBShellExtInfotipHandler:   Shell infotip handler (VB.NET)
CppShellExtInfotipHandler: Shell infotip handler (C++)

An infotip handler is a shell extension handler that provides pop-up text when the user hovers the mouse pointer over the object. It is the most flexible way to customize infotips. The alternative way is to specify either a fixed string or a list of certain file properties to be displayed (See the Infotip Customization section in http://msdn.microsoft.com/en-us/library/cc144067.aspx)

Demo

Here is a quick demo of the infotip handler code sample.  After you successfully build the CSShellExtInfotipHandler sample project in Visual Studio 2010, you will get a DLL: CSShellExtInfotipHandler.dll. Run 'Visual Studio Command Prompt (2010)' (or 'Visual Studio x64 Win64 Command Prompt (2010)' if you are on a x64 operating system) in the Microsoft Visual Studio 2010 \ Visual Studio Tools menu as administrator. Navigate to the folder that contains the build result CSShellExtInfotipHandler.dll and enter the command:

    Regasm.exe CSShellExtInfotipHandler.dll /codebase

The infotip handler is registered successfully if the command prints:

    "Types registered successfully"

Find a .cs file in the Windows Explorer (e.g. FileInfotipExt.cs in the sample folder), and hover the mouse pointer over it. you will see an infotip with the text:

    File: <File path, e.g. D:\CSShellExtInfotipHandler\FileInfotipExt.cs>
    Lines: <Line number, e.g. 123 or N/A>
    - Infotip displayed by CSShellExtInfotipHandler

 To unregister the infotip handler, run the following command in the same Visual Studio 2010 command prompt.

    Regasm.exe CSShellExtInfotipHandler.dll /unregister

 

Implementation Details

A. Creating and configuring the project

In Visual Studio 2010, create a Visual C# / Windows / Class Library project named "CSShellExtInfotipHandler". Open the project properties, and in the Signing page, sign the assembly with a strong name key file.

-----------------------------------------------------------------------------

B. Implementing a basic Component Object Model (COM) DLL

Shell extension handlers are all in-process COM objects implemented as DLLs. Making a basic .NET COM component is very straightforward. You just need to define a 'public' class with ComVisible(true), use the Guid attribute to specify its CLSID, and explicitly implements certain COM interfaces. For example,

    [ClassInterface(ClassInterfaceType.None)]
    [Guid("B8D98AB4-376B-45D0-9CF6-8BF22A588989"), ComVisible(true)]
    public class SimpleObject : ISimpleObject
    {
        ... // Implements the interface
    }

You even do not need to implement IUnknown and class factory by yourself because .NET Framework handles them for you.

-----------------------------------------------------------------------------

C. Implementing the infotip handler and registering it for a certain file class

-----------
Implementing the infotip handler:

The FileInfotipExt.cs file defines an infotip handler. The infotip handler must implement the IQueryInfo interface to create text for the tooltip, and implement the IPersistFile interface for initialization.

    [ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [Guid("00021500-0000-0000-c000-000000000046")]
    internal interface IQueryInfo
    {
        // The original signature of GetInfoTip is
        // HRESULT GetInfoTip(DWORD dwFlags, [out] PWSTR *ppwszTip);
        // According to the documentation, applications that implement this method
        // must allocate memory for ppwszTip by calling CoTaskMemAlloc. Calling
        // applications (the Shell in this case) calls CoTaskMemFree to free the
        // memory when it is no longer needed. Here, we set PreserveSig to false
        // (the default value in COM) to make the output parameter 'ppwszTip' the
        // return value. We also marshal the string return value as LPWStr. The
        // interop layer in CLR will call CoTaskMemAlloc to allocate memory and
        // marshal the .NET string to the memory.
        [return: MarshalAs(UnmanagedType.LPWStr)]
        string GetInfoTip(uint dwFlags);

        int GetInfoFlags();
    }

The IPersistFile interface is available in the System.Runtime.InteropServices.ComTypes namespace.
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comtypes.ipersistfile.aspx
 
    [ClassInterface(ClassInterfaceType.None)]
    [Guid("B8D98AB4-376B-45D0-9CF6-8BF22A588989"), ComVisible(true)]
    public class FileInfotipExt : IPersistFile, IQueryInfo
    {
        #region IPersistFile Members

        public void GetClassID(out Guid pClassID)
        {
            ...
        }

        public void GetCurFile(out string ppszFileName)
        {
            ...
        }

        public int IsDirty()
        {
            ...
        }

        public void Load(string pszFileName, int dwMode)
        {
            ...
        }

        public void Save(string pszFileName, bool fRemember)
        {
            ...
        }

        public void SaveCompleted(string pszFileName)
        {
            ...
        }

        #endregion  


        #region IQueryInfo Members

        public string GetInfoTip(uint dwFlags)
        {
            ...
        }

        public int GetInfoFlags()
        {
            ...
        }

        #endregion
    }

When you write your own handler, you must create a new CLSID by using the "Create GUID" tool in the Tools menu for the shell extension class, and specify the value in the Guid attribute.

    ...
    [Guid("B8D98AB4-376B-45D0-9CF6-8BF22A588989"), ComVisible(true)]
    public class FileInfotipExt : ...


  1. Implementing IPersistFile

  The Shell queries the extension for IPersistFile and calls its Load method passing the file name of the item over which mouse is placed.   IPersistFile.Load opens the specified file and initializes the wanted data.   In this code sample, we save the absolute path of the file.

    public void Load(string pszFileName, int dwMode)
    {
        // pszFileName contains the absolute path of the file to be opened.
        this.selectedFile = pszFileName;
    }

  The rest methods of IPersistFile are not used by the Shell for infotip handlers, so we can simply make them blank or throw a NotImplementedException exception.

  2. Implementing IQueryInfo

  After IPersistFile is queried, the Shell queries the IQueryInfo interface and the GetInfoTip method is called. GetInfoTip returns a string containing the tip to display.

  In this code sample, the example infotip is composed of the file path and the count of text lines.

    // Prepare the text of the infotip. The example infotip is composed of
    // the file path and the count of code lines.
    int lineNum = 0;
    using (StreamReader reader = File.OpenText(this.selectedFile))
    {
        while (reader.ReadLine() != null)
        {
            lineNum++;
        }
    }

    return string.Format("File: {0}\nLines: {1}\n" +
        "- Infotip displayed by CSShellExtInfotipHandler",
        this.selectedFile, lineNum.ToString());

The IQueryInfo.GetInfoFlags method is not currently used. We simply throw a NotImplementedException exception in the method.

-----------
Registering the handler for a certain file class:

Infotip handlers can be associated with a file class. The handlers are registered by setting the default value of the following registry key to be the CLSID the handler class.

    HKEY_CLASSES_ROOT\<File Type>\shellex\{00021500-0000-0000-C000-000000000046}

The registration of the infotip handler is implemented in the Register method of FileInfotipExt. The ComRegisterFunction attribute attached to the method enables the execution of user-written code other than the basic registration of the COM class. Register calls the ShellExtReg.RegisterShellExtInfotipHandler method in ShellExtLib.cs to associate the handler with a certain file type. If the file type starts with '.', it tries to read the default value of the HKCR\<File Type> key which may contain the Program ID to which the file type is linked. If the default value is not empty, use the Program ID as the file type to proceed the registration.

For example, this code sample associates the handler with '.cs' files. HKCR\.cs has the default value 'VisualStudio.cs.10.0' by default when Visual Studio 2010 is installed, so we proceed to register the handler under HKCR\VisualStudio.cs.10.0\ instead of under HKCR\.cs. The following keys and values are added in the registration process of the sample handler.

    HKCR
    {
        NoRemove .cs = s 'VisualStudio.cs.10.0'
        NoRemove VisualStudio.cs.10.0
        {
            NoRemove shellex
            {
                {00021500-0000-0000-C000-000000000046} =
                    s '{B8D98AB4-376B-45D0-9CF6-8BF22A588989}'
            }
        }
    }

The unregistration is implemented in the Unregister method of FileInfotipExt. Similar to the Register method, the ComUnregisterFunction attribute attached to the method enables the execution of user-written code during the unregistration process. It removes the registry key: HKCR\<File Type>\shellex\{00021500-0000-0000-C000-000000000046}.

Download

http://1code.codeplex.com/releases

And find the CS/VB/CppShellExtContextMenuHandler samples in the Visual Studio 2010 folder.

If you have any feedback about the samples, please email onecode@microsoft.com.

Please stay tuned for Part 3 of the series, which will talk about writing Drag and Drop Handler in managed languages.

Posted On Monday, October 11, 2010 11:57 AM | Feedback (4)
Device + Cloud: The code sample combining IE9, Windows Phone 7, and Windows Azure

This code sample demonstrates the following features:

 

• Two new features of IE9 for Windows 7 PC devices: HTML canvas and SVG.
• A Windows Phone 7 device application that renders a 3D bar chart.
• How to use the Windows Azure platform Dallas services.
• How to connect the devices using a Windows Azure cloud service.

 

Code sample download: http://1code.codeplex.com/releases/view/51868#DownloadId=152535

 

You can see a live demonstration of the IE9 samples. The pages require IE9 beta (http://windows.microsoft.com/ie9?os=win7&arch=a&browser=ie)
Canvas demo: http://smalldemos.cloudapp.net/Html5Demos/CanvasDemo.htm
SVG demo: http://smalldemos.cloudapp.net/Html5Demos/SvgDemo.htm

 

For a walkthrough of the sample, please refer to the Azure Technical Forum Support Team’s blog posts:

 

Part1: General description about how to combine the devices and the cloud: http://blogs.msdn.com/b/windows-azure-support/archive/2010/09/19/cloud-device-combine-the-power-of-windows-azure-ie-9-and-windows-phone-7.aspx

 

Part2: Walkthrough the canvas demo: http://blogs.msdn.com/b/windows-azure-support/archive/2010/09/19/cloud-device-combine-the-power-of-windows-azure-ie-9-and-windows-phone-7-part-2.aspx

 

Part3: Walkthrough the SVG demo and the cloud service: http://blogs.msdn.com/b/windows-azure-support/archive/2010/09/19/cloud-device-combine-the-power-of-windows-azure-ie-9-and-windows-phone-7-part-3.aspx

Posted On Friday, October 01, 2010 5:33 PM | Feedback (2)
Advertise on this site through Lake Quincy Media
Tag Cloud