Essential Silverlight 3- P1

Chia sẻ: Thanh Cong | Ngày: | Loại File: PDF | Số trang:50

lượt xem
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Essential Silverlight 3- P1: Khái quát Silverlight 3 không chỉ là lấp đầy với các chi tiết kỹ thuật, ví dụ rõ ràng, và thực hiện lời khuyên rằng sẽ làm cho bất kỳ ứng dụng Silverlight tốt hơn, nhưng Ashraf cũng bao gồm những hiểu biết rằng chỉ có thể đến từ một trong những nhà phát triển dẫn của thời gian chạy Silverlight. Từ đồ họa, văn bản, để phương tiện truyền thông cuốn sách này- có tất cả các thông tin cần thiết về thời gian chạy lõi 3 Silverlight....

Chủ đề:

Nội dung Text: Essential Silverlight 3- P1

  1. Please purchase PDF Split-Merge on www.very
  2. Praise for Essential Silverlight 3 “Essential Silverlight 3 is not only filled with technical details, clear examples, and performance tips that will make any Silverlight application better, but Ashraf also includes insights that can only come from one of the lead devel- opers of the Silverlight runtime. From graphics, to text, to media—this book contains all the information you need on the core Silverlight 3 runtime.” —Brad Abrams, product unit manager, Microsoft “The third iteration of Silverlight is a big step forward in true line-of-business capability for RIAs. Ashraf takes these new concepts and puts them forth in a meaningful and concise read.” —Jason Beres, Microsoft MVP; author; INETA Speaker “Essential Silverlight 3 is truly an essential book in the library of any Silverlight developer. The ‘Under the Hood’ portions of each chapter explain the details of Silverlight’s implementation, and the ‘Performance Tips’ explain how to use that information to get the most out of your soft- ware. I am very grateful I don’t have to track down or figure out all of this critical information on my own.” —Noah Gedrich, director of technology, BLITZ Agency “Ashraf Michail delivers an insightful and practical book for anyone seeking to better understand, master, and unlock the full potential of Silverlight 3. It is filled with code samples, performance tips, and other useful advice to help you create truly outstanding Silverlight applications.” —Oleg Kokorin, CEO, MS Team, LLC “Essential Silverlight 3 tackles in depth a rich, vast platform. The author has a depth of knowledge and technical insight that is present throughout, providing a pleasing ‘why’ on top of the usual ‘how.’” —Richard Leggett, interactive developer “This is a book of inestimable value on Silverlight. Even experienced Silverlight developers will learn from Essential Silverlight 3.” —Mark Monster, software engineer, Rubicon Please purchase PDF Split-Merge on to remove this watermark.
  3. “A great reference and textbook on Silverlight 3.” —Judith Myerson, systems architect and engineer “Chock full of performance tips and information about Silverlight internals that you won’t find anywhere else.” —Jeff Prosise, cofounder, Wintellect “Skillfully written, comprehensively explained, and logically delivered. Essential Silverlight 3 is undoubtedly a must-have study and keep- on-your-desk practical guide for building a wide range of high-value rich Internet applications.” —Ash Rofail, CEO, Santeon, Inc. “Essential Silverlight 3 is a must-read for anyone who wants a better understanding of the Silverlight Framework. In his book, Ashraf Michail, architect on the Silverlight team, offers unique insights into Silverlight’s architecture and design principles, along with guidance on how to improve the overall quality and performance of Silverlight applications.” —Gerhard Schneider, senior development lead, Microsoft “Essential Silverlight 3 does not just get your feet wet—its technical insights and performance tips take you for a deep dive into the Silverlight ocean.” —Velvárt András, Silverlight MVP; founder, Response Ltd. “This book really lives up to the title—Essential, indeed. Anyone doing Silverlight 3, or looking to get started with it, needs this book close at hand.” —Chris G. Williams, Microsoft MVP and principal consultant, Magenic Technologies “A must-read for all software developers who are trying to build rich Silverlight applications with great performance—it provides many useful performance tips. I would recommend it to anyone trying to improve performance of Silverlight 3 applications.” —Radenko Zec, senior software developer, Lanaco; INETA group leader, Banjaluka, Bosnia and Herzegovina Please purchase PDF Split-Merge on to remove this watermark.
  4. Essential Silverlight 3 Please purchase PDF Split-Merge on to remove this watermark.
  5. ® Microsoft .NET Development Series Visit /msdotnetseries for a complete list of available products. he award-winning Microsoft .NET Development Series was T established in 2002 to provide professional developers with the most comprehensive, practical coverage of the latest .NET technologies. Authors in this series include Microsoft architects, MVPs, and other experts and leaders in the field of Microsoft development technologies. Each book provides developers with the vital information and critical insight they need to write highly effective applications. Please purchase PDF Split-Merge on to remove this watermark.
  6. Essential Silverlight 3 Ashraf Michail Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City Please purchase PDF Split-Merge on to remove this watermark.
  7. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The .NET logo is either a registered trademark or trademark of Microsoft Corporation in the United States and/or other countries and is used under license from Microsoft. Microsoft, Windows, Visual Basic, Visual C#, and Visual C++ are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries/regions. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 For sales outside the United States, please contact: International Sales Visit us on the Web: Library of Congress Cataloging-in-Publication Data Michail, Ashraf. Essential Silverlight 3 / Ashraf Michail. p. cm. Includes index. ISBN 978-0-321-55416-1 (pbk. : alk. paper) 1. Silverlight (Electronic resource) 2. Multimedia systems. 3. Websites—Design. 4. Application software—Development. I. Title. QA76.575.M52187 2009 2009 006.7—dc22 2009026788 Copyright © 2010 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc. Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA 02116 Fax: (617) 671-3447 ISBN-13: 978-0-321-55416-1 ISBN-10: 0-321-55416-7 Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana. First printing, September 2009 Please purchase PDF Split-Merge on to remove this watermark.
  8. To my mother, for a lifetime of encouragement. Please purchase PDF Split-Merge on to remove this watermark.
  9. This page intentionally left blank Please purchase PDF Split-Merge on to remove this watermark.
  10. Contents Figures xvii Foreword xxiii Preface xxv Acknowledgments xxix About the Author xxxi 1 Silverlight Overview 1 Silverlight Principles 3 Web Deployment 3 Security 3 Media and Rich Internet Applications 4 Ease of Development 5 Cross Platform 5 Silverlight Features 6 Application Model 7 Graphics 7 Text 7 Input 8 Animation 8 Layout 8 Media 8 Controls 9 Data Binding 9 ix Please purchase PDF Split-Merge on to remove this watermark.
  11. x Contents Networking 9 Under the Hood 9 Where Are We? 10 2 Applications 11 Application Principles 11 Web Deployment and Out of Browser 12 Platform Libraries 12 Designer and Developer Collaboration 13 Cross Platform 13 Security 14 Creating an Application in Visual Studio 14 Application Components 15 Taking an Application Out of Browser (New in Silverlight 3) 21 XAML 22 XAP Package 30 Under the Hood 32 Architecture Overview 32 Silverlight Plug-In 33 Downloader 34 XAML Parser 35 .NET Common Language RunTime 36 Element Tree 36 Event System 37 Animation 37 Layout 38 Rendering 39 Where Are We? 39 3 Graphics 41 Graphics Principles 41 Vector Graphics and Bitmap Images 41 Retained Mode 43 Cross Platform Consistency 47 Tools 47 Balancing Image Quality and Speed 47 Please purchase PDF Split-Merge on to remove this watermark.
  12. Contents xi Graphics Elements 48 Shapes 48 Images 61 Brushes 62 Image Brushes 68 Strokes 69 Canvas 72 Under the Hood 81 Draw Loop 82 Rasterization 82 Bilinear Filtering 89 Incremental Redraw 92 Occlusion Culling 94 Multi-Core Rendering 94 How Content Gets to the Screen 95 Where Are We? 96 4 Text 97 Text Principles 98 Cross-Platform Consistency 98 Scale Independent Layout 98 Rendering for Readability 99 Text Elements 99 TextBlock 100 Glyphs 107 Under the Hood 110 Font Enumeration 110 Font Fallback 111 Font Download 111 Caches 112 Rasterization 112 Where Are We? 113 5 Input Events 115 Input Principles 115 Receiving Web Browser Events 116 Please purchase PDF Split-Merge on to remove this watermark.
  13. xii Contents Custom Controls 117 Cross-Platform Consistency 117 Multiple Languages 118 Input Events 118 Mouse Input Events 120 Keyboard Events and Focus 126 Under the Hood 128 Mouse Events 128 Keyboard Events 129 Asynchronously Firing Events 129 Where Are We? 130 6 Animation 131 Animation Principles 132 Time-Based Animation versus Frame-Based Animation 132 Changing Properties over Time 134 Custom Animations 135 Performance 136 Animation Elements 136 Starting an Animation 138 Interpolation and Key Frame Animations 140 Timelines 144 Easing Functions (New in Silverlight 3) 144 Custom Animation Functions (New in Silverlight 3) 147 Under the Hood 147 The Animation Tick 148 Property Change Speed 149 Screen Display 151 Where Are We? 152 7 Layout 153 Layout Principles 153 Automatic Sizing and Positioning 154 Automatic Application Resize 156 Scale Independent Layout 157 Layout Elements 158 Please purchase PDF Split-Merge on to remove this watermark.
  14. Contents xiii Canvas 158 Border 159 StackPanel 161 Grid 162 Layout Rounding 167 Building a Custom Layout 169 Layout Events 173 Under the Hood 174 The Layout Algorithm 174 Where Are We? 176 8 Media 177 Media Principles 178 Integrate Media 178 Deliver Content 178 Deliver Full Screen Experiences 179 Generate Players with Expression Media Encoder 180 Media Elements 180 Play a Video 180 Making Player Controls 183 Video Effects and Transitions 187 Full Screen 188 Connecting Video Markers to Application Display 189 Under the Hood 190 The Source 190 The Player 191 Where Are We? 193 9 Controls 195 Control Principles 196 Built-In Controls 196 Custom Controls 198 Customization 198 Control Elements 198 ContentControl and ItemsControl 199 VisualStateManager 203 Please purchase PDF Split-Merge on to remove this watermark.
  15. xiv Contents Styling 206 Create Custom Controls 207 Under the Hood 209 Control Instantiation 209 The Visual State Manager Algorithm 210 Where Are We? 211 10 Data Binding 213 Data Binding Principles 213 Data Sources 214 Automatic Connection and Synchronization 214 Declarative XAML Model 214 Data Binding Objects 215 Connecting to Data with a Binding 215 DataContext Inheritance 218 Data Synchronization and Binding Modes 219 Data Binding Collections with ItemsControl 221 Value Converters 225 Data Validation 227 Element to Element Binding (New in Silverlight 3) 228 Under the Hood 229 Binding Object 229 ItemsControl 230 Where Are We? 231 11 Effects 233 Effect Principles 233 Real-Time Speed 233 Common Built-In Effects 234 Effect Elements 234 Applying an Effect 234 Creating an Effect 236 Under the Hood 248 Surface Generation 248 BlurEffect and DropShadowEffect 249 Where Are We? 250 Please purchase PDF Split-Merge on to remove this watermark.
  16. Contents xv 12 GPU Acceleration 251 GPU Acceleration Principles 251 Achieve Better Performance for Common Scenarios 252 Maintain Good Image Quality 252 Maintain Reasonable Stability 252 GPU Acceleration Features 253 GPU Acceleration Prerequisites 253 Enable GPU Acceleration 253 Using the CacheMode Property 254 Diagnose Performance Problems 259 Under the Hood 263 Graphics Device Creation 263 Texture Creation 264 Rendering Stages with GPU Acceleration Enabled 265 Multiple Monitors 265 Where Are We? 265 Index 267 Please purchase PDF Split-Merge on to remove this watermark.
  17. This page intentionally left blank Please purchase PDF Split-Merge on to remove this watermark.
  18. Figures FIGURE 1.1: Example Silverlight sites shown at 2 FIGURE 1.2: Installing a Silverlight application so that it can run outside the Web browser 2 FIGURE 1.3: Visiting a Silverlight Web page without installing the Silverlight runtime 4 FIGURE 2.1: Visual Studio Silverlight application project 14 FIGURE 2.2: Hello World application 16 FIGURE 2.3: Application install menu 22 FIGURE 2.4: Application install prompt 22 FIGURE 2.5: Application running outside the Web browser 23 FIGURE 2.6: Example path 25 FIGURE 2.7: Architectural Overview 33 FIGURE 2.8: Layout Example 38 FIGURE 3.1: Scaling up an image of a circle 42 FIGURE 3.2: Scaling down an image of a circle 42 FIGURE 3.3: Scaling a vector graphic circle 42 FIGURE 3.4: Removing a rectangle with a retained mode API 44 FIGURE 3.5: Removing a rectangle with an immediate mode API 44 FIGURE 3.6: Rectangle element with an outline 49 FIGURE 3.7: Rectangle element with rounded corners 50 FIGURE 3.8: Ellipse element 51 xvii Please purchase PDF Split-Merge on to remove this watermark.
  19. xviii Figure s FIGURE 3.9: Line element 52 FIGURE 3.10: Pixels rendered for a Line element 53 FIGURE 3.11: Sharp horizontal line drawn with a Rectangle element 54 FIGURE 3.12: Example path 55 FIGURE 3.13: Path with an empty space in the center 58 FIGURE 3.14: Different fills for the same outline 59 FIGURE 3.15: Winding mode numbers resulting in a filled center space 60 FIGURE 3.16: Different fill as a result of a different point order 61 FIGURE 3.17: Image element example 62 FIGURE 3.18: Linear gradient brush 65 FIGURE 3.19: Radial gradient brush 66 FIGURE 3.20: Focal gradient brush 67 FIGURE 3.21: SpreadMethod example 68 FIGURE 3.22: ImageBrush example 68 FIGURE 3.23: Sample stroke applied to an ellipse 69 FIGURE 3.24: The widening process applied to an ellipse 70 FIGURE 3.25: The widening process applied to a triangle 71 FIGURE 3.26: StrokeDashArray example of long and short dashes 71 FIGURE 3.27: RenderTransform example of overlapping a rectangle over an ellipse 73 FIGURE 3.28: 3D projection example 75 FIGURE 3.29: Position three rectangles in the same 3D projection camera 76 FIGURE 3.30: Clipping example 78 FIGURE 3.31: Canvas Opacity versus per path Opacity 79 FIGURE 3.32: OpacityMask example 80 FIGURE 3.33: Sampling a circle 84 FIGURE 3.34: Sampling a circle with integer sample point coordinates 85 FIGURE 3.35: Anti-aliasing sampling pattern 85 FIGURE 3.36: Anti-aliased rasterization 86 FIGURE 3.37: Anti-aliasing seam example 87 FIGURE 3.38: Pixel snapped rasterization 88 FIGURE 3.39: Seams with a rotated edge 89 FIGURE 3.40: Image with bilinear filtering 90 FIGURE 3.41: Image with nearest neighbor 90 Please purchase PDF Split-Merge on to remove this watermark.
  20. Figure s xix FIGURE 3.42: The bilinear filtering process 91 FIGURE 3.43: Image scaling within good limits 91 FIGURE 3.44: Image scaling extremes 92 FIGURE 3.45: Incremental redraw regions 93 FIGURE 3.46: Dividing a scene for multi-core rendering 95 FIGURE 4.1: TextBlock example 100 FIGURE 4.2: TextBlock wrapping example 100 FIGURE 4.3: TextBlock border with ActualWidth and ActualHeight 101 FIGURE 4.4: TextBlock alignment example 103 FIGURE 4.5: TextBlock formatting example 104 FIGURE 4.6: Inherited formatting 104 FIGURE 4.7: Text radial gradient example 105 FIGURE 4.8: Math formula using Glyphs element 109 FIGURE 4.9: Text baseline 110 FIGURE 5.1: Hit-test area for a Canvas with a rectangle and circle 125 FIGURE 6.1: Frame-based animation 132 FIGURE 6.2: Time-based animation 133 FIGURE 6.3: Animation timing artifacts 135 FIGURE 6.4: Smooth spline versus linear segment interpolation 141 FIGURE 6.5: Bounce animation 145 FIGURE 6.6: Easing out functions 146 FIGURE 7.1: Surrounding text with a rounded rectangle 154 FIGURE 7.2: Positioning elements in a vertical stack 155 FIGURE 7.3: Automatic resize behavior 157 FIGURE 7.4: Positioning content explicitly with the Canvas element 158 FIGURE 7.5: Surrounding a TextBlock element with a border 160 FIGURE 7.6: Adding a rounded rectangle background to a TextBlock element 160 FIGURE 7.7: Padding a border element 160 FIGURE 7.8: Vertical StackPanel example 161 FIGURE 7.9: Horizontal StackPanel example 161 Please purchase PDF Split-Merge on to remove this watermark.



Đồng bộ tài khoản