<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Aimee Gurl... &#187; expressionblend</title>
	<atom:link href="http://aimeegurl.com/tag/expressionblend/feed/" rel="self" type="application/rss+xml" />
	<link>http://aimeegurl.com</link>
	<description>for as long as i can remember, technology has always fascinated me</description>
	<lastBuildDate>Thu, 13 Oct 2011 12:07:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Techfriday: Looping Panorama for Windows Phone 7 Series</title>
		<link>http://aimeegurl.com/2010/03/26/tech-friday-panoramic-looping-exercise/</link>
		<comments>http://aimeegurl.com/2010/03/26/tech-friday-panoramic-looping-exercise/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 16:39:00 +0000</pubDate>
		<dc:creator>Aimee</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[expressionblend]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[techfriday]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://aimeegurl.com/2010/03/26/tech-friday-panoramic-looping-exercise/</guid>
		<description><![CDATA[Just a quick note:&#160; I’m sure MS will be providing controls to this interface in the future so we don’t have to spend too much time building these controls ourselves This post, as with the previous one, was meant more as an Expression Blend Exercise for myself to be explore the features of Silverlight / [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />
<p>Just a quick note:&#160; I’m sure MS will be providing controls to this interface in the future so we don’t have to spend too much time building these controls ourselves <img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://aimeegurl.com/wp-content/uploads/2010/03/wlEmoticonsmile2.png" /> This post, as with the previous one, was meant more as an Expression Blend Exercise for myself to be explore the features of Silverlight / Windows Phone 7 and Expression Blend to see how much can be done with what we have today. </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:8070ac6e-1c02-408e-bf96-370447cfb807" class="wlWriterEditableSmartContent">
<div><object width="482" height="361"><param name="movie" value="http://www.youtube.com/v/3Da1DUf5W-I&amp;hl=en&amp;fs=1&amp;hl=en"></param><embed src="http://www.youtube.com/v/3Da1DUf5W-I&amp;hl=en&amp;fs=1&amp;hl=en" type="application/x-shockwave-flash" width="482" height="361"></embed></object></div>
<div style="width:482;clear:both;font-size:.8em;color:#000000">This is more of an Expression Blend exercise to simulate a looping panoramic interface on Windows Phone 7</div>
</div>
<p>There’s one annoying thing that I can’t figure out though: on the first scroll, you’ll notice from the video that the screen flickers. There’s probably something I’m doing wrong here but I just can’t figure it out yet <img class="wlEmoticon wlEmoticon-sad" alt="Sad" src="http://aimeegurl.com/wp-content/uploads/2010/03/wlEmoticonsad.png" /></p>
<p>So I had set out to accomplish two things: Simulate the looping background and sections in the panoramic interface on windows phone and instead of flicking, let the user touch and drag the controls from left to right before switching. I was able to accomplish the two, but like I mentioned, there’s an annoying thing that happens on the first transition from state one to state two. Another thing that’s wrong with this sample is that, I shouldn’t be switching states right away on a drag to left or drag to right. You should be able to pan a bit and the screen holds to that position till you pan to a certain threshold before the interface snaps to the next section. But yeah, maybe next time.</p>
<p>The first challenge was implementing the drag to next state instead of the flick. I couldn’t really isolate this into either a trigger or an action as it’s actually a combination of both, therefore a behavior. Basically, depending on the sum of the left and right value of the users drag motion, I trigger either GoToNextState() or GoToPreviousState(). Code for these two were modified from <a title="http://gallery.expression.microsoft.com/en-us/MIXBehaviorPack" href="http://gallery.expression.microsoft.com/en-us/MIXBehaviorPack">http://gallery.expression.microsoft.com/en-us/MIXBehaviorPack</a>.</p>
<p> <a href="http://aimeegurl.com/wp-content/uploads/2010/03/image18.png"><img style="border-right-width: 0px; margin: 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="left" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb19.png" width="563" height="262" /></a>
<p>So I built a PanoramicPanningBehavior that has a few properties I can set. </p>
<p>First there are&#160; the <strong>BackgroundElement</strong>, <strong>SectionsElement</strong>, <strong>TitleElement</strong>. I want them to be grouped so when it’s time for me to handle the drags, they don’t necessarily have to move at the same pace. That’s when the <strong>BackgroundMovementFactor</strong> and <strong>TitleMovementFactor </strong>come to play. Intstead of translating the background and title according to the value of the drag, I multiply it by the specified factor first. I’ve also let myself specify the <strong>StateGroup</strong> that has the states of our sections as described in <a href="http://aimeegurl.com/2010/03/18/panoramic-navigation-on-windows-phone-7-with-no-code">my previous post</a>, just in case you have other stategroups in the scene (though I haven’t tested this yet ^_^)</p>
<p> Now that I have the essential parts of my UI identified, I can now define what I want to do with them in my behavior when I start handling the events ManipulationDelta and ManipulationCompleted.   <br /> 
<p>&#160;</p>
<p>&#160;</p>
<p>First for ManipulationDelta, I first check to see whether the parts are not null, and then based on the input factors, I apply them to the Translation.X property of the DeltaManipulation, or basically the change in the touch points and assign the value to the TranslateX properties of the CompositeTransform of the elements that have been identified through the properties. I think it’s better to read the code <img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://aimeegurl.com/wp-content/uploads/2010/03/wlEmoticonsmile2.png" />&#160;</p>
<pre class="code"><span style="color: blue">void </span>RootVisual_ManipulationDelta(<span style="color: blue">object </span>sender, <span style="color: #2b91af">ManipulationDeltaEventArgs </span>e)
     {
         <span style="color: blue">if </span>(!e.IsInertial)
         {
             <span style="color: blue">if </span>(BackgroundElement != <span style="color: blue">null</span>) {
                 <span style="color: blue">var </span>BG = getElement(BackgroundElement).RenderTransform <span style="color: blue">as </span><span style="color: #2b91af">CompositeTransform</span>;
                 BG.TranslateX += e.DeltaManipulation.Translation.X * BackgroundMovementFactor;

             }
             <span style="color: blue">if </span>(SectionsElement != <span style="color: blue">null</span>) {
                 <span style="color: blue">var </span>SE = getElement(SectionsElement).RenderTransform <span style="color: blue">as </span><span style="color: #2b91af">CompositeTransform</span>;
                 SE.TranslateX += e.DeltaManipulation.Translation.X;

             }
             <span style="color: blue">if </span>(TitleElement != <span style="color: blue">null</span>) {
                 <span style="color: blue">var </span>TE = getElement(TitleElement).RenderTransform <span style="color: blue">as </span><span style="color: #2b91af">CompositeTransform</span>;
                 TE.TranslateX += e.DeltaManipulation.Translation.X* TitleMovementFactor;
             }

         };
     }</pre>
<p>&#160;</p>
<p>If I wanted to run the project at this point, I’ll have to create a stateGroup and the section states in order for this not to go haywire. When I recreated the project, I actually added the panning behavior last. Next we’ll see the reason why I say this is meant more as an exercise for myself (and maybe for building demo apps) than production code. I think from this screenshot you can more or less figure out what I did.</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2010/03/image19.png"><img style="border-right-width: 0px; margin: 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb20.png" width="1024" height="591" /></a></p>
<p>Okay, so seeing as how you’re able to, from the leftmost part of your UI, be able to pan even more to the left to peek and even transit into the rightmost section, there had to be something there. And since I didn’t want to duplicate all the controls, I wanted to use WPF’s VisualBrush. Sadly, this isn’t available for Silverlight, however, I did find this: <a href="http://dotneteers.net/blogs/vbandi/archive/2009/03/26/discovering-silverlight-3-poor-man-s-visualbrush-behavior.aspx">http://dotneteers.net/blogs/vbandi/archive/2009/03/26/discovering-silverlight-3-poor-man-s-visualbrush-behavior.aspx</a> When I tested it out, it wasn’t as performant as WPF’s visual brush, but since I only needed to draw the UI once, I thought this would do.If we had the PathListBox in WP7, that would have been a better option too.</p>
<p>If you look at my visual tree, I basically created a brush for the background image(<strong>image</strong>), the <strong>TitleGrid </strong>and the <strong>ContentGrid</strong> (which you won’t see since I collapsed it because there were more stuff inside. Next, you’ll notice that these elements are inside a stack and before and after each of them is a Rectangle. Basically, I created identically sized rectangles that use as brushes the PoorMansVisualBrush.</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2010/03/image20.png"><img style="border-right-width: 0px; margin: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="right" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb21.png" width="304" height="238" /></a>To do this, after adding a reference to the PoorMansVisualBrush (which I’ve made a WP version of ), I select the Rectangle and temporarily choose, TileBrush, click on Advanced Options in the <strong>Fill </strong>property and select <strong>Convert to New Resource… </strong>This will prompt me with a dialog to create a new brush resource and I’ll name it accordingly. In this Case, I have BackgroundBrush.</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2010/03/image21.png"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 20px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb22.png" width="648" height="434" /></a> </p>
<p>Next, with the behavior selected, I set the properties accordingly. Most important to note is to set the UpdateIntervalDuration to 00:00:00 so that the behavior doesn’t waste resources by repainting the brush. Next, you’ll want to go to each of the rectangles and assign their fill properties to the BrushResources you created. Also remember to set the <strong>Stroke </strong>to <strong>No brush </strong>especially if you have background images that are supposed to seamlessly merge the leftmost and rightmost portions. Now the tedious part is doing this for all the rectangles. <img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://aimeegurl.com/wp-content/uploads/2010/03/wlEmoticonsmile2.png" />&#160;</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2010/03/image22.png"><img style="border-right-width: 0px; margin: 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb23.png" width="856" height="373" /></a></p>
<p>
  <br />The last, and yet another tricky part is setting up the states. What you’re seeing here is pretty much the same as the last post where I have 3 states, to show my 3 sections. Note that when you position the states, you’ll want to position the actual to the middle/actual objects. It’ll probably be too difficult to set up using the rectangles with the brushes anyway since they don’t render at design time ^_^. Here, you’ll notice I’ve added custom transitions for when Section1State goes to Section3State and vice versa.</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2010/03/image23.png"><img style="border-right-width: 0px; margin: 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb24.png" width="978" height="340" /></a> </p>
<p>To do this, I’ll click on add transition button and select Section1State –&gt; Section3State </p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2010/03/image24.png"><img style="border-right-width: 0px; margin: 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb25.png" width="473" height="163" /></a> </p>
<p></p>
<p>In order to see what I’m doing better, I’ll switch to the Animation Workspace by pressing the function key [<strong>F6]. </strong>I’ve also minimized the stacks back so it’s easier to manage. With the transition to <strong>Section3State </strong>selected I’ll record a keyframe at the start, and end of the .5s transition.</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2010/03/image25.png"><img style="border-right-width: 0px; margin: 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb26.png" width="849" height="418" /></a></p>
<p>When I record a key frame at the end, it’ll actually default to moving to the right most part of the actual controls which I changed to the one below. I’ve highlighted the outlines of the rectangles that mimic the actual controls.</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2010/03/image26.png"><img style="border-right-width: 0px; margin: 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb27.png" width="874" height="480" /></a> </p>
<p></p>
<p>Do the same for transitioning Section3State-&gt;Section1State. What will happen here is the application will play this custom transition animation to showing the visual brushes and when the transition is done, it’ll switch to the destination state where the real controls are visible. </p>
<p></p>
<p>Run the app to test and that’s it!</p>
<p>Again, not an ideal solution for production but at least I got to learn a few more useful things in Blend that might be useful in the future.</p>
<p> I’ve uploaded the code here so if you want to test it out, download the zip file, rightclick –&gt; properties –&gt; Unblock to avoid getting those dll not found / inaccessible errors.<a href="http://aimeegurl.com/wp-content/uploads/2010/03/image27.png"><img style="border-bottom: 0px; border-left: 0px; margin: 11px 20px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://aimeegurl.com/wp-content/uploads/2010/03/image_thumb28.png" width="254" height="350" /></a></p>
<p>&#160;</p>
<p>
  </p>
<p><iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-bdfb7845c22e26b6.skydrive.live.com/embedicon.aspx/Projects/TechFriday/Panoramic%20Drag/PanoramaDrag.zip" frameborder="0" marginwidth="0" scrolling="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://aimeegurl.com/2010/03/26/tech-friday-panoramic-looping-exercise/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Happy Holidays Everyone!</title>
		<link>http://aimeegurl.com/2009/12/22/happy-holidays-everyone/</link>
		<comments>http://aimeegurl.com/2009/12/22/happy-holidays-everyone/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 19:11:15 +0000</pubDate>
		<dc:creator>Aimee</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[expressionblend]]></category>
		<category><![CDATA[expressiondesign]]></category>
		<category><![CDATA[silverlight4]]></category>
		<category><![CDATA[techfriday]]></category>
		<category><![CDATA[visualstudio2010]]></category>

		<guid isPermaLink="false">http://aimeegurl.com/2009/12/22/happy-holidays-everyone/</guid>
		<description><![CDATA[I was listening to some Christmas music today and the holiday spirit got the best of me. I managed to make a customizable e-greeting card using Silverlight 4. Since MS has only released a developer beta and no go-live license, users will have to manually download the Silverlight 4 beta plugin. I modified the html [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />
<p>I was listening to some Christmas music today and the holiday spirit got the best of me. I managed to make a customizable e-greeting card using Silverlight 4. Since MS has only released a developer beta and no go-live license, users will have to manually download the Silverlight 4 beta plugin. I modified the html code that the Silverlight SDK spits out to show this image and redirect it straight to the <a href="http://silverlight.net/getstarted/silverlight-4-beta/#tools">Silverlight Tools Page</a>:</p>
<p><a href="http://aimeegurl.com/wp-content/uploads/2009/12/MerryChristmas.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="MerryChristmas" border="0" alt="MerryChristmas" src="http://aimeegurl.com/wp-content/uploads/2009/12/MerryChristmas_thumb.png" width="674" height="527" /></a></p>
<p>I didn’t want to reinvent the wheel so I used some code that was already out there:</p>
<p><a href="http://www.wintellect.com/CS/blogs/jprosise/archive/2009/07/17/fun-with-savefiledialog-and-writeablebitmap.aspx">http://www.wintellect.com/CS/blogs/jprosise/archive/2009/07/17/fun-with-savefiledialog-and-writeablebitmap.aspx</a></p>
<p>- Code to encode an image to PNG and save to local hard drive</p>
<p><a href="http://channel9.msdn.com/learn/courses/Silverlight4/MagicMirror/MagicMirror/">http://channel9.msdn.com/learn/courses/Silverlight4/MagicMirror/MagicMirror/</a></p>
<p>- Silverlight 4 code to capture images from a Web Camera and Print</p>
<p>Tools I used:</p>
<p><a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx">Visual Studio 2010 Beta 2</a>&#160;</p>
<p><a href="http://www.microsoft.com/expression/products/Design_Overview.aspx">Microsoft Expression Design</a></p>
<p><a href="http://www.microsoft.com/expression/products/Blend_Overview.aspx">Microsoft Expression Blend Preview for .NET 4</a></p>
<p>And here’s the app! And yes, this qualifies for a TechFriday cause Christmas is on a&#8212; FRIDAY!</p>
]]></content:encoded>
			<wfw:commentRss>http://aimeegurl.com/2009/12/22/happy-holidays-everyone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

