Professional Documents
Culture Documents
Fenton Webb
Senior Developer Evangelist
Fenton has been a member of the Autodesk DevTech team since 2000. Originally a member of our EMEA team, he has recently relocated to California to work for DevTech Americas. Fenton is an expert in all the AutoCAD APIs, AutoCAD OEM, RealDWG and Revit. He particularly enjoys travelling to evangelise the APIs he support at our annual Developer Days conferences. Before joining Autodesk, Fenton worked for an ADN partner developing ObjectARX applications in the Civil and Structural Engineering domain.
Members-only website with 1000s of technical articles Unlimited technical support Product direction through conferences Marketing benefits
www.autodesk.com/joinadn
DevLab
San Francisco, USA Feb 1-5, 2010 Farnborough, UK Feb 8-12, 2010 Munich, Germany June 7-11, 2010 Other countries TBD
Course Objective
Im going to
Give an Overview talk about Windows Presentation Foundation Show you how you can use it in your own applications inside AutoCAD Let you see how easy and powerful it is and what it can do for you
Im not going to
Agenda
Part 1
What is WPF? Why Use WPF? WPF in AutoCAD WPF Demos Databinding Migration and Interoperability Questions
What is WPF?
Technical Information
Windows Presentation Foundation Next Generation Graphical developer Platform from Microsoft
Uses XAML
Why WPF?
Windows Presentation Foundation API Comparison
Windows Forms GUI, (forms, controls,etc) On-screen documents Fixed-format documents Images Audio/Video 2D graphics 3D graphics PDF Windows Forms/ GDI+ Windows Media Player Direct 3D WPF
X X X
X X X X X X X
X X X X
What is WPF?
Lets see it for real...
What is WPF?
Features Recap
Controls Similar to existing controls All Support rich content, regardless of control type
StackPanel stack either horizontally or vertically WrapPanels stack like standard html DockPanel for sophisticated layouts GridPanel for sophisticated layouts Based on vector graphics
Native resizable
What is WPF?
Features Recap
Sub pixel Clear type Provides Scale clarity Embed them into your own application Open type font support
What is WPF?
Features Recap
enable a precise presentation, independent of the display or printer hardware. dynamically adjust their content based on variables such as window size.
Flow Documents
Effects Shadows, Blur, Reflection, Glow, and more Can be applied Text, Images, Vector graphics
How about combining a Listbox filled with a list of Videos!? Or tooltip with a bitmap in it?! Or a button with different format text on it?
Always been difficult to get Product Designers to communicate their ideas properly to Engineering!
Offers interoperability between Window Forms, and even Win32 and MFC Allows for easy migration path to use WPF Current .NET Release 3.5 AutoCAD 2009 installs .NET 3.0 Based on .NET 2.0
Allows you to mix, match and Blend UIs, Controls, Data binding Thus allowing easy integration of media elements such as 2D, 3D, Audio, Video, Animation etc
Always been difficult to get Product Designers to communicate their ideas properly to Engineering!
XAML Declarative mark-up language Separates application design from the implementation
External Resource Files Designers and developers can now share the same technology base
Autodesk.Windows namespace
RibbonTab RibbonPanel
Autodesk.Customization namespace
ToolTip ToolTipContent
WPF Demonstrations
Show how...
Demo
AutoCAD.NET WPF Application
Demonstrating
Visual Studio 2005 sp1/2008 Creating an WPF Dialog with a button Modifying the button to use WPF features
WPF Demonstrations
Creating AutoCAD.NET WPF Gotchas
Error CS0103: The name InitializeComponent does not exist in the current context
Happens when adding WPF functionality to old Projects
Edit your project file so that the single line It seems Visual Studio 2008 doesnt have the problem
<Import Project=$(MSBuildBinPath)\Microsoft.CSharp.targets /> becomes... <Import Project=$(MSBuildBinPath)\Microsoft.CSharp.targets /> <Import Project=$(MSBuildBinPath)\Microsoft.WinFX.targets />
WPF Demonstrations
Show how...
Demo
Expression Blend AutoCAD.NET WPF Application
Demonstrating
Using Expression Blend 2 Visual Studio 20008 Creating an WPF Dialog with a button
WPF Demonstrations
Sample Demos...
Demo
AutoCAD Migrated WPF Samples
Demonstrating
Existing WPF Samples Ported to AutoCAD
WPF Demonstrations
Sample Demos...
Demo
More WPF Samples
Demonstrating
Existing WPF Samples
More Demos
WPF Databinding
One of the best features of WPF
Generally used for binding a UI Element to backend data (2 way) Works for an entire collection too!
Source
Target
WPF Databinding
Harnessing
DependencyProperty
More work to implement Total control Good for hooking in other tasks AutoCADs Ribbon uses INotifyPropertyChanged exclusively
WPF Databinding
Using a DependencyProperty
// pseudo code class myClass { // create member variable DependencyProperty mVisible; myClass() { // set the type of the DependencyProperty mVisible = DependencyProperty.Register("Visible", typeof(Boolean), typeof(myClass)); } }
WPF Databinding
Using the Databinding Interfaces
INotifyPropertyChanged
Source
INotifyCollectionChanged
Target
WPF Demonstrations
Show how...
Demo
Ribbon Bound to PaletteSet
Demonstrating
Creating a PaletteSet using WPF Custom Ribbon Control Binding the Text size to Slider
WPF Databinding
CLR Properties have issues
INotifyPropertyChanged / INotifyCollectionChanged
You can also implement it like I did, but its non standard
WPF Demonstrations
Show how...
Demo
Modal Modeless
Demonstrating
Data Binding Synchronization UI with Database
AutoCAD requires that we Open/Close objects before modifying Normal WPF Binding easy after that This will not work for a modeless dialog/palette
Transaction
Enables the user to discover the command line interface Enables the action recorder to record the commands
Modeless Solution
Data layer
Encapsulates
UI to drawing data transfer Drawing to UI data transfer
CollectionChanged
PropertyChanged
Idle event
Layer1
Layer2
Layer3
Layer4
ObjectClosed event
Layer1
Layer2
Layer3
Layer4
WPF Controls in Win32/MFC Mixed Mode DLL required (use /clr compiler setting) Use the HwndSource
Win32/MFC Controls in WPF UI Mixed Mode DLL required (use /clr compiler setting) Use the HwndHost
Wraps the HWND in a WPF element, which can be added to a WPF element tree.
Microsoft SilverLight
Cut down version of WPF mainly for use inside of browsers Take your XAML and paste it directly into a SilverLight Web application First steps towards cross platform WPF Who knows where this is going.
WPF
Further reading...
Getting Started - WPF - Get Started Accessibility - Accessibility Best Practices Localization - WPF Globalization and Localization Overview Performance - Optimizing WPF Application Performance Security - Windows Presentation Foundation Security Interoperation - WPF and Win32 Interoperation Overview
WPF
More Further reading...
Developer Center
www.autodesk.com/developautocad
Discussion Groups
http://discussion.autodesk.com