630 likes | 947 Views
Required Slide. SESSION CODE: WCL312. Optimizing Your Application for the Windows 7 User Experience . Yochay Kiriaty Senior Technical Evangelist Microsoft Corporation. Amazing User eXperience. Name Title Company. DEMO. Building A Great Windows 7 Applications.
E N D
Required Slide SESSION CODE: WCL312 Optimizing Your Application for the Windows 7 User Experience Yochay Kiriaty Senior Technical Evangelist Microsoft Corporation
Amazing User eXperience NameTitleCompany DEMO
Building A Great Windows 7 Applications Create new experiences on Windows 7 Differentiate • EXPERIENCE Become a first class Windows 7 citizen Optimize Productpasses Microsoft quality tests Compatible
Optimize for PerformanceGet the Most Out of Windows Performance Enhancements • I/O priorities and cancelable I/O • File System and Registry Transaction Support • Power efficiency improvements • Windows Error Reporting • Application restart and recovery with Restart Manager • Trigger-Start Services • Windows Troubleshooting Platform • Event Tracing for Windows (ETW)
Optimize for PerformanceGet the Most Out of Windows Performance Enhancements • Application restart and recovery with Restart Manager • I/O priorities and cancelable I/O • File System and Registry Transaction Support • Event Tracing for Windows (ETW) – high-performance instrumentation • Windows Error Reporting • Trigger-Start Services • Windows Troubleshooting Platform • Power efficiency improvements WLC306 - Fundamentals in Windows Applications for Developers: Graphics, Power, Services, and Profiling See recording
Optimize For User eXperienceMake sure your application looks and feels like Windows 7 first class citizen • Windows 7 Libraries • Become library aware and work with libraries • Federated Search • Windows Ribbon • Windows 7 Taskbar • Jump Lists • Aero Peek
Libraries Under The Hood • Library information is kept in a file (.library-ms) • The format of the .library-ms file is a private data structure and subject to changes • Use ONLY the Windows Shell Library APIs to manage and interact with libraries • Use the library file definition to: • Delete, rename, or wait for change notification (changes to the library structure) <libraryDescription> <name>@shell32.dll,-34575</name> <isLibraryPinned>-1</isLibraryPinned> <iconReference>imageres.dll,-1002</iconReference> <folderType>{7d49d726-3c21-4f05-99aa-fdc2c9474656}</folderType> …
Staying In-Sync with Windows 7 Libraries Part 1 DEMO
Using The API Create Library • Shell APIs are COM based • To use the Library objects, interfaces and functions you should: • #include <shobjidl.h> • #include <objbase.h> // IID_PPV_ARGS macro • To create a new Library: • HRESULT SHCreateLibrary(REFIID riid,void **ppv ); • With the macro: • IShellLibrary *pIShellLib; • SHCreateLibrary(IID_PPV_ARGS(&pIShellLib));
Create Library and Add Folder Win32 API 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"MyNew Library", LSF_MAKEUNIQUENAME, &pIShellItem); pIShellItem->Release(); pIShelLibrary->Release(); }
Create Library and Add Folder Using Windows API Code Pack //Create new library and add a folder using (ShellLibrary library = newShellLibrary(name, true)) { library.Add(folderPath); } //Load the document library, add new folder, pin to nav pan using (ShellLibrary lib = ShellLibrary.Load( "Documents", false)) { lib.Add(@"C:\"); lib.IsPinnedToNavigationPane = true; lib.DefaultSaveFolder = @"C:\"; }
Staying In-Sync with Windows 7 Libraries Part 2 DEMO
Windows 7 Federated Search The Best Internet and Intranet Search Experience on the Desktop
Federated SearchConsistent experience across providers; files and otherwise Document repository Enterprise data store Enterprise application
One Stop-Shop for Programming Windows 7 Libraries • http://windowsteamblog.com/windows/b/developers/archive/2010/04/14/windows-7-programming-guide-libraries-update.aspx
Windows Ribbon Modernize your application’s UI
Windows Ribbon • In-box with Windows 7, redistribution available to Windows Vista ® • Feature parity with Microsoft® Office 2007 Ribbon • Result-oriented UI Application Menu Contextual Tab Group Quick Access Toolbar Tab Help Button Contextual Tab Group
Windows Ribbon UI Architecture • Ribbon elements are specified in markup • Available controls • Menus, drop-down galleries, combo boxes, font control, buttons, spinners, tabs and groups and more • Application-Specific Business Logic • Windows Ribbon • Markup: Organization of controls • COM API: Initialization and events handling • <Ribbon> • <Tab> <Button … /> • </Tab> • </Ribbon> • MyHandler::Execute(…){ DoStuff();} • void DoStuff() • { • … • … • }
Windows Taskbar Modernize your application’s UI
Taskbar Buttons • Consolidation • Quick launch • Notification area icon • Desktop shortcut • Running application windows Multiple windows and hover Running Not running Active
How Are Windows Grouped?Enter: Application ID • It’s a string, not a GUID • Limited to 128 characters • Naming convention – Company.Product.SubProduct.Version • All your application components have it: • Process, shortcut, window, taskbar button, document type
Setting the Application ID • Process-wide – affects all windows in the current process: #include <windows.h> #pragma comment (lib, "shell32.lib") SetCurrentProcessExplicitAppUserModelId( L"Microsoft.Samples.AppId1"); TaskbarManager.SetCurrentProcessAppId( "Microsoft.Samples.AppId1");
Window Application ID • Change single window’s application ID PROPVARIANT pv; InitPropVariantFromString( L"Microsoft.Samples.AppId2", &pv); IPropertyStore *pps; HRESULT hr = SHGetPropertyStoreForWindow( hWnd, IID_PPV_ARGS(&pps)); pps->SetValue(PKEY_AppUserModel_ID, pv); //WinForms: TaskbarManager.SetApplicationIdForSpecificWindow (IntPtrwindowHandle, stringappId) //WPF: TaskbarManager.SetApplicationIdForSpecificWindow (System.Windows.Windowwindow, stringappId)
Windows Taskbar Application ID and its effects on taskbar buttons DEMO
Jump ListsA detailed look Pinned category Destinations (“nouns”) Known categories Custom categories User tasks Tasks (“verbs”) Taskbar tasks
Jump ListsDesign considerations • Surface key destinations and tasks • Recent and frequent are free • Pinned is also free (if users use it) • Respect items the user removes! • Addictive: You don’t look for documents anywhere else! • Users expect common tasks to be there
Customizing the Jump ListStep 1: Get the free stuff to work • Associate your program with the file extension • Use common file dialogs • Use explicit recent document API SHAddToRecentDocs(SHARDW_PATH, "file.ext"); RH.RegisterFileAssociations(...); OpenFileDialogofd = ...; ofd.ShowDialog(); JumpListjl = ...; jl.AddToRecent("file.ext");
Customizing the Jump ListStep 2: Adding tasks • What would your user like to do? • Launch your application with special arguments? • Launch other applications? • Tasks are IShellLink objects • Rich shortcut semantics including arguments, working directory, icon, and so on.
Customizing the Jump ListStep 2: Adding 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);
Customizing the Jump ListStep 3: Do you have categories? • Does it make sense to categorize documents? • Is frequent, recent, pinned not enough? • For example, Inbox, Outbox, Sales, Marketing … • Categories contain IShellItem or IShellLink objects • These are documents: You need a file association
Customizing the Jump ListStep 3: Adding categories IObjectCollection* poc = ...; IShellItem* item = ...; Poc->AddObject(item); ICustomDestinationList* pcdl = ...; Pcdl->BeginList(...); IObjectArray* poa = ... poc; Pcdl->AppendCategory(L"Sales", poa); Pcdl->CommitList(); JumpListjl = ...; jlm.AddCustomDestination(paramsJumpListCustomCategory[] customCategories);
Customizing Jump Lists http://channel9.msdn.com/posts/yochay/Programming-the-Windows-7-Taskbar--Jump-Lists-Part-2/
Get More From Taskbar ButtonsOverlay and progress icons • Consolidate: Uncluttered notification area • Provide progress and additional information through the taskbar button • It’s free if you use standard progress dialogs
Taskbar Overlay and ProgressDesign considerations • Notification area is now user controlled: • Leave yourself out if possible! • Use taskbar buttons for custom progress or status information
Taskbar Overlay and ProgressThe APIs ITaskbarList3* ptl = ...; ptl->SetOverlayIcon( hwnd, hicon, L"Accessible Description"); ptl->SetProgressState(hwnd, TBPF_NORMAL); for (int i = 0; i < MAX; ++i) { ptl->SetProgressValue(hwnd, i, MAX); } myForm.SetTaskbarOverlayIcon(icon, "..."); ProgressBarpb = ...; pb.SetTaskbarProgress();
Taskbar Overlay IconsThe APIs //WinForms: TaskbarManager.SetOverlayIcon (IntPtrwindowHandle, System.Drawing.Icon icon, stringaccessibilityText) //WPF: TaskbarManager.SetOverlayIcon (System.Windows.Window window, System.Drawing.Icon icon, stringaccessibilityText)
Windows Taskbar Overlay icons and progress bar DEMO
Using the Taskbar Button Overlay Icons and Progress Bars http://channel9.msdn.com/posts/yochay/Programming-the-Windows-7-Taskbar--Using-the-Taskbar-Button-Overlay-Icons-and-Progress-Bars/
Live Thumbnails • Live thumbnails: A livepreview • Windows Vista®: One thumbnail per window • Windows 7: Grouped thumbnails
Peek Preview (Aero Peek) Live peek without a click
Live Thumbnails and PeekDesign considerations • Desktop Window Manager (DWM) only talks to top-level windows • Child windows need a custom representation • The thumbnail might be “too much” or “not enough” • What if you could … • Test your thumbnails to make sure they are useful • If they aren’t, customize them!
Thumbnail Clip (Zoom) Zoom into the important parts!
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 = new ...; ttm.AddThumbnailPreview(TabbedThumbnailpreview)
Custom Previews and Thumbnail Clips http://channel9.msdn.com/posts/yochay/Programming-the-Windows-7-Taskbar--Custom-Previews-and-Thumbnail-Clips/