SilverlightShow: Silverlight Community http://www.silverlightshow.net/ Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples SilverlightShow.net http://www.rssboard.org/rss-specification Argotic Syndication Framework 2008.0.2.0, http://www.codeplex.com/Argotic en-US estoychev@completit.com (Emil Stoychev) Pencho Popadiyn on N-puzzle WP7 application <div style="padding-bottom: 5px; background-color: #f3f3f3; margin-top: 5px; padding-left: 10px; width: 200px; float: right; margin-left: 10px; padding-top: 5px;border: #dddddd 1px solid;"> <h3>Don't miss...</h3> <ul style="list-style-type: circle; margin: 0px; padding-left: 20px; font-size: 12px;"> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/Windows-Phone-7-Creating-Custom-Keyboard.aspx">Pencho's 'WP7–Creating Custom Keyboard' article</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/C-for-Android-and-iOS-Developers.aspx">WP7 for iPhone and Android Devs series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/Gergely-Orosz-on-Cocktail-Flow-WP7-application.aspx">Cocktail Flow WP7 Application</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/book/Beginning-Windows-Phone-7-Development.aspx">WP7 Development book: </a></li> </ul> <p style="padding-bottom: 5px;">         <a href="http://www.silverlightshow.net/book/Beginning-Windows-Phone-7-Development.aspx"><img alt="Beginning Windows Phone 7 Development" src="http://www.silverlightshow.net/Storage/WP7book.jpg" /></a> </p> <p style="font-size: 12px;">              <a href="http://www.silverlightshow.net/Books.aspx">Show more books...</a></p> </div> <p><em>Next in our WP7 showcase apps comes N-puzzle – a new, free gaming app developed by </em><a href="http://www.completit.com/"><em>CompletIT</em></a><em> and Pencho Popadiyn. Pencho is also a recognized article author at SilverlightShow (</em><a href="http://www.silverlightshow.net/Search.aspx?q=Pencho+Popadiyn&ro=1&tg=true&adv=false&t=1"><em>check his contributions</em></a><em>). </em></p> <p><strong>Q1. Pencho - please introduce yourself briefly (experience, interests, key projects, etc) and tell us more about the application you created - what are the key functionalities, major differences from other similar applications on the market, why do you think people would want to install this app on their phone?</strong></p> <p>A. Hello! I’m Pencho Popadiyn, I live in Sofia, Bulgaria and work as a .NET Developer for CompletIT. I am developing Silverlight/WPF since the very beginning. I enjoy programming WP7 in my free time. In fact this is not my first WP7 game. Last month I released my first app, it was a mahjong based game (search for <em>Shisen-Sho</em> in the marketplace). And I received a lot of positive feedback from the users, and that encouraged me to move on. About the puzzle. Well, it is based on the classic and extremely popular N puzzle game, where you have a frame of numbered square tiles in random order with one tile missing. The object of the puzzle is to place the tiles in order by making sliding moves that use the empty space. The game offers a number of built-in images; also the user can choose a custom image from the phone gallery or even to use the today’s Bing image as a source. If you don’t like images, you can play the classic modes with numbers or letters. You can save a game in progress and complete it later; there are four different board sizes and many other features. Here are the links to the game: </p> <ul> <li><a href="http://www.windowsphoneapplist.com/n-puzzle_game-a16302.html">http://www.windowsphoneapplist.com/n-puzzle_game-a16302.html</a> </li> <li><a href="http://social.zune.net/redirect?type=phoneApp&id=9b99ba3f-2377-e011-9210-002264c2fb72">http://social.zune.net/redirect?type=phoneApp&id=9b99ba3f-2377-e011-9210-002264c2fb72</a> </li> </ul> <p>                       <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Screenshot1_2.png"><img width="144" height="240" title="Screenshot1" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px solid;" alt="Screenshot1" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Screenshot1_thumb.png" /></a>                      <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Screenshot2_2.png"><img width="144" height="240" title="Screenshot2" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px solid;" alt="Screenshot2" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Screenshot2_thumb.png" /></a>                      <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Screenshot3_2.png"><img width="144" height="240" title="Screenshot3" style="padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px solid;" alt="Screenshot3" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Screenshot3_thumb.png" /></a></p> <p><strong>Q2. Why a puzzle? How did you get the idea to create this app?</strong></p> <p>A.Well I developed the same application for Silverlight a long time ago. And now I decided to port it for WP7. By the way, the original Silverlight application is available on SilverlightShow. Check out <a href="http://www.silverlightshow.net/items/Silverlight-n-Puzzle-Game.aspx">here</a>.</p> <p><strong>Q3. Which features were most challenging to develop in this game, and why?</strong></p> <p>A. Maybe the logic for downloading and using the <em>today’s Bing image</em> feature was most interesting. But generally as I said I had a Silverlight version of the puzzle, so it was relatively easy to port the project to WP7. <br /> However, since this is my second game, I am trying to take a more general look at the things. I am trying to extract common functionality and build something like an own framework (for internal usages of course). As I come to my code from time to time I am seeing a lot of repeating code and patterns. Besides the standards utilities and helper classes, I and my colleagues are spending some time in discussing and analyzing how to design some more complex stuff. So we could use it in our future projects.</p> <p><strong>Q4. Could you reveal some tip, some solution you used to work around a specific problem faced during the development of your application?</strong></p> <p>A. Hmm, that’s interesting question. The game is not complex, so I didn’t have any big challenges. However, during the development I hit several problems. Here are some of them. Let’s take a look at the PhotoChooserTask. It took me four hours to understand that navigating to another page directly from the Completed event is wrong. It leads to unbelievable behavior of the application, e.g. events are not firing, other are fired twice and something similar. <br /> I found other issues (bugs)<strong> </strong>with the tombstoning. For example, the Remove method of the application state dictionary is not working correctly, e.g. after the application activation event is raised, the entry is still there. <br /> One of the biggest challenges was related with the ApplicationBar. The ApplicationBarButton and MenuItem does not allow you data binding and attaching commands to the click events. Since I am a MVVM guy, having code for calling view model’s methods in the code-behind of the view is real pain in the a**. <br /> What I could advice the developers who are planning to start developing WP7 applications is to make their first steps with caution. There are a lot of unexpected obstacles. Also having WP7 device for testing is almost mandatory. I could tell you for sure, that testing on the emulator is not the same as testing on a real device (mainly in terms of performance and graphics).</p> <p>                       <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Screenshot4_2.png"><img width="144" height="240" title="Screenshot4" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px solid;" alt="Screenshot4" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Screenshot4_thumb.png" /></a>                      <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/Screenshot5_2.png"><img width="144" height="240" title="Screenshot5" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px solid;" alt="Screenshot5" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/Screenshot5_thumb.png" /></a>                      <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/Screenshot6_2.png"><img width="144" height="240" title="Screenshot6" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px solid;" alt="Screenshot6" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/Screenshot6_thumb.png" /></a></p> <p><strong>Q5. Which technology did you used for your games, Silverlight or XNA?</strong></p> <p>A.Well, as a developer having experience with Silverlight and WPF, I used Silverlight for developing my first games. But right now I am getting started with XNA and it is not far the moment when I’ll release something written on XNA.</p> <p><strong>Q6. Do you plan to upgrade the game with any new functionality later on?</strong></p> <p>A. Yes I’ll definitely do it; furthermore I am planning to do it in the next 2 weeks’ time frame. I have a lot of ideas in my mind. For example, I am planning to add a <em>video puzzle</em>. So, instead of image, the user will be able to select a video for puzzle source. I think it will be really interesting. Also I’ll add <em>history </em>functionality. But first, next week I’ll release a small update for the <em>Shisen-Sho</em> game.</p> <p>                                     <strong> <iframe width="425" height="349" src="http://www.youtube.com/embed/trL1FZB04a0" frameborder="0"></iframe></strong></p> <p><strong>Q7. How do you see the future of WP7, and applications for WP7?</strong></p> <p>A. “The future is so bright”, as in the song of C-Block. Ok, now seriously, I think WP7 will transform in a great platform not only for games but for business applications too. We have to be just more patient. Remember what was the situation with Silverlight at the very beginning – lack of features and functionality, bugs, etc. Today Silverlight is a complete platform. The same is the situation with Windows Phone 7. It is just at the beginning of its way. Just wait till the end of the year, when the next major players - Nokia and Mango will enter the gameJ. </p> <p><strong>Q8. What other ideas for next WP7 applications do you have?</strong> <br /> A. I haven’t decided yet what will be my next application, whether it will be a game or some application. I have several ideas and I am still discussing them with my colleagues. I am planning to release several apps and games in the next few months. Although they will be relatively simple, I am trying to make each next game much more complex than the previous one, adding more features and logic. I am still not planning to enter deep inside into the muddy water of the game development (for example, to create some complex shooter or action game). I want to build more confidence and experience (to pave the way, so to say)J. I want learn all specifics of the WP7 programming model in great, great details and try different programming approaches first, and then I’ll think for something more complex.</p> <p><strong>Thank you, Pencho! Wish lots of people would enjoy your game!</strong></p> http://www.silverlightshow.net/items/Pencho-Popadiyn-on-N-puzzle-WP7-application.aspx editorial@silverlightshow.net (Silverlight Show ) http://www.silverlightshow.net/items/Pencho-Popadiyn-on-N-puzzle-WP7-application.aspx#comments http://www.silverlightshow.net/items/Pencho-Popadiyn-on-N-puzzle-WP7-application.aspx Mon, 09 May 2011 04:04:00 GMT 360 Degrees Feedback by Kevin Dockx <p><em>In this white paper the </em><a href="http://www.silverlightshow.net/Search.aspx?q=kevin+dockx&adv=true&tg=true&ro=1&t=1&r=10&o=1" target="_self">article author Kevin Dockx</a><em> revealed the challenges behind building a Silverlight-powered 360-degree employee review solution with his company RealDolmen. You may address any questions on this white paper inside the Comments section below.<br /> </em></p> <p><span style="font-size: 18px;"><strong>Company Profile</strong> </span></p> <p><strong>Company name</strong>: RealDolmen <br /> <b>Website: </b><a href="http://www.realdolmen.com/">http://www.realdolmen.com/</a> <br /> <b>Industry: </b>ICT<b></b> <br /> <b>Brief company overview: <br /> <br /> </b>RealDolmen is one of Belgium’s largest ICT companies. We are a single-source supplier with wide expertise in various sectors (professional services, infrastructure, support, …) and technologies (the full Microsoft stack, Java, CAD/GIS, …). We have over 10.000 man-years of experience of service, a wide portfolio of ICT skills and a strong network of partners.<b> <br /> <br /> </b></p> <p><b></b></p> <p><span style="font-size: 18px;"><b>Project Overview</b> </span></p> <p><b>1. Describe what the project is about - goals, target users, key functionalities</b> </p> <p>The project, named <a href="https://www.360review.be/" target="_blank">360 review</a>, is all about automating 360 degrees review of persons, resulting in a report. A 360 review should be seen as “one person gets reviewed through a certain survey by a number of colleagues (and by himself)”, and this person is reviewed on a variety of subjects. The project has been designed to be offered in a Software as a Service model, with ease of use and reuse of inputted data in a multitude of languages in mind. The general business model is that a company that wants to engage in a 360 review of its employees comes to us, and we set up a client environment for this company. In that client environment, the company can input its employees, create questionnaires, start surveys and create reports from filled-out surveys. Once a survey starts, mails are sent out to the people that have to fill out the survey, and through the login details in that mail, they can open the application module which allows them to fill out the survey. </p> <p>So, the project consists of 3 parts: the Management part, which allows the administrator (that’s us) to create new client environments. The Client part, in which a client can manage questions, persons, questionnaires, surveys, … And the Employee part, in which an employee can fill out a survey created in the Client part. </p> <p>High on the list of priorities were an intuitive, easy-to-learn & fault-tolerant user interface, and low bandwidth use. </p> <p><strong>2. Did you have any limitations set - technologies to be used, time, resources, etc?</strong> </p> <p>The technology choice was actually quite easy to make: as we needed a performant, intuitive user interface, combined with low bandwidth use, using Silverlight was a no-brainer. As with all projects we undertake, a budget is set in advance, so of course time & resources are limited. </p> <p><strong>3. How was the project team composed?</strong> </p> <p>With all projects, we have functional analyst, technical analyst, general project manager, test team and developer roles. The key difference with this project was that we added a designer/devigner to the project team. To get a good user interface, that role is absolutely essential. Creating a good design takes up quite a lot of time: we had one devigner for 2 developers, and he was on the project during the complete duration of the project – but it was definitely worth it. </p> <p><strong>4. What Silverlight features were used in this project?</strong></p> <p>Almost every feature you’d expect in a line of business application: of course we used the data binding features heavily, but we also used parts of the Silverlight Toolkit (eg: TreeView, Charting), parts of the navigation framework, a bunch of custom controls, custom styling/theming and animations, validation, localization, … Data access is done with WCF RIA Services, backed by the Entity Framework on a SQL 2008 R2 DB, using both generated entities and custom DTO’s where necessary. </p> <p>We also used a custom, internal reference architecture which filled in the missing parts (eg: we have a custom navigation framework built on top of the one that’s already available, allowing us to specify exactly which role has access to what part of the application, we have rules and components for caching, logging and exception handling, we have all the necessary classes for MVVM, services for dialog windows, services to trigger animations, …) </p> <p><strong>5. Project snapshots </strong></p> <p><strong>                            </strong>  <a href="http://www.silverlightshow.net/Storage/Snap1.jpg" target="_blank"><img width="244" height="149" title="Snap1" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border-width: 0px;" alt="Snap1" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/Snap1_thumb.jpg" /></a>                   <a href="http://www.silverlightshow.net/Storage/Snap2.jpg" target="_blank"><img width="244" height="145" title="Snap2" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border-width: 0px;" alt="Snap2" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Snap2_thumb.jpg" /></a></p> <p>                              <a href="http://www.silverlightshow.net/Storage/Snap3.jpg" target="_blank"><img width="244" height="140" title="Snap3" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border-width: 0px;" alt="Snap3" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Snap3_thumb.jpg" /></a>                   <a href="http://www.silverlightshow.net/Storage/Snap4.jpg" target="_blank"><img width="244" height="143" title="Snap4" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border-width: 0px;" alt="Snap4" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/_Snap4_thumb.jpg" /></a> </p> <p style="text-align: center;"><strong>(Click on the pictures for a larger view)</strong> </p> <h6></h6> <p><strong><span style="font-size: 18px;">Problem and Solution Insight</span></strong></p> <p><strong>1. What were the pros and cons for using Silverlight to achieve those goals?</strong></p> <p>A big pro is definitely the almost unlimited UI customization options Silverlight offers. The fact that Silverlight runs on the client was also a big pro – for example, we generate reports client-side: all we need is the data to generate it with. In our case (where the needed data for the report, which includes quite a few graphs, is much smaller than the resulting report itself), this means the bandwidth usage is lower (as the reports don’t have to be sent to the client, only the data needed for the report). Performance-wise, an average report 25-page report including graphs is generated in about 2 seconds on an average client machine – and we don’t depend as much on the amount of concurrent users generating reports on the server. In general, keeping performance in mind for this specific application, Silverlight is the right choice: once the data is available, all operations are done on the client. </p> <p>A con was the availability of the plugin for possible customers: at the moment we started the project, it wasn’t as widespread as it is now. But currently, around 70% of internet-connected computers have the Silverlight plugin (source: riastats.com), so that isn’t an issue anymore.</p> <p><strong>2. What were the major Silverlight-related problems faced during development?</strong></p> <p>When we started development, we were working with Silverlight 3 and the then available version of WCF RIA Services, in Visual Studio 2008. By the time the project was completed, we were using Silverlight 4, Visual Studio 2010, and the latest version of WCF RIA Services. That means we went through 2 Silverlight versions, a new Visual Studio and 3 versions of WCF RIA Services during development – and some upgrades included changes that broke previously working code, especially in relation to WCF RIA Services. The main Silverlight related problem was definitely fast release of new versions: we lost quite some time because of that, and we had to throw away quite a bit of code we created for Silverlight 3 to support certain features that became available out of the box with Silverlight 4.</p> <p><strong>3. What was the reason to choose WCF RIA Services for data access? Did you consider other technologies as well?</strong> </p> <p>Low bandwidth usage (when used correctly), client-side change tracking, built-in validation on client/server and the ability to precisely choose what’s going over the wire through metadata and change-tracked DTO’s are all reasons to choose for WCF RIA Services. Next to that, the built-in security options (Authentication Domain Services) obviously saved us a lot of time & effort. </p> <p>For example, we didn’t want to submit every change in data to the server immediately: we wanted to keep this on the client and let the client decide when to sae the changes (resulting in a less chatty application). Having out-of-the-box change tracking really helps in scenarios like this. In essence, you can look at WCF RIA Services as having an Entity Framework-like ObjectContext to load data in, keep track of changes, … on your client. </p> <p>WCF RIA Services is often marketed as a framework for rapid application development, which it definitely is, but it’s a lot more than that: when you starting looking at it more closely, you’ll find a very powerful, very extensible framework. You get so much out of the box, and if you need something else, it’s pretty easy to add. But you have to look past the marketing talk ;-) </p> <p><strong>4. Did you face any challenges with using navigation in your application?</strong> </p> <p>Yes. We wanted to support deep linking, which drove us to the built-in navigation framework, but we quickly noticed that it isn’t sufficient (at all) for complex applications. For example: we needed to be able to navigate to a certain Uri, which had to create the UI by loading different views in different frames, and we had to be able to navigate to a certain “state” of a view, automatically. This kind of behavior isn’t available out of the box, so we heavily extended the existing navigation framework to get what we need. Through these extensions, we are now able to define a Uri and link it to different views in different states in different frames, and even define whether or not authentication/a certain role is required to access the Uri. </p> <p><b>5. Did you use any third-party controls? (which one and why, if appropriate)</b> </p> <p>We used some controls from the Silverlight toolkit, but next to that we created all our controls ourselves. They were too specific to be available through third-party vendors, and it’s actually quite easy to create custom Silverlight controls. </p> <p><b>6. What did you use for reporting?</b> </p> <p>For reporting we were looking for a solution which allowed us to create reports (in this case: Word documents) on the client. We evaluated a few possibilities, but SyncFusion DocIo really stood out for us: you can start from a template, easily fill in the data that’s needed and send the report to the client through a typical “Save as” dialog window. It’s also quite intuitive to use, and we had used the non-Silverlight versions of their reporting tools in the past, so we already had some experience with this. </p> <p><strong><span style="font-size: 18px;">Conclusion</span></strong></p> <p><strong>Were the initially set goals achieved, within the expected resources? What else has left to be improved?</strong> </p> <p>The initially set goals were definitely achieved, but we did experience a bit of overrun because of the various migrations we had to do due to the fast pace of new WCF RIA Services / Silverlight versions. However, we’re very happy with the application at the moment, and we get similar feedback from companies that use it. </p> <p>As for possible improvements in the future: there are always things we can add, more functionality, extra graphs and reports, … This project will keep on evolving day by day, depending on customer feedback. </p> http://www.silverlightshow.net/items/360-Degrees-Feedback-by-Kevin-Dockx.aspx editorial@silverlightshow.net (Silverlight Show ) http://www.silverlightshow.net/items/360-Degrees-Feedback-by-Kevin-Dockx.aspx#comments http://www.silverlightshow.net/items/360-Degrees-Feedback-by-Kevin-Dockx.aspx Thu, 24 Feb 2011 04:14:00 GMT Andrej Tozon on Hey weigh! WP7 application <div style="border:1px solid #dddddd;padding-bottom: 5px; background-color: #f3f3f3; margin-top: 5px; padding-left: 10px; width: 200px; float: right; margin-left: 10px; padding-top: 5px;"> <h3>Don't miss...</h3> <ul style="list-style-type: circle; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 20px; font-size: 12px;"> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/Windows-Phone-7-Part-1-Getting-Started.aspx">WP7 series by Andrea Boschin</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-What-is-Windows-Phone-7.aspx">What is Windows Phone series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/book/Windows-Phone-7-for-iPhone-Developers.aspx">WP7 for iPhone Developers book: </a></li> </ul> <p style="padding-bottom: 5px;">         <a href="http://www.silverlightshow.net/book/Windows-Phone-7-for-iPhone-Developers.aspx"><img style="border:1px solid; width: 115px; height: 150px;" alt="Beginning Windows Phone 7 Development" src="http://www.silverlightshow.net/Storage/WP7iPhone.jpg" /></a> </p> <p style="font-size: 12px;">              <a href="http://www.silverlightshow.net/Books.aspx">Show more books</a><img alt="" src="http://www.silverlightshow.net/Storage/arrow-content.jpg" /></p> </div> <p><strong>Q1. Andrej - please introduce yourself briefly (experience, interests, key projects, etc) and tell us more about the application you created - what are the key functionalities, major differences from other similar applications on the market, why do you think people would want to install this app on their WP7?</strong></p> <p>A. My name is Andrej Tozon and I’m working as a contractor with my own company in Slovenia. I’ve been developing for Windows for nearly 20 years now, working through a lot of technologies and languages in my past. Currently, my primary work interests are Silverlight, WPF and, lately, Windows Phone 7. I’m also a Client Application Development MVP. <br /> My first WP7 application, Hey weigh!, is a simple weight tracking tool, which you can use to track your weight. It’s a very basic, free app that lets you enter your weight for a day and keeps history for last 30 days. History is, besides in a scrolling list, also represented by a line chart. I wanted to keep it simple and clean so I only included those features I myself thought I needed to track my weight, so I could also say that it was a very personal project :) If that basic feature set and the looks appeal to other people, that’s great. There are other similar apps on the marketplace, offering additional features and users may find them more useful than mine. And that’s what’s so great and important about taking part in the large, global marketplace – you offer your vision of an application and watch the users all over the world responding to it.</p>                                    <iframe width="480" height="390" title="YouTube video player" class="youtube-player" src="http://www.youtube.com/embed/yBKxXWwFJRw" frameborder="0" type="text/html"></iframe> <p><strong>Q2. What was the motivation behind creating this application? How did you get the idea?</strong></p> <p>A. I think the key moment came around last Christmas, when people were led many discussions about food and having to take care when and how much to eat. Needing to control my weight myself occasionally, a weight tracking application seemed like a perfect warming up application that would lead me into the world of actual Windows Phone 7 development. I wanted to learn about the whole WP7 development lifecycle, including publishing to the marketplace, so I chose to do a simple application that I would offer as free, as free was (and currently still is) the only way I could get the application on the marketplace.</p> <p>                                            <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwfront.png"><img width="144" height="240" title="Front / weight entry screen" style="border:0px; background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" alt="Front / weight entry screen" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwfront_thumb.png" /></a>                            <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwlist.png"><img width="144" height="240" title="History" style="border:0px; background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" alt="History" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwlist_thumb.png" /></a></p> <p><strong>Q3. What were the challenges you faced when moving from Silverlight to the phone environment? What are the common difficulties a WP7 first-timer may face while developing his first app?</strong></p> <p>A. Being used to Silverlight 4, there were some initial hiccups with regard to lack of APIs, which is due to the fact that the Silverlight version on WP7 is based on a Silverlight 3. You just need to forget a few things you learned when developing with Silverlight 4. You also have to pay a lot more attention to how your application performs on the phone - there is fortunately plenty of reading available on the web in this area. One last thing to mention is you have to be very familiar with application design guidelines and marketplace submission requirements so you can design your application right from the very start. And don’t forget – even when you start thinking you’re very well read on the whole WP7 development story, the real fun begins when you get your hands dirty and put your theory into practice.</p> <p>                                            <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwchart.png"><img width="144" height="240" title="Chart spans " style="border:0px; background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" alt="Chart spans " src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwchart_thumb.png" /></a>                            <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwchart2.png"><img width="144" height="240" title="Chart spans " style="border:0px; background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" alt="Chart spans " src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwchart2_thumb.png" /></a></p> <p><strong>Q4. Could you reveal some tip, some solution you used to work around a specific problem faced during the development of your application?</strong></p> <p>A. There was one thing I wanted to get into the application and that was making data entry as simple as possible. I started with a simple text box but soon ran into many problems. I set textbox’s InputScope to “Number”, which limits data entry to numeric characters. But this setting wasn’t working out because user could enter other characters besides numerals, which called for entry validation, etc. I also thought that manual entry wasn’t the best approach anyway, because with weight tracking, every new entry is only a slight modification of a previous entry, so why force user to delete and/or retype the whole number, if there are better ways of adjusting the weight? <br /> So I came up with an idea of a custom number picker, which I based on the existing DatePicker that’s part of the Silverlight Toolkit for Windows Phone 7. The looks and behavior are similar, except that here you’re entering a decimal number instead of a date. The weight entry is faster this way because you only need to adjust the number tiles a bit to reach the new number and confirm it. No manual text entry is required at all.</p> <p>                                            <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwsip.png"><img width="144" height="240" title="TextBox with InputScope set to Numeric" style="border:0px; background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" alt="TextBox with InputScope set to Numeric" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwsip_thumb.png" /></a>                             <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwpicker.png"><img width="144" height="240" title="Custom number picker" style="border:0px; background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" alt="Custom number picker" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/hwpicker_thumb.png" /></a>          </p> <p> </p> <p><strong>Q5. Have you faced any performance challenges with Hey Weigh!? Was it hard to optimize your app so it may run smooth on the device?</strong></p> <p>A. Not really, because I wanted to keep application very simple and lightweight, but at the same time, I did want to try and put to work some of the performance guidelines that are emerging on the web through various weblogs - for example minimizing the (de)serialization time and data size, or loading data in the background after the application starts to ensure application shows its main screen as soon as possible.</p> <p><strong>Q6. How do you see the future of WP7, and applications for WP7?</strong></p> <p>A. I think the future of Windows Phone 7 looks good. Let’s not forget that this is first a phone first, and everything else, like it being an application platform, comes second. At least that’s how I look at things. Calls should be very easy to make and the phone (its OS) shouldn’t get in the way. WP7 does a good job with integrating with different services and social media networks, but there is still a lot of room for improvement. We’re only using the first version of phone’s OS today, so I’m very confident in that experience will only get better in the future. <br /> Windows Phone also makes a great application platform. Developers love it because it’s easy to program against, and those with previous experience with the .NET platform (and Silverlight in particular), they should feel like at home. The marketplace is growing bigger every day and there are some really great apps out there. OS performance improvements aside, my only wishes are that their prices stay in a reasonable range, to see more free apps and for Microsoft to enable every developer in the world (regardless of their country) to publish their apps (free or paid) on the marketplace as soon as possible.</p> <p><strong>Q7. What other ideas for next WP7 applications do you have? <br /> </strong>A. I have some ideas for my next applications, a couple of them games, which I would love to discuss about, when they get ready to publish and I could publish them myself, under my name. Unfortunately I don’t have a developer account myself, because Slovenia is not one of marketplace-supported countries; however, our local Microsoft office (their DPE team) was kind enough to publish the application in my behalf, which I thank them for. </p> <p>And with hopes for these marketplace-related issues to be resolved soon, I thank you for inviting me to have this interview.</p> <p><em><strong>Thanks for sharing your first experience with WP7, Andrej! Looking forward to see your next applications on the WP7 market!</strong></em></p> http://www.silverlightshow.net/items/Andrej-Tozon-on-Hey-weigh-WP7-application.aspx editorial@silverlightshow.net (Silverlight Show ) http://www.silverlightshow.net/items/Andrej-Tozon-on-Hey-weigh-WP7-application.aspx#comments http://www.silverlightshow.net/items/Andrej-Tozon-on-Hey-weigh-WP7-application.aspx Thu, 27 Jan 2011 02:50:00 GMT Tim Greenfield on PuzzleTouch WP7 Application <div style="padding-bottom: 5px; background-color: rgb(243,243,243); margin-top: 5px; padding-left: 10px; width: 200px; float: right; margin-left: 10px; padding-top: 5px;border: rgb(221,221,221) 1px solid;"> <h3>Don't miss...</h3> <ul style="list-style-type: circle; margin: 0px; padding-left: 20px; font-size: 12px;"> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/Search.aspx?q=wp7&adv=true&tg=true&ro=0&df=11-16-2010&dt=12-12-2010&t=1&r=10&o=1">See all wp7 showcases</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-What-is-Windows-Phone-7.aspx">What is Windows Phone series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/Search.aspx?q=wp7&adv=true&ro=0&t=1,2,3,4,5&r=10&o=1">Read all wp7 materials</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/book/Beginning-Windows-Phone-7-Development.aspx">WP7 Development book: </a></li> </ul> <p style="padding-bottom: 5px;">         <a href="http://www.silverlightshow.net/book/Beginning-Windows-Phone-7-Development.aspx"><img alt="Beginning Windows Phone 7 Development" src="http://www.silverlightshow.net/Storage/WP7book.jpg" /></a> </p> <p style="font-size: 12px;">              <a href="http://www.silverlightshow.net/Books.aspx">Show more books</a><img alt="" src="http://www.silverlightshow.net/Storage/arrow-content.jpg" /></p> </div> <p><em>The next WP7 developer who we introduce to you is Tim Greenfield who will reveal some secrets behind the creation of his PuzzleTouch application. Tim also gives some advices to those of you who consider to start developing for Windows Phone 7.</em></p> <p><strong>Q1. Tim - please introduce yourself briefly (experience, interests, key projects, etc) and tell us more about the application you created - what are the key functionalities, major differences from other similar applications on the market, why do you think people would want to install this app on their WP7?</strong></p> <p>A. My name is Tim Greenfield, I am a software engineer working for Vertigo Software and the founder of PuzzleTouch and MyPadlock. I am also a blogger, speaker, and former Silverlight Insider. My WP7 app, PuzzleTouch Jigsaw Puzzles is a jigsaw puzzle game with very realistic looking puzzle pieces and a natural feel to moving and snapping the pieces together. Besides dozens of interesting puzzles to choose from, you can also take a picture with your camera and turn it into a jigsaw puzzle. Plus, you can email these personal puzzles to friends or post them on Facebook from within the app, allowing friends and family can play your puzzle on the web for free. PuzzleTouch Jigsaw Puzzles also has an advanced mode to add even greater challenge.</p> <strong> <p>          <embed width="540" height="335" src="http://www.youtube.com/v/0VTtXAI6_xU?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" /></p> <p><a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot1_2.png"><img width="144" height="240" title="screenshot1" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px;border: 0px;" alt="screenshot1" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot1_thumb.png" /></a>Q2. What was the motivation behind creating this application? How did you get the idea?</p> </strong> <p>A. The idea was essentially a “no-brainer”. I had invested over a year into developing the award winning website: PuzzleTouch.com (written in Silverlight), so I already had an extensive code-base that I knew I could easily leverage for the phone. Furthermore, the mobile platform is in many ways an even better venue for jigsaw puzzles. After all, you can touch the pieces like you would real with real jigsaw puzzles, the device is portable which makes it great for traveling, killing time in airports, …etc (something impossible to do with real jigsaw puzzles tethered to your dining room table :) And last, your phone has a built in puzzle maker… your phone’s camera!</p> <p><strong>Q3. Did you have any performance when you started your application on the device? What were the main challenges to make it perform fast enough?</strong></p> <p>A. I had already spent a good deal of time fine-tuning the PuzzleTouch.com website to handle various performance intensive tasks such as supporting 1000 piece jigsaw puzzles that you can easily zoom and pan as well as video jigsaw puzzles that play moving videos inside each puzzle piece. So, in many ways I was fairly far along already. However, after porting, I found I was still pushing the limits of the phone’s hardware. My main troubles were related to frame rate when dragging and rotating puzzle pieces. In the end, I did an exhaustive review of how I was using hardware acceleration and animations and fine tuned it further to boost the frame-rate during game play.</p> <p>                                                      <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot3_2.png"><img width="171" height="256" title="screenshot3" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="screenshot3" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot3_thumb.png" /></a>         <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot2_2.png"><img width="171" height="256" title="screenshot2" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="screenshot2" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot2_thumb.png" /></a></p> <p><strong>Q4. What were the challenges you faced when moving from Silverlight in/out of the browser to the phone environment?</strong></p> <p>A. Design, design, design. I wanted my app to look like a Windows Phone 7 app and not like a ported website. Starting with the PuzzleTouch.com code base got me very far very fast but I had to avoid temptation to simply rebuild a smaller version of my website for the phone. I actually ended up finishing the app for the phone and then throwing it away and starting over with the design. In the end, I moved away from having multiple pages leading up to the actual puzzle play screen and instead used the panorama control to build a succinct, user-friendly interface all on a single page to select or create your jigsaw puzzle.</p> <p><strong><a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot4_2.png"><img width="240" height="144" title="screenshot4" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px;border: 0px;" alt="screenshot4" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot4_thumb.png" /></a>Q5. Did you have to drop some features from your Web-based version to make it work fast?</strong></p> <p>A. Yes. As mentioned, PuzzleTouch.com supported up to 1000 pieces as well as video jigsaw puzzles. 1000 piece puzzles would not make sense on such a small screen nor would it perform reasonably well. And Silverlight for WP7 doesn’t support VideoBrush (the only way to build video jigsaw puzzles). Both features had to be dropped but it actually allowed me to clean up my UI by not presenting the user with so many choices. I honed in on what the best number of pieces would be on the phone and tweaked the app to make the experience as good as possible instead of trying to build a one size fits all app as the website tries to do.</p> <p><strong>Q6. Could you reveal some tip, some solution you used to work around a specific problem faced during the development of your application?</strong></p> <p>A. WP7 doesn’t support pixel shaders yet, and drop shadows were paramount to the realistic look and feel of the puzzle pieces. Fortunately, I came up with an alternative by creating a duplicate set of translucent black puzzle pieces and placing them behind the real puzzle pieces at a small offset. I was able to animate their position when the pieces were rotated to give the effect of a fixed light source while rotating the pieces and expand them when the piece was touched to give the appearance of the puzzle piece being lifted ever so slightly off the screen for a little 3D realism. In the end, it performed great and looked 100 times better than without any kind of drop shadow. Sometimes these little details make all the difference and it was well worth the time to get it right.</p> <p>                                                         <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot7_2.png"><img width="171" height="256" title="screenshot7" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="screenshot7" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot7_thumb.png" /></a>         <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot8_2.png"><img width="171" height="256" title="screenshot8" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="screenshot8" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot8_thumb.png" /></a></p> <p><strong>Q7. Have you faced any performance challenges with PuzzleTouch? Was it hard to optimize your app so it may run smooth on the device?</strong></p> <p>A. As mentioned, the underlying PuzzleTouch technology was already fairly well tuned and made great use of hardware acceleration so most of the work was already done. However, I did spend a fair amount of time looking at the performance readouts on the phone and made minor adjustments until I was happy. Fortunately, most of the same performance considerations in Silverlight for the web apply to the phone so in the end, I was actually able to roll some of my WP7 changes into the web version to improve it as well. All of this really demonstrates the power of code-sharing and why it is strategically important for Microsoft to develop Silverlight web/desktop with Silverlight for WP7.</p> <p><strong>Q8. How do you see the future of WP7, and applications for WP7?</strong></p> <p>A. WP7 is very appealing from a consumer perspective; in my opinion it competes on just about every level with Android and iPhone. It has some serious catch up to do to compete as a brand, but the platform’s quality and feature set is surprisingly on par and in some ways better than the competition. The handful of features it is missing will almost certainly show up in vNext, and because the phone carriers have limited control over the updates, users won’t be stuck with an outdated OS like they are with Android. </p> <p>From the developer’s perspective, I actually see the developer’s story as possibly one of the greatest benefits to the platform. Microsoft has arguably the best programming stack available today and by leveraging Silverlight and XNA, developers won’t have to learn anything new and can even re-use vast amounts of code and external libraries to make development even faster. Furthermore, because the specifications are more tightly controlled and the phone carriers can’t meddle with the OS, app compatibility across different devices is practically irrelevant (the opposite from Android). In the end, these advantages are huge and we are sure to benefit from an amazing marketplace in both the number and the quality of apps available.</p> <p><strong>Q9. What considerations a Silverlight developer should make before starting to develop for WP7?</strong></p> <p>A. #1: If you’re porting an app, expect to redesign it. Not just for limited real-estate and touch support, but for the entire UX. #2: If you’re starting from scratch or porting, teach yourself what good design on a Windows Phone 7 looks like. Go out to the marketplace and look at the other apps. What do and don’t you like and why? #3: Familiarize yourself with some of the WP7 basics. Spend an hour on each of the following topics by building a quick proof of concept app to test the waters with: hardware acceleration, panorama and pivot controls, navigation, tombstoning, & touch. Once you have these basics under your belt, you’ll be far less likely to paint yourself into a corner down the road. #4: People are going to hate me for saying this, but don’t go overboard worrying about performance right from the start. Build POCs for the areas you suspect may have performance issues but don’t be afraid to rely on refactoring too. I’ve read blogs stating to stay away from binding and to stick to code-behind. While it is definitely true that this will result in better performance, sometimes you just don’t always need better performance and I’d say in most cases: bind away and tweak later. Don’t sacrifice clarity for performance if you don’t need to.</p> <p>                                                <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot9_2.png"><img width="171" height="256" title="screenshot9" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="screenshot9" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot9_thumb.png" /></a>           <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot10_2.png"><img width="171" height="256" title="screenshot10" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="screenshot10" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/screenshot10_thumb.png" /></a></p> <p><strong>Q10. What other ideas for next WP7 applications do you have?</strong></p> <p>A. I actually just released my second WP7 app called BobbleHead that allows you to make bobblehead dolls on your phone. You can take pictures of friends, and put their face on some pretty funny bobblehead bodies then shake, poke and push the head to make it bobble like a real bobble head doll. A free trial is included and it was a ton of fun to build. Additionally, I’m also working a new version of PuzzleTouch for Kids (PuzzleTouch Jr.) and a more difficult version of PuzzleTouch (PuzzleTouch Extreme). Coming soon!</p> <p><strong>Q11. What is your opinion about Silverlight 5 and the new features announced at FireStarter?</strong></p> <p>A. I think this might actually be the most impressive Silverlight release since v2. There are a lot of great improvements for performance as well as productivity that Silverlight developers will be able to leverage to make Silverlight even more powerful than it already is. Silverlight is quickly becoming the premium platform for desktop and web development and I’m constantly impressed by the pace and level of innovation we’re seeing. Presumably, most of these great improvements will also find their way into the WP7 platform soon as well.</p> <p><em><strong>Thanks, Tim! Hope we talk to you again soon and discuss your BobbleHead App!</strong></em></p> http://www.silverlightshow.net/items/Tim-Greenfield-on-PuzzleTouch-WP7-Application.aspx editorial@silverlightshow.net (Silverlight Show ) http://www.silverlightshow.net/items/Tim-Greenfield-on-PuzzleTouch-WP7-Application.aspx#comments http://www.silverlightshow.net/items/Tim-Greenfield-on-PuzzleTouch-WP7-Application.aspx Mon, 13 Dec 2010 00:00:00 GMT Laurent Duveau on Morse Code Flash Light WP7 Application <a href="http://www.silverlightshow.net/book/Professional-Windows-Phone-7-Game-Development-Creating-Games-using-XNA-Game-Studio-4.aspx"></a><a href="http://www.silverlightshow.net/book/Professional-Windows-Phone-7-Game-Development-Creating-Games-using-XNA-Game-Studio-4.aspx"></a>  <div style="padding-bottom: 5px; background-color: rgb(243,243,243); margin-top: 5px; padding-left: 10px; width: 200px; float: right; margin-left: 10px; padding-top: 5px;border: rgb(221,221,221) 1px solid;"> <h3>Don't miss...</h3> <ul style="list-style-type: circle; margin: 0px; padding-left: 20px; font-size: 12px;"> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-Stock-Quoting-Demo-Series-Part1.aspx">WP7 Stock Quoting Demo series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-What-is-Windows-Phone-7.aspx">What is Windows Phone series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/Paul-Juenger-on-WHS-Phone-WP7-Application.aspx">WHS Phone WP7 Application</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/book/Professional-Windows-Phone-7-Game-Development-Creating-Games-using-XNA-Game-Studio-4.aspx">Windows Phone 7 book: </a></li> </ul> <p style="padding-bottom: 5px;">         <a href="http://www.silverlightshow.net/book/Professional-Windows-Phone-7-Game-Development-Creating-Games-using-XNA-Game-Studio-4.aspx"><img style="border: 0px solid;" alt="Windows Phone 7 game development book" src="http://www.silverlightshow.net/Storage/BookWP7.png" usemap="#rade_img_map_1291385581316" /></a> </p> <p style="font-size: 12px;">              <a href="http://www.silverlightshow.net/Books.aspx">Show more books...</a></p> </div> <p><em>The next Windows Phone 7 application that we bring to your attention is Morse Code Flash Light – one app created mostly for fun. Its author, Laurent Duveau, agreed to share some details about the app as well as some tips on developing for WP7.</em></p> <p><strong>Q1. Laurent - please introduce yourself briefly and tell us more about the application you created - what are the key functionalities, major differences from other similar applications on the market, why do you think people would want to install this app on their WP7? <br />  <br /> </strong>A. I am a Silverlight MVP and co-founder of RunAtServer Montreal (www.runatserver.com), we are specialized in Silverlight and Windows Phone apps. We do Architecture/Dev/UI Design/Coaching/Training/Speaking... <br /> My “Morse Code Flash Light” app allows the user to translate text in morse code, then use the phone as a flash light to “read” it. Obviously it falls in the “funny tools” category, I don’t know if anyone will ever seriously use it, but who knows… anyway it was fun to build and it’s free! Try the “Shake for a random word” feature…</p> <p>                                                             <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/capture3_2.png"><img width="268" height="444" title="capture3" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="capture3" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/capture3_thumb.png" /></a></p> <p><strong>Q2. What was the motivation behind creating this application? How did you get the idea? <br />  <br /> </strong>A. The idea came from my left brain; it’s a “toy” project… I needed an excuse to try development for the phone. As an experienced Silverlight developer I wanted to learn this new platform and see if there were any big differences. Since then we have had more serious mobile projects at work but they are not deployed yet.</p> <p>                                                   <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/capture1_2.png"><img width="148" height="244" title="capture1" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="capture1" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/capture1_thumb.png" /></a>               <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/capture2_2.png"><img width="148" height="244" title="capture2" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="capture2" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/capture2_thumb.png" /></a></p> <p><strong>Q3. What were the challenges you faced when moving from Silverlight in/out of the browser to the phone environment?<br />   <br /> </strong>A. It was not that hard, tools are the same (VS2010 & Blend), C#, .NET, … there are some specificities, like the Silverlight version, phone features, entire touch UI (make BIG buttons), but nothing major. <br /> The “31 days of Windows Phone 7” by Jeff Blankenburg helped a lot: <br /> <a href="http://www.jeffblankenburg.com/post/31-Days-of-Windows-Phone-7.aspx" target="_blank">http://www.jeffblankenburg.com/post/31-Days-of-Windows-Phone-7.aspx</a></p> <p><strong>Q4. Could you reveal some tip, some solution you used to work around a specific problem faced during the development of your application? <br />  <br /> </strong>A. I didn’t really had problems while developing, but more during the Marketplace certification process. My problem was around navigation and the back button behavior which was really weird at first. To make it short: circular navigation is not recommended, get the user to press the back button instead.</p> <p><strong>Q5. Have you faced any performance challenges with Morse Code Flash Light? Was it hard to optimize your app so it may run smooth on the device? <br />  <br /> </strong>A. Not really because this is a very little app. But it is true that you need to optimize your dev for the phone, much more than regular Silverlight. You have limited screen real estate, limited performance, ... any list of data needs UI optimization with things like defer loading, local cache.</p> <p><strong>Q6. How do you see the future of WP7, and applications for WP7?<br />   <br /> </strong>A. I see a great potential in the WP7 platform, both in terms of applications to create (everything is to be done, we need to fill the marketplace!), and for developers, because if just a part of the army of .NET developers realize how easy it is to create WP7 apps, that will be crazy! To have a great mobile platform you need a Marketplace with tons of apps.</p> <p><strong>Q7. What other ideas for next WP7 applications do you have? <br />  <br /> </strong>A. I have a few more ideas for WP7 applications… something around location services… wait and see!</p> <p><strong>Q8. What is your opinion on the recent announcement by Microsoft on the future of Silverlight and HTML5? <br />  <br /> </strong>A. I am happy to see Microsoft adding some diversity in its RIA strategy and will focus on HTML5 as well. There has been a lot of confusion around this message but this is all what it is. We have Silverlight for the richness and HTML5 for the reach. For me Silverlight has never been a tool to kill everything else. I have always been a strong advocate of using Silverlight only if needed and where there is real values add. I will almost never use Silverlight for regular websites, it does not make sense. <br /> So the shift in strategy does not change anything in my job and for my business, I have always used Silverlight for rich line of business applications for intranet or desktop, and that will not change anytime soon. Doing web stuff for the iPad is HTML(5) only, so I’m glad that Microsoft focus on that as well, this is a market they can’t ignore. I am sure we will soon have tools in Visual Studio to help produce HTML5.</p> <p><em>For more information on Laurent’s future projects visit his blog </em><a href="http://weblogs.asp.net/lduveau"><em>http://weblogs.asp.net/lduveau</em></a><em> or follow him on Twitter <strong>@LaurentDuveau</strong>.</em></p> http://www.silverlightshow.net/items/Laurent-Duveau-on-Morse-Code-Flash-Light-WP7-Application.aspx editorial@silverlightshow.net (Silverlight Show ) http://www.silverlightshow.net/items/Laurent-Duveau-on-Morse-Code-Flash-Light-WP7-Application.aspx#comments http://www.silverlightshow.net/items/Laurent-Duveau-on-Morse-Code-Flash-Light-WP7-Application.aspx Fri, 03 Dec 2010 00:00:00 GMT Johan Dahlbäck on Marathon WP7 Application <div style="border:1px solid #dddddd;padding-bottom: 5px; background-color: #f3f3f3; margin-top: 5px; padding-left: 10px; width: 200px; float: right; margin-left: 10px; padding-top: 5px;"> <h3>Don't miss...</h3> <ul style="list-style-type: circle; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 20px; font-size: 12px;"> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-Stock-Quoting-Demo-Series-Part1.aspx">WP7 Stock Quoting Demo series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-What-is-Windows-Phone-7.aspx">What is Windows Phone series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/Gergely-Orosz-on-Cocktail-Flow-WP7-application.aspx">Cocktail Flow WP7 Application</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/book/Beginning-Windows-Phone-7-Development.aspx">WP7 Development book: </a></li> </ul> <p style="padding-bottom: 5px;">         <a href="http://www.silverlightshow.net/book/Beginning-Windows-Phone-7-Development.aspx"><img alt="Beginning Windows Phone 7 Development" src="http://www.silverlightshow.net/Storage/WP7book.jpg" /></a> </p> <p style="font-size: 12px;">              <a href="http://www.silverlightshow.net/Books.aspx">Show more books...</a></p> </div> <p><em></em><em>The next WP7 application we present is called Marathon and it keeps track of your movement with the help of a GPS-receiver. It’s the perfect companion for sporting activates such as running, skiing or even skydiving. We introduce you to Johan Dahlbäck who will tell us how otherwise his app can be used.</em></p> <p><strong></strong> </p> <p><strong>Q1. Johan - please introduce yourself briefly and tell us more about the application you created - what are the key functionalities, major differences from other similar applications on the market, why do you think people would want to install this app on their WP7?</strong></p> <p style="text-align: left;">A. I'm 24 years old and live in Stockholm, Sweden. I've been working as an IT-consultant for the past 2.5 years, mainly with SharePoint development. On my spare time I'm working on my application "Marathon", which is a tool that uses the location service on the device to record the users movement. It's mainly made for runners, but works well for most outdoor sports where you measure distance (someone actually used Marathon during a skydive, so I guess it's up to your imagination :)). One neat feature a lot of people appreciate is the voice announcement, which can be set to trigger at time or distance intervals. I'm using it together with my previous recordings to compete against myself and give me the motivation I need to reach my goals. Running is quite popular now days, and I believe most people will find an application such as Marathon useful for their training.</p> <p>You don't have to be serious runner to use it, it can still be fun to keep track of your results.</p>                                  <div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:ecb2c08f-a661-4882-b8ed-330ada364f89" style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;"> <div id="02ba4c02-e537-49c6-a447-2e48664ba8fd" style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;"> <div><embed width="448" height="252" src="http://www.youtube.com/v/vldm4WVguLk?hl=en&hd=1" type="application/x-shockwave-flash"></embed></div> </div> <strong> <div> <div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:ecb2c08f-a661-4882-b8ed-330ada364f89" style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;"><strong><br /> </strong></div> </div> Q2. What was the motivation behind creating this application? How did you get the idea?</strong></div> <p>A. I started running a few years ago. At that time I didn't live close to any trial, so I had no idea how well I performed. It was about the same time smartphones started to show up with GPS-receivers, so I got the idea of creating Marathon to solve this problem. I bought a Windows Mobile device and started coding, unfortunately my motivation wasn't that great during the winter and it took almost a year before the application was ready for its first release.</p> <p>                                        <img alt="" width="189" height="273" src="http://www.silverlightshow.net/Storage/userfiles/WP7Charts.png" /><img alt="" width="188" height="271" src="http://www.silverlightshow.net/Storage/userfiles/Wp7Goals.png" /></p> <p><strong>Q3. What were the challenges you faced when moving from Silverlight in/out of the browser to the phone environment?</strong></p> <p>A. I had very little experience with Silverlight prior to Windows Phone. So I can't say I did such a transition. But I guess one of the biggest differences is how you interact with the device. Phones have small screens, so it doesn't fit much information on one page. You'll also have to worry about performance to keep a smooth user experience and not drain the battery. The phone apps can be interrupted at any time, so you have to make sure you can restore the current state.</p> <p><strong><img alt="" width="180" height="258" style="display: inline; float: right;" src="http://www.silverlightshow.net/Storage/userfiles/Wp7Announce.png" />Q4. Which measures does Marathon track? Which measure was the hardest to implement?</strong></p> <p>A. Marathon mainly tracks the distance you've moved (both vertically and horizontally), so it can provide you with information about your speed, altitude change, calories burned, distance and time. It also keeps all your positions so it can plot it on a map (this feature didn't make it to the first release, but it's available if you upload your result online). The hardest part was to make sure the charts didn't consume to much resources. They are based on the charts in the Silverlight Toolkit, which were not originally developed for Windows Phone. They still work great, but it was a bit of a risk to use them since I wasn't able to do any tests on a real device until a few days before release.</p> <p><strong>Q5. Have you faced any performance challenges with Marathon? Was it difficult to optimize your app so it may run smooth on the device?</strong></p> <p>A. Since I couldn't get hold of a Windows Phone 7 device during the development I tried to stick to simple animations and standard controls as much as possible for the first version. I did get hold of a developer device for 5 days before the release, so I could do some tweaking and make sure everything was working as intended. The most difficult part was to make sure the device response quickly when it's unlocked after a recording. At that time I have to update the graphs and the map. It turns out that the way I was using the Bing Maps control locked the UI while it was downloading data. I didn't realize this until it was too late to fix for the first version, so I had to remove the map (I blame the good 3G reception where I live ;)).</p> <p><strong>Q6. From a developer point of view, what are the challenges while working with the GPS? Is it easy to use the API? What could Microsoft do better?</strong></p> <p>A. The location service in Windows Phone 7 works great, I can't imagine a way to make it easier to use. Marathon was first developed for Windows Mobile which wasn't as easy to work with. Some of the early devices had quite some problem to get the first fix, so it was hard to know if it was my fault or the devices GPS-receiver. With Windows Phone 7 it just works. It's always a bit tricky to work with GPS since the signal is far from perfect, but I could reuse my previous code by simply replacing the GPS-wrapper. So the hard work I put down for my Windows Mobile application came to good use once again.</p> <p>                                 <img alt="" width="283" height="407" src="http://www.silverlightshow.net/Storage/userfiles/Wp7Goals.png" /><img alt="" width="243" height="351" src="http://www.silverlightshow.net/Storage/userfiles/Wp7Share.png" /></p> <p><strong>Q7. How do you see the future of WP7, and applications for WP7?</strong></p> <p>A. The platform has a lot of potential thanks to Silverlight and XNA. Both are great technologies which let the developer focus on the features of their applications and games. Since there are strict hardware restrictions you don't have to worry about performance on different kind of devices, which also makes it a lot easier to develop. Smartphones today are all about third party applications, so the most important feature is to make sure the developer have great tools to work with.</p> <p><strong>Q8. What other ideas for next WP7 applications do you have?</strong></p> <p>A. I still have a lot of features I want to add to Marathon, so I'll probably not start with anything new for a while.</p> <p><strong><img alt="" width="171" height="247" style="display: inline; float: right;" src="http://www.silverlightshow.net/Storage/userfiles/WP7Dashboard.png" />Q9. What is your opinion on the recent announcement by Microsoft on the future of Silverlight and HTML5?</strong></p> <p>A. With Silverlight on phones, soon the Xbox and in cars (Windows Embedded Automotive) it's really making up for its original codename "WPF/E" (Windows Presentation Foundation Everywhere). It's an amazing technology and so is HTML5. Now that they are starting to overlap each other more and more the choice of technology isn't always crystal clear. But they both have a future and I don't believe any of them will be killed off by the other in the near future. When it comes to phone applications I welcome HTML5 as an alternative (but not replacement) to Silverlight. More and more companies want quite simple applications to expose their products for end users in one way or another. They'll benefit a lot if they can support Windows Phone, Android and iOS without writing 3 applications from scratch.</p> <p><strong>Thanks, Johan. Keep running ahead with Silverlight!</strong></p> http://www.silverlightshow.net/items/Johan-Dahlb-ck-on-Marathon-WP7-Application.aspx editorial@silverlightshow.net (Silverlight Show ) http://www.silverlightshow.net/items/Johan-Dahlb-ck-on-Marathon-WP7-Application.aspx#comments http://www.silverlightshow.net/items/Johan-Dahlb-ck-on-Marathon-WP7-Application.aspx Wed, 01 Dec 2010 00:00:00 GMT Dimaz Pramudya on Fuel My Car WP7 Application <div style="padding-bottom: 5px; background-color: rgb(243,243,243); margin-top: 5px; padding-left: 10px; width: 200px; float: right; margin-left: 10px; padding-top: 5px;border: rgb(221,221,221) 1px solid;"> <h3>Don't miss...</h3> <ul style="list-style-type: circle; margin: 0px; padding-left: 20px; font-size: 12px;"> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-Stock-Quoting-Demo-Series-Part1.aspx">WP7 Stock Quoting Demo series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-What-is-Windows-Phone-7.aspx">What is Windows Phone series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/Paul-Juenger-on-WHS-Phone-WP7-Application.aspx">WHS Phone WP7 Application</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/book/Professional-Windows-Phone-7-Game-Development-Creating-Games-using-XNA-Game-Studio-4.aspx">Windows Phone 7 book: </a></li> </ul> <p style="padding-bottom: 5px;">         <a href="http://www.silverlightshow.net/book/Professional-Windows-Phone-7-Game-Development-Creating-Games-using-XNA-Game-Studio-4.aspx"><img style="border: 0px solid;" alt="Windows Phone 7 game development book" src="http://www.silverlightshow.net/Storage/BookWP7.png" usemap="#rade_img_map_1291385581316" /></a> </p> <p style="font-size: 12px;">              <a href="http://www.silverlightshow.net/Books.aspx">Show more books...</a></p> </div> <p><em>The next author we’re going to meet is Dimaz Pramudya who was kind enough to share with us some details on his latest project – the Fuel My Car WP7 app. Dimaz also hints about his next WP7 app which we are going to keep an eye on.</em></p> <p><strong>Q1. Dimaz - please introduce yourself briefly (experience, interests, key projects, etc) and tell us more about the application you created - what are the key functionalities, major differences from other similar applications on the market, why do you think people would want to install this app on their WP7?</strong></p> <p>A. Hi everyone, I’m Dimaz Pramudya and I’ve been working in a number of industries in the past 5 years as a Technical Consultant. Few years ago, I was thrilled to invent SOAK along with few of my teammates, which we ended up winning the Software Design category for Microsoft Imagine Cup 2008 in Paris. Fast forward to today, I am the founder of salenear.me, a website that allows people to find great deals near them on their mobile phones.</p> <p>At around June this year, I created a WP7 application called “Fuel My Car”. In a nutshell, Fuel My Car is a social mobile application that one can use to find nearby petrol stations. The major differences from similar application are the great User Experience and the ability to find the near real-time prices for petrol stations near them which we achieve through a combination of fuel price feed from data agencies and the social interaction from the users.</p> <p>              <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/FuelMyCar_2.jpg"><img width="640" height="327" title="FuelMyCar" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="FuelMyCar" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/FuelMyCar_thumb.jpg" /></a></p> <p><strong>Q2. What was the motivation behind creating this application? How did you get the idea?</strong></p> <p>A. I found it hard to find nearby petrol stations if I was driving in an unknown area. Also, I would love to know the fuel price in advance so that I can make my buying decision accordingly.</p> <p><strong>Q3. What were the challenges you faced when moving from Silverlight in/out of the browser to the phone environment?</strong></p> <p>A. The user experience is completely different. When you are building Silverlight in browser, chances are you will be connected to the internet 99% of the time. Where as in the mobile context, you can’t rely on internet connectivity. You may be online at one time, and offline the next minute because you are going through the underground tunnel.</p> <p>Hence, when building a phone application, you should cater for the offline scenario and provide intuitive way to tell the user that they are currently offline.</p> <p><strong>Q4. Could you reveal some tip, some solution you used to work around a specific problem faced during the development of your application?</strong></p> <p>A. One of the tricky challenges is how to let the user know whether the application is in online / offline mode. I could just popup a message or stick in a label somewhere, but that’s not a great user experience. Then, the thought came to me. What if I “dim” the background image so that the users see a “greyish” background when they are offline and the full color background when they are online? From the comment I’ve got on my blog (<a href="http://www.dynamicslight.com/">www.dynamicslight.com</a>), people love this sort of experience.</p> <p><strong>Q5. Have you faced any performance challenges with Fuel My Car? Was it hard to optimize your app so it may run smooth on the device?</strong></p> <p>A. I faced several performance issues mainly with Listbox and loading images. Luckily, David Ans (Delay) shared the code for DeferredLoadListBox and LowProfileImageLoader which solves my perf issue.</p> <p><strong>Q6. From a developer point of view, what are the challenges while working with the GPS? Is it easy to use the API? What could Microsoft do better?</strong></p> <p>A. Getting the right accuracy from the GeoCoordinateWatcher without sacrificing the responsiveness of the application. But apart from that, I’m pretty happy with the GPS implementation. </p> <p><strong>Q7. How do you see the future of WP7, and applications for WP7?</strong></p> <p>A. Looking at the growth of WP7 right now, I would see it takes off mid next year. Combined with the easy to use development tools, I think WP7 is a heaven for SL / .NET Developers.</p> <p><strong>Q8. What other ideas for next WP7 applications do you have?</strong></p> <p>A. At the moment, I’m finishing up the WP7 application for my new venture <a href="http://www.salenear.me/" target="_blank">www.salenear.me</a> The application enables bargain hunters to discover and search for great sales around them. Stay tuned for updates @salenearme</p> <p><strong>Q9. What is your opinion on the recent announcement by Microsoft on the future of Silverlight and HTML5?</strong></p> <p>A. HTML 5 is great if you are targeting the latest browsers, however you will run into issues if your users are using older browsers. Plus your development experience isn’t going to be as nice as Silverlight *yet*. I think by Microsoft going Silverlight for their WP7 really shows the great commitment on the platform at least for the next few years. </p> <p><strong>Thanks, Dimaz, for revealing more on Fuel My Car. We hope to meet again soon to discuss your Sale Near Me app.</strong></p> http://www.silverlightshow.net/items/Dimaz-Pramudya-on-Fuel-My-Car-WP7-Application.aspx editorial@silverlightshow.net (Silverlight Show ) http://www.silverlightshow.net/items/Dimaz-Pramudya-on-Fuel-My-Car-WP7-Application.aspx#comments http://www.silverlightshow.net/items/Dimaz-Pramudya-on-Fuel-My-Car-WP7-Application.aspx Tue, 30 Nov 2010 00:00:00 GMT Paul Juenger on WHS Phone WP7 Application <div style="padding-bottom: 5px; background-color: rgb(243,243,243); margin-top: 5px; padding-left: 10px; width: 200px; float: right; margin-left: 10px; padding-top: 5px;border: rgb(221,221,221) 1px solid;"> <h3>Don't miss...</h3> <ul style="list-style-type: circle; margin: 0px; padding-left: 20px; font-size: 12px;"> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-Stock-Quoting-Demo-Series-Part1.aspx">WP7 Stock Quoting Demo series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-What-is-Windows-Phone-7.aspx">What is Windows Phone series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/Dimaz-Pramudya-on-Fuel-My-Car-WP7-Application.aspx">Fuel My Car WP7 Application</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/book/Professional-Windows-Phone-7-Application-Development.aspx">Windows Phone 7 book: </a></li> </ul> <p style="padding-bottom: 5px;">         <a href="http://www.silverlightshow.net/book/Professional-Windows-Phone-7-Application-Development.aspx"><img style="border: 0px solid;" alt="Professional Windows Phone 7 Application Development book" src="http://www.silverlightshow.net/Storage/WP7App.jpg" usemap="#rade_img_map_1291385581316" /></a> </p> <p style="font-size: 12px;">              <a href="http://www.silverlightshow.net/Books.aspx">Show more books...</a></p> </div> <p><em>Next in our series of featured WP7 applications comes WHS Phone – an app that lets you connect to your Windows Home Server and stream music, view photos, and much more. </em><em>We talk to its author Paul Juenger on why this application will have a shelf life of more than a couple of weeks.</em></p> <p><em></em> </p> <p> </p> <p><strong>Q1. Paul - please introduce yourself briefly (experience, interests, key projects, etc) and tell us more about the application you created - what are the key functionalities, major differences from other similar applications on the market, why do you think people would want to install this app on their WP7?</strong></p> <p>A. My name is Paul Juenger. I am a software engineer for a defense contractor and specialize in ASP.NET. When I’m not working, spending time with family, or golfing, I research and develop applications with Microsoft technologies that I do not get use at work; i.e. Silverlight, WPF, MVC, WCF, etc. Around July of this year I became really interested in Windows Phone 7.</p> <p>My first application is WHS<b> </b>Phone. WHS Phone is a WP7 Silverlight application that lets you connect to your Windows Home Server and stream music, access photos, and manage your server. You no longer need to pick and choose the music, podcasts, and photos that you want to sync with your phone because of limited space. WHS Phone integrates with the photo library allowing you to select photos from your phone’s library and upload them to your Windows Home Server. You can also download photos from your server to the phone’s library to view them offline. WHS Phone allows you to view server disk space and usage, manage users and<b> </b>shares, and view computers that are connected to your Windows Home Server. If you have a Windows Phone 7 and a Windows Home Server then you will really enjoy WHS Phone.</p>                                       <div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:3e5114ce-11c3-4859-847f-cd5a3e36b5ad" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;"> <div id="45ca880b-8eb3-4e68-bc0b-f0c31618178f" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;"> <div><embed width="448" height="252" src="http://www.youtube.com/v/2kWaH9_frjw?hl=en&hd=1" type="application/x-shockwave-flash" /></div> </div> </div> <p><strong>Q2. What was the motivation behind creating this application? How did you get the idea?</strong></p> <p>A. When I was brainstorming for application ideas I started by examining my IPhone. It was full of applications that were mostly games that I would play for a week or two and then quickly go into a folder never to be seen again. This helped me come up with three requirements: it must be something that I personally would use, something that users would want to pin to their start screen, and something that would have a shelf life of more than a couple of weeks. The idea came to me when I was reading an article about Skydrive integration with Windows Phone 7. Skydrive is a nice feature, but why would I want to limit myself to 25 gigabytes when I have over three terabytes of storage in my own private little cloud (my Windows Home Server). That’s when I decided to write WHS Phone.</p> <p>                                                     <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/AudioPlayerScreenshot.png"><img width="144" height="240" title="AudioPlayerScreenshot" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="AudioPlayerScreenshot" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/AudioPlayerScreenshot_thumb.png" /></a>                    <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/MusicScreenshot.png"><img width="144" height="240" title="MusicScreenshot" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="MusicScreenshot" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/MusicScreenshot_thumb.png" /></a></p> <p><strong>Q3. What were the challenges you faced when moving from Silverlight in/out of the browser to the phone environment?</strong></p> <p><a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/PhotosScreenshot.png"><img width="144" height="240" title="PhotosScreenshot" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; float: right; padding-top: 0px;border: 0px;" alt="PhotosScreenshot" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/PhotosScreenshot_thumb.png" /></a>A. I had very little Silverlight exposure when I started writing WHS Phone. I wrote a client/server chat application when Silverlight 2 was released and that was about it. The biggest hurdle for me was learning xaml<b>.</b> I have a strong working knowledge of how things work in Win Forms and ASP.NET<b>,</b> but Silverlight is<b> </b>different. I had to take a couple days off from developing WHS Phone and just learn xaml, Expression Blend, and how to use templates.</p> <p><strong>Q4. Could you reveal some tip, some solution you used to work around a specific problem faced during the development of your application?</strong></p> <p>A. The Silverlight Toolkit for Windows Phone is an open source project hosted at CodePlex. It provides some controls missing from the WP7 SDK such as the wrap panel, list picker, and context menu, to name a few. It saved me a lot of time during development. Telerik also has a set of controls for WP7 that provides these controls as well (<a href="http://www.telerik.com/products/windows-phone.aspx" target="_blank">free download available here</a>).</p> <p><strong>Q5. Have you faced any performance challenges with WHS Phone? Was it hard to optimize your app so it may run smooth on the device?</strong></p> <p>A. One performance issue that I came across in WHS Phone is a listbox with a couple hundred items in it that uses images in the data template. It is fine with static images, but the photo browser in WHS Phone displays thumbnails. I found that making a call to return the list of photos and then use a background thread to get the thumbnails worked well. I also only load the thumbnails that are visible to lower the amount of data transferred.</p> <p><strong>Q6. What is the target audience of WHS Phone?</strong></p> <p>A. The target audience is anyone who has access to a Windows Home Server. It is not just for administrators of the Home Server. You can configure the permissions for each user on the server through the WHS Phone add in. For instance, my wife can stream music and access photos, but I have the server management features turned off for her account. She loves it.</p> <p>                                                    <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/UserPermissionsScreenshot.png"><img width="144" height="240" title="UserPermissionsScreenshot" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="UserPermissionsScreenshot" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/UserPermissionsScreenshot_thumb.png" /></a>                          <a href="http://www.silverlightshow.net/Storage/Users/SilverlightShow/UserScreenshot.png"><img width="144" height="240" title="UserScreenshot" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;border: 0px;" alt="UserScreenshot" src="http://www.silverlightshow.net/Storage/Users/SilverlightShow/UserScreenshot_thumb.png" /></a></p> <p><strong>Q7. Technologically speaking, how do you enable music streaming directly from your server to the phone?</strong></p> <p>A. Music Streaming was a challenge, but is not something I would like to disclose at this time. :)</p> <p><strong>Q8. What other ideas for next WP7 applications do you have? </strong></p> <p>A. A friend and I have a prototype application that brings WHS Phone functionality to Windows 7.</p> <p><strong>Q9. How do you see the future of WP7, and applications for WP7?</strong></p> <p>A. WP7 is a very promising platform. I hear a lot of people say that it is too late in the game to release a new phone operating system. I say why? Is “the phone” going away and Microsoft does not have enough time to catch and surpass the Android and IPhone market? Of course not. Only time will tell the impact of Windows Phone 7. I would have liked to have seen it release a year or two ago, but think about the integration features of WP7. It connects to xBox Live, Skydrive, Zune, integrates SharePoin, has a Silverlight front end, and runs the full XNA 4.0 framework. It wasn’t just a matter of building a new operating system. Microsoft had to improve all of these technologies so they could integrate into the operating system. After using my WP7 for a couple weeks now I think it is a winner. I have had a number of loyal IPhone and Android users ask to see my phone and immediately say “Wow, that’s fast and smooth, does my carrier have phones with WP7?”</p> <p>As for application development, Microsoft knows how to produce good developer tools. WP7 development is a dream compared to IPhone and Android development. The WP7 emulator is fast and debugging directly on the phone is very easy. Since Microsoft is requiring minimum phone hardware specs and are controlling OS updates I think we will have to deal with far less fragmentation than Android developers. Building a game that can be run on WP7, xBox, and Windows is very compelling. It really is an enjoyable and powerful platform to develop for.</p> <p><strong>Q10. What is your opinion on the recent announcement by Microsoft on the future of Silverlight and HTML5?</strong></p> <p>A. I know my view might not be what your typical reader wants to here, but I am an ASP.NET developer, sorry.</p> <p>My initial reaction was shock. Silverlight has had good market penetration and a lot of big companies, such as Netflix, use it. But, after the announcement sunk in, I have to say I agree with Microsoft’s choice to back HTML 5. As an ASP.NET developer I look forward to working with HTML 5. Have you seen the hardware accelerated HTML capabilities of IE 9? I feel it is a step in the right direction and I applaud Microsoft for their decision to back an open standard over their own product. That said, I do not think it is the end of Silverlight. It is just too good of a product to let it just go away.</p> <p><strong>Thanks, Paul, for your accurate answers. Looking forward to your new projects.</strong></p> <p><strong>More information about this application can be found at <a href="http://www.whsphone.com/" target="_blank">http://www.whsphone.com/</a></strong></p> http://www.silverlightshow.net/items/Paul-Juenger-on-WHS-Phone-WP7-Application.aspx editorial@silverlightshow.net (Silverlight Show ) http://www.silverlightshow.net/items/Paul-Juenger-on-WHS-Phone-WP7-Application.aspx#comments http://www.silverlightshow.net/items/Paul-Juenger-on-WHS-Phone-WP7-Application.aspx Tue, 30 Nov 2010 00:00:00 GMT René Schulte on Pictures Lab WP7 Application <div style="border:1px solid #dddddd;padding-bottom: 5px; background-color: #f3f3f3; margin-top: 5px; padding-left: 10px; width: 200px; float: right; margin-left: 10px; padding-top: 5px;"> <h3>More on this topic..</h3> <ul style="list-style-type: circle; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 20px; font-size: 12px;"> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-Stock-Quoting-Demo-Series-Part1.aspx">WP7 Stock Quoting Demo series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-What-is-Windows-Phone-7.aspx">What is Windows Phone series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/Gergely-Orosz-on-Cocktail-Flow-WP7-application.aspx">Cocktail Flow WP7 application</a> </li> </ul> </div> <p><strong></strong></p> <p><em>While picking the WP7 apps to feature on SilverlightShow, PicturesLab impressed us with the host of advanced effects one may apply to the images on his phone. We meet René Schulte to find out more on the full set of functionalities packed in this application, and the challenges faced while developing it.</em></p> <p><strong>Q1. René - Please introduce yourself briefly and tell us more about the application you created - what are the key functionalities, major differences from other similar applications on the market, why do you think people would want to install this app on their WP7? <br /> <br /> </strong>A. I’m a .Net, Silverlight and Windows Phone developer and Microsoft <a href="http://mvp.support.microsoft.com/profile/Rene.Schulte">Silverlight MVP</a> passionate about real-time computer graphics, physics, AI, and algorithms. I love C#, Shaders, Augmented Reality, and computer vision. I started the <a href="http://slartoolkit.codeplex.com/">SLARToolkit</a>, the <a href="http://writeablebitmapex.codeplex.com/">WriteableBitmapEx</a>, and the <a href="http://matrix3dex.codeplex.com/">Matrix3DEx</a> Silverlight open source projects, and I have a <a href="http://rene-schulte.info/">Silverlight website</a> powered by real time soft body physics. I’m also a regular author for various magazines and Microsoft's Coding4Fun. Contact information can be found on my <a href="http://rene-schulte.info/">Silverlight website</a>, my <a href="http://blog.rene-schulte.info/">blog</a>, or via <a href="http://twitter.com/rschu">Twitter</a>.</p> <p>My main Windows Phone app is called Pictures Lab and is meant to be the ultimate picture effects application for Windows Phone. If you like to take photos then this app is a perfect addition to your phone’s toolset. Or like msnbc.com wrote: "The app, a Swiss Army knife of photo tweaks". <br /> <br /> Pictures Lab comes with more than 20 controllable and easy-to-use advanced effects like different vintage and hipster-like effects, Tilt Shift (miniature faking), Lomo, Soften, Auto Adjust, Sharpen, Comic, Bulge, B& W, Sepia and many more. Dynamic previews of the effects are shown in a list, making it possible to easily pick the right one. It is also possible to crop and rotate images. An enhanced picture can be saved to the phone’s pictures hub. The app performs the image processing on the original picture in its original resolution, thus making it also possible to print the image or use it as desktop wallpaper. </p> <div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:d3ee50c9-46b9-4b4d-8f1d-de8ceddbfe39" style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;"> <div id="ae125ebc-c873-4678-ab5b-c89f49cc6569" style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;"> <div><embed width="425" height="355" src="http://www.youtube.com/v/QXwMdaiu9DI&hl=en" type="application/x-shockwave-flash"></embed></div> </div> </div> <p><strong>The complete feature list:</strong></p> <ul> <li>21 advanced effects: Seven different vintage and hipster-like effects, Tilt Shift (miniature faking), Lomo, Soften, Auto Adjust, Sharpen, Comic, Bulge, B& W, Sepia, Saturate, Edge Detection, Night Vision, Negative and Bitmap. </li> <li>Editable effect parameters with ready-to-use default values. </li> <li>Crop and rotate. </li> <li>Multi-touch manipulation for Tilt Shift and other effects where multi-touch is meaningful. </li> <li>The app can save edited pictures with advanced effects applied in full resolution even on a device with 256 MB RAM. Thus making it also possible to print the image or use it as desktop wallpaper </li> <li>Full Pictures Hub Extras integration. </li> <li>The trial version includes the complete functionality and all the effects, only the save functionality is disabled. </li> <li>Support for landscape and portrait orientation. </li> <li>Effect list with dynamic previews and caching of the larger previews. </li> <li>Flicking through the effects on the main page. </li> <li>State preservation when the app is deactivated (tombstoning). </li> <li>Localization for English and German. </li> </ul> <p><strong>Q2. What was the motivation behind creating this application? How did you get the idea? <br /> <br /> </strong>A. It started with an article series for Coding4Fun about a picture effects application for Windows Phone. The Coding4Fun version was released for free on the Marketplace and is open source! I continued my work on this project, enhanced the effects and added more features and many more effects. <br /> <br /> <strong>Q3. What were the main challenges you faced when moving from Silverlight in/out of the browser to the phone environment? <br /> <br /> </strong>A. The limited resources. Processing pictures with advanced image effects at full resolution needs a lot of memory and CPU. </p> <p><a href="http://www.silverlightshow.net/Storage/Users/chiara/plab1.png"><img width="148" height="244" title="plab1" style="border:0px;display: inline;" alt="plab1" src="http://www.silverlightshow.net/Storage/Users/chiara/plab1_thumb.png" /></a>       <a href="http://www.silverlightshow.net/Storage/Users/chiara/plab2_2.png"><img width="161" height="244" title="plab2" style="border:0px;display: inline;" alt="plab2" src="http://www.silverlightshow.net/Storage/Users/chiara/plab2_thumb.png" /></a>       <a href="http://www.silverlightshow.net/Storage/Users/chiara/plab5.png"><img width="244" height="147" title="plab5" style="border:0px;display: inline;" alt="plab5" src="http://www.silverlightshow.net/Storage/Users/chiara/plab5_thumb.png" /></a> <br />   <br /> <strong>Q4. Have you faced any performance challenges with PicturesLab? Was it hard to optimize your app so it may run smooth on the device? <br /> <br /> </strong>A. Yes, the hardest challenge was to keep the memory consumption below the Windows Phone limit of 90 MB. I also did a lot of optimization to make the processing as fast as possible. </p> <p><strong>Q5. Have you already made profit from this application? Do you see WP7 as a good platform for making money out of it? <br /> </strong><br /> A. Microsoft doesn’t provide any statistics until February 2011. The first payout is also scheduled for February 2011. Many developers are not happy about this lack of essential statistics and we brought this to the attention of the right people several times. <br /> The first batch of phones was sold out at many shops. This is promising and I hope the demand will continue. I think it’s possible to make a good amount of money with Windows Phone apps. You only need a good idea and good developer and designer skills. <br /> <br /> <strong>Q6. How do you see the future of WP7, and applications for WP7? <br /> <br /> </strong>A. I will continue my work with the platform and develop more applications. I wouldn’t do this if I had no trust in the success. Many blogs and advisory firms also see a bright future and estimate a growing market share in the next years. <br /> <br /> <strong>Q7. What other ideas for next WP7 applications do you have? <br /> <br /> </strong>A. Expect more features for Pictures Lab, like borders, frames, more effects and many more features. I will also develop another fun photo app and as soon as real-time camera access is available I’ll provide a version of my Augmented Reality library SLARToolkit. <br /> <br /> <strong>Q8. What is your opinion on the recent announcement by Microsoft on the future of Silverlight and HTML5? <br /> <br /> </strong>A. Silverlight is not dead and Microsoft is continuing the investment in Silverlight, not only for WP7 development. Silverlight will be the right choice for rich apps in the future, HTML5 for cross platform, non-rich apps. <br /> Microsoft is hosting the Silverlight Firestarter event on 2<sup>nd</sup> December 2010. Scott Guthrie will be presenting the “Future of Silverlight” in his keynote. It’s streamed live and a must see if you’re interested in Silverlight’s future <a href="http://www.silverlight.net/news/events/firestarter/">http://www.silverlight.net/news/events/firestarter/</a> <br /> <br /> <em>Thanks, René, for revealing more on PcituresLab. We hope to meet again soon to discuss your next WP7 application!</em></p> http://www.silverlightshow.net/items/Ren-Schulte-on-Pictures-Lab-WP7-Application.aspx editorial@silverlightshow.net (Svetla Stoycheva ) http://www.silverlightshow.net/items/Ren-Schulte-on-Pictures-Lab-WP7-Application.aspx#comments http://www.silverlightshow.net/items/Ren-Schulte-on-Pictures-Lab-WP7-Application.aspx Thu, 18 Nov 2010 09:58:00 GMT Garry McGlennon on ezyTip WP7 application <div style="padding-bottom: 5px; background-color: rgb(243,243,243); margin-top: 5px; padding-left: 10px; width: 200px; float: right; margin-left: 10px; padding-top: 5px;border: rgb(221,221,221) 1px solid;"> <h3>More on this topic..</h3> <ul style="list-style-type: circle; margin: 0px; padding-left: 20px; font-size: 12px;"> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-Stock-Quoting-Demo-Series-Part1.aspx">WP7 Stock Quoting Demo series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-What-is-Windows-Phone-7.aspx">What is Windows Phone series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/Ren-Schulte-on-Pictures-Lab-WP7-Application.aspx">Pictures Lab WP7 Application</a> </li> </ul> </div> <p><em>Next in our series of featured WP7 applications comes ezyTip – a very useful application when it comes to paying your restaurant or other bills. We talk to its author Garry McGlennon on why this application is appreciated.</em></p> <p><em></em> </p> <p> </p> <p><a href="http://www.silverlightshow.net/Storage/Users/chiara/Screen2.png"><img width="148" height="244" title="Screen2" style="display: inline; float: right; margin-left: 10px; margin-right: 0px;border: 0px;" alt="Screen2" src="http://www.silverlightshow.net/Storage/Users/chiara/Screen2_thumb.png" /></a> <strong>Q1. Garry - please introduce yourself briefly and tell us more about the application you created - what are the key functionalities, major differences from other similar applications on the market, why do you think people would want to install this app on their WP7? <br /> </strong><br /> A. I’m a senior software developer/consultant, and you’ll typically find me at a Redmond based software company. I run a blog at <a href="http://dotnetprofessional.com/">dotNetProfessional.com</a> and also have a few projects on CodePlex. My main technology interests at the moment are Silverlight, Windows Phone 7 and Windows Azure which together offer a compelling story.</p> <p>The first application I developed (ezyTip) is designed to be a best of breed application. It provides a high quality UI with practically every option you’d want in a tip calculator. The key features include, fast data entry, numerous rounding options including mirror, bill splitting, sales tax support and easy tip percent selection all of which is customizable by the user to provide that personal experience. It also supports emailing the results so you and your guests can remember what was paid.</p> <p>When compared to the plethora of other tip calculators on the marketplace it clearly stands out as the only one of high quality coupled with extensive features. Also at introductory price US$0.99 it’s a bargain.</p> <embed width="425" height="264" src="http://www.youtube.com/v/2wehM5PvpkU?fs=1&hl=en_US&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" /> <p><strong>Q2. What was the motivation behind creating this application? How did you get the idea?</strong><a href="http://www.silverlightshow.net/Storage/Users/chiara/Screen3.png"><img width="148" height="244" title="Screen3" style="display: inline; float: right; margin-left: 10px; margin-right: 0px;border: 0px;" alt="Screen3" src="http://www.silverlightshow.net/Storage/Users/chiara/Screen3_thumb.png" /></a> <br /> <br /> A. As I had already written the application on Windows Mobile 6.5, it was an obvious first choice to port to WP7. The project allowed me to become familiar with the new platform while doing a fairly simple application, though as the end result shows I didn’t make it too simple. <br /> <br /> <strong>Q3. What were the main challenges you faced when moving from Silverlight in/out of the browser to the phone environment? <br /> <br /> </strong>A. I hadn’t done that much work with Silverlight for the Desktop so that wasn’t much of a challenge. The challenge was in learning Blend and the limitations of SL for Windows Phone. <br /> <br /> <strong>Q4. Do you plan to further upgrade this application with additional features? How do you see this application evolve? <br /> <br /> </strong>A. The application is fairly feature complete. The only addition that might be warranted is the ability to do uneven splits. However, if this will be done will really depend on user demand for such a feature.</p> <p><strong>Q5. Have you already made profit from this application? Do you see WP7 as a good platform for making money out of it? <br /> </strong><br /> A. It’s too early to have made any money (we won’t know our sales until next year!). It’s also a little early to know if WP7 is a platform that will make money for developers. However, much like everything else those who take the early risks typically reap the largest rewards. <br /> <br /> <strong>Q6. How do you see the future of WP7, and applications for WP7? <br /> <br /> </strong>A. WP7 definitely has its flaws, however given how far it’s come in 2 years I can only see good things for its future. Microsoft have to invest in this platform and it’s not often MS don’t do well in a market they become serious about. <br /> <br /> <strong>Q7. What other ideas for next WP7 applications do you have? <br /> </strong>A. I am currently working on the next major application, which unlike the ezyTip application will have wide spread appeal. It like ezyTip will take the approach of being best of breed and so I think if you take photos you’ll want to take a serious look at it when it comes out. The initial version is hopefully going to be released by the end of the month or early December. <br /> <br /> <strong>Q8. What is your opinion on the recent announcement by Microsoft on the future of Silverlight and HTML5? <br /> </strong><br /> A. I think it’s all a storm in a tea cup, given HTML 5 is so far from a standard and won’t have nearly the same feature set of SL4/5, let alone decent tooling. However, I do pity those developers who end up writing full applications in JavaScript!</p> <p> </p> <p><em><strong>Thanks Garry! Look forward to talk to you again soon, and discuss your next WP7 masterpiece!</strong></em></p> http://www.silverlightshow.net/items/Garry-McGlennon-on-ezyTip-WP7-application.aspx editorial@silverlightshow.net (Svetla Stoycheva ) http://www.silverlightshow.net/items/Garry-McGlennon-on-ezyTip-WP7-application.aspx#comments http://www.silverlightshow.net/items/Garry-McGlennon-on-ezyTip-WP7-application.aspx Wed, 17 Nov 2010 11:48:00 GMT Gergely Orosz on Cocktail Flow WP7 application <div style="border:1px solid #dddddd;padding-bottom: 5px; background-color: #f3f3f3; margin-top: 5px; padding-left: 10px; width: 200px; float: right; margin-left: 10px; padding-top: 5px;"> <h3>More on this topic..</h3> <ul style="list-style-type: circle; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 20px; font-size: 12px;"> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-Stock-Quoting-Demo-Series-Part1.aspx">WP7 Stock Quoting Demo series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/WP7-What-is-Windows-Phone-7.aspx">What is Windows Phone series</a> </li> <li style="padding-bottom: 5px;"><a href="http://www.silverlightshow.net/items/Garry-McGlennon-on-ezyTip-WP7-application.aspx">ezyTip WP7 application</a> </li> </ul> </div> <p><em>Since the release of Windows Phone 7, a number of applications from WP7 marketplace have been reviewed and discussed. We wanted to pick for you some of the most impressive ones and discuss with their authors what it took them to design and launch an application meeting a lot of UI and performance requirements. <br /> We introduce you now to Gergely Orosz and the application he and his team developed – Cocktail Flow. <br /> </em><br /> <strong>Q1. Gergely – most SilverlightShow readers know you as </strong><a href="http://www.silverlightshow.net/items/Interview-with-SilverlightShow-WP7-Quiz-Third-day-Winner-Gergely-Orosz-gergelyorosz.aspx"><strong>one of the winners</strong></a><strong> in our </strong><a href="http://www.silverlightshow.net/news/SilverlightShow-Windows-Phone-7-Daily-Quiz-Win-an-MSDN-Subscription-Every-Day.aspx"><strong>WP7 quiz</strong></a><strong>. We are glad that we meet you again to discuss a very curious WP7 application you developed – Cocktail Flow. Please tell us more about it - what are the key functionalities, major differences from other similar applications on the market, why do you think people would want to install this app on their WP7? <br /> <br /> </strong>A. <a href="http://cocktailflow.com/">Cocktail Flow</a> is probably one of the slickest and feature rich mobile cocktail applications on any platform and <a href="http://www.bing.com/visualsearch?g=wp7&qpvt=Windows+Phone+7+Apps&FORM=Z9GE#toc=0&s=2">is currently the 2<sup>nd</sup> highest rated</a> application on the Windows Phone marketplace. Its visuals immediately set it apart from all competitors and it’s useful features – like selecting ingredients from the home cabinet and shopping recommendations with price estimation – make it a very handy and useful application. If you’re interested in cocktails even a little, this is a definite must have application on your phone.</p> <div class="wlWriterEditableSmartContent" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:99ff4f7a-3927-4f33-ac80-3076052d8d2f" style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;"> <div id="0ac56aab-d9a9-4e01-91b6-79f6dfb6e672" style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;"> <div><embed width="425" height="355" src="http://www.youtube.com/v/Qghf4e2n0Yc&hl=en" type="application/x-shockwave-flash"></embed></div> </div> </div> <p>  <br /> <strong>Q2. What was the motivation behind creating this application? How did you get the idea? <br /> <br /> </strong>A. I’ve previously built a small, Flash based cocktail site that has been getting great feedback, but could never attract a significant number of visitors. I’ve been planning on porting the concept to mobile, however saw the iPhone market overcrowded and the Android platform fragmented – I wasn’t sure if developing for either would pay off. Windows Phone 7, however seemed like a great choice to do a simple port for – the marketplace is not yet overcrowded and developing for the platform is possibly the easiest for all.</p> <p>After starting work on the prototype with some of my friends at <a href="http://teamdistinction.com/">Distinction</a>, we’ve realized that we are able to create a much better user interface than we originally thought. Originally we only aimed to create a cocktail application providing a comparable user experience as on the iPhone or perhaps Android, however after numerous iterations we were confident to aim for possibly the best mobile experience among all cocktail mobile applications – a goal which – based on the positive feedback we-re getting - I think we’ve managed to achieve.</p> <p><strong>Q3. What were the main challenges you faced when moving from Silverlight in/out of the browser to the phone environment? <br /> <a href="http://www.silverlightshow.net/Storage/Users/chiara/cabinet_2.jpg"><img width="604" height="316" title="cabinet" style="border:0px;display: inline;" alt="cabinet" src="http://www.silverlightshow.net/Storage/Users/chiara/cabinet_thumb.jpg" /></a> <br />   <br /> </strong>A. We’ve done a great deal of research and prototyping on how to fit in to the Windows Phone 7 user experience in a native way, how to make the application really “Metro”. Some official guideline documents are available on this topic, however it took us a considerable effort to work out an interface that felt truly “Metro” while not giving up our application theme. We found that user interfaces that look good in the browser had to be completely rethought and iPhone user interfaces also didn’t feel right on WP7 – we had to come up with an original and new design which was much more work than we expected. <br />   <br /> <strong>Q4. Have you faced any performance challenges with your application? Was it hard to optimize your app so it may run smooth on the device? <br /> <br /> </strong>A. We weren’t lucky enough to secure a developer device prior to launch, so we were only able to test the application three times (mostly on Microsoft events) before releasing to the marketplace. The first time we did, the results were quite shocking: performance on the emulator is much better than on the device. Most of our performance issues have been with the Silverlight ListBox on WP7 being quite inefficient – we’ve tried all of the suggested performance improvements, but finally settled on implementing paging within the list for decent speed. Our application also uses lots of images, so we’ve had to spend a lot of time making sure images loaded in a lazy way and stayed in memory afterwards.</p> <p><strong>Q5. Your application features an impressive interface - in terms of both colors and imagery. How did you decide to go for it, does the interface contribute to the success of the application?</strong></p> <p><strong><a href="http://www.silverlightshow.net/Storage/Users/chiara/cocktails_2.jpg"><img width="604" height="254" title="cocktails" style="border:0px;display: inline;" alt="cocktails" src="http://www.silverlightshow.net/Storage/Users/chiara/cocktails_thumb.jpg" /></a> <br /> <br /> </strong>A. Most of the people who look at the application compliment the interface, which we worked a lot on to make it as slick and as “Metro” as possible. We’ve worked with a great designer at Distinction who’s influenced the final design a lot, as well as the numerous design iterations we’ve gone through. However I think the real value of the application is that apart from the impressive presentation is that its actually really feature rich and the features integrate nicely in the interface.</p> <p><strong>Q6. How do you see the future of WP7, and applications for WP7? <br /> <br /> </strong>A. Before the launch on various talks (like <a href="http://gregdoesit.com/2010/09/why-you-should-get-started-with-wp7-development/">TechMeetup</a> and <a href="http://gregdoesit.com/2010/10/slides-code-and-additional-resources-to-the-talk-developing-for-windows-phone-7/">Alt.Net</a>) I’ve expressed that I believe in a few years’ time the smartphone market will be dominated by iPhone, Android and Windows Phone 7. I think at that time mobile application developers will almost exclusively be focusing on these platforms. Having experienced the new phone myself I think this is still the case – which is great potential for developers targeting Windows Phone 7 as it’s really easy to gain visibility in the marketplace right now, which is huge potential on the long run. <br /> <br /> <strong>Q7. What is your opinion on the recent announcement by Microsoft on the future of Silverlight and HTML5? <br /> <br /> </strong>A. As my day job I work at a UK based financial consultancy, Scott Logic, where we’re delivering business solutions to the financial sector. We’re seeing a lot of growth in the need for Silverlight and WPF development, while currently no demand for HTML5. An important part of this is that Silverlight code written to run in browsers can be easily ported to the desktop – and with Windows Phone 7 – to mobile as well (see the <a href="http://www.scottlogic.co.uk/blog/colin/2010/10/white-paper-silverlight-wpf-and-windows-phone-7-cross-platform-development/">white paper of my colleague</a> on this). I think Silverlight will have an even more important role in cross platform (web, mobile and desktop) application development, while HTML5 will mostly be used for web and mobile content presentation, but not complex applications. </p> http://www.silverlightshow.net/items/Gergely-Orosz-on-Cocktail-Flow-WP7-application.aspx editorial@silverlightshow.net (Svetla Stoycheva ) http://www.silverlightshow.net/items/Gergely-Orosz-on-Cocktail-Flow-WP7-application.aspx#comments http://www.silverlightshow.net/items/Gergely-Orosz-on-Cocktail-Flow-WP7-application.aspx Wed, 17 Nov 2010 11:04:00 GMT Case Study: SilverlightShow Showcase <p>Since recently, SilverlightShow has a <a href="http://www.silverlightshow.net/Showcase.aspx">brand new Showcase section</a>, with a much better, more intuitive interface to review all showcases featured on the website.</p> <p>What did it take to redesign this section? What problems and issues had to be resolved, or have yet to be dealt with? We find this out in a case study submitted by one of <a href="http://www.completit.com/">CompletIT</a> Senior Silverlight developers Nikolay Raychev. Nikolay has been responsible for the server-side development, integration with Silverlight solutions and SEO of the 2 main company websites - <a href="http://www.completit.com/">www.completit.com</a> and <a href="http://www.silverlightshow.net/">www.silverlightshow.net</a>. Due to his huge Silverlight experience he was assigned the development of the entire Showcase section.</p> <h4> </h4> <h4>Project Overview</h4> <p><strong>1. Describe what the project is about - goals, target users, key functionalities</strong></p> <p>The main goal of the project was to replace the old (and also old-fashioned) showcase section of SilverlightShow with something new, interactive and easy to use. After the showcase page has loaded, all images had to be visible at once so the user could see all of them without going through pages, etc. The whole composition had to be zoomable, and also draggable, so the user could look at the items when the scene was zoomed in. A tooltip had to be displayed telling the user what’s the current item about. A dialog window had to show detailed information. </p> <p>An important requirement was that the gallery had to support ordering by month so the user could see the latest items right away, as well as be able to browse through the items submitted earlier. The project had to be integrated in SilverlightShow using the existing data. The items had to open their old URLs so we wouldn’t lose the search engine indexation.</p> <p><strong>2. Did you have any limitations set - technologies to be used, time, resources, etc?</strong></p> <p>Since <a href="http://www.completit.com/">CompletIT</a> is company is focused on delivering Silverlight solutions, and SilverlightShow is entirely dedicated to this technology there was no other choice but develop the module entirely in Silverlight. The timeframe was tight, not just because we are looking to expedite the redesign of SilverlightShow, but also because I had proposed to develop this project for my master’s thesis, and I had specific time constraints for that. Of course this required preparing tons of documentation to accompany the project, but it was definitely worth the efforts - I know that other university students, in addition to SilverlightShow visitors, will be able to learn from my experience. </p> <p><strong>3. What Silverlight features were used in this project? <br />  </strong></p> <ul> <li>Animations: <ul> <li>Build-in animations API based on Storyboards </li> <li>Expression Blend 4 FluidMoveBehavior </li> </ul> </li> <li>ZoomablePanel and ZoomController – custom controls previously developed for our <a href="http://www.silverlightshow.net/Books.aspx">Book Shelf</a> </li> <li>RatingControl - custom control previously developed for our Book Shelf </li> <li>EllipsePanel – custom control developed for the current project </li> <li>Other custom controls and templates </li> <li>Third-party Silverlight controls (Telerik RadWindow, ComponentOne RichTextBox, Toolkit ActivityControl </li> <li>Render Transforms API: <ul> <li>ScaleTransform </li> <li>TranslateTransform </li> </ul> </li> <li>DispatcherTimer </li> <li>Mouse events API </li> <li>VisualTreeHelper </li> <li>3D Projection API </li> <li>HTML Page API </li> <li>MVVM </li> <li>Prism </li> <li>WCF - Silverlight enabled services  </li> </ul> <p><strong>4. Project snapshots before / after</strong></p> <p><strong>Before:</strong></p> <p><a href="http://www.silverlightshow.net/Storage/Users/chiara/Before_1_2.jpg"><img width="244" height="229" title="Before_1" style="display: inline;border: 0px;" alt="Before_1" src="http://www.silverlightshow.net/Storage/Users/chiara/Before_1_thumb.jpg" /></a> </p> <p><strong>After:</strong></p> <p><a href="http://www.silverlightshow.net/Storage/Users/chiara/After_1_2.jpg"><img width="244" height="162" title="After_1" style="display: inline;border: 0px;" alt="After_1" src="http://www.silverlightshow.net/Storage/Users/chiara/After_1_thumb.jpg" /></a>   <a href="http://www.silverlightshow.net/Storage/Users/chiara/After_2_2.jpg"><img width="244" height="122" title="After_2" style="display: inline;border: 0px;" alt="After_2" src="http://www.silverlightshow.net/Storage/Users/chiara/After_2_thumb.jpg" /></a>    <a href="http://www.silverlightshow.net/Storage/Users/chiara/After_3_2.jpg"><img width="244" height="173" title="After_3" style="display: inline;border: 0px;" alt="After_3" src="http://www.silverlightshow.net/Storage/Users/chiara/After_3_thumb.jpg" /></a> </p> <p><b></b></p> <h4>Problem and Solution Insight</h4> <p><strong>1. What were the pros and cons for using Silverlight to achieve those goals?</strong></p> <p>The main advantages of using Silverlight were:</p> <ul> <li>Using the same business objects as were used in the server part </li> <li>Easy consuming of the WCF services </li> <li>Easy creation of animations using storyboards. Using Expression Blend FluidMoveBehavior for animating movement of objects from one list to another </li> <li>Data Binding.<b></b> </li> </ul> <p><strong>2. What were the major Silverlight-related problems faced during development?</strong></p> <p>In accordance with the provided design initially the items had to fill an ellipse and after clicking a button they had to order by month.</p> <p><b>One of the problems was “How to make the items order as a filled ellipse?”</b></p> <p>Together with Emil Stoychev we decided to make a custom layout control derived from Panel. At first I was thinking to start building the ellipse from the center when one of our colleagues – Bogdana Rakova came with the idea that the items can be divided into groups, for every group there would be columns and every column would have more items compared to the previous and the difference is n. This number n is different for the different groups and is decreasing for every next group. Finally the number n reaches 0. It’s enough to build half of the ellipse and you can mirror the rest. It’s good to work in such a smart team :) Colleagues are giving these clever ideas exactly when you need them. So I started developing the algorithm. It wasn’t so complex but wasn’t something you can build and test in a day or two. Finally a custom control called EllipsePanel was created.</p> <p><b>Another problem was how to make items go smoothly to their positions ordered by month.</b> </p> <p>Here the Behaviors in Blend 4 came to use. I watched a <a href="http://live.visitmix.com/MIX10/Sessions/CL55">video with Kenny Young at MIX</a> who was showing how to use them. So I came with the solution with two ItemsControls. The first is making use of the EllipsePanel as an ItemsPanel in order to arrange the items as ellipse. The second one is using a StackPanel for the ordering by months and a second ItemsControl in its ItemTemplate for the ordering of items for every month. The real objects are moved from one list to another list structure in the ViewModel and the FluidMoveBehavior is making the visual part.</p> <h4> </h4> <h4>Conclusion</h4> <p><strong>Were the initially set goals achieved, within the expected resources? What else has left to be improved?</strong> </p> <p>We think that we managed to achieve the initial goals of the project, but there are still some issues to work on.</p> <ul> <li>The initial load time should be improved. Now the application is waiting not just for the results from the service, but also for every image to load. We discussed to initially display a “Loading” image for every item until that item’s image loaded. We’ll further work on this. </li> <li>The ellipse algorithm isn’t perfect so the width/height ratio of the ellipse varies depending of the number of items. This is also something we’ll be working to improve. </li> </ul> <p>Of course, we’ll keep working to further improve and enhance this Showcase application, and for that we would surely count on the feedback of SilverlightShow users too!</p> http://www.silverlightshow.net/items/Case-Study-SilverlightShow-Showcase.aspx editorial@silverlightshow.net (Svetla Stoycheva ) http://www.silverlightshow.net/items/Case-Study-SilverlightShow-Showcase.aspx#comments http://www.silverlightshow.net/items/Case-Study-SilverlightShow-Showcase.aspx Fri, 30 Jul 2010 02:37:00 GMT Animated navigation between Pages <p><em><span style="line-height: 115%; font-family: calibri, sans-serif; font-size: 11pt;">This article is compatible with the latest version of Silverlight.</span></em></p> <p><strong>This is part</strong><strong> 8</strong><strong> </strong><strong>of the series “Silverlight in Action”</strong></p> <p><strong>Here, we’re sharing our experience from the amazing</strong><strong> </strong><strong><a href="http://www.completit.com/" target="_blank">CompletIT</a> web site.</strong></p> <h3>Introduction</h3> <p>In this session, we will cover one quite popular, but still very useful, technique for adding interaction to your web-site - "<em>How to enable animations between pages using the Silverlight Navigation Framework</em>". So, whenever we navigate to a page using HyperlinkButton, Browser history, Back / Forward browser buttons or just navigate to a deep-link, we'll be able to run animation between the content of the pages. This technique is very useful for both - Line Of Business (LoB) Applications and Rich Internet Applications (RIA). It also gives a lot of interactivity and enhance the overall User Experience of the web-site.</p> <p>Plenty of different animations can be defined between the pages content. And here is one example of an animated transition between two pages.</p> A snapshot of the transition between <em>Contacts</em> page and <em>Services</em> page. <h4><a href="http://www.silverlightshow.net/Storage/Users/miromiroslavov/AnimationBetweenPages_2.png"><img width="754" height="357" title="AnimationBetweenPages" style="display: inline;border: 0px;" alt="AnimationBetweenPages" src="http://www.silverlightshow.net/Storage/Users/miromiroslavov/AnimationBetweenPages_thumb.png" /></a> </h4> <h4>Try a simple transition between <em>The ThreeDWorld</em> page and <em>The Book Folding Effect</em></h4> <h5>Just click on the hyperlinks or navigate back / forward.</h5> <p><object width="750" height="500" data="data:application/x-silverlight-2," type="application/x-silverlight-2" autoupdate="true"> <param name="source" value="http://www.silverlightshow.net/Storage/demos/TransitionFrame.xap"/> <param name="minRuntimeVersion" value="4.0.41108.0"/> <param name="background" value="White"/> <param name="autoUpgrade" value="true"/> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.41108.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"> </a> </object></p> <h3>Implementation</h3> <p>The idea is pretty simple: in order to have animation between two contents, we need to have them both live before the whole transition finishes.</p> <p>First, let’s start with inheriting from the <strong>Frame</strong> class and let’s name it TransitioningFrame. The Frame class is a simple ContentControl with enabled some Navigation features. And as a normal ContentControl, when the user navigates to another page (changes the Content), the old content will be thrown away (and that is what we need to workaround). We’ll do this with having two ContentPresenters in the ControlTemplate of the TransitioningFrame class. This idea is vey common and broadly used, for example, in the <a href="http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html">toolkit’s</a> TransitionContentControl.</p> <h5>The TransitioningFrame class</h5> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> TransitioningFrame : Frame</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #0000ff;">private</span> ContentPresenter currentContentPresentationSite;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #0000ff;">private</span> ContentPresenter previousContentPresentationSite;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> TransitioningFrame()</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> DefaultStyleKey = <span style="color: #0000ff;">typeof</span>(TransitioningFrame);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span> OnApplyTemplate()</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> <span style="color: #0000ff;">base</span>.OnApplyTemplate();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> previousContentPresentationSite = GetTemplateChild(<span style="color: #006080;">"PreviousContentPresentationSite"</span>) <span style="color: #0000ff;">as</span> ContentPresenter;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> currentContentPresentationSite = GetTemplateChild(<span style="color: #006080;">"CurrentContentPresentationSite"</span>) <span style="color: #0000ff;">as</span> ContentPresenter;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (currentContentPresentationSite != <span style="color: #0000ff;">null</span>)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> currentContentPresentationSite.Content = Content;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span> OnContentChanged(<span style="color: #0000ff;">object</span> oldContent, <span style="color: #0000ff;">object</span> newContent)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> <span style="color: #0000ff;">base</span>.OnContentChanged(oldContent, newContent);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> ((currentContentPresentationSite != <span style="color: #0000ff;">null</span>) && (previousContentPresentationSite != <span style="color: #0000ff;">null</span>))</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span> currentContentPresentationSite.Content = newContent;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> previousContentPresentationSite.Content = oldContent;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span> VisualStateManager.GoToState(<span style="color: #0000ff;">this</span>, <span style="color: #006080;">"Normal"</span>, <span style="color: #0000ff;">false</span>);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span> VisualStateManager.GoToState(<span style="color: #0000ff;">this</span>, <span style="color: #006080;">"Transition"</span>, <span style="color: #0000ff;">true</span>);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <p>The trick is to run an animation (go to “transition” state) when the content is changed.</p> <h5>The TransitioningFrame ControlTemplate</h5> <p>The control template is also very straight forward. It will keep the two content presenters and will also define the transition animations. We will use VisualStateManager for dealing with the animations. And let’s define two states:</p> <ul> <li><strong><em>Transition</em> </strong>state - run the animation between pages. (You will need to change this in order to make custom animations) </li> <li><strong><em>Normal</em></strong> state - enables the control to go back to Transition state, when needed. </li> </ul> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;"><</span><span style="color: #800000;">ControlTemplate</span> <span style="color: #ff0000;">TargetType</span><span style="color: #0000ff;">="TransitionFrame:TransitioningFrame"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Border</span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #0000ff;">="{TemplateBinding HorizontalContentAlignment}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="{TemplateBinding VerticalContentAlignment}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="{TemplateBinding Background}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #ff0000;">BorderBrush</span><span style="color: #0000ff;">="{TemplateBinding BorderBrush}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> <span style="color: #ff0000;">BorderThickness</span><span style="color: #0000ff;">="{TemplateBinding BorderThickness}"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">VisualStateManager.VisualStateGroups</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">VisualStateGroup</span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="PresentationStates"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">VisualState</span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="Normal"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">VisualState</span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="Transition"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Storyboard</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ObjectAnimationUsingKeyFrames</span> <span style="color: #ff0000;">BeginTime</span><span style="color: #0000ff;">="00:00:00"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetName</span><span style="color: #0000ff;">="PreviousContentPresentationSite"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetProperty</span><span style="color: #0000ff;">="(UIElement.Visibility)"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DiscreteObjectKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:00"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DiscreteObjectKeyFrame.Value</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Visibility</span><span style="color: #0000ff;">></span>Visible<span style="color: #0000ff;"></</span><span style="color: #800000;">Visibility</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">DiscreteObjectKeyFrame.Value</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">DiscreteObjectKeyFrame</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DiscreteObjectKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:01.300"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DiscreteObjectKeyFrame.Value</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Visibility</span><span style="color: #0000ff;">></span>Collapsed<span style="color: #0000ff;"></</span><span style="color: #800000;">Visibility</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">DiscreteObjectKeyFrame.Value</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">DiscreteObjectKeyFrame</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">ObjectAnimationUsingKeyFrames</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DoubleAnimationUsingKeyFrames</span> <span style="color: #ff0000;">BeginTime</span><span style="color: #0000ff;">="00:00:00"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetName</span><span style="color: #0000ff;">="CurrentContentPresentationSite"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetProperty</span><span style="color: #0000ff;">="(UIElement.Opacity)"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">SplineDoubleKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:00"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="0"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">SplineDoubleKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:00.300"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="1"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">DoubleAnimationUsingKeyFrames</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DoubleAnimationUsingKeyFrames</span> <span style="color: #ff0000;">BeginTime</span><span style="color: #0000ff;">="00:00:00"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetName</span><span style="color: #0000ff;">="CurrentContentPresentationSite"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetProperty</span><span style="color: #0000ff;">="(UIElement.RenderTransform).(CompositeTransform.TranslateX)"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum38" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">SplineDoubleKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:00"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum39" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="100"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum40" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">SplineDoubleKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:00.300"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum41" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="0"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum42" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">DoubleAnimationUsingKeyFrames</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum43" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum44" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DoubleAnimationUsingKeyFrames</span> <span style="color: #ff0000;">BeginTime</span><span style="color: #0000ff;">="00:00:00"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum45" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetName</span><span style="color: #0000ff;">="PreviousContentPresentationSite"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum46" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetProperty</span><span style="color: #0000ff;">="(UIElement.Opacity)"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum47" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">SplineDoubleKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:00"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum48" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="1"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum49" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">SplineDoubleKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:00.300"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum50" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="0"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum51" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">DoubleAnimationUsingKeyFrames</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum52" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum53" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DoubleAnimationUsingKeyFrames</span> <span style="color: #ff0000;">BeginTime</span><span style="color: #0000ff;">="00:00:00"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum54" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetName</span><span style="color: #0000ff;">="PreviousContentPresentationSite"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum55" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetProperty</span><span style="color: #0000ff;">="(UIElement.RenderTransform).(CompositeTransform.TranslateX)"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum56" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">SplineDoubleKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:00"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum57" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="0"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum58" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">SplineDoubleKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:00.300"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum59" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="-100"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum60" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">DoubleAnimationUsingKeyFrames</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum61" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Storyboard</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum62" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">VisualState</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum63" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">VisualStateGroup</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum64" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">VisualStateManager.VisualStateGroups</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum65" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Grid</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum66" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentPresenter</span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="PreviousContentPresentationSite"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum67" style="color: #606060;"> </span> <span style="color: #ff0000;">Content</span><span style="color: #0000ff;">="{x:Null}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum68" style="color: #606060;"> </span> <span style="color: #ff0000;">ContentTemplate</span><span style="color: #0000ff;">="{TemplateBinding ContentTemplate}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum69" style="color: #606060;"> </span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #0000ff;">="{TemplateBinding HorizontalContentAlignment}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum70" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="{TemplateBinding VerticalContentAlignment}"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum71" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentPresenter.RenderTransform</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum72" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">CompositeTransform</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum73" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">ContentPresenter.RenderTransform</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum74" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">ContentPresenter</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum75" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentPresenter</span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="CurrentContentPresentationSite"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum76" style="color: #606060;"> </span> <span style="color: #ff0000;">Content</span><span style="color: #0000ff;">="{x:Null}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum77" style="color: #606060;"> </span> <span style="color: #ff0000;">ContentTemplate</span><span style="color: #0000ff;">="{TemplateBinding ContentTemplate}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum78" style="color: #606060;"> </span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #0000ff;">="{TemplateBinding HorizontalContentAlignment}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum79" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="{TemplateBinding VerticalContentAlignment}"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum80" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentPresenter.RenderTransform</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum81" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">CompositeTransform</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum82" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">ContentPresenter.RenderTransform</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum83" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">ContentPresenter</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum84" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Grid</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum85" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Border</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum86" style="color: #606060;"> </span><span style="color: #0000ff;"></</span><span style="color: #800000;">ControlTemplate</span><span style="color: #0000ff;">></span></pre> <!--CRLF--></div> </div> <h3>Conclusion</h3> <p>Animations are one of the very powerful tools, provided by the Silverlight engine. And it’s great that we can use them to animate the transition between pages. This can give our web-site, so much interactivity, richness and good impressions. The good news is that is as easy as creating a custom animation and add it to Transition state of TransitioningFrame template.</p> <h3><a href="http://www.silverlightshow.net/Storage/Sources/TransitionFrame.zip">Download the code</a></h3> <p>Stay tuned for more articles from this series coming up next week.</p> http://www.silverlightshow.net/items/Animated-navigation-between-Pages.aspx editorial@silverlightshow.net (Miroslav Miroslavov ) http://www.silverlightshow.net/items/Animated-navigation-between-Pages.aspx#comments http://www.silverlightshow.net/items/Animated-navigation-between-Pages.aspx Tue, 08 Jun 2010 07:46:00 GMT Navigation in 3D world of 2D objects <p><em><span style="line-height: 115%; font-family: calibri, sans-serif; font-size: 11pt;">This article is compatible with the latest version of Silverlight.</span></em></p> <p><strong>This is part</strong><strong> 7</strong><strong> </strong><strong>of the series “Silverlight in Action”.</strong></p> <p><strong>Here we’re sharing our experience from the amazing</strong><strong> </strong><strong><a href="http://www.completit.com/" target="_blank">CompletIT</a> web site.</strong></p> <h3>Introduction</h3> <p>It’s always complicated, when you have to deal with 3D objects. No matter what environment and framework you choose, you’ll need to learn a lot of complicated structures and procedures in order to implement even a simple scenario. But the bigger problem in Silverlight is the lack of “native” support for 3D (those helpful frameworks). There are some available frameworks out there, but they tend to be very heavy (because of the complex nature of the 3D), so when you need good performance, you’d better to do everything on your own.</p> <p>That’s why in this article, we’ll create a very simple 3D framework, that will allows us to position normal 2D objects like Grids, Buttons, Borders and TextBlocks in a 3D world and also allows us to move the camera(the viewer) all over the place.</p> <h4>A snapshot of the 3D world</h4> <h4><a href="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Portfolio_2.jpg"><img width="904" height="447" title="Portfolio" style="width: 623px; display: inline; height: 317px;border: 0px;" alt="Portfolio" src="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Portfolio_thumb.jpg" /></a> </h4> <h4>Try the navigation by yourself. </h4> <h5>Just click and drag to move the Camera and wheel the mouse to zoom.</h5> <p><object width="650" height="450" data="data:application/x-silverlight-2," type="application/x-silverlight-2" autoupdate="true"> <param name="source" value="http://www.silverlightshow.net/Storage/demos/ThreeDWorld.xap"/> <param name="minRuntimeVersion" value="4.0.41108.0"/> <param name="background" value="White"/> <param name="autoUpgrade" value="true"/> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.41108.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"> </a> </object></p> <h3>Implementation</h3> <p>We will implement a simple 3D abstraction. In order to do that, we will define a class to hold the 3 coordinates – X, Y, Z of each object, that will be placed on the 3D scene. This class will also define the Camera (the Viewer’s position) and will allow us to project each object on the screen based on the coordinates and the camera position. The actual projection will calculate the needed translation and scaling. You can read more information about the 3D projection <a href="http://en.wikipedia.org/wiki/3D_projection">here</a>.</p> <h5>The ThreeD class</h5> <p>In order to make it possible to set on each element on the scene, x, y and z coordinates, lets define the corresponding attached properties. Also since the scene will support only one viewer (camera), we can define its coordinates as static double properties.</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">readonly</span> DependencyProperty XProperty =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span> DependencyProperty.RegisterAttached(<span style="color: #006080;">"X"</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #0000ff;">double</span>), <span style="color: #0000ff;">typeof</span>(ThreeD), <span style="color: #0000ff;">new</span> PropertyMetadata(0.0));</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">readonly</span> DependencyProperty YProperty =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> DependencyProperty.RegisterAttached(<span style="color: #006080;">"Y"</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #0000ff;">double</span>), <span style="color: #0000ff;">typeof</span>(ThreeD), <span style="color: #0000ff;">new</span> PropertyMetadata(0.0));</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">readonly</span> DependencyProperty ZProperty =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> DependencyProperty.RegisterAttached(<span style="color: #006080;">"Z"</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #0000ff;">double</span>), <span style="color: #0000ff;">typeof</span>(ThreeD), <span style="color: #0000ff;">new</span> PropertyMetadata(0.0));</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">double</span> CameraX</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> get;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> set;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">double</span> CameraY</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> get;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> set;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">double</span> CameraZ</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> get;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> set;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">double</span> CenterScreenX</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> get;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span> set;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">double</span> CenterScreenY</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> get;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span> set;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum38" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum39" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum40" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">double</span> GetX(DependencyObject obj)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum41" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum42" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">double</span>)obj.GetValue(XProperty);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum43" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum44" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum45" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> SetX(DependencyObject obj, <span style="color: #0000ff;">double</span> <span style="color: #0000ff;">value</span>)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum46" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum47" style="color: #606060;"> </span> obj.SetValue(XProperty, <span style="color: #0000ff;">value</span>);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum48" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum49" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum50" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">double</span> GetY(DependencyObject obj)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum51" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum52" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">double</span>)obj.GetValue(YProperty);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum53" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum54" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum55" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> SetY(DependencyObject obj, <span style="color: #0000ff;">double</span> <span style="color: #0000ff;">value</span>)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum56" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum57" style="color: #606060;"> </span> obj.SetValue(YProperty, <span style="color: #0000ff;">value</span>);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum58" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum59" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum60" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">double</span> GetZ(DependencyObject obj)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum61" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum62" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> (<span style="color: #0000ff;">double</span>)obj.GetValue(ZProperty);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum63" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum64" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum65" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> SetZ(DependencyObject obj, <span style="color: #0000ff;">double</span> <span style="color: #0000ff;">value</span>)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum66" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum67" style="color: #606060;"> </span> obj.SetValue(ZProperty, <span style="color: #0000ff;">value</span>);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum68" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <p>After we can set 3D coordinates to our normal visuals, we’ll need a method to project them on the screen. In order to do that, lets first clarify the scene. The screen is with Z = 0 coordinate, so every object will have positive Z and the viewer will be able to “fly” through them. And here is the actual projection method.</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> Project(FrameworkElement element)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> CompositeTransform transform = element.EnsureTransform();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #0000ff;">double</span> x = GetX(element);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> <span style="color: #0000ff;">double</span> y = GetY(element);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;">double</span> z = GetZ(element);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (CameraZ <= z)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> element.Visibility = Visibility.Collapsed;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> <span style="color: #0000ff;">else</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> element.Visibility = Visibility.Visible;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> <span style="color: #0000ff;">double</span> factor = CameraZ / (CameraZ - z);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> transform.TranslateX = (x - CameraX) * factor + CenterScreenX;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> transform.TranslateY = (y - CameraY) * factor + CenterScreenY;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> element.Opacity = transform.ScaleX = transform.ScaleY = Math.Abs(1 - factor);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <p>Let me explain the code in a couple of words. </p> <ul> <li>When the camera goes “behind” the object, we will collapse it. </li> <li>Otherwise – calculate the factor of the distance between the camera to the screen and the camera to the object. After that (x – CameraX) * factor will give us the X offset. (can look at <a href="http://en.wikipedia.org/wiki/File:Perspective_Transform_Diagram.png">this</a> wiki diagram to see it more clearly). And at the end we normalize the coordinates by adding the Center of screen offsets. </li> <li>And the scaling is also very important for the real 3D effect. The Opacity is not obligatory, but can be added for more realistic effect. </li> </ul> <h5>The ThreeDPanel class</h5> <p>In order to make the camera live, lets create an attached behavior for a panel. This class will hold the logic of moving the camera, zooming and projecting the objects back to 2D. It’s as simple as moving the camera’s X, Y and Z coordinates responding to Mouse events.</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> FixZIndex(Panel panel)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #0000ff;">int</span> index = 0;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #0000ff;">foreach</span> (UIElement child <span style="color: #0000ff;">in</span> panel.Children.OrderBy(ThreeD.GetZ))</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> Canvas.SetZIndex(child, ++index);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> }</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> PanelSizeChanged(<span style="color: #0000ff;">object</span> sender, SizeChangedEventArgs e)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> var panel = (Panel) sender;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> ThreeD.CameraX = ThreeD.CenterScreenX = e.NewSize.Width/2;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> ThreeD.CameraY = ThreeD.CenterScreenY = e.NewSize.Height/2;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> FixZIndex(panel);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> ProjectChildren(panel);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> PanelMouseMove(<span style="color: #0000ff;">object</span> sender, MouseEventArgs e)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> var panel = (Panel) sender;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (isDragging)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span> Point currentPoint = e.GetPosition(panel);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> Move(panel, currentPoint);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> PanelMouseLeftButtonUp(<span style="color: #0000ff;">object</span> sender, MouseButtonEventArgs e)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span> var panel = (Panel) sender;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> isDragging = <span style="color: #0000ff;">false</span>;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span> panel.ReleaseMouseCapture();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum38" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum39" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum40" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> PanelMouseWheel(<span style="color: #0000ff;">object</span> sender, MouseWheelEventArgs e)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum41" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum42" style="color: #606060;"> </span> var panel = (Panel) sender;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum43" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum44" style="color: #606060;"> </span> Point zoomCenter = e.GetPosition(panel);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum45" style="color: #606060;"> </span> Zoom(panel, zoomCenter, Math.Sign(e.Delta)*zoomChange);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum46" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum47" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum48" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> PanelMouseLeftButtonDown(<span style="color: #0000ff;">object</span> sender, MouseButtonEventArgs e)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum49" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum50" style="color: #606060;"> </span> var panel = (Panel) sender;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum51" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum52" style="color: #606060;"> </span> panel.CaptureMouse();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum53" style="color: #606060;"> </span> isDragging = <span style="color: #0000ff;">true</span>;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum54" style="color: #606060;"> </span> startDragPoint = e.GetPosition(panel);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum55" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum56" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum57" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> Move(Panel panel, Point currentPoint)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum58" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum59" style="color: #606060;"> </span> ThreeD.CameraX -= ((currentPoint.X - startDragPoint.X)/2);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum60" style="color: #606060;"> </span> ThreeD.CameraY -= ((currentPoint.Y - startDragPoint.Y)/2);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum61" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum62" style="color: #606060;"> </span> ProjectChildren(panel);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum63" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum64" style="color: #606060;"> </span> startDragPoint = currentPoint;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum65" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum66" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum67" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> Zoom(Panel panel, Point zoomCenter, <span style="color: #0000ff;">double</span> deltaZoom)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum68" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum69" style="color: #606060;"> </span> ThreeD.CameraZ -= deltaZoom;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum70" style="color: #606060;"> </span> ThreeD.CameraX += (zoomCenter.X - ThreeD.CameraX)*(deltaZoom/ThreeD.CameraZ);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum71" style="color: #606060;"> </span> ThreeD.CameraY += (zoomCenter.Y - ThreeD.CameraY)*(deltaZoom/ThreeD.CameraZ);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum72" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum73" style="color: #606060;"> </span> ProjectChildren(panel);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum74" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum75" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum76" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> ProjectChildren(Panel panel)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum77" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum78" style="color: #606060;"> </span> <span style="color: #0000ff;">foreach</span> (FrameworkElement element <span style="color: #0000ff;">in</span> panel.Children)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum79" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum80" style="color: #606060;"> </span> ThreeD.Project(element);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum81" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum82" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <p>It’s also tricky to change the items <em>Canvas.ZIndex</em> property according to theirs Z coordinate (It’s done in the FixZIndex method).</p> <h5>The MainPage xaml</h5> <p>Using this simple 3D framework is as easy as setting the needed 3D coordinates and manipulating the camera. Have a look at the code and check yourself.</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><Canvas x:Name=<span style="color: #006080;">"LayoutRoot"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span> Background=<span style="color: #006080;">"{StaticResource background}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> ThreeDWorld:ThreeDPanel.IsThreeDPanel=<span style="color: #006080;">"True"</span>></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <Grid ThreeDWorld:ThreeD.X=<span style="color: #006080;">"200"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Y=<span style="color: #006080;">"100"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Z=<span style="color: #006080;">"100"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> MaxWidth=<span style="color: #006080;">"300"</span>></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> <Border Background=<span style="color: #006080;">"Red"</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> <TextBlock Text=<span style="color: #006080;">"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam blandit mattis ullamcorper. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas"</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> </Grid></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> <Grid ThreeDWorld:ThreeD.X=<span style="color: #006080;">"100"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Y=<span style="color: #006080;">"250"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Z=<span style="color: #006080;">"50"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> MaxWidth=<span style="color: #006080;">"300"</span>></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> <Border Background=<span style="color: #006080;">"Green"</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> <TextBlock Text=<span style="color: #006080;">"Etiam porttitor leo at turpis mattis sed convallis tortor consequat. Donec vel sodales felis. Fusce euismod mollis aliquet. Morbi nec augue ipsum, non sodales risus. Fusce at sem vel diam congue vestibulum ut a enim. Praesent eget lorem vitae purus sagittis ultricies."</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> </Grid></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> <Grid ThreeDWorld:ThreeD.X=<span style="color: #006080;">"300"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Y=<span style="color: #006080;">"225"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Z=<span style="color: #006080;">"150"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> MaxWidth=<span style="color: #006080;">"300"</span>></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> <Border Background=<span style="color: #006080;">"Blue"</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> <TextBlock Text=<span style="color: #006080;">"Suspendisse sit amet nunc hendrerit enim iaculis bibendum. Sed ut metus nec felis congue interdum et at orci. Duis imperdiet, mi eget eleifend porta, dui lacus consequat tortor, ac euismod purus ipsum id purus. Sed sollicitudin elementum ultrices. Vestibulum hendrerit dolor justo."</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> </Grid></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> <Grid ThreeDWorld:ThreeD.X=<span style="color: #006080;">"400"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Y=<span style="color: #006080;">"125"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Z=<span style="color: #006080;">"125"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> MaxWidth=<span style="color: #006080;">"300"</span>></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span> <Border Background=<span style="color: #006080;">"Yellow"</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span> <TextBlock Text=<span style="color: #006080;">"Vivamus nulla tortor, ornare et commodo nec, gravida eget justo. Nunc dignissim, nibh a posuere auctor, libero odio pretium turpis, convallis placerat sem sapien eget lectus. Curabitur nulla sapien, mollis auctor egestas vitae, tincidunt et ante."</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span> </Grid></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> <Grid ThreeDWorld:ThreeD.X=<span style="color: #006080;">"500"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Y=<span style="color: #006080;">"300"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum38" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Z=<span style="color: #006080;">"100"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum39" style="color: #606060;"> </span> MaxWidth=<span style="color: #006080;">"300"</span>></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum40" style="color: #606060;"> </span> <Border Background=<span style="color: #006080;">"Ivory"</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum41" style="color: #606060;"> </span> <TextBlock Text=<span style="color: #006080;">"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam blandit mattis ullamcorper. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas"</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum42" style="color: #606060;"> </span> </Grid></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum43" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum44" style="color: #606060;"> </span> <Grid ThreeDWorld:ThreeD.X=<span style="color: #006080;">"500"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum45" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Y=<span style="color: #006080;">"175"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum46" style="color: #606060;"> </span> ThreeDWorld:ThreeD.Z=<span style="color: #006080;">"140"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum47" style="color: #606060;"> </span> MaxWidth=<span style="color: #006080;">"300"</span>></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum48" style="color: #606060;"> </span> <Border Background=<span style="color: #006080;">"Gold"</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum49" style="color: #606060;"> </span> <TextBlock Text=<span style="color: #006080;">"Suspendisse sit amet nunc hendrerit enim iaculis bibendum. Sed ut metus nec felis congue interdum et at orci. Duis imperdiet, mi eget eleifend porta, dui lacus consequat tortor, ac euismod purus ipsum id purus. Sed sollicitudin elementum ultrices. Vestibulum hendrerit dolor justo."</span> /></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum50" style="color: #606060;"> </span> </Grid></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum51" style="color: #606060;"> </span></Canvas></pre> <!--CRLF--></div> </div> <h3>Conclusion</h3> <p>Sometimes is better for simple scenarios to have simple solutions, as that one. It is lightweight and performs well, as well as, is doing what it’s suppose to do – abstracting the complex 3D world and give us an easy way to create more beautiful User Interface. For more complex scenarios regarding 3D in Silverlight, you can look at the <a href="http://kit3d.codeplex.com/">Kit 3D</a> available at codeplex.</p> <h3><a href="http://www.silverlightshow.net/Storage/Sources/ThreeDWorld.zip">Download the code</a></h3> <p>Stay tuned for more articles from this series coming up next week.</p> http://www.silverlightshow.net/items/Navigation-in-3D-world-of-2D-objects.aspx editorial@silverlightshow.net (Miroslav Miroslavov ) http://www.silverlightshow.net/items/Navigation-in-3D-world-of-2D-objects.aspx#comments http://www.silverlightshow.net/items/Navigation-in-3D-world-of-2D-objects.aspx Mon, 31 May 2010 11:30:00 GMT Book Folding effect using Pixel Shader <p><em><span style="line-height: 115%; font-family: calibri, sans-serif; font-size: 11pt;">This article is compatible with the latest version of Silverlight.</span></em></p> <p><strong>This is part</strong><strong> 6</strong><strong> </strong><strong>of the series “Silverlight in Action”.</strong></p> <p><strong>Here we’re sharing our experience from the amazing</strong><strong> </strong><strong><a href="http://www.completit.com/" target="_blank">CompletIT</a> web site.</strong></p> <h3>Introduction</h3> <p>In this article, we’ll examine one very interesting approach for creating Rich UI. It’s a program that manipulates the UI just before the actual rendering on the screen – and it’s called <strong><a href="http://en.wikipedia.org/wiki/Pixel_shader">PixelShader</a></strong>. Its name says that this program is processing the <strong>Pixels </strong>(of a frame that Silverlight renders), and <strong>Shader </strong>stands for a program that calculates the rendering effect, most of the time - on the GPU.</p> <h5>Pixel shaders in brief:</h5> <ol> <li>Pixel shaders are written in <a href="http://en.wikipedia.org/wiki/High_Level_Shader_Language">HLSL</a> (High Level Shader Language) and are usually saved in “.fx” files. </li> <li>The code is compiled using DirectFX compiler into “.ps” file. </li> <li>In Silverlight, the compiled effect is wired by inheriting the ShaderEffect base class. </li> <li>After that you can apply this effect on UIElements, using the UIElement.Effect property. </li> <li>At runtime, the effect is executed on each pixel, rendered for that Element(bitmap) and we end up with a new bitmap that is visualized on the screen. </li> </ol> <p>Writing pixel shader effects is very tricky. The HLSL is not very common language and somehow it might be confusing. In order to feel more comfortable during reading this article, we recommend that you to take a look at <a href="http://www.silverlightshow.net/items/Pixel-Effects-in-Silverlight-3.aspx">this</a> article – it’s about shader basics and contains stuff that you’ll need to know in order to create custom pixel shaders.</p> <p>And let’s see how to create a “Book folding Pixel Shader effect” like this one:</p> <h4>A snapshot of folding the page content</h4> <p><a href="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Folding_2.jpg"><img width="754" height="373" title="Folding" style="width: 657px; display: inline; height: 350px;border-width: 0px;" alt="Folding" src="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Folding_thumb.jpg" /></a> </p> <h4>Try the folding by yourself. Just click on the Image.<object width="640" height="480" data="data:application/x-silverlight-2," type="application/x-silverlight-2" autoupdate="true"> <param name="source" value="http://www.silverlightshow.net/Storage/demos/FoldingEffect.xap"/> <param name="minRuntimeVersion" value="3.0.40624.0"/> <param name="background" value="White"/> <param name="autoUpgrade" value="true"/> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"> </a> </object></h4> <h3>Implementation</h3> <h5>The ExampleFolding.fx</h5> <p>Pixel shaders can define global input variables by using the so called <em>registers </em>(There is one parameter that is compulsory - <em>sampler2D input</em>  - this is the input bitmap). In our example, we’ll need one more parameter (<strong>left</strong>) that will be the left position of the element after folding, relative to the original element position. It’ll vary from 0 to 0.5. This can also be the folding angle, but for the sake of simplicity, we’ll use left as an input parameter. At the end, when we run the actual animation on this parameter from 0 to 0.5 and back to 0, we’ll have a folding effect.</p> <p>Having the left parameter, we’ll use a simple math to transform the current point passed to the main function of the shader (<strong>uv</strong>). Once we have transformed the point, we’ll get the pixel for that point from the original bitmap – the input parameter. </p> <p>The transformation of the current point is done by, first, transforming the bitmap bounds to fit in the new bounds (having smaller width) and, second, by interpolating the point, considering the angle of folding.</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span>sampler2D input : register(s0);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span><span style="color: #0000ff;">float</span> left : register(c0);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span>float4 transform(float2 uv : TEXCOORD) : COLOR</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;">float</span> right = 1 - left;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> float2 tuv = float2((uv.x - left) / (right - left), uv.y); <span style="color: #008000;">// transforming the curent point (uv) according to the new boundaries.</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> <span style="color: #0000ff;">float</span> tx = tuv.x;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (tx > 0.5)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> tx = 1 - tx;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> <span style="color: #0000ff;">float</span> top = left * tx;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> <span style="color: #0000ff;">float</span> bottom = 1 - top; </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (uv.y >= top && uv.y <= bottom)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> <span style="color: #0000ff;">float</span> ty = lerp(0, 1, (tuv.y - top) / (bottom - top)); <span style="color: #008000;">//linear interpolation between 0 and 1 considering the angle of folding. </span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> tex2D(input, float2(tuv.x, ty)); <span style="color: #008000;">// get the pixel from the transformed x and interpolated y.</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> 0;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span>}</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span>float4 main(float2 uv : TEXCOORD) : COLOR </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span>{ </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span> <span style="color: #0000ff;">float</span> right = 1 - left;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span>(uv.x > left && uv.x < right)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> transform(uv);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> 0;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <p>Something that might be very interesting is that during folding, we can see behind the element with the applied effect. This is due to the following code:</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span>float4 main(float2 uv : TEXCOORD) : COLOR </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>{ </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #0000ff;">float</span> right = 1 - left;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span>(uv.x > left && uv.x < right)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> transform(uv);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> 0;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <p>We’re returning 0 for all points outside the new boundaries and 0 means transparent color.</p> <h5>The ExampleFoldingEffect.cs</h5> <p>This is the class that wires the <em>ExampleFolding.ps</em> and the UIElements. It has two Dependency properties for the shader parameters (the input and left).</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;">using</span> System;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span><span style="color: #0000ff;">using</span> System.Windows;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span><span style="color: #0000ff;">using</span> System.Windows.Media;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span><span style="color: #0000ff;">using</span> System.Windows.Media.Effects;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span><span style="color: #0000ff;">namespace</span> FoldingEffect</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> ExampleFoldingEffect : ShaderEffect</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">readonly</span> DependencyProperty InputProperty = RegisterPixelShaderSamplerProperty(<span style="color: #006080;">"Input"</span>, <span style="color: #0000ff;">typeof</span>(ExampleFoldingEffect), 0);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">readonly</span> DependencyProperty LeftProperty = DependencyProperty.Register(<span style="color: #006080;">"Left"</span>, <span style="color: #0000ff;">typeof</span>(<span style="color: #0000ff;">double</span>), <span style="color: #0000ff;">typeof</span>(ExampleFoldingEffect), <span style="color: #0000ff;">new</span> PropertyMetadata(0.0, PixelShaderConstantCallback(0)));</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> ExampleFoldingEffect()</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> PixelShader pixelShader = <span style="color: #0000ff;">new</span> PixelShader</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> UriSource =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> <span style="color: #0000ff;">new</span> Uri(<span style="color: #006080;">"/FoldingEffect;component/ExampleFolding.ps"</span>, UriKind.Relative)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> };</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> <span style="color: #0000ff;">this</span>.PixelShader = pixelShader;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> <span style="color: #0000ff;">this</span>.UpdateShaderValue(InputProperty);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> <span style="color: #0000ff;">this</span>.UpdateShaderValue(LeftProperty);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> Brush Input</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> get</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> ((Brush)(<span style="color: #0000ff;">this</span>.GetValue(InputProperty)));</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span> set</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span> <span style="color: #0000ff;">this</span>.SetValue(InputProperty, <span style="color: #0000ff;">value</span>);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span> } </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">double</span> Left</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span> get</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum38" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum39" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> ((<span style="color: #0000ff;">double</span>)(<span style="color: #0000ff;">this</span>.GetValue(LeftProperty)));</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum40" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum41" style="color: #606060;"> </span> set</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum42" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum43" style="color: #606060;"> </span> <span style="color: #0000ff;">this</span>.SetValue(LeftProperty, <span style="color: #0000ff;">value</span>);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum44" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum45" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum46" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum47" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <h5>Applying the Effect</h5> <p>Applying ExampleFoldingEffect is as easy as applying any other effect (like built-in <em>DropShadowEffect</em>).</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;"><</span><span style="color: #800000;">Border</span> <span style="color: #ff0000;">BorderBrush</span><span style="color: #0000ff;">="Black"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span> <span style="color: #ff0000;">BorderThickness</span><span style="color: #0000ff;">="2"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #ff0000;">Margin</span><span style="color: #0000ff;">="10"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #ff0000;">Padding</span><span style="color: #0000ff;">="5"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Image</span> <span style="color: #ff0000;">Source</span><span style="color: #0000ff;">="Desert.jpg"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Border.Effect</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">FoldingEffect:ExampleFoldingEffect</span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="foldingEffect"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Border.Effect</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span><span style="color: #0000ff;"></</span><span style="color: #800000;">Border</span><span style="color: #0000ff;">></span></pre> <!--CRLF--></div> </div> <h5>Animating the Effect</h5> <p>The shader itself is static if applied once. If we apply the effect for example with a value of 0.25, we’ll see the static half-folded image and that’s it. In order to accomplish the result of animated folding, we’ll have to create an animation over that effect and more precisely – over the Left dependency property. In this way, on each frame of the animation, the effect will be applied again with updated Left property, so the image will be more/less folded.</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;"><</span><span style="color: #800000;">Storyboard</span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="foldAnimation"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DoubleAnimationUsingKeyFrames</span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetName</span><span style="color: #0000ff;">="foldingEffect"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #ff0000;">Storyboard</span>.<span style="color: #ff0000;">TargetProperty</span><span style="color: #0000ff;">="Left"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">EasingDoubleKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:00.5"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #ff0000;">EasingFunction</span><span style="color: #0000ff;">="{StaticResource easeOut}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">=".5"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">EasingDoubleKeyFrame</span> <span style="color: #ff0000;">KeyTime</span><span style="color: #0000ff;">="00:00:01"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> <span style="color: #ff0000;">EasingFunction</span><span style="color: #0000ff;">="{StaticResource easeIn}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="0"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">DoubleAnimationUsingKeyFrames</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span><span style="color: #0000ff;"></</span><span style="color: #800000;">Storyboard</span><span style="color: #0000ff;">></span></pre> </div> </div> <h3>Conclusion</h3> <p>Pixel shaders are very powerful Silverlight features that allow us to manipulate UI rendering on a pixel level. Once that you are comfortable with HLSL, you’ll be able to do amazing things with ease. There are also a lot of great examples out there on the web, built for WPF or Silverlight. You can also browse and examine some of them by using the <a href="http://shazzam-tool.com/">Shazzam tool</a>, which also gives you a very good environment for creating pixel shaders.</p> <h3><a href="http://www.silverlightshow.net/Storage/Sources/FoldingEffect.zip">Download the code</a></h3> <p>Stay tuned for more articles from this series coming up next week.</p> http://www.silverlightshow.net/items/Book-Folding-effect-using-Pixel-Shader.aspx editorial@silverlightshow.net (Miroslav Miroslavov ) http://www.silverlightshow.net/items/Book-Folding-effect-using-Pixel-Shader.aspx#comments http://www.silverlightshow.net/items/Book-Folding-effect-using-Pixel-Shader.aspx Tue, 25 May 2010 00:00:00 GMT Smoke effect <p><em><span style="line-height: 115%; font-family: calibri, sans-serif; font-size: 11pt;">This article is compatible with the latest version of Silverlight.</span></em></p> <p><strong>This is part</strong><strong> 5</strong><strong> </strong><strong>of the series “Silverlight in Action”.</strong></p> <p><strong>Here we’re sharing our experience from the amazing</strong><strong> </strong><strong><a href="http://www.completit.com/" target="_blank">CompletIT</a> web site.</strong></p> <h4><strong></strong></h4> <p>Maybe the hardest feature to implement from the entire site was the Smoking menu effect. We’ve tried out a lot of ideas and I’m going to summarize some of them:</p> <ol> <li>We thought to use a <strong>video</strong> as a background, but its performance was bad. Blending the video with the background was hard to do. Randomizing the smoke to make it more realistic would be almost impossible if using a video, as well. </li> <li>After that we tried to make a <strong>Path</strong> that looks close to one knot from the smoke. We copied that path for example 50-100 times, randomized these paths in some manner and animated them to move like smoke. This idea was partly close to the effect, but still far away from a real smoke effect. And also hard to scale. </li> <li>One very interesting approach that we found was to create a snapshot of real smoke. And then to use <strong>PixelShader </strong>effect to create the fluid movement of the smoke. This idea could be implemented but needs a lot of work, more than basic physics knowledge and the writing of lots of code in HLSL, which wasn’t that easy. Also it was not very clear if this was going to perform good enough (knowing that the whole site is moving and flying around). </li> <li><strong><a href="http://en.wikipedia.org/wiki/Particle_system" target="_blank">Particle system</a></strong>. There are already some Silverlight smoke particle system realizations out there on the web. This was maybe the most obvious way of creating a smoke effect and also somehow easy to do, but the actual result was not very satisfying and didn't look like fluid smoke. </li> </ol> <p> </p> <h3>Here is a snapshot of the real look of the smoke.</h3> <p><a href="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Smoke_2.jpg"><img width="749" height="370" title="Smoke" style="width: 639px; display: inline; height: 325px;border: 0px solid;" alt="Smoke" src="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Smoke_thumb.jpg" /></a> </p> <h3>Smoke effect in Action</h3> <p><object width="600" height="400" data="data:application/x-silverlight-2," type="application/x-silverlight-2" autoupdate="true"> <param name="source" value="http://www.silverlightshow.net/Storage/demos/SmokeEffect.xap"/> <param name="minRuntimeVersion" value="4.0.41108.0"/> <param name="background" value="White"/> <param name="autoUpgrade" value="true"/> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.41108.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"> </a> </object></p> <h3>The Idea - <a href="http://en.wikipedia.org/wiki/Sprite_(computer_graphics)" target="_blank">Sprite Animation</a></h3> <p>We’ve decided to implement an idea that is very old and well-know in games development. A sprite animation is a predefined sequence of related images that looks like an animation/movement when changed in a fast way. In our example we change smoke frames on 20 frames per second. All image frames are around 100.</p> <h3>Implementation</h3> <p>There are a couple of different approaches to achieve sprite by using Silverlight. And one of the widespread implementations includes creating an Image control in Blend for every frame and after that creating a Key-Frame animation that hides the previous and shows the new one. Also you can create a big image that has all the frames and you can then clip this big image to show the current frame.</p> <p>But we’ve implemented it in another way. We hold only one Image control and change its Source property on every frame. We’ll create a base class called <strong>ImageSequenceControl </strong>that will do most of our job. It’ll hook up the CompositionTarget.Rendering event and will change the frames accordingly.</p> <p>In the constructor of this control we’ll pass a parameter - <em>fps (frames per second).</em> When having it we can calculate the interval between the frames.</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;">protected</span> ImageSequenceControl(<span style="color: #0000ff;">int</span> frames, <span style="color: #0000ff;">double</span> fps)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span> : <span style="color: #0000ff;">this</span>()</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #0000ff;">this</span>.frames = frames;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> averageInterval = TimeSpan.TicksPerSecond / fps;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <p>And here is the <em>CompositionTarget.Rendering</em> handler.</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #008000;">//Raised before drawing of every frame.</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> CompositionTarget_Rendering(<span style="color: #0000ff;">object</span> sender, EventArgs e)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #0000ff;">long</span> now = DateTime.Now.Ticks;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> <span style="color: #008000;">//Since we run on custom fps, we need to check if it's time to draw new frame.</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (now - lastTick < averageInterval)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span>;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (AutoReverse && now < pauseStart + pauseSec)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span>;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> <span style="color: #008000;">//We've finished the frames and may start again.</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (frame == frames)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (AutoReverse)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> Randomise();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> pauseStart = now;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> frame = startFrame;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (AutoReverse)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> <span style="color: #008000;">//Managing the opacity to make the effect of disapearing when reaching the last frames.</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span> <span style="color: #0000ff;">double</span> ratio = (<span style="color: #0000ff;">double</span>)(frame - startFrame) / (frames - startFrame);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> image.Opacity = .5 - 2 * (.5 - ratio) * (.5 - ratio);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> <span style="color: #008000;">//Show the next frame.</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span> image.Source = images[frame - 1];</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span> frame += 1;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span> lastTick = now;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <p>The actual Image information (url sources) is implemented in the sub-classes like <strong>SmokeControl.</strong></p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> SmokeControl : ImageSequenceControl</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>{ </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">readonly</span> Random random = <span style="color: #0000ff;">new</span> Random();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> SmokeControl()</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> : <span style="color: #0000ff;">base</span>(118, 10)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> AutoReverse = <span style="color: #0000ff;">true</span>;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> RenderTransformOrigin = <span style="color: #0000ff;">new</span> Point(0, 1);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">string</span> GetImageName(<span style="color: #0000ff;">int</span> index)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">string</span>.Format(<span style="color: #006080;">"Smoke/Comp 1 {0:000}.png"</span>, index);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> <span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span> Randomise()</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> CompositeTransform transform = <span style="color: #0000ff;">this</span>.EnsureTransform();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> transform.Rotation = random.Next(-30, 0);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> startFrame = random.Next(1, frames / 2);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <h3><a href="http://www.silverlightshow.net/Storage/Sources/SmokeEffect.zip">Download the code</a></h3> <p>Stay tuned for more articles from this series coming up next week.</p> http://www.silverlightshow.net/items/Smoke-effect.aspx editorial@silverlightshow.net (Miroslav Miroslavov ) http://www.silverlightshow.net/items/Smoke-effect.aspx#comments http://www.silverlightshow.net/items/Smoke-effect.aspx Mon, 17 May 2010 07:52:00 GMT Flying objects against you <p><em><span style="line-height: 115%; font-family: calibri, sans-serif; font-size: 11pt;">This article is compatible with the latest version of Silverlight.</span></em></p> <p><strong>This is part</strong><strong> 4</strong><strong> </strong><strong>of the series “Silverlight in Action”.</strong></p> <p><strong>Here we’re sharing our experience from the amazing</strong><strong> </strong><strong><a href="http://www.completit.com/" target="_blank">CompletIT</a> web site.</strong></p> <p>This time we will cover how to build kind of particle system with flying “3D” objects against you. In our example the objects are thrown against you when you click to open a menu item.</p> <p>Lets first see how it looks.</p> <p><a href="http://www.silverlightshow.net/Storage/Users/miromiroslavov/ThrowingObjects_2.png"><img width="749" height="407" title="ThrowingObjects" style="display: inline;border: 0px solid;" alt="ThrowingObjects" src="http://www.silverlightshow.net/Storage/Users/miromiroslavov/ThrowingObjects_thumb.png" /></a></p> <p>And double click on the surface to see ‘<em>Flying Objects against you</em>’ in action.</p> <h3><object width="745" height="400" data="data:application/x-silverlight-2," type="application/x-silverlight-2" autoupdate="true"> <param name="source" value="http://www.silverlightshow.net/Storage/demos/FlyingObjects.xap"/> <param name="minRuntimeVersion" value="3.0.40624.0"/> <param name="background" value="White"/> <param name="autoUpgrade" value="true"/> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"> </a> </object></h3> <h3>The Idea</h3> <p>On double click we’ll create 50 fake 3D pyramids, that will fly against the screen. The effect of throwing is implemented using Scaling to simulate like the objects are flying against you and Translation to simulate the moving of the items. And at the end we’ll animate the opacity of the objects to make them disappear. </p> <p>Of course you can create more objects and make them fly – like <em>pigs</em>, balls or something that comes to your mind.</p> <p>The pyramids are simple 3 paths with random color for one of the sides and we’ll apply some random transformations to make them look more different and realistic.</p> <h3>Implementation</h3> <p>Lets discuss more on the actual effect and not the objects like pyramids. </p> <p>First of all we’ll need a Canvas on top of everything to hold the flying objects, animate them inside and at the end remove the canvas from the scene. It’s as easy as a 3 steps.</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;">void</span> ElementMouseLeftButtonDown(<span style="color: #0000ff;">object</span> sender, System.Windows.Input.MouseButtonEventArgs e)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #0000ff;">long</span> now = DateTime.Now.Ticks;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (lastTick - now <= 200)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> Point point = e.GetPosition(<span style="color: #0000ff;">null</span>);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> Canvas canvas = <span style="color: #0000ff;">new</span> Canvas();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> LayoutRoot.Children.Add(canvas);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> var spreading = SpreadingObjects.GetSpreadAnimaion(point, canvas);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> spreading.Completed += (s, e1) => LayoutRoot.Children.Remove(canvas);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> spreading.Begin();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> lastTick = now;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span>}</pre> </div> </div> <p>In order to spread the objects on the scene we’ll need a staring point and the parent panel to hold the objects. And here is what happens in a couple of steps.</p> <ol> <ol> <li>Prepare the objects </li> <li>Translate them on the starting point. </li> <li>Scale them down for example to .5 of their actual sizes. </li> <li>Animate their position to random X and Y in a radios of 500 around the central point. </li> <li>Animate their scale for example to 3 to make them fly against us. </li> <li>Animate their opacity at the near end to make them disappear. </li> <li>And finally use a CubicEase to give a more realistic effect to the animations. </li> </ol> </ol> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Storyboard GetSpreadAnimaion(Point startPoint, Panel objectsCanvas)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> var spreading = <span style="color: #0000ff;">new</span> Storyboard(); </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int</span> i = 0; i < ObjectFactory.PyramidsCount; i++)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> FrameworkElement randomObject = ObjectFactory.CreatePyramid();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> CompositeTransform transform;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> randomObject.EnsureTransform(<span style="color: #0000ff;">out</span> transform);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> transform.TranslateX = startPoint.X;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> transform.TranslateY = startPoint.Y;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> transform.ScaleX = transform.ScaleY = .5;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> objectsCanvas.Children.Add(randomObject);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> var translateXAnimation = transform.CreateTranslateXAnimation(startPoint.X + RandomHelper.Next(-Radius, Radius),Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> var translateYAnimation = transform.CreateTranslateYAnimation(startPoint.Y + RandomHelper.Next(-Radius, Radius), Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> var scaleXAnimation = transform.CreateScaleXAnimation(3, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> var scaleYAnimation = transform.CreateScaleYAnimation(3, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> var opacityAnimation = randomObject.CreateOpacityAnimation(0, OpacityBeginTime, Seconds - OpacityBeginTime);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> translateXAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span> translateYAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> scaleXAnimation.EasingFunction = scaleYAnimation.EasingFunction = <span style="color: #0000ff;">new</span> CubicEase</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span> EasingMode = EasingMode.EaseIn</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> };</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span> spreading.Children.Add(translateXAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span> spreading.Children.Add(translateYAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span> spreading.Children.Add(scaleXAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> spreading.Children.Add(scaleYAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span> spreading.Children.Add(opacityAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum38" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum39" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum40" style="color: #606060;"> </span> spreading.Completed += (s, e1) => objectsCanvas.Children.Clear();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum41" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span> spreading;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum42" style="color: #606060;"> </span>}</pre> <!--CRLF--></div> </div> <h3><a href="http://www.silverlightshow.net/Storage/Sources/FlyingObjects.zip" target="_blank">Download the code</a></h3> <p>Stay tuned for the next articles from this series coming up next week.</p> http://www.silverlightshow.net/items/Flying-objects-against-you.aspx editorial@silverlightshow.net (Miroslav Miroslavov ) http://www.silverlightshow.net/items/Flying-objects-against-you.aspx#comments http://www.silverlightshow.net/items/Flying-objects-against-you.aspx Wed, 12 May 2010 00:00:00 GMT Flipping panels <p><em><span style="line-height: 115%; font-family: calibri, sans-serif; font-size: 11pt;">This article is compatible with the latest version of Silverlight.</span></em></p> <p><strong>This is part</strong><strong> 3</strong><strong> </strong><strong>of the series “Silverlight in Action”</strong></p> <p><strong>Here we’re sharing our experience from the amazing</strong><strong> </strong><strong><a href="http://www.completit.com/" target="_blank">CompletIT</a> web site.</strong></p> <h4><strong></strong></h4> <p>In this ‘”how to” session, we’ll cover one of the most interesting and hardest to implement part of the site - How to flip the menu item and simultaneously show the actual page behind. The result of the effect should be like the page text is on the back of the menu.</p> <p>Lets first see how it looks.</p> <h3>Flipping begin</h3> <p><a href="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Flipping_begin_2.jpg"><img width="754" height="373" title="Flipping_begin" style="display: inline;border: 0px solid;" alt="Flipping_begin" src="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Flipping_begin_thumb.jpg" /></a> </p> <h3>Flipping back</h3> <p><a href="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Flipping_2.jpg"><img width="754" height="376" title="Flipping" style="display: inline;border: 0px solid;" alt="Flipping" src="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Flipping_thumb.jpg" /></a> </p> <h3>See it in action</h3> <p> <object width="640" height="360" data="data:application/x-silverlight-2," type="application/x-silverlight-2" autoupdate="true"> <param name="source" value="http://www.silverlightshow.net/Storage/demos/FlippingCard.xap"/> <param name="minRuntimeVersion" value="4.0.41108.0"/> <param name="background" value="White"/> <param name="autoUpgrade" value="true"/> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.41108.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"> </a> </object></p> <h3>Idea</h3> <p>The trick is in having two elements that live independent of each other – the menu and the actual page. We will flip the menu to the half, hide it at that point and animate the page from the mid point to the center of screen with normal size. So first we need to find the mid-point where we’ll change them.</p> <p>Here is what happens in more detailed steps.</p> <ol> <li>Find the mid-point based on the centers of the menu item and the page </li> <li>Prepare the two elements <ol> <li>Show the Page by changing it’s visibility </li> <li>Hide it with Opacity = 0 (<strong>those two steps are to prevent Layout pass when showing the page and hiding the menu – basically it shouldn’t happen layout pass thought the entire animation</strong>) </li> <li>Position the page at the mid-point and Rotate it on Y by –90° </li> <li>Scale it back to the size that the Menu item will have at the mid-point </li> </ol> </li> <li>Begin flipping the Menu <ol> <li><em>PlaneProjection.RotationY to 90° </em></li> <li>Translate the Menu item to the mid-point where will interchange with the page – <em>TranslateTransform</em> </li> </ol> </li> <li>Hide the Menu item – Opacity = 0 </li> <li>Show the Page – Opacity = 1 </li> <li>Flip the Page from the mid point to the center of the screen <ol> <li>Scale it to 1, to make it real size </li> <li>Translate it to it’s original position </li> <li>Rotate it on Y to 0 </li> </ol> </li> </ol> <p>To implement this algorithm we’ll create Attached behavior for FrameworkElement with two attached properties:</p> <ol> <li><strong><em>IsFlipping </em></strong>of type bool <strong><em>– </em></strong>That will enable the flipping behavior for this element. </li> <li><strong><em>Element</em></strong> of type FrameworkElement – That will give reference to the element at the back. </li> </ol> <h3> </h3> <h3>Implementation</h3> <h3></h3> <h3></h3> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span>FrameworkElement back = GetElement(element);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span><span style="color: #0000ff;">if</span> (back == <span style="color: #0000ff;">null</span>)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #0000ff;">return</span>;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> P</span>laneProjection cardProjection;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span>element.EnsureProjection(<span style="color: #0000ff;">out</span> cardProjection);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span>ScaleTransform cardScale;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span>TranslateTransform cardTranslate;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span>RotateTransform cardRotate;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span>SkewTransform cardSkew;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span>element.EnsureTransforms(<span style="color: #0000ff;">out</span> cardScale, <span style="color: #0000ff;">out</span> cardRotate, <span style="color: #0000ff;">out</span> cardSkew, <span style="color: #0000ff;">out</span> cardTranslate);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span>ScaleTransform backScale;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span>TranslateTransform backTranslate;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span>RotateTransform backRotate;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span>SkewTransform backSkew;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span>back.EnsureTransforms(<span style="color: #0000ff;">out</span> backScale, <span style="color: #0000ff;">out</span> backRotate, <span style="color: #0000ff;">out</span> backSkew, <span style="color: #0000ff;">out</span> backTranslate);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span>PlaneProjection backProjection;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span>back.EnsureProjection(<span style="color: #0000ff;">out</span> backProjection);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span>backProjection.RotationX = -90;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span>back.Opacity = 0;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span>back.Visibility = Visibility.Visible;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span>root.UpdateLayout();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span><span style="color: #008000;">//Position the two animations to meet at the mid. point.</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span><span style="color: #0000ff;">double</span> w = (back.ActualWidth + element.ActualWidth) / 2;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span><span style="color: #0000ff;">double</span> h = (back.ActualHeight + element.ActualHeight) / 2;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span><span style="color: #0000ff;">double</span> scaleX = w / element.ActualWidth;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span><span style="color: #0000ff;">double</span> scaleY = h / element.ActualHeight;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span><span style="color: #0000ff;">double</span> backScaleX = w / back.ActualWidth;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum38" style="color: #606060;"> </span><span style="color: #0000ff;">double</span> backScaleY = h / back.ActualHeight;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum39" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum40" style="color: #606060;"> </span>Point center = element.TransformToVisual(<span style="color: #0000ff;">null</span>).Transform(<span style="color: #0000ff;">new</span> Point(element.ActualWidth / 2, element.ActualHeight / 2));</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum41" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum42" style="color: #606060;"> </span><span style="color: #0000ff;">double</span> x = root.ActualWidth / 2 - center.X;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum43" style="color: #606060;"> </span><span style="color: #0000ff;">double</span> y = root.ActualHeight / 2 - center.Y;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum44" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum45" style="color: #606060;"> </span>backScale.ScaleX = backScaleX;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum46" style="color: #606060;"> </span>backScale.ScaleY = backScaleY;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum47" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum48" style="color: #606060;"> </span>backTranslate.X = -x / 2;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum49" style="color: #606060;"> </span>backTranslate.Y = -y / 2;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum50" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum51" style="color: #606060;"> </span>DoubleAnimation mainProjection = AnimationFactory.CreateProjectionXAnimation(cardProjection, 90, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum52" style="color: #606060;"> </span>DoubleAnimation scaleXAnimation = AnimationFactory.CreateScaleXAnimation(cardScale, scaleX, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum53" style="color: #606060;"> </span>DoubleAnimation scaleYAnimation = AnimationFactory.CreateScaleYAnimation(cardScale, scaleY, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum54" style="color: #606060;"> </span>DoubleAnimation translateXAnimation = AnimationFactory.CreateTranslateXAnimation(cardTranslate, cardTranslate.X + x / 2, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum55" style="color: #606060;"> </span>DoubleAnimation translateYAnimation = AnimationFactory.CreateTranslateYAnimation(cardTranslate, cardTranslate.Y + y / 2, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum56" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum57" style="color: #606060;"> </span>mainProjection.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum58" style="color: #606060;"> </span> translateXAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum59" style="color: #606060;"> </span> translateYAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum60" style="color: #606060;"> </span> scaleXAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum61" style="color: #606060;"> </span> scaleYAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum62" style="color: #606060;"> </span> <span style="color: #0000ff;">new</span> QuadraticEase</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum63" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum64" style="color: #606060;"> </span> EasingMode = EasingMode.EaseIn</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum65" style="color: #606060;"> </span> };</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum66" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum67" style="color: #606060;"> </span>DoubleAnimation backProjectionAnimation = AnimationFactory.CreateProjectionXAnimation(backProjection, 0, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum68" style="color: #606060;"> </span>DoubleAnimation backScaleXAnimation = AnimationFactory.CreateScaleXAnimation(backScale, 1, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum69" style="color: #606060;"> </span>DoubleAnimation backScaleYAnimation = AnimationFactory.CreateScaleYAnimation(backScale, 1, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum70" style="color: #606060;"> </span>DoubleAnimation backTranslateXAnimation = AnimationFactory.CreateTranslateXAnimation(backTranslate, 0, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum71" style="color: #606060;"> </span>DoubleAnimation backTranslateYAnimation = AnimationFactory.CreateTranslateYAnimation(backTranslate, 0, Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum72" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum73" style="color: #606060;"> </span>var backOpacityAnimation = <span style="color: #0000ff;">new</span> ObjectAnimationUsingKeyFrames();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum74" style="color: #606060;"> </span>backOpacityAnimation.KeyFrames.Add(<span style="color: #0000ff;">new</span> DiscreteObjectKeyFrame</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum75" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum76" style="color: #606060;"> </span> KeyTime = TimeSpan.FromSeconds(0),</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum77" style="color: #606060;"> </span> Value = 1</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum78" style="color: #606060;"> </span> });</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum79" style="color: #606060;"> </span>Storyboard.SetTarget(backOpacityAnimation, back);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum80" style="color: #606060;"> </span>Storyboard.SetTargetProperty(backOpacityAnimation, <span style="color: #0000ff;">new</span> PropertyPath(<span style="color: #006080;">"Opacity"</span>));</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum81" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum82" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum83" style="color: #606060;"> </span>backProjectionAnimation.BeginTime =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum84" style="color: #606060;"> </span> backScaleXAnimation.BeginTime =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum85" style="color: #606060;"> </span> backScaleYAnimation.BeginTime =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum86" style="color: #606060;"> </span> backTranslateXAnimation.BeginTime =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum87" style="color: #606060;"> </span> backTranslateYAnimation.BeginTime =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum88" style="color: #606060;"> </span> backOpacityAnimation.BeginTime =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum89" style="color: #606060;"> </span> TimeSpan.FromSeconds(Seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum90" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum91" style="color: #606060;"> </span>backProjectionAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum92" style="color: #606060;"> </span> backScaleXAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum93" style="color: #606060;"> </span> backScaleYAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum94" style="color: #606060;"> </span> backTranslateXAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum95" style="color: #606060;"> </span> backTranslateYAnimation.EasingFunction =</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum96" style="color: #606060;"> </span> <span style="color: #0000ff;">new</span> QuadraticEase</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum97" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum98" style="color: #606060;"> </span> EasingMode = EasingMode.EaseOut</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum99" style="color: #606060;"> </span> };</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum100" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum101" style="color: #606060;"> </span>var flipping = <span style="color: #0000ff;">new</span> Storyboard();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum102" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum103" style="color: #606060;"> </span>flipping.Children.Add(mainProjection);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum104" style="color: #606060;"> </span>flipping.Children.Add(scaleXAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum105" style="color: #606060;"> </span>flipping.Children.Add(scaleYAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum106" style="color: #606060;"> </span>flipping.Children.Add(translateXAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum107" style="color: #606060;"> </span>flipping.Children.Add(translateYAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum108" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum109" style="color: #606060;"> </span>flipping.Children.Add(backOpacityAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum110" style="color: #606060;"> </span>flipping.Children.Add(backProjectionAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum111" style="color: #606060;"> </span>flipping.Children.Add(backScaleXAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum112" style="color: #606060;"> </span>flipping.Children.Add(backScaleYAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum113" style="color: #606060;"> </span>flipping.Children.Add(backTranslateXAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum114" style="color: #606060;"> </span>flipping.Children.Add(backTranslateYAnimation);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum115" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum116" style="color: #606060;"> </span>flipping.Completed += (s, e1) =></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum117" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum118" style="color: #606060;"> </span> element.Visibility = Visibility.Collapsed;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum119" style="color: #606060;"> </span>};</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum120" style="color: #606060;"> </span>flipping.Begin();</pre> </div> </div> <p>Using the behavior is as easy as declaring two visuals, for example Grids, and wire them up – one to serve as front page and one as back.</p> <h3>How to use the behavior</h3> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;"><</span><span style="color: #800000;">Grid</span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="front"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span> <span style="color: #ff0000;">Height</span><span style="color: #0000ff;">="100"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #ff0000;">Width</span><span style="color: #0000ff;">="100"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #ff0000;">FlippingCard:DraggingBehavior</span>.<span style="color: #ff0000;">IsDraggable</span><span style="color: #0000ff;">="True"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #ff0000;">FlippingCard:FlippingBehavior</span>.<span style="color: #ff0000;">IsFlipping</span><span style="color: #0000ff;">="True"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> <span style="color: #ff0000;">FlippingCard:FlippingBehavior</span>.<span style="color: #ff0000;">Element</span><span style="color: #0000ff;">="{Binding ElementName=back}"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Yellow"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span><span style="color: #0000ff;"></</span><span style="color: #800000;">Grid</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span><span style="color: #0000ff;"><</span><span style="color: #800000;">Grid</span> <span style="color: #ff0000;">Margin</span><span style="color: #0000ff;">="10"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="back"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="PowderBlue"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> <span style="color: #ff0000;">MouseLeftButtonUp</span><span style="color: #0000ff;">="BackMouseLeftButtonUp"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">StackPanel</span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #0000ff;">="Center"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="Center"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">TextBlock</span> <span style="color: #ff0000;">Text</span><span style="color: #0000ff;">="Back Page"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> <span style="color: #ff0000;">FontSize</span><span style="color: #0000ff;">="48"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">TextBlock</span> <span style="color: #ff0000;">Text</span><span style="color: #0000ff;">="Click to go back"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> <span style="color: #ff0000;">Foreground</span><span style="color: #0000ff;">="Gray"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> <span style="color: #ff0000;">FontSize</span><span style="color: #0000ff;">="18"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">StackPanel</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Grid.Effect</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DropShadowEffect</span> <span style="color: #ff0000;">BlurRadius</span><span style="color: #0000ff;">="5"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> <span style="color: #ff0000;">Color</span><span style="color: #0000ff;">="Red"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span> <span style="color: #ff0000;">ShadowDepth</span><span style="color: #0000ff;">="0"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> <span style="color: #ff0000;">Opacity</span><span style="color: #0000ff;">=".7"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Grid.Effect</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span><span style="color: #0000ff;"></</span><span style="color: #800000;">Grid</span><span style="color: #0000ff;">></span></pre> </div> </div> <h3><a href="http://www.silverlightshow.net/Storage/Sources/FlippingCard.zip" target="_blank">Download Source Code.</a></h3> <p>Stay tuned for the next articles from this series coming up next week.</p> http://www.silverlightshow.net/items/Flipping-panels.aspx editorial@silverlightshow.net (Miroslav Miroslavov ) http://www.silverlightshow.net/items/Flipping-panels.aspx#comments http://www.silverlightshow.net/items/Flipping-panels.aspx Wed, 05 May 2010 10:22:00 GMT Floating Visual Elements <p><em><span style="line-height: 115%; font-family: calibri, sans-serif; font-size: 11pt;">This article is compatible with the latest version of Silverlight.</span></em></p> <p><strong>This is part</strong><strong> 2</strong><strong> </strong><strong>of the series “Silverlight in Action”.</strong></p> <p><strong>Here we’re sharing our experience from the amazing</strong><strong> </strong><strong><a href="http://www.completit.com/" target="_blank">CompletIT</a> web site.</strong></p> <h4><strong></strong></h4> <p>As you may already know, every Silverlight application “<em>must”</em> have some objects floating around in a quite 3D manner. For example, let’s make a panel with happy faces floating around the screen in a controlled way, like this one.</p> <h3>See how it looks</h3> <p><a href="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Floating_2.png"><img width="749" height="370" title="Floating" style="display: inline;border: 0px solid;" alt="Floating" src="http://www.silverlightshow.net/Storage/Users/miromiroslavov/Floating_thumb.png" /></a> </p> <h3>Floating in Action</h3> <p><object width="600" height="300" data="data:application/x-silverlight-2," type="application/x-silverlight-2" autoupdate="true"> <param name="source" value="http://www.silverlightshow.net/Storage/demos/FloatingObjects.xap"/> <param name="minRuntimeVersion" value="3.0.40624.0"/> <param name="background" value="White"/> <param name="autoUpgrade" value="true"/> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"> </a> </object></p> <h3>Idea</h3> <p>The idea is to create an attached behavior for a panel, so that when enabled, through attached property it’ll make all panel’s children float around. To make this effect we will use <em>PlaneProjection </em>and <em>TranslateTransform</em>. We’ll create <em>Storyboard </em>that<em> </em>will animate these properties, to random values (but in controlled manner with a threshold) and when it completes – the animation will begin again with changed “To” by random. This way we’ll create random continuous floating of the visual objects.</p> <h3>Implementation</h3> <p>We need a class that holds the attached property. Let’s name it <em>FloatingService. </em>It has one attached property, for instance <em>IsChildrenFloating</em> of type boolean to trigger the behavior and two more properties to handle the Maximum allowed values for the PlaneProjection and TranslateTransform. So when <em>IsChildrenFloating</em> is attached to the panel with value of true, all its children will start floating. </p> <p>This is how we control the animation in the <em>FloatingService</em> class.</p> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span>var panel = sender <span style="color: #0000ff;">as</span> Panel;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span><span style="color: #0000ff;">if</span> (panel != <span style="color: #0000ff;">null</span>)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span>{</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> var projectionMax = GetProjectionMax(panel);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> var translateMax = GetTranslateMax(panel);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;">foreach</span> (UIElement child <span style="color: #0000ff;">in</span> panel.Children)</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> var storyboard = <span style="color: #0000ff;">new</span> Storyboard();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> PlaneProjection planeProjection;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> child.EnsureProjection(<span style="color: #0000ff;">out</span> planeProjection);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> DoubleAnimation projectionX = AnimationFactory.CreateProjectionXAnimation(planeProjection, random.Next(-projectionMax, projectionMax), seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> DoubleAnimation projectionY = AnimationFactory.CreateProjectionYAnimation(planeProjection, random.Next(-projectionMax, projectionMax), seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> DoubleAnimation projectionZ = AnimationFactory.CreateProjectionZAnimation(planeProjection, random.Next(-projectionMax, projectionMax), seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> storyboard.Children.Add(projectionX);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> storyboard.Children.Add(projectionY);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> storyboard.Children.Add(projectionZ);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> ScaleTransform scale;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> TranslateTransform translate;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> RotateTransform rotate;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> SkewTransform skew;</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> child.EnsureTransforms(<span style="color: #0000ff;">out</span> scale, <span style="color: #0000ff;">out</span> rotate, <span style="color: #0000ff;">out</span> skew, <span style="color: #0000ff;">out</span> translate);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> DoubleAnimation translateX = AnimationFactory.CreateTranslateXAnimation(translate, random.Next(-translateMax, translateMax), seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> DoubleAnimation translateY = AnimationFactory.CreateTranslateYAnimation(translate, random.Next(-translateMax, translateMax), seconds);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> storyboard.Children.Add(translateX);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span> storyboard.Children.Add(translateY);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span>  </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span> storyboard.Completed += (s, e1) =></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span> {</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> projectionX.To = random.Next(-projectionMax, projectionMax);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span> projectionY.To = random.Next(-projectionMax, projectionMax);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum38" style="color: #606060;"> </span> projectionZ.To = random.Next(-projectionMax, projectionMax);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum39" style="color: #606060;"> </span> translateX.To = random.Next(-translateMax, translateMax);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum40" style="color: #606060;"> </span> translateY.To = random.Next(-translateMax, translateMax);</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum41" style="color: #606060;"> </span> storyboard.Begin();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum42" style="color: #606060;"> </span> };</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum43" style="color: #606060;"> </span> storyboard.Begin();</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum44" style="color: #606060;"> </span> }</pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum45" style="color: #606060;"> </span>}</pre> </div> </div> <p>So we create Storyboard from code, to hold the 5 animations – for rotating X,Y,Z and translating X,Y. And when the Storyboard finishes we choose new random values for end of the animations and start it again.</p> <p>And now we only need to use the attached behavior to begin the floating of visuals.</p> <h3>How to use the behavior</h3> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;"><</span><span style="color: #800000;">StackPanel</span> <span style="color: #ff0000;">FloatingObjects:FloatingService</span>.<span style="color: #ff0000;">IsChildrenFloating</span><span style="color: #0000ff;">="True"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span> <span style="color: #ff0000;">FloatingObjects:FloatingService</span>.<span style="color: #ff0000;">TranslateMax</span><span style="color: #0000ff;">="10"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #ff0000;">FloatingObjects:FloatingService</span>.<span style="color: #ff0000;">ProjectionMax</span><span style="color: #0000ff;">="25"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #ff0000;">Orientation</span><span style="color: #0000ff;">="Horizontal"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="Center"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">StackPanel.Resources</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Style</span> <span style="color: #ff0000;">TargetType</span><span style="color: #0000ff;">="ContentControl"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> <span style="color: #ff0000;">x:Key</span><span style="color: #0000ff;">="faceControl"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="Height"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="75"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="Width"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="75"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="Margin"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="10"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="Effect"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter.Value</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">DropShadowEffect</span> <span style="color: #ff0000;">BlurRadius</span><span style="color: #0000ff;">="5"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> <span style="color: #ff0000;">Color</span><span style="color: #0000ff;">="Black"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> <span style="color: #ff0000;">Opacity</span><span style="color: #0000ff;">=".7"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Setter.Value</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Setter</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="Template"</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter.Value</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ControlTemplate</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Grid</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Rectangle</span> <span style="color: #ff0000;">Fill</span><span style="color: #0000ff;">="{TemplateBinding Background}"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Ellipse</span> <span style="color: #ff0000;">Height</span><span style="color: #0000ff;">="10"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> <span style="color: #ff0000;">Width</span><span style="color: #0000ff;">="10"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> <span style="color: #ff0000;">Fill</span><span style="color: #0000ff;">="Blue"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span> <span style="color: #ff0000;">Margin</span><span style="color: #0000ff;">="20 20 0 0"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #0000ff;">="Left"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="Top"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Ellipse</span> <span style="color: #ff0000;">Height</span><span style="color: #0000ff;">="10"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span> <span style="color: #ff0000;">Fill</span><span style="color: #0000ff;">="Blue"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span> <span style="color: #ff0000;">Width</span><span style="color: #0000ff;">="10"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> <span style="color: #ff0000;">Margin</span><span style="color: #0000ff;">="0 20 20 0"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #0000ff;">="Right"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum38" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="Top"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum39" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Path</span> <span style="color: #ff0000;">Data</span><span style="color: #0000ff;">="M0,0 A 10, 10 0 0 0 25, 0"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum40" style="color: #606060;"> </span> <span style="color: #ff0000;">Stroke</span><span style="color: #0000ff;">="#FFFA0D0D"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum41" style="color: #606060;"> </span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #0000ff;">="Center"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum42" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="Bottom"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum43" style="color: #606060;"> </span> <span style="color: #ff0000;">Margin</span><span style="color: #0000ff;">="0 0 0 10"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum44" style="color: #606060;"> </span> <span style="color: #ff0000;">StrokeThickness</span><span style="color: #0000ff;">="2"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum45" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Grid</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum46" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">ControlTemplate</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum47" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Setter.Value</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum48" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Setter</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum49" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Style</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum50" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">StackPanel.Resources</span><span style="color: #0000ff;">></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum51" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum52" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum53" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Yellow"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum54" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum55" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Silver"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum56" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum57" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Cyan"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum58" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum59" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Green"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum60" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum61" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Brown"</span> <span style="color: #0000ff;">/></span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum62" style="color: #606060;"> </span><span style="color: #0000ff;"></</span><span style="color: #800000;">StackPanel</span><span style="color: #0000ff;">></span></pre> <!--CRLF--></div> </div> <h3><a href="http://www.silverlightshow.net/Storage/Sources/FloatingObjects.zip">Download the code</a></h3> <p>Stay tuned for the next articles from this series coming up next week.</p> http://www.silverlightshow.net/items/Floating-Visual-Elements.aspx editorial@silverlightshow.net (Miroslav Miroslavov ) http://www.silverlightshow.net/items/Floating-Visual-Elements.aspx#comments http://www.silverlightshow.net/items/Floating-Visual-Elements.aspx Tue, 04 May 2010 03:23:00 GMT Visuals staring at the mouse cursor <p><em>This article is compatible with the latest version of Silverlight. </em></p> <p><strong>This is part 1 of the series "Silverlight in Action".</strong></p> <p><strong>Here we’re sharing our experience from the amazing </strong><a href="http://www.completit.com/"><strong>CompletIT </strong></a><strong>web site. </strong></p> <h4><strong></strong></h4> <h4><strong></strong></h4> <p>Let's suppose we want our visual objects to "watch" and "follow with eyes" the mouse cursor while it moves around. The idea is simply to define our visuals to be somehow on a different Z coordinate than the actual screen is. This way while moving the cursor around, the visual objects will look and follow the mouse. We'll use a simple <strong>PlaneProjection</strong> to achieve this.</p> <p>This is very important part of the actual “look and feel” of the web site. The main menu items are following the mouse while moving the cursor around.</p> <h3>See how it looks</h3> <p><a href="http://www.silverlightshow.net/Storage/Users/miromiroslavov/FollowMouse_2.jpg"><img width="749" height="361" title="FollowMouse" style="display: inline;border: 0px solid;" alt="FollowMouse" src="http://www.silverlightshow.net/Storage/Users/miromiroslavov/FollowMouse_thumb.jpg" /></a> </p> <h3></h3> <h3>Following in action</h3> <p><object width="640" height="300" data="data:application/x-silverlight-2," type="application/x-silverlight-2" autoupdate="true"> <param name="source" value="http://www.silverlightshow.net/Storage/demos/FollowingMouse.xap"/> <param name="minRuntimeVersion" value="3.0.40624.0"/> <param name="background" value="White"/> <param name="autoUpgrade" value="true"/> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"> </a> </object></p> <h3>Implementation</h3> The idea is to create an attached behavior for a panel, so all its children will stare at the mouse. We need two attached properties of the behaviour: <ul> <li><strong>IsChildrenFollowingMouse </strong>- just to enable the behavior for that panel. </li> <li><strong>ItemsZ </strong>- the Z coordinate of the Items. This means how far the items are from the screen. </li> </ul> <p>We need to handle the <strong>MouseMove</strong> event, so we can rotate our visuals in such a way, that they will look like are following the mouse. </p> <h5>Here is the actual magic</h5> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> panel_MouseMove(<span style="color: #0000ff;">object</span> sender, MouseEventArgs e) </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>{ </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> var panel = sender <span style="color: #0000ff;">as</span> Panel; </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #0000ff;">if</span> (panel != <span style="color: #0000ff;">null</span>) </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> { </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> var point = e.GetPosition(panel); </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> var z = GetItemsZ(panel); </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> <span style="color: #0000ff;">foreach</span> (FrameworkElement item <span style="color: #0000ff;">in</span> panel.Children) </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> { </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> var center = item.TransformToVisual(panel).Transform(<span style="color: #0000ff;">new</span> Point(item.ActualWidth / 2, item.ActualHeight / 2)); </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> <span style="color: #008000;">//Vector from current point to 3D center of the item. </span></pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> <span style="color: #0000ff;">double</span> len = Math.Sqrt(Math.Pow(center.X - point.X, 2) + Math.Pow(center.Y - point.Y, 2) + z * z); </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> <span style="color: #0000ff;">double</span> cosOy = (center.Y - point.Y) / len; </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> <span style="color: #0000ff;">double</span> cosOx = (center.X - point.X) / len; </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> PlaneProjection projection; </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> EnsureProjection(item, <span style="color: #0000ff;">out</span> projection); </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> projection.RotationX = Math.Acos(cosOy) * (180 / Math.PI) - 90; </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> projection.RotationY = 90 - Math.Acos(cosOx) * (180 / Math.PI); </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> } </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> } </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span>} </pre> <!--CRLF--></div> </div> <p>What we actually do is just a simple math. We calculate the angles between the line (from the cursor to the center of the item) and the Ox and Oy axes of the item’s surface (the item's actually with different z-coordinate from the screen). Having the angles, we can calculate the needed RotationX and RotationY properties. You can see the drawing over the screenshot for reference.</p> <p>So let's see how we use the newly created Attached properties, to force our panel's children to track the mouse.</p> <h5>How to use the behavior</h5> <div id="codeSnippetWrapper" style="text-align: left; padding-bottom: 4px; line-height: 12pt; overflow-x: auto; overflow-y: auto; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'courier new', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text; padding-top: 4px;border: silver 1px solid;"> <div id="codeSnippet" style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum1" style="color: #606060;"> </span><span style="color: #0000ff;"><</span><span style="color: #800000;">Grid</span> <span style="color: #ff0000;">x:Name</span><span style="color: #0000ff;">="LayoutRoot"</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Grid.Resources</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Style</span> <span style="color: #ff0000;">TargetType</span><span style="color: #0000ff;">="StackPanel"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> <span style="color: #ff0000;">x:Key</span><span style="color: #0000ff;">="st"</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="FollowingMouse:FollowingService.IsChildrenFollowingMouse"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="True"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="FollowingMouse:FollowingService.ItemsZ"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="200"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Style</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Grid.Resources</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">StackPanel</span> <span style="color: #ff0000;">Orientation</span><span style="color: #0000ff;">="Horizontal"</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource st}"</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">StackPanel.Resources</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum13" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Style</span> <span style="color: #ff0000;">TargetType</span><span style="color: #0000ff;">="ContentControl"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum14" style="color: #606060;"> </span> <span style="color: #ff0000;">x:Key</span><span style="color: #0000ff;">="faceControl"</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum15" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="Height"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum16" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="75"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum17" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="Width"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum18" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="75"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum19" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="Margin"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum20" style="color: #606060;"> </span> <span style="color: #ff0000;">Value</span><span style="color: #0000ff;">="10"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum21" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter</span> <span style="color: #ff0000;">Property</span><span style="color: #0000ff;">="Template"</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum22" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Setter.Value</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum23" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ControlTemplate</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum24" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Grid</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum25" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Ellipse</span> <span style="color: #ff0000;">Fill</span><span style="color: #0000ff;">="{TemplateBinding Background}"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum26" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Ellipse</span> <span style="color: #ff0000;">Height</span><span style="color: #0000ff;">="10"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum27" style="color: #606060;"> </span> <span style="color: #ff0000;">Width</span><span style="color: #0000ff;">="10"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum28" style="color: #606060;"> </span> <span style="color: #ff0000;">Fill</span><span style="color: #0000ff;">="Blue"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum29" style="color: #606060;"> </span> <span style="color: #ff0000;">Margin</span><span style="color: #0000ff;">="20 20 0 0"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum30" style="color: #606060;"> </span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #0000ff;">="Left"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum31" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="Top"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum32" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Ellipse</span> <span style="color: #ff0000;">Height</span><span style="color: #0000ff;">="10"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum33" style="color: #606060;"> </span> <span style="color: #ff0000;">Fill</span><span style="color: #0000ff;">="Blue"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum34" style="color: #606060;"> </span> <span style="color: #ff0000;">Width</span><span style="color: #0000ff;">="10"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum35" style="color: #606060;"> </span> <span style="color: #ff0000;">Margin</span><span style="color: #0000ff;">="0 20 20 0"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum36" style="color: #606060;"> </span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #0000ff;">="Right"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum37" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="Top"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum38" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">Path</span> <span style="color: #ff0000;">Data</span><span style="color: #0000ff;">="M0,0 A 10, 10 0 0 0 25, 0"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum39" style="color: #606060;"> </span> <span style="color: #ff0000;">Stroke</span><span style="color: #0000ff;">="#FFFA0D0D"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum40" style="color: #606060;"> </span> <span style="color: #ff0000;">HorizontalAlignment</span><span style="color: #0000ff;">="Center"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum41" style="color: #606060;"> </span> <span style="color: #ff0000;">VerticalAlignment</span><span style="color: #0000ff;">="Bottom"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum42" style="color: #606060;"> </span> <span style="color: #ff0000;">Margin</span><span style="color: #0000ff;">="0 0 0 10"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum43" style="color: #606060;"> </span> <span style="color: #ff0000;">StrokeThickness</span><span style="color: #0000ff;">="2"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum44" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Grid</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum45" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">ControlTemplate</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum46" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Setter.Value</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum47" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Setter</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum48" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">Style</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum49" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">StackPanel.Resources</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum50" style="color: #606060;"> </span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum51" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum52" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Yellow"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum53" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum54" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Silver"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum55" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum56" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Cyan"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum57" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum58" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Green"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum59" style="color: #606060;"> </span> <span style="color: #0000ff;"><</span><span style="color: #800000;">ContentControl</span> <span style="color: #ff0000;">Style</span><span style="color: #0000ff;">="{StaticResource faceControl}"</span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum60" style="color: #606060;"> </span> <span style="color: #ff0000;">Background</span><span style="color: #0000ff;">="Brown"</span> <span style="color: #0000ff;">/></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum61" style="color: #606060;"> </span> <span style="color: #0000ff;"></</span><span style="color: #800000;">StackPanel</span><span style="color: #0000ff;">></span> </pre> <!--CRLF--> <pre style="text-align: left; padding-bottom: 0px; line-height: 12pt; overflow-x: visible; overflow-y: visible; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; color: black; font-size: 8pt; padding-top: 0px;border-style: none;"><span id="lnum62" style="color: #606060;"> </span><span style="color: #0000ff;"></</span><span style="color: #800000;">Grid</span><span style="color: #0000ff;">></span> </pre> </div> </div> <h3><a href="http://www.silverlightshow.net/Storage/Sources/FollowingMouse.zip">Download the code.</a></h3> <p>Stay tuned for the next articles from this series coming up next week</p> http://www.silverlightshow.net/items/Visuals-staring-at-the-mouse-cursor.aspx editorial@silverlightshow.net (Miroslav Miroslavov ) http://www.silverlightshow.net/items/Visuals-staring-at-the-mouse-cursor.aspx#comments http://www.silverlightshow.net/items/Visuals-staring-at-the-mouse-cursor.aspx Thu, 22 Apr 2010 11:28:00 GMT Completit.com - the challenges behind building a corporate website in Silverlight <p><a href="http://www.completit.com/"><em>CompletIT</em></a><em> – the company behind SilverlightShow – has recently launched its </em><a href="http://www.completit.com/"><em>new corporate website</em></a><em>, done entirely in Silverlight. In this case study, CompletIT CTO Emil Stoychev and Development Lead Miroslav Miroslavov reveal the challenges faced during the management and development of this Silverlight project.</em>  </p> <h3><strong>Company Profile</strong></h3> <p><strong>Company name</strong>: CompletIT <br /> <strong>Website</strong>: <a href="http://www.completit.com/">http://www.completit.com/</a> <br /> <strong>Industry</strong>: Software Development, Consultations, Trainings <br /> <strong>Brief intro to company</strong>: CompletIT is a privately owned company specialized in Silverlight software development, Silverlight training and consulting services. Founded in 2006, the company has successfully delivered more than 30 customer projects, ranging from small business applications to large enterprise solutions. CompletIT was selected as Microsoft Featured Silverlight Partner for March 2010, and is a Microsoft Certified Gold Partner. </p> <h3><strong>Project Overview</strong></h3> <p><strong>Project goals and key functionalities</strong></p> <p>The main goal of the project was to show what CompletIT can do with Silverlight without saying a word. We wanted to demonstrate to our website visitors (who are our current or potential customers) what can be achieved with Silverlight, what a powerful technology it is, what level of interactivity may be achieved with it, how the user experience may be improved by using Silverlight. Among the key functionalities in the project are flying 3D objects, interactive navigation with some object flying in the clouds, animated page flipping, animated 360˚ navigation flip, 3D world in which you can move.</p> <p><strong>Project limitations - technologies to be used, time, resources, etc</strong>.</p> <p>We are focused on Silverlight so that technology was a must. It was hard to estimate the project duration as the application was too futuristic and nothing like what we've been working on before. We decided on a fairly optimistic timeframe for completion of the project, and only because of the commitment and experience of the whole team we managed to meet it.</p> <p><strong>Silverlight features used in this project</strong></p> <ul> <li>Animations: <ul> <li>Build-in animations API based on Storyboards </li> <li>Custom animations based on CompositionTarget.Rendering </li> <li>Custom animations based on DispatcherTimer </li> <li>Sprite animations </li> </ul> </li> <li>WriteableBitmap API for performance optimizations </li> <li>3D Projection API </li> <li>Render Transforms API <ul> <li>ScaleTransform </li> <li>TranslateTransform </li> <li>RotateTransform </li> <li>SkewTransform </li> </ul> </li> <li>Math formulas </li> <li>Mouse events API </li> <li>Custom controls and templates </li> <li>WCF - Silverlight enabled services  </li> <li>Third-party Silverlight control </li> </ul> <p><strong>Other technologies used</strong> </p> <p>WCF services, Sitefinity CMS </p> <p><strong>Project snapshots</strong> - <strong>before / after</strong></p> <p><img alt="" style="width: 648px; height: 216px;" src="http://www.silverlightshow.net/Storage/userfiles/dc7c56mc_315g3zhc4fz_b.png" /></p> <p><img alt="" style="width: 648px; height: 216px;" src="http://www.silverlightshow.net/Storage/userfiles/dc7c56mc_316c4s42kgt_b.png" /></p> <p><img alt="" style="width: 648px; height: 216px;" src="http://www.silverlightshow.net/Storage/userfiles/dc7c56mc_317dq48twhp_b.png" /></p> <h3>  </h3> <h3><strong>Problems Faced and Solutions</strong></h3> <p><strong>One of the hardest problems was "How to make smoke effect?"</strong> <br /> We've tried a lot of ideas and read almost everything on the net about "how to simulate smoke", but all of them had problems and they weren't exactly what we needed. But finally we came up with the solution on our own. We've created a Sprite-like animation with preset frames, some custom control logic and finally - we had a great smoking main menu! <br /> <br /> <strong>Another huge problem was "How to make the whole application deep-linkable, navigateable and fully integrated with browsers?" <br /> </strong>We needed to be integrated with the browser, but also the pages had to navigate to each other using animation. We thought about using TransitioningContentControl from the Silverlight Toolkit, but instead of control we needed to transition between pages. And that's how we came up with solution. Now we have nice transitions and animations while navigating back and forward.</p> <p><strong>The whole look and feel of the site is amazing. But how can all of this work in the browser, and perform well enough?</strong> <br /> Performance was the hardest thing to deal with. We read a lot of blogs and articles, watched a lot of videos from the biggest conferences. Finally, we summarized all performance tips and tricks and implemented most of them. We also created some custom animation logic to achieve better performance. We ended up with a very well-performing website (considering all these nice animations). <br /> Of course all the features like 3D world and the animations in it, flying and floating things were also interesting problems. But with the very powerful Silverlight APIs, we've been able to implement them with ease.</p> <h3><strong>Conclusions</strong></h3> <p>We think we managed to achieve the initial goals of the project, because we received a lot of positive feedback, a lot of compliments for our work. There aren't many Silverlight based application on the web that incorporate so many animations and interactivity. The final performance that we achieved is more than pleasant - we got around 30% CPU usage which talks both for the platform and for the quality of our applications. For comparison, most of the DeepZoom based applications use more than 70% of CPU.</p> <p>People like interactivity, animations, weird design ideas and we think Silverlight is more than appropriate to build that kind of stuff. For future projects we would definitely bet on great user experience and interactivity. </p> <p> </p> <h3 style="line-height: 30px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 20px; font-weight: normal;"><strong>Related Articles:</strong></h3> <div> <ol> <li><a href="http://www.silverlightshow.net/items/Visuals-staring-at-the-mouse-cursor.aspx" target="_self">Visuals staring at the mouse cursor</a> </li> <li><a href="http://www.silverlightshow.net/items/Floating-Visual-Elements.aspx" target="_self">Floating Visual Elements</a> </li> <li><a href="http://www.silverlightshow.net/items/Flipping-panels.aspx" target="_self">Flipping panels</a> </li> <li><a href="http://www.silverlightshow.net/items/Flying-objects-against-you.aspx" target="_self">Flying objects against you</a> </li> <li><a href="http://www.silverlightshow.net/items/smoke-effect.aspx" target="_self">Smoke effect</a> </li> <li><a href="http://www.silverlightshow.net/items/Book-Folding-effect-using-Pixel-Shader.aspx" target="_self">Book Folding effect using Pixel Shader</a> </li> <li><a href="http://www.silverlightshow.net/items/Navigation-in-3D-world-of-2D-objects.aspx" target="_self">Navigation in 3D world of 2D objects</a> </li> <li><a href="http://www.silverlightshow.net/items/Animated-navigation-between-Pages.aspx" target="_self">Animated navigation between Pages</a> </li> </ol> </div> <p> </p> http://www.silverlightshow.net/items/Completit.com-the-challenges-behind-building-a-corporate-website-in-Silverlight.aspx editorial@silverlightshow.net (Svetla Stoycheva ) http://www.silverlightshow.net/items/Completit.com-the-challenges-behind-building-a-corporate-website-in-Silverlight.aspx#comments http://www.silverlightshow.net/items/Completit.com-the-challenges-behind-building-a-corporate-website-in-Silverlight.aspx Fri, 16 Apr 2010 01:55:00 GMT