19 – 21 MARCH 2006 Riyadh, Saudi Arabia
Smart Client Development, How to make applications go smarter with VS2005 Goksin Bakir Yage Ltd, Microsoft Regional Director, MEA
Agenda Smart Clients Tools ToolStrips Custom renderers, colors, items DataGridView Custom painting, formatting, column types BackgroundWorker Cancellation, progress updates, responsive UI TableLayoutPanel Dynamic layout, content Scenarios
Smart Client Tough to deploy Heavyfootprint “DLLHell” Networkdependency Reduced Reduced User UserExperience Complex to develop Web services and offline/online support Deviceadaptability Broad reach Easy change management Easy to deploy Rich User Experience High developer productivity ResponsiveUI
Smart Client Features Local resources Direct display and peripheral access Responsive graphics, printers, digital camera’s, etc. Use of installed applications Word, Excel, VSTO Connected Access to network resources Web services, SQL Databases
Smart Client Features Offline capable Cache online data Update when connected Datasets in smart documents Intelligent deployment and update Easy non-administrator deployment Automatic updates Smart document deployment Rich / easy developer experience
Smart Client Technologies Visual Studio 2005 Rich visual designer support Integrated ClickOnce testing and deployment Visual Studio Tools for Office.NET Framework 2.0 Windows Forms 2.0 ClickOnce deployment
Visual Studio 2005 Project templates Get up and going quickly Common application types Designers Simplifies development of UI and layout Rich User Control development Rich support for Custom Controls
What is “smart” Local resources and user experience Offline capable Intelligent deployment and update Multithreaded Crash Proof
Visual Studio 2005 Data New data-bound controls Schema-based typed-data set designer Support for iterative maintenance of generated data-code Partial types for maintainable customizations of auto- generated code Reduced need for “mapping” or “glue” code Server explorer Integrated data manipulation
ClickOnce Deployment ClickOnce application deployment published on a web or file server Client follows link to server Application deployed locally in user’s profile directory & executed Subsequent executions check for updates & execute local install Server Client application files
ClickOnce Smart Client deployment technology Provides web-deployment simplicity End User Provide web-deployment flexibility Publisher Other parallels to web-applications Applications are isolated per-user Can be executed with limited local permissions Locally executed, rich features
ClickOnce Features Follow a link to install an application Automatic w/minimal or no decision points web-style deployment Automatic update of application Security isolation and optional restricted permissions Non-administrative installs
ClickOnce & VS 2005 Project Settings Publish tab Set deployment location Configure data files for deployment Other settings: version, online-only or online-offline, CD installations and other details Project Settings Security tab Calculating permissions required by your application to function Also add permissions using SecurityException at runtime Setting permissions in the manifest required to run Partial trust and full trust supported
Application Updates Auto-update deployment options Before application launch, or Update check occurs after app-launch Scheduled update checks Weekly, monthly, etc. Project Settings Publish tab Settings for update checking
ToolStrips Replaces MainMenu, ContextMenu, ToolBar and StatusBar HWNDless architecture Same OM across all containers System and professional renderers ToolStripControlHost
Datagridview Replaces DataGrid Extensible and Flexible Bound, Unbound, Virtual, Mixed Eleventy billion PMEs Text, Image, Button, Link cells/columns Cell-based, not Column-based Cell styles (Font, Color, Formatting) Cell-level events Mouse, Formatting, Validate, Error, others... Custom Column Types High performance Display, scrolling, updates
Backgroundworker BackgroundWorker Simplify creating responsive applications Easier to perform long running tasks without “freezing” the UI Simplify Thread use in Windows Forms applications
Automatically acquired ThreadPool Thread no UI updates allowed… UI Thread DoWork(){ If (!CancellationPending){ If (!CancellationPending){ FindInFiles() FindInFiles() }} StartFindInFiles() ProgressChanged(){ Update UI Update UI} RunWorkerCompleted() EndFindInFiles() RunWorkerAsync() ReportProgress() Diagram: BackgroundWorker
Tablelayoutpanel Layout Controls TableLayoutPanel Similar to HTML Table control Address localization scenarios Facilitate creation of resizable UI Support data-driven UI (e.g., labels from a DB)
Diagram: Login Dialog Equal %, preserve minimum size, lower right alignment Only occupy necessary space Right aligned, Grow/Shrink to accommodate label length AutoScaleRightToLeft Font Changes DPI Changes
DEMO
What Is: Occasionally Connected Empowering users to leverage their computer, applications, data and files regardless of network availability Application proactively retrieves necessary data necessary to work offline As the network comes available, the application will automatically sync their work and log conflicts for the user to resolve Network operations occur in the background so the user can stay focused on their task Example: Outlook 2003
Resources Needed Offline Data A subset of the data from the server(s) Heterogeneous Sync (SQL Server, Oracle, DB2, …) Files Not all data exists within the database Media files, Office Files, … Application Messaging (Web Services, WCF, …) Ability to queue outbound messages Ability to async process inbound messages Read Only Informational/Reference Data Services Ability to pre-fetch data from existing services
Occasionally Connected Smart Client Background Tasks Network Resources Data Sync Services Data Access API Data Store Message Queuing Message Caching Files File Sync Services Microsoft Windows / Windows Mobile Visual Studio Smart Client Application / UI Application Updates Canned UI Controls
Sales Smart Client Background Tasks Works Corp Architecture Network Services SyncServices Data Store WeatherCaching Order Submission Queue Promo Videos App Logic DesktopTabletPCPocketPC Smart Phone DataServer Sync Service s Order WeatherServices Product Catalog My Customers Order Scratchpad My Inventory App Updates
Which Local Data Store? Microsoft Database Technologies SQL Server 2005 SQL Server Express Edition SQL Server Mobile Edition Jet (Access) Microsoft Visual FoxPro (.dbf) Excel XML WinFS Something new
SQL Server Express Great improvements over MSDE Simple install from web or local MSI ClickOnce will BootStrap SSE if not installed Connect w/File Path Connection String User Instance feature for File Path Connecitons Great for VS Development
Deploying SSE For Occasionally Connected Scenarios Base Install of SSE ClickOnce Bootstrapper Requires Admin Rights Replication w/SSE Replication not supported w/User Instances Enable SQL Server Authentication Add DBO Privileged Account Script creation of database Verify / Create / Attach database at startup Deploy SQL Server Replication.Dlls
Occasionally Connected Devices Servers Desktops Laptops Tablet PC’s Windows CE Pocket PC Smart Phone ? Win 32 Sweetspot
Local Database Options Server Workgroup Desktop Laptop Tablet PC Windows CE Device Pocket PC Smart Phone Win 32 SQL Server Express SQL Server Multi User Single User Scenarios SQL Mobile
Deploying SQL Server Mobile SQL Server Mobile Engine Add runtime dlls to project (sqlce*.dll) C:\Program Files\Microsoft Visual Studio 8\Common7\IDE File size <1.4mb Set files to Copy to Output Directory = Copy if newer ADO for SQL Server Mobile Add reference to Microsoft SQL Mobile Located in: C:\Program Files\Microsoft Visual Studio 8\ _ Common7\IDE\PublicAssemblies\System.Data.SqlServerCE.dll File Size ~224k
How - To Sync Roll your own Ultimate in flexibility Highest cost to develop and maintain Merge Replication Most power, broadest features for different data partitions, spans all devices Need DBO/DBA privileges, must “own” server Remote Data Access (RDA) Easy entry point for well partitioned data, no config to database Limited to SQL Server Mobile TechnologyRoll your own Merge Replication Remote Data Access XML - DataSets SQL Server Express SQL Server Mobile
Local App RDA Sync Architecture Server Data SQL Server Mobile Database Engine DAL UI InOut IIS w / Sync ISAPI dll RDA Sync Engine
BackgroundTasks / Steps Runs on a background thread of the application Executes collection of steps Start / Stop similar to Windows Services Executes in a loop based on a Timer Can be triggered by Network Resources Marshals progress / completed info to UI thread
Community Resources INETA MEA ! mea.ineta.org
Smart Client Summary Rich features easier than ever to implement Windows Forms 2.0 new controls Windows Forms 2.0 improved data integration Installation and update easier than ever ClickOnce web-style simplicity ClickOnce web-style security SmartClient rich feature-set Customers access existing and new application features easily Customers access your application with or without network connectivity