380 likes | 600 Views
CL12. Developing with the Windows API Code Pack for .NET Framework. Yochay Kiriaty Technical Evangelist Microsoft Corporation. Agenda. Why are we here? The Windows API Code Pack Introduction Demos Demos Demos … Roadmap. Why Are We Here? (Part I).
E N D
CL12 Developing with the Windows API Code Pack for .NET Framework Yochay Kiriaty Technical Evangelist Microsoft Corporation
Agenda • Why are we here? • The Windows API Code Pack • Introduction • Demos DemosDemos… • Roadmap
Why Are We Here? (Part I) • We all write Windows Client applications • Windows 7 has some cool features • Taskbar • Shell and Libraries • Sensor and Location • Multitouch • New DirectX • Etc…
Why We Are Here? (Part II) • We all write Windows Client applications • Windows 7 has some cool features • All these features expose a native (win32) API • Today - there are no equivalent Managed APIs available to developers in the .NET Framework • “Interoping” with Unmanaged Code might be a little difficult sometimes
Accessibility from managed code Easy • Directly-callable using. NET interop mechanisms • Example: RSS, Office • C++/CLI or PInvoke signatures • Example: Application Recovery and Restart • Raw Win32 • Examples: Power Management, Windows Vista Wizards • COM • Examples: Search and Organize APIs • Extra difficult to call from managed code • Examples: Common File Dialogs, Network Awareness Hard
What is Windows API Code Pack? • Managed class library to access to Windows (7) features • Windows Shell namespace (supporting for Shell property system) • Taskbar Jumplists, Icon Overlay, Progress bar, Thumbnail, etc… • Windows Task Dialogs , Explorer Browser and other controls • Direct3D 11.0 and DXGI 1.0/1.1 APIs • Sensor Platform APIs • Extended Linguistic Services APIs • Windows Restart Manager • Power APIs • Other…. • http://code.msdn.com/windowsAPICodePack
New Windows API Code Pack Version announcing Version 1.0.1
Windows API Code pack Shell • Taskbar • Libraries • Explorer Browser • Known Folders • Task Dialogs • Shell Properties
Windows Taskbar Features Main Features • Overlay icons & progress bars • Jump lists (destinations, tasks) • Thumbnail toolbars • Custom thumbnails • Tabbed thumbnails Design Tip • Build a great Taskbar Icon • Forget about Quick Launch and the system tray
Customizing the Jump ListAdding tasks IObjectCollection* poc = ...; IShellLink* task = ...; Poc->AddObject(task); ICustomDestinationList* pcdl = ...; Pcdl->BeginList(...); IObjectArray* poa = ... poc; Pcdl->AddUserTasks(poa); Pcdl->CommitList(); JumpListjl = ...; jl.AddUserTasks(paramsIJumpListTask[] tasks);
Creating Thumbnail Toolbars UINT wm_tbc = RegisterWindowMessage( "TaskbarButtonCreated"); MSG m; GetMessage(..., &m); if (m.message == wm_tbc) { ITaskbarList3* ptl = ...; THUMBBUTTON btn = {...}; ptl->ThumbBarAddButtons(m.hWnd, 1, &btn); } WinForms: AddButtons(IntPtrwindowHandle, paramsThumbnailToolbarButton[] buttons) WPF: AddButtons(UIElement control, paramsThumbnailToolbarButton[] buttons)
Customizing Live Thumbnails DwmSetWindowAttribute( ...,DWMWA_HAS_ICONIC_BITMAP,...); DwmSetWindowAttribute( ...,DWMWA_FORCE_ICONIC_REPRESENTATION,...); /* in the WndProc */ case WM_DWMSENDICONICTHUMBNAIL: HBITMAP hbm = ...; DwmSetIconicThumbnail(hwnd, hbm, ...); TabbedThumbnailManagerttm = ...; ttm.AddThumbnailPreview(TabbedThumbnail preview)
Creating Thumbnail Toolbars WinForms AddButtons(IntPtrwindowHandle, params ThumbnailToolbarButton[] buttons) WPF: AddButtons(UIElementcontrol, params ThumbnailToolbarButton[] buttons)
Setting Overlay Icon WinForms TaskbarManager.SetOverlayIcon( IntPtrwindowHandle, System.Drawing.Iconicon, string accessibilityText) WPF TaskbarManager.SetOverlayIcon( System.Windows.Window window, System.Drawing.Iconicon, string accessibilityText)
Taskbar Demos JumpLists, Thumbnail Buttons, Clipping, and custom Preview
Shell and Libraries Integration A library is a collection of folders • Folders are grouped together for a purpose • They don’t have to share a physical root Very useful and user-friendly Developer guidelines: • Use correct version of the Common File Dialog (CFD) • CFD may return a “library” as the saved location • A library has a default save location • There are APIs for syncing with libraries
Customizing Live Thumbnails IShellLibrary *pIShelLibrary; HRESULT hr = SHCreateLibrary( IID_PPV_ARGS(&pIShelLibrary)); if (SUCCEEDED(hr)) { IShellItem *pIShellItem; SHAddFolderPathToLibrary(pIShelLibrary, L"C:\\Users\\Public\\Documents"); hr = pIShelLibrary->SaveInKnownFolder(FOLDERID_Libraries, L"My New Library", LSF_MAKEUNIQUENAME, &pIShellItem); pIShellItem->Release(); pIShelLibrary->Release(); } ShellLibrary library = new ShellLibrary(name, true) library.Add(folderPath);
Libraries Demo
Windows Sensor and Location Platform Develop better and more productive user experiences • Enable environmentally based applications Uniform APIs for working with sensors • No need to target vendor-specific APIs • Consistent interface for sensors, extensions for location • Access control and privacy • Application • Sensor API • UMDF Driver • Sensor Device
Ambient Light Sensor Optimize for best user experience • Change screen brightness • Out of the box with Windows 7 Drive adaptive user interface • LCD displays are difficult to read outdoors in direct sunlight • Utilize knowledge of ambient lighting conditions to improve PC usability • Change contrast, color theme, and font size to be more readable in direct sunlight
MSDN Reader Demo Light-Aware User Interface
XNA Racing Game Demo Ambient Light and Accelerometer Sensors
Many more topics • Managed class library to access to Windows (7) features • Windows Shell namespace (supporting for Shell property system) • Taskbar Jumplists, Icon Overlay, Progress bar, Thumbnail, etc… • Windows Task Dialogs, Explorer Browser and other controls • Direct3D 11.0 and DXGI 1.0/1.1 APIs • Sensor Platform APIs • Extended Linguistic Services APIs • Windows Restart Manager • Power APIs • Other…. • http://code.msdn.com/windowsAPICodePack
Windows 7 Managed Roadmap Today Tomorrow
Windows API Code Pack Roadmap Ver 2.0 Expanded Shell API coverage Ver - 0.9 Preview Ver – 1.0.1 Bug-fixes Ver 1.5 Fundamentals Ver - 1.0 Initial release Mar 2010 June 2009 Aug 2009 Nov 2009 Q2 / Q3 2010
Call To Action • Windows 7 Application Compatibility • Optimize for Windows 7 • Use Windows 7 new Taskbar & jump lists • Become library aware • Manage files & data with libraries • Create Amazing Expereinces: • Enhance User Experience with Sensor and Location • Adopt the new DirectX Graphic APIs • Develop for Multitouch
Resources • Windows Developer Center (MSDN) • http://msdn.microsoft.com/en-us/windows/default.aspx • Windows 7 Training Kit • Channel 9 - http://channel9.msdn.com/learn/windows • Windows 7 Developers Blog • http://windowsteamblog.com/blogs/developers/default.aspx • Windows 7 on Channel 9 • http://channel9.msdn.com/windows
YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation forms online at MicrosoftPDC.com
Learn More On Channel 9 • Expand your PDC experience through Channel 9 • Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses channel9.msdn.com/learn Built by Developers for Developers….
Windows 7 Taskbar and WPF 4 • XAML support for JumpLists • Supported • Overlay Icons and Progress Bar • JumpLists • Thumbnail Toolbars • Not Supported • Custom thumbnail and thumbnail Preview • Thumbnail clipping
Taskbar using XAML • <JumpList.JumpList> • <JumpList> • <JumpTaskApplicationPath="notepad.exe" CustomCategory="External Tools" • Description="Take Notes" Title="Start Notepad" • IconResourcePath="notepad.exe" IconResourceIndex="0" /> • <JumpTaskApplicationPath="calc.exe" CustomCategory="External Tools" • Description="Perform some calculations" Title="Start Calculator" • IconResourcePath="calc.exe" IconResourceIndex="0" /> • </JumpList> • </JumpList.JumpList>