360 likes | 516 Views
CL09. How Microsoft Visual Studio 2010 Was Built with WPF 4. Paul Harrington Principal Software Engineer Microsoft Corporation. Why, What, How, Who?. Why WPF? What WPF features are used? How was it built? Who was involved?. Why WPF?. Technological Prove the capabilities of WPF 4.0.
E N D
CL09 How Microsoft Visual Studio 2010 Was Built with WPF 4 Paul Harrington Principal Software Engineer Microsoft Corporation
Why, What, How, Who? • Why WPF? • What WPF features are used? • How was it built? • Who was involved?
Why WPF? • Technological • Prove the capabilities of WPF 4.0
The Visual Studio 2010 IDE demo Paul Harrington Principal Software Engineer Visual Studio Platform Team
Why WPF? • Technological • Prove the capabilities of WPF 4.0 • Architectural • Separated Presentation • Support for long range road map • Key VS 2010 features need it • Editor, Architecture editor, Parallel tools… • We took the “pain” so you don’t have to
What WPF Features are used? • Declarative UI using XAML • Data binding • Managed and native data models • Style templates • Application Resources • Interop with Win32 • Integration with the message loop • New text stack based on DirectWrite
Staged Approach • Define the data models • Replace the main window with WPF • Write new • Window Manager, Command Bar presentation • Hidden behind switches, off by default • Scout with selected teams • Test, test, test • Reverse the switches • Leave old presentation for regression testing • Remove old code
A lesson learned: Test conversion costs • We underestimated the cost of rewriting test cases • Too many HWND assumptions • Many different testing frameworks • But there were opportunities • Unify test frameworks • UI Automation accessibility framework • Test at the data layer
What were the challenges? • Mixed mode application • Native and Managed code • WPF and HWNDs (Win32 and WinForms) • Keep existing extensions working • Allow new extensions to take advantage of WPF • Don’t “stop the train” • Text Clarity • Performance
Challenges of a Mixed-Mode App • Interop in the data layer • Managed code binding to native models • Interop in the presentation layer • Composition of new and old • Focus and activation • Integration with the message loop
Composition of new and old • interfaceIVsWindowPane : IUnknown • { • HRESULT SetSite ([in] IServiceProvider *pSP); • HRESULT CreatePaneWindow([in] HWND hwndParent, • [in] int x, [in] int y, • [in] intcx, [in] int cy, • [out] HWND *hwnd); • HRESULT GetDefaultSize([out] SIZE *psize); • HRESULT ClosePane(void); • HRESULT LoadViewState([in] IStream *pstream); • HRESULT SaveViewState([in] IStream *pstream); • HRESULT TranslateAccelerator(LPMSG lpmsg); • }
Presentation-neutral interfaces • interfaceIVsUIElementPane : IUnknown • { • HRESULT SetUIElementSite([in] IServiceProvider *pSP); • HRESULT CreatePane([out] IUnknown **ppunkUIElement); • HRESULT GetDefaultUIElementSize([out] SIZE *psize); • HRESULT CloseUIElementPane(void); • HRESULT LoadUIElementState([in] IStream *pstream); • HRESULT SaveUIElementState([in] IStream *pstream); • HRESULT TranslateUIElementAccelerator(MSG *lpmsg); • }
Integrating with the Message Loop and Focus Handling demo Paul Harrington Principal Software Engineer Visual Studio Platform Team
Integrating with the Message Loop • ComponentDispatcher • RaiseThreadMessage method • Managing Focus • HwndSource.DefaultAcquireHwndFocusInMenuMode • Use WindowsFormsHost • Menu mode • InputManager.Push/PopMenuMode methods • Listen to PreviewGotKeyboardFocus
Text and Image Clarity • “Fuzzy” images • UseLayoutRounding = "True" • “Blurry” text • TextFormattingMode = "Display"
DirectWrite demo Paul Harrington Principal Software Engineer Visual Studio Platform Team
Performance • Startup • Atomic operations on the Visual Tree • Memory usage • VMMap • SOS.dll, !dumpheap –stat • Windows Performance Analyzer (xperf) • Hardware versus Software rendering • Virtual machines and Remote Desktop • Scrolling in the Editor
Scrolling Performance • Visual.VisualScrollableAreaClip • Hint to software renderer to use scrolling • Best with • UseLayoutRounding="True"
Who? • Core team of about 12 people • 7 developers • 5 testers • WPF Team • Expression Suite Team
WPF Sessions @ PDC09 • PDC09-CL09How Microsoft Visual Studio 2010 Was Built with Windows Presentation Foundation 4 TUE 11/17/2009, 11:00AM - 12:00PM, Room 502A • PDC09-CL11Advanced Windows Presentation Foundation Application Performance Tuning and Analysis TUE 11/17/2009, 4:30PM - 5:30PM, Room Petree Hall D) • CHALK TALK Deep Dive into WPF4 Multi-Touch APIs WED 11/18/2009 11:00PM - 12:00PM, The Big Room • PDC09-CL31 Mastering WPF Graphics and Beyond WED 11/18/2009, 12:30-1:15PM, Room Hall E - 151 • PDC09-CL10Windows Presentation Foundation 4 Plumbing and Internals THUR 11/19/2009, 10:00AM - 11:00AM, Room Hall E – 151 • PDC09-CL27Multi-Touch on Microsoft Surface and Windows 7 for .NET Developers THUR 11/19/2009 , 11:30AM - 12:30PM, Room Petree Hall C • PDC09-CL24XAML Futures in Microsoft .NET Framework, Microsoft Silverlight and Tools, THUR 11/19/2009 , 1:45PM - 2:45PM, Room Hall F - 153 • MORE WPF 4 @ WPF Community sitehttp://connect.microsoft.com/wpf
Resources • Snoop http://www.blois.us/Snoop/ • Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 • After download, run “Install Windows Performance Toolkit”. Installs: • Windows Performance Analyzer (XPerf) • WPF Performance Suite (VisualProfiler, Perforator) • VMMap.exe live.sysinternals.com • XamlPad is in the Windows 6.0A SDK • Use a XamlPad.exe.config to run on WPF 4.0
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….
DirectWrite formatting and rendering modes • TextOptions.TextFormattingMode= • "Ideal" • "Display" • TextOptions.TextRenderingMode= • "Auto" • "Aliased" • "Grayscale" • "ClearType"
DirectWrite • Ideal • Display
Display Ideal
Running XamlPad on WPF 4.0 • Create a file called XamlPad.exe.config with the following contents. Save it alongside XamlPad.exe. • <?xmlversion ="1.0"?> • <configuration> • <startup> • <requiredRuntimeversion="v4.0" /> • </startup> • </configuration>