tag:blogger.com,1999:blog-887975141009593463Fri, 12 Mar 2010 17:59:50 +0000HackingSilverlightSilverlight for the real world... HackingSilver.nethttp://hackingsilverlight.blogspot.com/noreply@blogger.com (david.kelley)Blogger241125tag:blogger.com,1999:blog-887975141009593463.post-1925394388865268466Fri, 12 Mar 2010 17:46:00 +00002010-03-12T09:59:50.870-08:00silverlight insidersHacking Silverlightsilverlight 4silverlightc#jeremiahhackinghackcomDirty Dirty Silverlight Hack... - Silverlight 4 Hack: Use Native/Desktop CLR Without COM RegistrationHere is a hack of the month. Jeremiah is probably my favoriate Silverlight Prodagy and he has done it again with this wonderful hack, 'Use Native/Desktop CLR Without COM Registration' I like the first line, "WARNING: Information and code here can easily be abused. Please do not use it as a crutch in application planning, but more for utter despair or experimentation. Thus I wrote this blog post from that perspective."<br /><br />Certainly Jeremiah's code can be abused but what is really interesting to me is how this is one more way to push the limits of what Silverlight can do. 'Hacking' doesn't have to be evil but can be just that pushing the limits and making things better. With that commentary here is the first paragraph and sample code from his article and for the rest you will have to go read his post:<br /><br />Silverlight 4 + OOB + Elevated Trust gives us the ability to use COM. That would be extremely useful (vs. really useful), except we cannot use just any COM class. It has to support IDispatch (COM automation). It also has to have a ProgID associated to it. That leaves you still with quite a few built-in COM objects to work with, as Justin document's quite well here. What about running our own native or .NET code? One would have to register a COM object first, which requires administrator rights. That’s no fun for an end user! Optimally, it would be nice to be able to add your desktop CLR objects as resources to your XAP, and from Silverlight code, be able to instantiate and use your Desktop .NET classes. This is a hack to do just that.<br /><br />Huh? What does the hack do?<br />Let me explain it in code.<br /><br />/* Create our Desktop .NET helper */<br />dynamic fullDotNetProxy = fullDotNetProxy = ComAutomationFactory.CreateObject("ClrProxy");<br /><br />/* Have our .NET helper load up our .NET assembly we extracted from our SL app resources */<br />dynamic assembly = fullDotNetProxy.GetAssembly(m_assembliesPath + "\\Inject.Test.dll");<br /><br />/* Get our .NET Type */<br />dynamic testClassType = fullDotNetProxy.GetDotNetType(assembly, " Inject.Test.TestClass");<br /><br />/* Create an object instance of our .NET type */<br />m_testClass = fullDotNetProxy.CreateInstance(testClassType);<br /><br />/* Run our RunMe method on our .NET object */<br />m_testClass.RunMe();<br /><br /><br />Read the rest at:<br /><br /><a href="http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/442/Silverlight-4-Hack-Use-Native-Desktop-CLR-Without-COM-Registration.aspx">http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/442/Silverlight-4-Hack-Use-Native-Desktop-CLR-Without-COM-Registration.aspx</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-1925394388865268466?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/03/dirty-dirty-silverlight-hack.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-7151791689204215859Thu, 04 Mar 2010 22:43:00 +00002010-03-04T14:51:41.185-08:00snackhackProgramatically Setting Margin On Elements...Foo.Margin = new Thickness(0, 50, 24, 6);<br /><br />really thats it...<br /><br />as defined by:<br /><br />[Named UIElement].Margin = new Thickness( [double] , [double], [double], [double]);<br /><br />or go the extra mile and use intellisense...<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-7151791689204215859?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/03/programatically-setting-margin-on.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-6092098597532811007Thu, 04 Mar 2010 05:32:00 +00002010-03-03T21:33:32.119-08:00agileinteractcmmmethodologyarchitectureUXDoes Your Agile/UX (User eXperience) Shop have a CMM Rating?I posted this article on Interact:<br /><br />"<span style="FONT-FAMILY: 'Georgia', 'serif'; FONT-SIZE: 10pt">CMM? what is that? is the typical response I get when asking about CMM. For starters CMM = Capability Maturity Model For Software Engineering project methodologies. Basically it’s a way to rate how good a software shop is with regard to its process. Now in the UX/Agile space talk of applying Software Engineering metrics such as the Capability Maturity Model For Software Engineering from Carnegie Mellon University might be a bit more than most will deal with <img class="wp-smiley" alt=":)" src="http://www.interactseattle.org/wp-includes/images/smilies/icon_smile.gif" /> however being exposed to both worlds I think it is worthwhile to talk about what UX/Agile can learn..."</span><br /><span style="FONT-FAMILY: 'Georgia', 'serif'; FONT-SIZE: 10pt"></span><br /><span style="FONT-FAMILY: 'Georgia', 'serif'; FONT-SIZE: 10pt">Read more at <a href="http://www.interactseattle.org/?p=476">http://www.interactseattle.org/?p=476</a> </span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-6092098597532811007?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/03/does-your-agileux-user-experience-shop.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-4042088402087337715Tue, 16 Feb 2010 19:27:00 +00002010-02-22T23:03:57.705-08:00Hacking SilverlightPDCbixapUXhackHacking the Xap for Business Intelligence (BI)I did a post a while ago on 'Hacking <span id="SPELLING_ERROR_0" class="blsp-spelling-error"><span id="SPELLING_ERROR_0" class="blsp-spelling-error">Xap</span></span>' files primarily around <span id="SPELLING_ERROR_1" class="blsp-spelling-corrected">dynamical</span> loading resources. The past few months I have been playing with another even cooler way to 'hack' <span id="SPELLING_ERROR_2" class="blsp-spelling-error"><span id="SPELLING_ERROR_1" class="blsp-spelling-error">xap</span></span> files. In this case its about business and taking a <span id="SPELLING_ERROR_3" class="blsp-spelling-error"><span id="SPELLING_ERROR_2" class="blsp-spelling-error">precompiled</span></span> <span id="SPELLING_ERROR_4" class="blsp-spelling-error"><span id="SPELLING_ERROR_3" class="blsp-spelling-error">xap</span></span> file and <span id="SPELLING_ERROR_5" class="blsp-spelling-corrected">instrumenting</span> that <span id="SPELLING_ERROR_6" class="blsp-spelling-error"><span id="SPELLING_ERROR_4" class="blsp-spelling-error">xap</span></span> file without recompiling your application or any code changes to the application. This kind of detailed usage information can be extremely helpful in looking at how applications are used and help identify key areas to focus on. From a hack standpoint to take a <span id="SPELLING_ERROR_7" class="blsp-spelling-error"><span id="SPELLING_ERROR_5" class="blsp-spelling-error">precompiled</span></span> <span id="SPELLING_ERROR_8" class="blsp-spelling-error"><span id="SPELLING_ERROR_6" class="blsp-spelling-error">xap</span></span> and put 'code' into all the method calls dynamically is just cool. Granted that collected information just doesn't show up on your desktop, you have to build a web service to collect the data but just the fact that I can take a <span id="SPELLING_ERROR_9" class="blsp-spelling-error"><span id="SPELLING_ERROR_7" class="blsp-spelling-error">precompiled</span></span> <span id="SPELLING_ERROR_10" class="blsp-spelling-error"><span id="SPELLING_ERROR_8" class="blsp-spelling-error">xap</span></span> and get it wired up without any jumping around is just cool.<br /><br />so lets get to the meat of my experience...<br /><br />I meet with a guy at <span id="SPELLING_ERROR_11" class="blsp-spelling-error"><span id="SPELLING_ERROR_9" class="blsp-spelling-error">PDC</span></span>09 at well <span id="SPELLING_ERROR_12" class="blsp-spelling-error"><span id="SPELLING_ERROR_10" class="blsp-spelling-error">PDC</span></span> from Preemptive Solutions <a href="http://www.preemptive.com/">http://www.preemptive.com/</a> and he brought up a tool that they have that is part of their '<span id="SPELLING_ERROR_13" class="blsp-spelling-error"><span id="SPELLING_ERROR_11" class="blsp-spelling-error">dotfuscator</span></span>' product. Most .net developers have either heard of '<span id="SPELLING_ERROR_14" class="blsp-spelling-error"><span id="SPELLING_ERROR_12" class="blsp-spelling-error">dotfuscator</span></span>' or seen it since its part of visual studio. But part of their main '<span id="SPELLING_ERROR_15" class="blsp-spelling-error"><span id="SPELLING_ERROR_13" class="blsp-spelling-error">dotfuscator</span></span>' tool is around 'Business Intelligence' and a little known additional feature that in my mind should be the main focus is my main interest and the subject of this post. In any case I got excited about this <span id="SPELLING_ERROR_16" class="blsp-spelling-error"><span id="SPELLING_ERROR_14" class="blsp-spelling-error">xap</span></span> hacking tool er 'Business Intelligence tool' and he got myself a license.<br /><br />So I got my license and found that getting it working is/was very problematic, not only a license key but an activation key and a bi key etc. I had to get a hold of tech support basically twice with an ongoing thread with their tech support... to be honest I'm no longer a fan of <span id="SPELLING_ERROR_17" class="blsp-spelling-error"><span id="SPELLING_ERROR_15" class="blsp-spelling-error">DRM</span></span> or any other security system that prevents apps from running when installed or secures files. I understand that this is needed to keep software from being pirated and intellectual property stolen but preemptive got way overly excited with their implementation.<br /><br />Install experience and setup aside it all seems pretty straight forward. The hard part of using the software is building the <span id="SPELLING_ERROR_18" class="blsp-spelling-error"><span id="SPELLING_ERROR_16" class="blsp-spelling-error">wcf</span></span> service and collecting the data. Once you get a service up and running though you basically just need to load your <span id="SPELLING_ERROR_19" class="blsp-spelling-error"><span id="SPELLING_ERROR_17" class="blsp-spelling-error">xap</span></span> and pick where you want to collect data in your app and point it at the web service. The fact that you don't need to re-<span id="SPELLING_ERROR_20" class="blsp-spelling-corrected">compile</span> your <span id="SPELLING_ERROR_21" class="blsp-spelling-error"><span id="SPELLING_ERROR_18" class="blsp-spelling-error">xap</span></span> is just awesome. And from a <span id="SPELLING_ERROR_22" class="blsp-spelling-error"><span id="SPELLING_ERROR_19" class="blsp-spelling-error">ux</span></span> standpoint getting this data really gives you insight into your application that you just couldn't get without writing <span id="SPELLING_ERROR_23" class="blsp-spelling-error"><span id="SPELLING_ERROR_20" class="blsp-spelling-error">alot</span></span> of code up front.<br /><br />If BI around usage of your application is important to you in building better <span id="SPELLING_ERROR_24" class="blsp-spelling-error"><span id="SPELLING_ERROR_21" class="blsp-spelling-error">Silverlight</span></span> apps then this tool is worth the <span id="SPELLING_ERROR_25" class="blsp-spelling-corrected">hassle</span> of getting it setup. As a <span id="SPELLING_ERROR_22" class="blsp-spelling-error">Silverlight</span> 'guy' I would list this as a critical tool in your tool <span id="SPELLING_ERROR_26" class="blsp-spelling-error"><span id="SPELLING_ERROR_23" class="blsp-spelling-error">Silverlight</span></span> toolbox.<br /><br />So to be fair to the company they provide an endpoint that users can use and I'm told there is a <span id="SPELLING_ERROR_24" class="blsp-spelling-error">codeplex</span> project for helping you build an <span id="SPELLING_ERROR_25" class="blsp-spelling-error">in house</span> solution and put the results on a <span id="SPELLING_ERROR_26" class="blsp-spelling-error">sharepoint</span> web part. My only issue with that is having another company have my usage data which or course would be crazy. Certainly I would not want anyone having my data as I have virtually no trust in other companies and their network security... but alas others might be <span id="SPELLING_ERROR_27" class="blsp-spelling-error">ok</span> with that. and using <span id="SPELLING_ERROR_28" class="blsp-spelling-error">sharepoint</span>... well just say no ;) <span id="SPELLING_ERROR_29" class="blsp-spelling-error">Sharepoint</span> provides a great solution if you don't want to customize it too much... :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-4042088402087337715?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/02/hacking-xap-for-business-intelligence.htmlnoreply@blogger.com (david.kelley)4tag:blogger.com,1999:blog-887975141009593463.post-4302880694282056781Thu, 11 Feb 2010 17:18:00 +00002010-02-11T09:25:05.799-08:00silverlightpixelshaderhackMore On Pixel ShadersSo don't get to excited, I'm certainly not the apotheosis of man and pixelshaders like Walter (<a href="http://shazzam-tool.com/" target="_blank">http://shazzam-tool.com/</a> ) but I do think they are really cool and along those lines I saw this great post off nokola this morning on 'Hue Shift in Pixel Shader 2.0' If your into pixel shaders this is a cool shader effict that as suggested in the title 'shifts the hue'. one of the reasons this post is cool is that it provides the shader source which makes worth while. :)<br /><br /><br /><a href="http://nokola.com/blog/post/2010/02/09/Someone-Said-it-Was-Impossible-Hue-Shift-in-Pixel-Shader-20-(Silverlight).aspx" target="_blank">http://nokola.com/blog/post/2010/02/09/Someone-Said-it-Was-Impossible-Hue-Shift-in-Pixel-Shader-20-(Silverlight).aspx</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-4302880694282056781?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/02/more-on-pixel-shaders.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-8720517392121498435Wed, 10 Feb 2010 22:35:00 +00002010-02-10T14:52:18.801-08:003DHacking Silverlighteinarisilverlight 4baldersilverlighthackinghackSilverlight 4 - 3D (ish)One of the great new features in Silverlight 3 was the ability todo psuedo 3d via what alot of us joke about as 2.5D. things like prespective transforms and the like.<br /><br />One of my fellow MVP's <a href="http://www.ingebrigtsen.info/">Einar Ingebrigtsen</a> got a bit zellous (must have been bored) and make this awesome tool kit for 3d (ish) in Silverlight 4. Granted its not native into the platform but honestly I'm not sure I want it built in. To much over head... But using a toolkit likeEinar's Balder really makes it reasonable.<br /><br />Here is the Sample Browser:<br /><a href="http://www.ingebrigtsen.info/silverlight/Balder/20100208/TestPage.html">http://www.ingebrigtsen.info/silverlight/Balder/20100208/TestPage.html</a><br /><br />and the code here:<br /><a href="http://balder.codeplex.com/">http://balder.codeplex.com</a> <br />and<br /><a href="http://github.com/einari/Balder">http://github.com/einari/Balder</a> <br /><br />from a ux standpoint I think the kind of visualization work for business is just awesome. Balder should be in everyones tool kit.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-8720517392121498435?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/02/silverlight-4-3d-ish.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-2470721203541206775Fri, 22 Jan 2010 18:53:00 +00002010-01-24T13:46:27.904-08:00MVVMsilverlightxamlsilverlight 3c#Lunch With Interact - MVVM Made EasyWe did a cool video pod cast on MVVM Made Easy. Had Erik Mork, Fabio Matsui and Jeremiah Morrill and we talked about MVVM and MVVM made easy and did a demo showing how to build an MVVM using this simple approach for an application in Silverlight.<br /><br /><a href="http://www.vimeo.com/8915487">http://www.vimeo.com/8915487</a><br /><br />check it out for more info...<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-2470721203541206775?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/01/lunch-with-interact-mvvm-for-tards.htmlnoreply@blogger.com (david.kelley)1tag:blogger.com,1999:blog-887975141009593463.post-7678219617033990707Thu, 21 Jan 2010 23:51:00 +00002010-01-24T13:56:07.723-08:00MVVMcodeplexsilverlightsilverlight 3Dependency Injection Made EasyPart of the whole fun with doing 'ard'd samples is just the fun of doing something not quit PC but the bottom line really is doing clear and concise samples that are easy to understand. Granted MVVM really was getting out of control so there was allot of passion about this but in general simple, clear and concise works much better in teaching ideas and concepts especially for less then geniuses such as my self. Today's post comes out of some editing of a video blog post on MVVM Made Simple and some one's mention of using dependency injection over standard binding to a ViewModel in MVVM. That said that is what I'll show today. The most simple implementation of Dependency Injection. Take a look at this sample Xaml code from a few from a Silverlight app using MVVM Made Simple:<br /><br />&lt;UserControl.DataContext&gt;<br />&lt;Simple:AViewModelClass /&gt;<br />&lt;/UserControl.DataContext&gt;<br /><br />You can see that we are setting the data context to the view in XAML to a particular ViewModel. In MVVM the idea is that the View is data bound to a ViewModel using DataContext and typically done in Xaml. From here Dependency Injection is one of those concepts that is over complicated by most poeple and mixed with MVVM that makes all of it harder to understand. So really if you are already reading this I'm making the assuming you have worked with MVVM Made Simple and understands it complete. That being the case Dependency Injection is a tweak to MVVM that allows from a programmatic standpoint more flexibility as to the ViewModel being bound to the View.<br /><br />The Xaml we looked at above is removed or at least the contents of DataContext is removed but in our codebehind we can do this:<br /><br />this.DataContext = new AViewModelClass();<br /><br />and now you know Dependency Injection... for 'ards (like me) at least. :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-7678219617033990707?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/01/dependency-injection-for-tards.htmlnoreply@blogger.com (david.kelley)3tag:blogger.com,1999:blog-887975141009593463.post-9176987267929247541Wed, 20 Jan 2010 19:22:00 +00002010-01-20T11:26:29.998-08:00wirestonesilverlighttvsimontouchMVPsilverlighttimsilverlight 3Silverlight TV Episode 3: Multi-Touch 101 with SilverlightJohn interviews Silverlight MVP David Kelley (thats me) about developing multi-touch applications in Silverlight. I discuss the types of multi-touch hardware and my experiences in developing real world multi-touch applications. Then I jumps right into the code and shows how to create a multi-touch application with Silverlight 3 or 4! The application David demonstrates walks through the key multi-touch events, handling those events, touch IDs, tracking the location of the touch points, and much more. Being a sly devil, John even got David to commit to coming on the show again and demonstrating some advanced multi-touch samples and sharing his stories of how developers have broken their monitors using multi-touch!<br /><br />David also calls out props to Tim Heuer and Davide Zordan!<br /><br /><a href="http://channel9.msdn.com/shows/SilverlightTV/Silverlight-TV-Episode-3-Multi-Touch-101-with-Silverlight/#Page=1">http://channel9.msdn.com/shows/SilverlightTV/Silverlight-TV-Episode-3-Multi-Touch-101-with-Silverlight/#Page=1</a> <br /><br />here is a quick post to the SL3 code we used from Tim Heuer<br /><br />Watch the video here:<br /><a href="http://timheuer.com/blog/archive/2009/07/30/silverlight-3-multi-touch-introduction-fundamentals-basics.aspx">http://timheuer.com/blog/archive/2009/07/30/silverlight-3-multi-touch-introduction-fundamentals-basics.aspx</a> <br /><br />this code converts easily to SL4 also here is a quick post more about the UX concepts used in multitouch<br /><br /><a href="http://hackingsilverlight.blogspot.com/2010/01/silverlight-multi-touch-in-real-world.html">http://hackingsilverlight.blogspot.com/2010/01/silverlight-multi-touch-in-real-world.html</a> <br /><br />also the simon demo that includes multitouch (will have an SL4 version at MIX) that Davide Zordan and I worked on.<br /><br /><a href="http://simon.codeplex.com/">http://simon.codeplex.com/</a> <br /><br />also John's post is <a href="http://johnpapa.net/silverlight/multi-touch-101-silverlight-tv-episode-3/">http://johnpapa.net/silverlight/multi-touch-101-silverlight-tv-episode-3/</a> <br /><br />watch for more on this topic in the next few months.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-9176987267929247541?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/01/silverlight-tv-episode-3-multi-touch.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-6413001440904090598Fri, 15 Jan 2010 00:57:00 +00002010-01-14T17:11:33.476-08:00wirestonesimonsilverlightMIXmicrosoftMIX10k Wirestones - the game...first shameless self promotion... Please check it out and vote 5 starts... Here is the link:<br /><br /><a href="http://mix10k.visitmix.com/entry/details/186">http://mix10k.visitmix.com/entry/details/186</a> <br /><br />That aside this is an interesting contest where the goal is to build the coolest application in under 10k in Silverlight 4 (what other kind is there?) and the problem is that this is not the binary but the source files... and it turns out the wirestone log in Adobe Illustrator had a lot of path data or defined 'points'... that being the case it took me a while to get something that would fit. <br /><br />If you interested in games like this there is a codeplex project we use for demos at <a href="http://simon.codeplex.com/">http://Simon.codeplex.com/</a> and you can go to <a href="http://www.hackingsilverlight.net/Simon.html">http://www.HackingSilverlight.net/Simon.html</a> to play the game.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-6413001440904090598?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/01/mix10k-wirestones-game.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-1194322209623113740Thu, 14 Jan 2010 15:47:00 +00002010-01-14T11:59:12.262-08:00touchretailmultitouchtimsilverlight 3Silverlight Multi-Touch In the Real World (once you go touch you never go back)John Papa asked me to help do a 10 minute segment for the <span id="SPELLING_ERROR_0" class="blsp-spelling-error">Silverlight</span> TV show for Channel 9. This got me thinking about <span id="SPELLING_ERROR_1" class="blsp-spelling-corrected">multi touch</span> from a demo standpoint and made me really think about what we have learned so far.<br /><br />In the general since we (as an industry or society) are really just starting to see touch become a major part of our day <span id="SPELLING_ERROR_2" class="blsp-spelling-corrected">to do</span> human machine interaction. On the Microsoft stack using Surface, Windows 7 and <span id="SPELLING_ERROR_3" class="blsp-spelling-error">WPF</span>/<span id="SPELLING_ERROR_4" class="blsp-spelling-error">Silverlight</span> <span id="SPELLING_ERROR_5" class="blsp-spelling-corrected">Multi touch</span> support it is really becoming standard stuff. At <a href="http://www.wirestone.com/" target="_blank"><span id="SPELLING_ERROR_6" class="blsp-spelling-error">Wirestone</span></a> we have really been on the fore front of doing user experience testing and real world development over the past year primarily in the retail space. Now the specific projects I can't talk about yet but let me see if I can come up with some usability rules that might help in your development. If you first just trying to figure out how <span id="SPELLING_ERROR_7" class="blsp-spelling-corrected">to do</span> it in <span id="SPELLING_ERROR_8" class="blsp-spelling-error">Silverlight</span> (starting in at least <span id="SPELLING_ERROR_9" class="blsp-spelling-error">Silverlight</span>3 or better) there is one main <span id="SPELLING_ERROR_10" class="blsp-spelling-error">API</span> you need to care about.<br /><br />take a look at this line of code:<br /><br />Touch.<span id="SPELLING_ERROR_11" class="blsp-spelling-error">FrameReported</span> += new <span id="SPELLING_ERROR_12" class="blsp-spelling-error">TouchFrameEventHandler</span>(Touch_<span id="SPELLING_ERROR_13" class="blsp-spelling-error">FrameReported</span>);<br /><br />this associates our one event handler that we care about. now lets take a look at using the event handler:<br /><br />void Touch_<span id="SPELLING_ERROR_14" class="blsp-spelling-error">FrameReported</span>(object sender, <span id="SPELLING_ERROR_15" class="blsp-spelling-error">TouchFrameEventArgs</span> e)<br />{<br /><span id="SPELLING_ERROR_16" class="blsp-spelling-error">foreach</span> (<span id="SPELLING_ERROR_17" class="blsp-spelling-error">TouchPoint</span> <span id="SPELLING_ERROR_18" class="blsp-spelling-error">tp</span> in e.<span id="SPELLING_ERROR_19" class="blsp-spelling-error">GetTouchPoints</span>(Positions))<br />{<br />if (<span id="SPELLING_ERROR_20" class="blsp-spelling-error">tp</span>.Action == <span id="SPELLING_ERROR_21" class="blsp-spelling-error">TouchAction</span>.Down)<br />{<br />// DO SOMETHING<br />}<br />else if (<span id="SPELLING_ERROR_22" class="blsp-spelling-error">tp</span>.Action == <span id="SPELLING_ERROR_23" class="blsp-spelling-error">TouchAction</span>.Up)<br />{<br />// DO SOMETHING ELSE<br />}<br />else if (<span id="SPELLING_ERROR_24" class="blsp-spelling-error">tp</span>.Action == <span id="SPELLING_ERROR_25" class="blsp-spelling-error">TouchAction</span>.Move)<br />{<br />// OR DO SOMETHING MORE ELSE<br />}<br />}<br />}<br /><br />you'll note that basically we are looping through the touch points, we get touch id's and based on the touch action we can do whatever it is we want. I encourage you to take a look at Tim's post on this and download his sample as he goes through this in detail and built a great <span id="SPELLING_ERROR_26" class="blsp-spelling-corrected">multi touch</span> app for testing how touch works using this method.<br /><br />check it out here and download <span id="SPELLING_ERROR_27" class="blsp-spelling-error">Tims</span> app. (it also converts to <span id="SPELLING_ERROR_28" class="blsp-spelling-error">SL</span>4 seamlessly):<br /><br /><a href="http://timheuer.com/blog/archive/2009/07/30/silverlight-3-multi-touch-introduction-fundamentals-basics.aspx">http://timheuer.com/blog/archive/2009/07/30/silverlight-3-multi-touch-introduction-fundamentals-basics.aspx</a><br /><br />so now that we talked out how <span id="SPELLING_ERROR_29" class="blsp-spelling-corrected">to do</span> basic <span id="SPELLING_ERROR_30" class="blsp-spelling-corrected">multi touch</span> lets get back to my experience in user experience development with <span id="SPELLING_ERROR_31" class="blsp-spelling-corrected">multi touch</span>.<br /><br />In our work we have been doing <span id="SPELLING_ERROR_32" class="blsp-spelling-corrected">allot</span> of users studies with Retail systems including kiosks, touch walls, surface and the like. But my <span id="SPELLING_ERROR_33" class="blsp-spelling-corrected">favorite</span> lesson learned has <span id="SPELLING_ERROR_34" class="blsp-spelling-error">todo</span> with the <span id="SPELLING_ERROR_35" class="blsp-spelling-error">UX</span> professionals... One day have a long day of debugging and unit testing I went home and wanted to check email on our home computer. I forget what it was exactly but I went to touch the screen and for several minutes I couldn't, I think I almost broke it before I realized that it wasn't touch. And the next week I realized that everyone on the team was having the same problem. Worse still once you realized that was a problem I found I can't stop... really once I went touch... I can't go back. don't get my wrong 'touch' will not replace the mouse in its current form/technology but it extends our experience and allows technology to be better integrated into our lives. <br /><br />So lets talk about another story we saw in users studies. There are lots of different kinds of hardware, apps and technologies. One good thing to watch out for is the 'kinds' of things that register as a 'touch'. So in <span id="SPELLING_ERROR_36" class="blsp-spelling-error">Silverlight</span> on my <span id="SPELLING_ERROR_37" class="blsp-spelling-error">multitouch</span> laptop its not a big deal but I have seen hardware that the light conditions effect <span id="SPELLING_ERROR_38" class="blsp-spelling-corrected">touches</span> and even worse some of the hard where is so sensitive that the brush of a sleeve can cause problems. Granted this is more a surface thing then the typical <span id="SPELLING_ERROR_39" class="blsp-spelling-error">Silverlight</span> retail kiosk but still. When building experiences you need to get they system, hardware and any other bits in place so that you can see how users interact with the system so I can identify things like this 'before' they go live.<br /><br />When considering design some good things to think about include How the user will tend to interact with the system. On thing you notice is that you loose those the mouse. no mouse overs etc. We have found that user's need and expect feedback. and many times when users 'touch' elements in the <span id="SPELLING_ERROR_40" class="blsp-spelling-error">UI</span> and nothing happens the user then tends to think that they did something wrong. Help the users by providing feed back even if its just a <span id="SPELLING_ERROR_41" class="blsp-spelling-corrected">subtle</span> 'bonk' noise that lets the users know the touch was received. When the user does touch something that does something make sure that 'something' shows that on the screen <span id="SPELLING_ERROR_42" class="blsp-spelling-corrected">IE</span> drop shadow forms and element moves slightly etc. <br /><br />Also remember that we have trained our users to do and respond to computer <span id="SPELLING_ERROR_43" class="blsp-spelling-error">UI</span> a certain way. Consider that frequently we see users 'double' touch where the users expects there to be something like a double click. Users also tend to click the bottom of images or things below the image before things above. I can't express enough how much better a system is that has gone through <span id="SPELLING_ERROR_44" class="blsp-spelling-corrected">extensive</span> user testing and user centric design can be from a User Experience standpoint. <br /><br />Another big topic in now days is gestures, in <span id="SPELLING_ERROR_45" class="blsp-spelling-error">Silverlight</span> this can mean 'more' code :) but focusing on the user we found that users tend <span id="SPELLING_ERROR_46" class="blsp-spelling-corrected">to do</span> only a few things 90% of the time or more... Touch, move and pinch... everything else that users use once they get past the fact they can touch everything is secondary at least currently. Although subtle things like letting users <span id="SPELLING_ERROR_47" class="blsp-spelling-error">resize</span> via pinch and the use of touch in the <span id="SPELLING_ERROR_48" class="blsp-spelling-error">UI</span> that has been carefully thought out regarding interaction really cranks up the end product. <br /><br />But given considerations like that... touch is where its at and once you go touch, you never go back. :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-1194322209623113740?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/01/silverlight-multi-touch-in-real-world.htmlnoreply@blogger.com (david.kelley)3tag:blogger.com,1999:blog-887975141009593463.post-4504116792085827224Wed, 06 Jan 2010 19:45:00 +00002010-01-06T11:51:25.860-08:00designersWPFHacking SilverlighteventdevelopersMIXGetting Developers and Designers to play nice... and MIXFor those of you that don't know MIX is the most important Microsoft related conference of the year. Also MIX has decided to have an open call this year for speakers... and the Public gets to vote... in an effort to get my sessions to the top of the list I'm emailing everyone in my contact list to ask your help in voting for my sessions... :)<br /><br />Here are the steps:<br /><br /><br />1. Click <a href="http://visitmix.com/opencallvote/Entry?entryId=BREAKI077">http://visitmix.com/opencallvote/Entry?entryId=BREAKI077</a><br /><br />2. Click ‘add to ballot’<br /><br />3. Click ‘Submit Your Ballot’<br /><br />If you have more time start here:<br /><br />1. <a href="http://tinyurl.com/ye9uzwz">http://tinyurl.com/ye9uzwz</a><br /><br />and then add all 3 sessions and vote them<br /><br />Please and Thank you. and feel free to get all your friends to vote too…<br /><br />For those of you that want more information here are the abstracts... normally you just send them to the people organizing a show but this year they are making everyone vote... :( or maybe this is a good thing... I guess it depends on if I get selected... ;)<br /><br />Here are the 3 topics:<br /><br /><strong>Title: Breaking Down Walls – The Story of Getting designers and developers working together in an Agency Environment<br /></strong><br /><strong>Abstract</strong>: Breaking Down Walls is about the wall between designers and developers in the typical design shop. Getting everyone to cross over, communicate and build better UX is where we are going and where many of the best Interactive Design firms are already. When designers and developers learn to communicate, and work together they really start to be able to make the best use of the tools they have from Adobe to Expression to Visual Studio, all these tools can be used in an open collaborative environment like never before. Learn to make magic here or at least learn how it has been done at Wirestone and other agencies that have done it successfully.<br /><br /><strong>Title: Multi Dos and Don’t touches –Multi Touch Development from the trenches</strong><br /><br /><strong>Abstract</strong>: David talks about his experience in the retail space with real world multi-touch applications from touch kiosks to Surface and Silverlight. David will talk about the customer experience and how user centered design and multi-touch work in the retail world with ‘live’ customers as well as the perspective of designers, developers, IA and others regarding multi-touch. From stories about developers touching too much and about good ideas gone amuck David gets it all out on the table.<br /><br /><strong>Title: Hacking Silverlight 4</strong><br /><br /><strong>Abstract</strong>: From MVVM for Tard’s to hosting Silverlight in WPF and getting around silly security sandbox’s, this session is about pushing the limits of Silverlight and making things easier to do. With a ‘It shouldn’t be that hard’ attitude to development some of the best work in Silverlight can sometimes be a bit of a hack and this session will talk about some of the most useful hacks. From using external hosts, the DOM bridge and even flash; Silverlight can do just about anything given half a chance or a few hacks.<br /><br />again that link is <a href="http://tinyurl.com/ye9uzwz">http://tinyurl.com/ye9uzwz</a> please vote for me :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-4504116792085827224?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/01/getting-developers-and-designers-to.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-2649676760124462372Tue, 05 Jan 2010 06:47:00 +00002010-01-04T23:14:06.020-08:00Hacking Silverlightimagesc#hackinghackAsynchronous Image Loading in SilverlightSo one task that was bugging me today was doing image loading asynchronously so as to not drag the app down. Now there are some 'xaml' ways of doing this in wpf and supposedly in SL but alas I have not seem it work well. I'm working on a larger class that does this better but here is the basics of how I got it to work in C# code... to start with lets take a look at the following code:<br /><br /><br />WebClient client = new WebClient();<br />client.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);<br /><br />if (ImagePath.IndexOf("http") < 0)<br />{<br />string URL = System.Windows.Browser.HtmlPage.Document.DocumentUri.AbsoluteUri;<br />ImagePath = URL.Substring(0, URL.LastIndexOf('/')) + "/" + ImagePath;<br />}<br /><br />client.OpenReadAsync(new Uri(ImagePath, UriKind.RelativeOrAbsolute), ImagePath);<br /><br />this code lived in the constructor of the class I made. Basically its a user control that replaces the image tag so I can use it in Xaml or programatically etc. in this case I needed to use it programmatically to generate this image 'effect' that I was working on so I passed it into the constructor. the key to the code above is it creates a web client, then checks the url and finally calls the async method that loads the image.<br /><br />the next bit of code is the event handler:<br /><br />void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)<br />{<br />try<br />{<br />BitmapImage ImageToLoad = new BitmapImage();<br />ImageToLoad.SetSource(e.Result as Stream);<br />TargetImage.Source = ImageToLoad;<br />}<br />catch (Exception)<br />{ }<br />}<br /><br />this code is simple enough. Basically the BitmapImage is created and we load the result as a stream into it and then use that to set the source on an image. At least for me this seemed to work well. I'll probably add a few other features namely some reference counting so when I load 1000 of these it doesn't try to grab them all at once...<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-2649676760124462372?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2010/01/asynchronous-image-loading-in.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-163557152288280582Wed, 30 Dec 2009 09:21:00 +00002009-12-30T01:39:15.042-08:00WPFHacking SilverlightxamlxaphackinghackSilverlight Hosting in WPF<span id="SPELLING_ERROR_0" class="blsp-spelling-error">Ok</span> so we know this has been done. Yawn, and it can be done any number of ways from hacking it in a browser control but actually doing it in <span id="SPELLING_ERROR_1" class="blsp-spelling-error">WPF</span> without the browser control can be a huge pain. Here is a little trick that helps you do just that without all the jumping around.<br /><br />Jeremiah, (this programmer <span id="SPELLING_ERROR_2" class="blsp-spelling-corrected">extraordinaire</span> with apparently WAY to much time on his hands) wrote this little <span id="SPELLING_ERROR_3" class="blsp-spelling-error">codeplex</span> project that is a '<span id="SPELLING_ERROR_4" class="blsp-spelling-error">WPF</span> Panel' that hosts <span id="SPELLING_ERROR_5" class="blsp-spelling-error">Silverlight</span>. <a href="http://silverlightviewport.codeplex.com/">http://silverlightviewport.codeplex.com/</a><br /><br />pretty slick, if you dive into the code it is kind of complicated but to use it is straight forward enough. If you download the project and run it you can see it in his test application running a <span id="SPELLING_ERROR_6" class="blsp-spelling-error">xap</span> in Window1.<span id="SPELLING_ERROR_7" class="blsp-spelling-error">xaml</span>.<br /><br />&amp;<span id="SPELLING_ERROR_8" class="blsp-spelling-error">lt</span>;<span id="SPELLING_ERROR_9" class="blsp-spelling-error">slvp</span>:<span id="SPELLING_ERROR_10" class="blsp-spelling-error">SilverlightViewportElement</span> <span id="SPELLING_ERROR_11" class="blsp-spelling-error">BaseUrl</span>="http://silverlight.net/"<br />Source="http://silverlight.net/clientBin/showcasenav/ShowcaseNav.xap"<br /><span id="SPELLING_ERROR_12" class="blsp-spelling-error">ViewportSize</span>="550,550"<br /><span id="SPELLING_ERROR_13" class="blsp-spelling-error">RenderFps</span>="40"<br />x:Name="<span id="SPELLING_ERROR_14" class="blsp-spelling-error">slViewport</span>"&gt;<br />&amp;<span id="SPELLING_ERROR_15" class="blsp-spelling-error">lt</span>;<span id="SPELLING_ERROR_16" class="blsp-spelling-error">slvp</span>:<span id="SPELLING_ERROR_17" class="blsp-spelling-error">SilverlightViewportElement</span>.Effect&gt;<br />&amp;<span id="SPELLING_ERROR_18" class="blsp-spelling-error">lt</span>;<span id="SPELLING_ERROR_19" class="blsp-spelling-error">DropShadowEffect</span> <span id="SPELLING_ERROR_20" class="blsp-spelling-error">BlurRadius</span>="50" /&gt;<br />&amp;<span id="SPELLING_ERROR_21" class="blsp-spelling-error">lt</span>;/<span id="SPELLING_ERROR_22" class="blsp-spelling-error">slvp</span>:<span id="SPELLING_ERROR_23" class="blsp-spelling-error">SilverlightViewportElement</span>.Effect&gt;<br />&amp;<span id="SPELLING_ERROR_24" class="blsp-spelling-error">lt</span>;<span id="SPELLING_ERROR_25" class="blsp-spelling-error">slvp</span>:<span id="SPELLING_ERROR_26" class="blsp-spelling-error">SilverlightViewportElement</span>.<span id="SPELLING_ERROR_27" class="blsp-spelling-error">LayoutTransform</span>&gt;<br />&amp;<span id="SPELLING_ERROR_28" class="blsp-spelling-error">lt</span>;<span id="SPELLING_ERROR_29" class="blsp-spelling-error">RotateTransform</span> Angle="10" /&gt;<br />&amp;<span id="SPELLING_ERROR_30" class="blsp-spelling-error">lt</span>;/<span id="SPELLING_ERROR_31" class="blsp-spelling-error">slvp</span>:<span id="SPELLING_ERROR_32" class="blsp-spelling-error">SilverlightViewportElement</span>.<span id="SPELLING_ERROR_33" class="blsp-spelling-error">LayoutTransform</span>&gt;<br />&amp;<span id="SPELLING_ERROR_34" class="blsp-spelling-error">lt</span>;/<span id="SPELLING_ERROR_35" class="blsp-spelling-error">slvp</span>:<span id="SPELLING_ERROR_36" class="blsp-spelling-error">SilverlightViewportElement</span>&gt;<br /><br />you'll notice this is all the standard <span id="SPELLING_ERROR_37" class="blsp-spelling-error">WPF</span> fare but lets look at the properties on the main panel itself. First is our base <span id="SPELLING_ERROR_38" class="blsp-spelling-error">url</span> that tells the control the domain in which the <span id="SPELLING_ERROR_39" class="blsp-spelling-error">xap</span> or <span id="SPELLING_ERROR_40" class="blsp-spelling-error">silverlight</span> application lives. Next we have the 'Source' which points to our <span id="SPELLING_ERROR_41" class="blsp-spelling-error">xap</span> file. We then set a view port size as '<span id="SPELLING_ERROR_42" class="blsp-spelling-error">ViewportSize</span>' and then the last one we will mention is '<span id="SPELLING_ERROR_43" class="blsp-spelling-error">RenderFps</span>' which is the 'speed' that the <span id="SPELLING_ERROR_44" class="blsp-spelling-error">Silverlight</span> is 'rendered' into your panel. In effect your app now runs in the <span id="SPELLING_ERROR_45" class="blsp-spelling-error">WPF</span> app. Nice and clean as long as you don't look at the source for the panel which is more a work of art... :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-163557152288280582?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/12/silverlight-hosting-in-wpf.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-2072012514719301572Wed, 30 Dec 2009 08:58:00 +00002009-12-30T01:31:02.503-08:00javascriptHacking SilverlighthtaHTMLhackinghackSelf Editing XML FileThis particular post is a rehash of one I didn't some years back. Basically it is a little technique I developed some 7 or 8 years ago to solve a simple database issue once but I wanted only one file to exist in this case the exe or sorts that was also the xml file. As this applies to Silverlight in the since that I can use this application technique to also be used as a shell for a Silverlight application without all the silly security barriers... > : )<br /><br />DISCLAMIER: I AM NOT RESPONSIBLE FOR THE USE OF THIS TECHNOLOGY IN FACT YOU SHOULD STOP READING NOW BEFORE YOU HURT YOUR SELF OR OTHERS...<br /><br />But lets not focus on that... lets focus on the mechanics of what we are talking about. A long time ago in a galaxy far far away there was a company called Microsoft that as the center of the universe they released this cool little DHTML technology back before they changed the name to AJAX and it was still cool called an HTA or Hyper Text Application or 'HTml Application' which basically is an HTML file with the file extension of '.hta' instead of '.html' and when you have one of these locally and you click on it, it then renders without all that silly browser chrome/buttons etc. oh and with the rights of a win32 app installed locally...<br /><br />Basically with a little markup you can control and manipulate the browser chrome and any com object on the system with a script friendly API you can talk to.<br /><br />Now this 'hta' thing works if the page is hosted on a web page too... albeit you get ONE security dialog that doesn’t really explain what is going on and if the user clicks ok the hta runs as a locally installed app w/o silly security sandbox stuff going on... and yes that basically means it can for all intents and purposes fdisk your hard drive...<br /><br />DISCLAMER 2: STOP READING HERE AND DON'T DO THIS STUFF.<br /><br />Like anything though this can be used for good and evil.<br /><br />Ok back to how to-do it. if you Google HTA on Bing (or Google) you can get the reference material for hta's but basically it is an html file that runs in a version of IE w/o the sandbox. so basically any html that works there works in the hta too with the added addition of this tag:<br /><br />&lt;HTA:APPLICATION id="oVDProcess"<br />applicationName="Virtual Desktop - Lite"<br />singleinstance="yes"<br />caption="no"<br />contextmenu="no"<br />innerborder="no"<br />scroll="no"<br />showintaskbar="no"<br />version="1.0.032"<br />SELECTION="no"<br />windowState="normal"<br />icon="img\im_gray.ico"<br />/ &gt;<br /><br />Now as mentioned you can also access any of your com objects the XML Document object or the 'File System' object... here is some sample code from my magic self editing file:<br /><br />var oDOM = null;<br />var giHeight = 360;<br />var giWidth = 800;<br /><br />function initFrm() {<br />try {<br />self.resizeTo( giWidth, giHeight );<br />self.moveTo( ( window.screen.availWidth - giWidth ) / 2, ( window.screen.availHeight - giHeight ) / 2 );<br /><br />oDOM = new ActiveXObject("Microsoft.XMLDOM");<br />oDOM.async = false;<br />oDOM.loadXML( oXMLDATA.innerHTML );<br />instantReport();<br />} catch(e) {<br />alert( "Your OS is missing components or they are disabled for processing XML data!\nDESC: " + e.description );<br />}<br />}<br /><br />Notice in this case the code creates the xml document object and loads part of the 'HTML' in...<br /><br />And here is another sample:<br /><br /><br />function saveSelf() {<br />var oFSO = new ActiveXObject("Scripting.FileSystemObject");<br />var oTempFile = oFSO.OpenTextFile( "xLinks.XML.hta", 1 );<br />var sSelfSource = String( oTempFile.ReadAll() );<br /><br />var oPAGEARRAY = sSelfSource.split( '&lt;meta' + ' val="2345"/&gt;' );<br /><br />var sNewSource = oPAGEARRAY[0] + '&lt;meta' + ' val="2345"/&gt; &lt;xml id="oXMLDATA"&gt; ' + oDOM.xml + ';&lt;/xml&gt;&lt;meta' + ' val="2345"/&gt; ' + oPAGEARRAY[2]<br /><br />var oSDOM = new ActiveXObject("Microsoft.XMLDOM");<br />oSDOM.async = false;<br />oSDOM.loadXML( sNewSource );<br /><br />if( oSDOM.xml != "" ) {<br />var oNewFile = oFSO.CreateTextFile( "xLinks.XML.hta", 1 );<br />oNewFile.WriteLine( oSDOM.xml );<br />oNewFile.close();<br />oNewFile = null;<br />alert( "Save Success!" );<br />window.close();<br />} else {<br />alert( "Save Operation Failed!" );<br />}<br />}<br /><br />This function creates a File System Object. The trick here is basically the file runs as an HTA i.e. executable but then loads itself as a xml file or custom xml data base and updates 'records' in itself and overwrites itself. Now the trick here is that your HTML must be XML complaint. Really if you don't know what this means maybe you should start somewhere else before reading about how to hurt yourself with this stuff... :)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-2072012514719301572?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/12/self-editing-xml-file.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-6441439070689403288Mon, 07 Dec 2009 23:51:00 +00002009-12-07T22:23:28.667-08:00Hacking Silverlightsilverlight.netc#xaphackinghackHacking the Silverlight Xap fileEvery now and then I find I need to pull resources out of a Xap file. One of the issues with this is knowing what’s in the XAP. There have been a number of solutions I’ve used over the years (ok that is like 2.5 ish years) like having an index file either a Csv or Xml etc. A few weeks ago I ran across this little class that some guys were talking about on the Silverlight Insiders/MVP thread called un-zipper found here:<br /><br /><a href="http://www.sharpgis.net/post/2009/04/21/REALLY-small-unzip-utility-for-Silverlight.aspx">http://www.sharpgis.net/post/2009/04/21/REALLY-small-unzip-utility-for-Silverlight.aspx</a><br /><br />What is cool about this class is it makes getting the assets out of a zap even if you don’t know what is in the xap up front easy and straight forward. From a using standpoint you basically need to create a webclient and a call and use the Unzipper to run through the contents. The Unzipper class deals with mucking up what is in the xap so all you need to-do is run through the collection and pull out what you need… Let us take a look at what you need to-do:<br />Assuming you have the Unzipper class (download here) you need the following libraries:<br /><br />using System.Collections.ObjectModel;<br />using System.Net;<br />using System.Windows.Controls;<br /><br />From here we need to create a web client<br /><br />WebClient wc = new WebClient();<br />wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);<br />wc.OpenReadAsync(new Uri("HackingXaps.xap", UriKind.RelativeOrAbsolute));<br /><br /><br />In this code we create the WebClient, add a handler and run the call pointed at our xap we want to load.<br /><br />void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)<br />{<br />if (e.Error == null)<br />{<br />UnZipper unzip = new UnZipper(e.Result);<br /><br />foreach (string filename in unzip.GetFileNamesInZip())<br />{<br />//do something with the file name…?<br />}<br />}<br />}<br /><br />From here you can pretty much do whatever you want. Look to see this in the up coming version of the HackingSilverlight library.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-6441439070689403288?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/12/hacking-silvelright-xap-file.htmlnoreply@blogger.com (david.kelley)3tag:blogger.com,1999:blog-887975141009593463.post-8386838634481892868Thu, 26 Nov 2009 08:06:00 +00002009-11-26T00:12:25.980-08:00visual studiovictorsilverlightiaexpressionIntegratorUXtardmicrosoftMaking an IntegratorThere are still a lot of names for it but I’m going with ‘Integrator.’ I’m not sure exactly who coined this but I tend to like it. But what is an Integrator? At least in the context of the WPF/Silverlight world an Integrator tends to be some one that sits between a design team and the developer team at least initially when a company first gets someone to fill the integrator role. In the long term the Integrator becomes more the designer as part of an integrated team where there is not a design team or a developer team and we get into this Agile sort of cross discipline team that is building better UX faster in order of magnitude then anything before. There are lots of things that have come together of the past few decades to make this kind of team possible. We are going to focus on the Integrator but let take a quick look at the cross discipline team that the integrator role tends to move teams towards.<br /><br />The New UX team tends to be on one spectrum a developer that can do dev work in the data base, in the web services space and then into the .NET and WPF. This developer might be a software architect with expanded data modeling an application modeling etc but tends to also be able to do some light reasonable UI and knows what good design looks like. The next team member might be an IA or Information Architect. Granted the Software Architect might have some IA skills and if so might even be a UX Architect. So the IA helps make sure the data and the flow of the IA in the IA are solid on the up take for the team but on the end the IA is making sure the user experience is good and doing user testing and other interfacing with users to make sure what they see makes since and works well.<br /><br />From IA we start to get into the Integrator role, the Integrator will have a sound understanding of IA, UX and be able to write code but most importantly they are able to visually decompose what they see into Xaml and do design and design integration. Going Past the Integrator is the pure designer then might live in more disconnected tools. But as a team evolves into this sort of zen state each role including the dev’s, the IA, the architects, the designers and integrators tend to take on some of the skills of all the others. When everyone can do a little bit of everything the team is able to functional more tightly than ever before using some version of Agile and WPF/Silverlight todo more better and faster than before. It is even possible to take this even further and bring in the PM (Project Manager) to be able to work with customers and take on much of the skills of the IA.<br /><br />In a way the Integrator can become kind of a seed that when planted in the fertile soil of a dev team that loves design and a design team that loves to see their hot designs alive over time turns the team into a UX monster (in a good way). Here is where we see the best innovation and the hottest UX (User eXperiences) at least in my experience.<br /><br />Integrators are not born though they have to be grown (again in my experience). Now we get to the point of the article… how do you grow, build or otherwise make and Integrator?<br />So there seems to be two kinds of coal for building the integrator: The Designer and The Developer. In either case there are good points and bad points about each kind of ‘coal’…<br />For the Developer (especially/mainly the WPF/Silverlight developer) the good points are if they are already comfortable with Xaml and building WPF/Silverlight applications jumping into blend and becoming technically proficient is relatively straight forward but on the downside… if a developer doesn’t have any design sense at all… really give up now before you hurt someone. The hardest part of making a rock star integrator is getting a design sense, point 8 Helvetica is NOT the same as point 9 Ariel and if there is a question over it then you need to start again. Ok so we then make a huge assumption that you have some design sense. How do you cultivate it? Well ideally working in blend with some hot designers (and no this does not mean ‘hot’ looking although that is good too). But here is a good reading list for the dev aspiring ‘Design Integrator’<br /><br />• Presentation Zen (really you must stop making crappy slides) <a href="http://www.amazon.com/Presentation-Zen-Simple-Design-Delivery/dp/0321525655/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022426&amp;sr=8-1">http://www.amazon.com/Presentation-Zen-Simple-Design-Delivery/dp/0321525655/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022426&amp;sr=8-1</a><br /><br />• A Whole New Mind by Daniel Pink <a href="http://www.amazon.com/Whole-New-Mind-Right-Brainers-Future/dp/1594481717/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022506&amp;sr=1-1">http://www.amazon.com/Whole-New-Mind-Right-Brainers-Future/dp/1594481717/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022506&amp;sr=1-1</a><br /><br />• Foundation Expression Blend 3 with Silverlight By Victor Gaudioso (<a href="http://www.amazon.com/Foundation-Expression-Blend-Silverlight-Foundations/dp/1430219505/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259021904&amp;sr=8-1">http://www.amazon.com/Foundation-Expression-Blend-Silverlight-Foundations/dp/1430219505/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259021904&amp;sr=8-1</a> )<br /><br />• Neuro Web Design – What makes them click? by Weinschenk <a href="http://www.amazon.com/Neuro-Web-Design-Makes-Click/dp/0321603605/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022564&amp;sr=1-1">http://www.amazon.com/Neuro-Web-Design-Makes-Click/dp/0321603605/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022564&amp;sr=1-1</a> <br /><br />• Information Architecture by Wodtike and Govella <a href="http://www.amazon.com/Information-Architecture-Blueprints-Web-2nd/dp/0321600800/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1259022633&amp;sr=1-2">http://www.amazon.com/Information-Architecture-Blueprints-Web-2nd/dp/0321600800/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1259022633&amp;sr=1-2</a><br /><br />• MVVM for tards (<a href="http://tard.codeplex.com/">http://tard.codeplex.com/</a> )<br /><br />• Foundation Silverlight 3 Animation by Jeff Paries <a href="http://www.amazon.com/Foundation-Silverlight-Animation-Jeff-Paries/dp/143022407X/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022673&amp;sr=1-1">http://www.amazon.com/Foundation-Silverlight-Animation-Jeff-Paries/dp/143022407X/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022673&amp;sr=1-1</a> <br /><br />Once you get this or in the process of getting this along with working with a designer is learning how to talk to designers. More than any other thing is team dynamics and team dynamics is primarily about good communication. Outside of the basics of good communication is when coming from the dev world to the design world you need to get in touch with the vernacular as much as possible. Working with designers you can get it from osmosis to some degree assuming you don’t piss them off, part of this means that when you talk to designers about changing their process understand that you probably don’t understand their world and that you can’t be condescending with really you probably don’t know what you are talking about when it comes to design. As an example designer typically don’t’ name and group elements in the same way that a dev is going to need them. When you talk to designers about naming conventions you need to be nice and explain why you need their help to have things grouped and named in the assets even from Photoshop and Illustrator.<br /><br />What about making a designer into an integrator?<br /><br />In this case the biggest problem tends to be getting past the normal design tools to looking at Xaml at times, wiring up a basic event and some basic code. Understanding the basics of how to work with dev’s is secondary to getting the new design integrator up to speed. While the designer brings the most critical skill to the Integrator role (being a design sense) they have a huge learning curve to wrap their mind around Xaml and Code. While a designer doesn’t need to code an Integrator needs too at least a bit. Much like the dev needing to understand design at a certain level the same goes for the designer to understand some coding in the context of Xaml and Visual Studio.<br /><br />So how do you get a Designer to be able to write a method in Visual Studio? I would say to start with the most obvious and that is blend. The designer has to be interested in being an Integrator. If the designer is not passionate about learning to make their designs real then they are going to have a hard time. Starting with Blend the tool is designed to at least on some level be straight forward for designers and for starters they can focus on the WYSIWYG. For example all the short cut key codes are the same or mostly the same as Photoshop and the tool is great for doing WYSIWYG sort of ‘design’ but the native format is Xaml. Once the designer gets to the point of being limited then introducing Xaml to the designer is a great next step. So building on this to being able to wire up and event in code and launching in VSTS is about the limit. Here is where the sweet spot kind of happens and this like the dev being an integrator works best when it is a composite designer developer team.<br /><br />From a learning standpoint the reading list might be:<br /><br />• Foundation Silverlight 3 Animation by Jeff Peries <a href="http://www.amazon.com/Foundation-Silverlight-Animation-Jeff-Paries/dp/143022407X/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022673&amp;sr=1-1">http://www.amazon.com/Foundation-Silverlight-Animation-Jeff-Paries/dp/143022407X/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022673&amp;sr=1-1</a> <br /><br />• Foundation Expression Blend 3 with Silverlight By Victor Gaudioso (<a href="http://www.amazon.com/Foundation-Expression-Blend-Silverlight-Foundations/dp/1430219505/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259021904&amp;sr=8-1">http://www.amazon.com/Foundation-Expression-Blend-Silverlight-Foundations/dp/1430219505/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259021904&amp;sr=8-1</a> )<br /><br />• MVVM for tards (<a href="http://tard.codeplex.com/">http://tard.codeplex.com/</a> )<br />• A Whole New Mind by Daniel Pink <a href="http://www.amazon.com/Whole-New-Mind-Right-Brainers-Future/dp/1594481717/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022506&amp;sr=1-1">http://www.amazon.com/Whole-New-Mind-Right-Brainers-Future/dp/1594481717/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022506&amp;sr=1-1</a><br /><br />• Neuro Web Design – What makes them click? by Weinschenk <a href="http://www.amazon.com/Neuro-Web-Design-Makes-Click/dp/0321603605/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022564&amp;sr=1-1">http://www.amazon.com/Neuro-Web-Design-Makes-Click/dp/0321603605/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1259022564&amp;sr=1-1</a><br /><br />• Information Architecture by Wodtike and Govella <a href="http://www.amazon.com/Information-Architecture-Blueprints-Web-2nd/dp/0321600800/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1259022633&amp;sr=1-2">http://www.amazon.com/Information-Architecture-Blueprints-Web-2nd/dp/0321600800/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1259022633&amp;sr=1-2</a><br /><br />So let us go back to what is an Integrator?<br /><br />The Integrator needs to appreciate design and to do good design and recognize good design. An Integrator needs to be able to be able to visually decompose a design and build it in Blend as Xaml. An Integrator needs to learn how to talk to designers and developers and be able understand the needs of both. Dev’s need names, designers need design time data and that sort of thing. Most of all the Integrator needs to help facilitate the communication dynamic between design and development and that is what makes the magic juice you see in some of the high end UX companies building on the Microsoft Stack.<br /><br />Lastly one of the key aspects of getting companies to buy off on supporting the transition from traditional approaches to composite teams (of designers, developers and integrators and IA’s and anyone else we can get our hands) is ROI for better UX. Companies need to see how better UX can increase productivity, increase sales and user satisfaction and more. And they need to see how the composite team using designers, developers and integrators using the Microsoft WPF/Silverlight stack (Xaml, .NET 4, Visual Studio, Expression Suite) saves development costs, time to market and enable the better UX in general. That is the job of the integrator…<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-8386838634481892868?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/11/making-integrator.htmlnoreply@blogger.com (david.kelley)1tag:blogger.com,1999:blog-887975141009593463.post-5966703284422308008Tue, 24 Nov 2009 19:16:00 +00002009-11-24T11:31:15.920-08:00javascriptHacking SilverlightsilverlighthackinghackSilverlight and Dual Screen Monitors...So I'm working on this dual screen kiosk thing and want to use Silverlight as for some reason I can't use WPF / .net4 etc. long story and not the point. What do I do now?<br /><br />Well along time ago in a galaxy mostly still down the street I used do alot of 'dhtml' or ajax kinds of things or whatever we are calling it now days and there was this little thing called an hta you could do to get around all that silly security stuff in the browser that keeps you from nuking the hard drive, and file system access etc.<br /><br />So the trick I found is to have the hta host the Silverlight app and have it resize its self to take up all the monitors. with a third monitor hidden in the kiosk... poof, Silverlight dual screen full screen black magic.<br /><br />for those interested in hta's:<br /><br /><a href="http://msdn.microsoft.com/en-us/library/ms536495(VS.85).aspx">http://msdn.microsoft.com/en-us/library/ms536495(VS.85).aspx</a><br /><br />basically you want the following properties set on the hta tag in the html header:<br /><br />caption=no<br />contextmenu=no<br />indderborder=no<br />border=none<br />windowstate=normal<br />scroll=no<br />showintaskbar=no<br /><br />and then on load on the body tag execute the following:<br /><br />window.moveTo(0,0);<br />window.resizeTo(x,y);<br /><br />which could be a function of<br />window.screen.availWidth and or window.screen.availHeight<br /><br />see black ecma magic saves the day.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-5966703284422308008?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/11/silverlight-and-dual-screen-monitors.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-6092696945809160038Thu, 22 Oct 2009 21:10:00 +00002009-10-22T14:12:51.457-07:00wirestoneMVVMHacking SilverlightinteractSD2IGPDCUXDevelopers on Better Design, User Experience and Why It MattersThe PDC BOF team is pleased to announce another Birds-of-a-Feather session.<br /><br />Developers on Better Design, User Experience and Why It Matters<br /><br />What is the return-on-investment of building better User Experiences (UX)?<br />How does User Interface (UI) design affect your business?<br /><br />Come join the discussion on why User Experience matters and how it applies to the real world.<br /><br />In the current world of web 2.0 and with talk of design being important, help us understand why it matters to you and what we get out of good User Interface design. Let’s talk about the technologies on the web and on the desktop that do and don’t support the development of well designed applications, and how we can apply better practices to our own projects. Equally important, let’s discuss how we can bridge the typical gap in cross discipline team dynamics.<br /><br />Tell us about your secret sauce or just listen to what others have to say. From great enabling technologies like Silverlight or WPF to tried and true web development in ASP.NET using MVC, everyone has a story to tell about UI and design in the Microsoft world.<br /><br /><a href="http://www.pdcbof.com/post/220173613/bof-session-developers-on-better-design-user">http://www.pdcbof.com/post/220173613/bof-session-developers-on-better-design-user</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-6092696945809160038?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/10/developers-on-better-design-user.htmlnoreply@blogger.com (david.kelley)3tag:blogger.com,1999:blog-887975141009593463.post-8590455704461195289Sat, 17 Oct 2009 08:05:00 +00002010-01-24T14:01:55.732-08:00MVVMHacking Silverlightbest practicessilverlightsilverlight 3hackhardFinally a Simple MVVM in SilverlightSo a week or so ago I ran across this article/post by Jeremiah Morrill (<a href="http://jmorrill.hjtcentral.com/Home/tabid/428/EntryId/432/MVVM-for-Tarded-Folks-Like-Me-or-MVVM-and-What-it-Means-to-Me.aspx">MVVM-for-Tarded-Folks-Like-Me-or-MVVM-and-What-it-Means-to-Me.aspx</a> ) was agasp that some spent the time to make MVVM so understandable. What will I do now that everyone can understand MVVM? I pinged Jeremiah and he was open to making this a framework on codeplex seeing as there are only 35 versions of MVVM frameworks out there already albeit no matter how good they are they usually include bits that have todo with 5 or 7 other design patterns so lets take a look at building an MVVM app with just the Simple Framework for MVVM. To start with the Simple framework consistes of one class with three lines of real code:<br /><br />public class TardViewModelBase : INotifyPropertyChanged<br />{<br />public event PropertyChangedEventHandler PropertyChanged;<br /><br />public void InvokePropertyChanged(string propertyName)<br />{<br />var e = new PropertyChangedEventArgs(propertyName);<br />PropertyChangedEventHandler changed = PropertyChanged;<br />if (changed != null) changed(this, e);<br />}<br />}<br /><br />I know I know its a work of art but this really is all you need. Now using this class is just as simple to create an MVVM application using the simple framework. First create a model class like so:<br /><br />public class AModelClass<br />{<br />// super easy version<br />public string SomeValue { get; set; }<br />}<br /><br />ok so maybe also make it return some data magically. Next you need to create your complex view model class that inherits from ViewModelBase like so (WARNING: this is the complicated part...)<br /><br />public class AViewModelClass : ViewModelBase<br />{<br />private AModelClass MyModel;<br /><br />public AViewModelClass()<br />{<br />MyModel = new AModelClass();<br />}<br /><br />public string SomeValue<br />{<br />get { return MyModel.SomeValue; }<br />set<br />{<br />if (MyModel.SomeValue != value)<br />{<br />MyModel.SomeValue = value;<br />InvokePropertyChanged("SomeValue");<br />}<br />}<br />}<br />}<br /><br />So now we have a model that returns some data and then we have our view model that we can bind do. Now to create a View (ie user control) with xaml akin to this:<br /><br />&gt;UserControl.DataContext&lt;<br />&gt;Simple:AViewModelClass /&lt;<br />&gt;/UserControl.DataContext&lt;<br />&gt;Grid x:Name="LayoutRoot" Background="White"&lt;<br />&gt;TextBox Text="{Binding SomeValue, Mode=TwoWay}" /&lt;<br />&gt;/Grid><br /><br />If you really like you can get extra complicated and load view in shell or whatever in Xaml like so:<br /><br />&gt;simple:AViewClass /&lt;<br /><br />so some other fancy thing... but that is all it takes to have some Model View View Model going on. Nice simple...<br /><br /><a href="http://tard.codeplex.com/">http://simple.codeplex.com/</a><br /><br />stay tuned for maybe commanding for tards...<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-8590455704461195289?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/10/finally-simple-mvvm-in-silverlight.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-8729990344079783850Fri, 16 Oct 2009 21:56:00 +00002009-10-16T15:34:03.925-07:00Hacking Silverlightsilverlightsilverlight 3hackSilverlight Hack of the Week - Auto ZoomJustin Angel did a tweet about this and I must admit its cool and I had never even thought out this before but you can set autozoom and on zoom event in silverlight for when the browser host supports zoom on a page.<br /><br /><strong>AutoZoom</strong><br />Auto zoom is the simplest. hook this up in the html and this the silverlight control will be able to be zoomed as the browser zooms.<br /><br />&lt;param name="enableautozoom" value="[bool (ie true or false for the tards that dont know what a bool is]"/&gt;<br /><br /><a href="http://msdn.microsoft.com/en-us/library/dd833074(VS.95).aspx">http://msdn.microsoft.com/en-us/library/dd833074(VS.95).aspx</a> <br /><br /><strong>on zoom</strong><br />so if you are using the first feature you can also then have an event handlers to do something special on zoom. the on zoom html param allows you to define an event handler on such.<br /><br />&lt;param name="onzoom" value="[functionname]"/&gt;<br /><br /><br /><a href="http://msdn.microsoft.com/en-us/library/dd833068(VS.95).aspx">http://msdn.microsoft.com/en-us/library/dd833068(VS.95).aspx</a> <br /><br /><a href="http://msdn.microsoft.com/en-us/library/system.windows.interop.content.zoomed(VS.95).aspx">http://msdn.microsoft.com/en-us/library/system.windows.interop.content.zoomed(VS.95).aspx</a> <br /><br />all in all some simple hacks that are not so much hacks but just kind of obscure things in Silverlight.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-8729990344079783850?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/10/silverlight-hack-of-week-auto-zoom.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-7707020624894326083Thu, 24 Sep 2009 15:48:00 +00002009-09-24T09:04:57.733-07:00silverlight 3controlsBuilding a Dial ControlA friend posed a question a few weeks back about implementing a dial control. I found a few but they seemed problematic so I decided it can't possibly be that hard. So the idea is a control with a custom event for dial position change that I can add templates etc to change the look and feel of the control to any kind of dial I want and bind an event handler to so that in can control say volumn. I posted how to implement a custom event last week so I'll focus specifically on the rest of the dial control. Lets start with the template in Generic.xaml.<br /><br />&lt;Style TargetType="DialTest:Dial"&gt;<br />&lt;Setter Property="Template"&gt;<br />&lt;Setter.Value&gt;<br />&lt;ControlTemplate TargetType="DialTest:Dial"&gt;<br />&lt;Grid x:Name="Knob" Background="Transparent" &gt;<br />&lt;ContentPresenter x:Name="Background" Content="{TemplateBinding KnobBackground}"/&gt;<br />&lt;ContentPresenter x:Name="DialKnob" Content="{TemplateBinding KnobFace}" RenderTransformOrigin="0.5,0.5" &gt;<br />&lt;ContentPresenter.RenderTransform&gt;<br />&lt;TransformGroup&gt;<br />&lt;RotateTransform x:Name="DialAngle" Angle="0" /&gt;<br />&lt;/TransformGroup&gt;<br />&lt;/ContentPresenter.RenderTransform&gt;<br />&lt;/ContentPresenter&gt;<br />&lt;/Grid&gt;<br />&lt;/ControlTemplate&gt;<br />&lt;/Setter.Value&gt;<br />&lt;/Setter&gt;<br />&lt;/Style&gt;<br /><br />So from this template we can see that the control will have a wrapper grid to force content to be resized as set and two content presenters one for the background and one for the dial and further a rotate transform on the dial so we can make it turn. As noted these content presenters imply that we have two dependency properties for the dial face and background but we will also have DP's for setting the start or minimum or max angle setting of the dial (0 to 360 degrees).<br /><br />In our constructor then we set our template and then OnApplyTemplate() we wire things together like so:<br /><br />Knob = ((Grid)GetTemplateChild("Knob"));<br />DialAngle = ((RotateTransform)GetTemplateChild("DialAngle"));<br /><br />Knob.MouseLeftButtonUp += new MouseButtonEventHandler(Knob_MouseLeftButtonUp);<br />Knob.MouseLeave += new MouseEventHandler(Knob_MouseLeave);<br />Knob.MouseLeftButtonDown += new MouseButtonEventHandler(Knob_MouseLeftButtonDown);<br />Knob.MouseMove += new MouseEventHandler(Knob_MouseMove);<br /><br />base.OnApplyTemplate();<br /><br />if (Minimum > 0 &amp;&amp; Minimum < 360)<br />{<br />SetPosition(Minimum);<br />}<br /><br />this wires our internal events we use to make the wiring work. What we are doing todo is on mouse down we will calculate the angle of that related to the control and then turn the dial to that position. we then fire off the angle changed event or custom event. The hard part turned out to the just figuring out the math and it turns out that this not the best method 'mathmatically' speaking but this works well. Once get a point from the mouse down we do this to get the relative angle:<br /><br /> double TheDiameter = Knob.ActualWidth;<br /> double CurrentHeight = Knob.ActualHeight;<br /><br /> double Radius = TheDiameter / 2;<br /><br /> double AngleOfRotation = AngleOfRotationQuadrant(TheDiameter, CurrentHeight, NewPoint);<br /><br /> //int DialQuadrant = 1;<br /> if ((NewPoint.X > Radius) && (NewPoint.Y <= Radius))<br /> {<br /> //DialQuadrant = 2;<br /> AngleOfRotation = 90.0 + (90.0 - AngleOfRotation);<br /> }<br /> else if ((NewPoint.X > Radius) && (NewPoint.Y > Radius))<br /> {<br /> //DialQuadrant = 4;<br /> AngleOfRotation = 180.0 + AngleOfRotation;<br /> }<br /> else if ((NewPoint.X < Radius) && (NewPoint.Y > Radius))<br /> {<br /> //DialQuadrant = 3;<br /> AngleOfRotation = 270.0 + (90.0 - AngleOfRotation);<br /> }<br /> return AngleOfRotation;<br /><br />Basically we calculate 90 degress of position for he dial face quadrant that the event was in and then add the relative additional quadrants as needed to get the correct angle. getting the quadrant goes like this: <br /><br /> double DialRadius = CurrentWidth / 2;<br /><br /> Point CenterPoint = new Point(DialRadius, CurrentHeight / 2);<br /> Point StartPoint = new Point(0, CurrentHeight / 2);<br /><br /> double TriangleTop = Math.Sqrt(ToThePowerOfTwo(NewPoint.X - CenterPoint.X) + ToThePowerOfTwo(CenterPoint.Y - NewPoint.Y));<br /><br /> double TriangleHeight = (NewPoint.Y > CenterPoint.Y) ? NewPoint.Y - CenterPoint.Y : CenterPoint.Y - NewPoint.Y;<br /><br /> return ((TriangleHeight * Math.Sin(90.0)) / TriangleTop) * 100;<br /><br />now we can set the angle in 'SetPosition(); like this: <br /> if (Minimum > 0 && Max > 0 && Minimum < 360 && Max <= 360 )<br /> {<br /> if (AngleOfRotation < Minimum)<br /> {<br /> AngleOfRotation = Minimum;<br /> }<br /> if (AngleOfRotation > Max)<br /> {<br /> AngleOfRotation = Max;<br /> }<br /> } <br /><br /> DialAngle.Angle = AngleOfRotation;<br /><br /> OnPositionChanged(new DialEventArgs(AngleOfRotation)); <br /><br />the last line being our custom event. and poof it works... So in xaml using the control might look like this: <br /><br /> &lt;cc:Dial x:Name="NewKnobControl" Height="100" Width="100" PositionChangedEvent="NewKnobControl_PositionChangedEvent" Minimum="45.0" Max="135" &gt; <br /> &lt;cc:Dial.KnobFace&gt;<br /> &lt;Grid &gt; <br /> &lt;Ellipse Fill="Aquamarine" /&gt;<br /> &lt;Rectangle x:Name="Indicator" Height="10" Width="49" Fill="Blue" Margin="1,45,50,45" /&gt;<br /> &lt;/Grid&gt;<br /> &lt;/cc:Dial.KnobFace&gt;<br /> &lt;/cc:Dial&gt;<br /><br />nice and simple, needs some design love but you get the point. The dial control code will be up on HackingSilverlight.codeplex.com some time this week.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-7707020624894326083?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/09/building-dial-control.htmlnoreply@blogger.com (david.kelley)4tag:blogger.com,1999:blog-887975141009593463.post-279044114819441900Tue, 22 Sep 2009 03:46:00 +00002009-09-21T20:49:05.639-07:00interactadamexpressionryanSD2IGblendadobeBlend/Catalyst Smack Down?Designer and Developer Workflow<br /><br />Is it a myth? Marketing lingo? Or could it be real with the help of powerful tools?<br /><br />Listen in as Ryan Stewart from Adobe and Adam Kinney from Microsoft discuss the workflow concept from their respective point of views. Ryan will demonstrate how Flash Catalyst works within the Flash Platform development cycle. Adam will show how Expression Blend fits into the Silverlight development workflow.<br /><br />Come join the fun with two of the best speakers in the world on Adobe/Blend at Interact<br /><br /><a href="http://www.seattled2ig.org/?p=257">http://www.seattled2ig.org/?p=257</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-279044114819441900?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/09/blendcatalyst-smack-down.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-4528177378987963152Thu, 17 Sep 2009 16:15:00 +00002009-09-17T09:18:01.787-07:00silverlightsilverlight 3firestarterThe Gu a Silveright firestarterif your paying attention and want to learn some Silverlight they are streaming the gu and more all star speakers free from the Silverlight firestarter at:<br /><br /><a href="http://www.msdnevents.com/firestarter/online/index.html">http://www.msdnevents.com/firestarter/online/index.html</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-4528177378987963152?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/09/gu-silveright-firestarter.htmlnoreply@blogger.com (david.kelley)0tag:blogger.com,1999:blog-887975141009593463.post-2122656707681767438Sat, 12 Sep 2009 13:34:00 +00002009-09-12T06:40:22.088-07:00eventinteractsilverlightsilverlight 3SD2IGfirestarterDon't Forget about Silverlight WeekSo this coming week is really really exciting and I wanted to make sure no one forgot. The stars have aligned and 4 big events are all happening in Seattle: <br /><br />Monday:<br />.NET Developer Association User Group Meeting - Featuring Jesse Liberty<br /><a href="http://www.dotnetda.com/Events/EventNewsletter.aspx?EventDate=9/14/2009">http://www.dotnetda.com/Events/EventNewsletter.aspx?EventDate=9/14/2009</a><br /><br />Tuesday<br />Silverlight Geek Dinner<br /><a href="http://adamkinney.com/Blog/silverlight-geek-dinner-sep-15th-seattleredmondbellevue">http://adamkinney.com/Blog/silverlight-geek-dinner-sep-15th-seattleredmondbellevue</a><br /><br />Wed<br />Interact Seattle - Featuring Tim Hueur<br /><a href="http://www.interactseattle.org/">http://www.InteractSeattle.org/</a><br /><br />Thur<br />Silverlight 3 Firestarter Event<br /><a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032422412&amp;Culture=en-US">http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032422412&amp;Culture=en-US</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/887975141009593463-2122656707681767438?l=hackingsilverlight.blogspot.com' alt='' /></div>http://hackingsilverlight.blogspot.com/2009/09/dont-forget-about-silverlight-week.htmlnoreply@blogger.com (david.kelley)0