<?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>Everything Silverlight &#187; GalacticImg</title>
	<atom:link href="http://www.michaelsnow.com/tag/galacticimg/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michaelsnow.com</link>
	<description></description>
	<lastBuildDate>Thu, 28 Apr 2011 21:43:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Silverlight Tip of the Day #18 &#8211; Elastic Scrolling</title>
		<link>http://www.michaelsnow.com/2010/05/11/silverlight-tip-of-the-day-18-elastic-scrolling/</link>
		<comments>http://www.michaelsnow.com/2010/05/11/silverlight-tip-of-the-day-18-elastic-scrolling/#comments</comments>
		<pubDate>Tue, 11 May 2010 17:31:47 +0000</pubDate>
		<dc:creator>Snowman</dc:creator>
				<category><![CDATA[images]]></category>
		<category><![CDATA[scrolling]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[GalacticImg]]></category>

		<guid isPermaLink="false">http://www.silverlightdev.net/2010/05/11/silverlight-tip-of-the-day-18-elastic-scrolling/</guid>
		<description><![CDATA[If you have ever used an iPhone you will notice the scrolling is very elastic in nature. If you hit the end of the scroll it will go a little further before bouncing back. Also, the faster you flick your finger, the faster the scrolling starts off before gradually slowing down as the scrolling comes [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever used an iPhone you will notice the scrolling is very elastic in nature. If you hit the end of the scroll it will go a little further before bouncing back. Also, the faster you flick your finger, the faster the scrolling starts off before gradually slowing down as the scrolling comes to a stop.</p>
<p>I have updated my Image Viewer application (<a href="http://www.galacticimg.com">http://www.galacticimg.com</a>) to mimic this behavior. Since it’s not yet touch screen based, you can simply use mouse left click-hold to scroll rather than your finger.</p>
<p>The implementation is pretty straight forward but I am very interested in getting people’s feedback especially if you can think of a more efficient way to accomplish this.</p>
<p>To start, the following event is the event used to monitor for left mouse clicks. Velocity is used to determine the current scroll speed. VerticalOffset is the distance the panel has scrolled so far. The offsets are used to determine the speed of the scroll. As long as the mouse left button is down DraggingPanel will be set to true.</p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">private</span> <span class="kwrd">double</span> _verticalOffset = 0.0; </pre>
<pre><span class="kwrd">private</span> <span class="kwrd">double</span> _offset = 0.0; </pre>
<pre class="alt"><span class="kwrd">private</span> <span class="kwrd">double</span> _previousOffset = 0.0; </pre>
<pre><span class="kwrd">private</span> <span class="kwrd">int</span> _velocity = 0; </pre>
<pre class="alt">&#160;</pre>
<pre><span class="kwrd">private</span> <span class="kwrd">void</span> PanelCanvas_MouseLeftButtonDown(<span class="kwrd">object</span> sender, MouseButtonEventArgs e) </pre>
<pre class="alt">{ </pre>
<pre>    <span class="kwrd">this</span>.Focus(); </pre>
<pre class="alt">    _draggingPanel = <span class="kwrd">true</span>; </pre>
<pre>    PanelCanvas.CaptureMouse(); </pre>
<pre class="alt">    _velocity = 0; </pre>
<pre>    _offset = e.GetPosition(<span class="kwrd">this</span>).X - _verticalOffset; </pre>
<pre class="alt">    _previousOffset = e.GetPosition(<span class="kwrd">this</span>).X; </pre>
<pre>} </pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>In the MouseMove event I check to see if the DraggingPanel is true (meaning the left mouse is still down). If so, I calculate the new position of the panel and determine the velocity based upon how fast the mouse is moving. Finally, I set the new position of the ThumbnailCanvas which is the Canvas that contains all my images.</p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">private</span> <span class="kwrd">void</span> PanelCanvas_MouseMove(<span class="kwrd">object</span> sender, MouseEventArgs e) </pre>
<pre>{ </pre>
<pre class="alt">    <span class="kwrd">if</span> (<span class="kwrd">true</span> == _draggingPanel) </pre>
<pre>    { </pre>
<pre class="alt">        _verticalOffset = e.GetPosition(<span class="kwrd">this</span>).X - _offset; </pre>
<pre>        _velocity = (<span class="kwrd">int</span>)(e.GetPosition(<span class="kwrd">this</span>).X - _previousOffset); </pre>
<pre class="alt">        _previousOffset = e.GetPosition(<span class="kwrd">this</span>).X; </pre>
<pre>        ThumbnailCanvas.SetValue(Canvas.LeftProperty, (<span class="kwrd">double</span>)_verticalOffset); </pre>
<pre class="alt">    } </pre>
<pre>} </pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>
  </p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>If the mouse left click up event is fired I set DraggingPanel to false and release the mouse capture.</p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">private</span> <span class="kwrd">void</span> PanelCanvas_MouseLeftButtonUp(<span class="kwrd">object</span> sender, MouseButtonEventArgs e) </pre>
<pre>{ </pre>
<pre class="alt">    PanelCanvas.ReleaseMouseCapture(); </pre>
<pre>    _draggingPanel = <span class="kwrd">false</span>; </pre>
<pre class="alt">} </pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>I have a timer called EllasticScroll() that runs in the background. There are two conditions it checks for:</p>
<p>1. In the case where you scroll beyond the boundary of the images ScrollDistance is set and the panel “bounces back” to position zero.&#160; To test this out scroll to the left when you first start the <a href="http://www.galacticimg.com/#/Pages/PicturesPage">Galactic Image</a> app and you will see the bounce back effect.</p>
<p>2. The left mouse has been released and the auto-scrolling kicks in. It scrolls the panel based upon the current velocity which is trickled down to zero. If the scroll goes 200 pixels beyond the boundary, I stop the velocity setting it to zero and I set ScrollDistance so that is bounces back to zero.</p>
<div class="csharpcode">
<pre class="alt">_timer.Interval = TimeSpan.FromMilliseconds(20); </pre>
<pre>_timer.Tick += <span class="kwrd">new</span> EventHandler(EllasticScroll); </pre>
<pre class="alt">_timer.Start(); </pre>
<pre>&#160;</pre>
<pre class="alt"><span class="kwrd">private</span> <span class="kwrd">void</span> EllasticScroll(<span class="kwrd">object</span> sender, EventArgs e) </pre>
<pre>{ </pre>
<pre class="alt">    <span class="kwrd">if</span> (_scrollDistance != 0) </pre>
<pre>    { </pre>
<pre class="alt">        <span class="kwrd">int</span> distance = _scrollDistance / 10; </pre>
<pre>        _scrollCounter++; </pre>
<pre class="alt">        <span class="kwrd">if</span> (_scrollCounter == 10) </pre>
<pre>            _scrollDistance = 0; </pre>
<pre class="alt">        _verticalOffset += distance; </pre>
<pre>        <span class="kwrd">if</span> (_verticalOffset &gt; 0 &amp;&amp; distance &gt; 0) </pre>
<pre class="alt">            _verticalOffset = 0.0; </pre>
<pre>        ThumbnailCanvas.SetValue(Canvas.LeftProperty, (<span class="kwrd">double</span>)_verticalOffset); </pre>
<pre class="alt">    } </pre>
<pre>    <span class="kwrd">else</span> <span class="kwrd">if</span> (<span class="kwrd">false</span> == _draggingPanel &amp;&amp; _velocity != 0) </pre>
<pre class="alt">    { </pre>
<pre>        _verticalOffset += _velocity; </pre>
<pre class="alt">        ThumbnailCanvas.SetValue(Canvas.LeftProperty, (<span class="kwrd">double</span>)_verticalOffset); </pre>
<pre>        <span class="kwrd">double</span> v = (<span class="kwrd">double</span>)_velocity; </pre>
<pre class="alt">        v = v / 1.1; </pre>
<pre>        _velocity = (<span class="kwrd">int</span>)v; </pre>
<pre class="alt">        <span class="kwrd">if</span> (_verticalOffset &gt; 200) </pre>
<pre>        { </pre>
<pre class="alt">            _scrollCounter = 0; </pre>
<pre>            _velocity = 0; </pre>
<pre class="alt">            _scrollDistance = -(<span class="kwrd">int</span>)(_verticalOffset); </pre>
<pre>        } </pre>
<pre class="alt">    } </pre>
<pre>} </pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>If you need more details let me know. In the meantime, go over and check out the <a href="http://www.galacticimg.com/#/Pages/PicturesPage">application</a> and let me know what you think! </p>
<p>Thank you,<br />
  <br />&#8211;Mike</p>
<p><a href="http://www.galacticimg.com/#/Pages/PicturesPage"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.michaelsnow.com/wp-content/uploads/2010/06/image5.png" width="600" height="581" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelsnow.com/2010/05/11/silverlight-tip-of-the-day-18-elastic-scrolling/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Flickr/Bing/Google High End Image Viewer</title>
		<link>http://www.michaelsnow.com/2010/04/23/flickrbinggoogle-high-end-image-viewer/</link>
		<comments>http://www.michaelsnow.com/2010/04/23/flickrbinggoogle-high-end-image-viewer/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 18:15:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[images]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[GalacticImg]]></category>

		<guid isPermaLink="false">http://www.silverlightdev.net/?p=62</guid>
		<description><![CDATA[I have been working on a prototype for an Image Viewer that allows you to perform image based searches against search engines such as Bing, Google as well as Flickr. I hope to gradually add others including SmugMug, DeviantArt and more. You will need Silverlight 4 to view this application so if you haven’t upgraded [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on a prototype for an Image Viewer that allows you to perform image based searches against search engines such as Bing, Google as well as Flickr. I hope to gradually add others including SmugMug, DeviantArt and more. You will need Silverlight 4 to view this application so if you haven’t upgraded yet you can do so via <a href="http://www.silverlight.net/getstarted/">this link</a>.</p>
<p>To view this Silverlight application go to: <a href="http://www.GalacticImg.com">http://www.GalacticImg.com</a></p>
<p>I would be very interested in getting people’s <u>feedback.</u> What do you think of the UI, easy of use, etc? Is this a useful app for you and if so what features would you like to see added? You can respond here in the forum or click the “Contact Us” button located on the bottom-left of the application.</p>
<p>Below is a screenshot of the application.</p>
<p><a href="http://www.michaelsnow.com/wp-content/uploads/2010/06/image482.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.michaelsnow.com/wp-content/uploads/2010/06/image48_thumb2.png" width="600" height="541" /></a> </p>
<p><strong><font size="4">Searching</font></strong></p>
<p>In the search bar, enter the keywords(s) you want to search on and click the arrow to the right of the search bar to perform your search. You can change which engine you want to search against by clicking on the drop down magnifying class button located to the left of the search bar.</p>
<p><a href="http://www.michaelsnow.com/wp-content/uploads/2010/04/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.michaelsnow.com/wp-content/uploads/2010/04/image_thumb2.png" width="403" height="31" /></a> </p>
<p><strong><font size="4">Scrolling &amp; Zooming</font></strong></p>
<p>You can zoom in and out by clicking on the Zoom +/- buttons located on the bottom of screen. You can also use the mouse wheel button to zoom in and out.</p>
<p><a href="http://www.michaelsnow.com/wp-content/uploads/2010/04/image3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.michaelsnow.com/wp-content/uploads/2010/04/image_thumb3.png" width="87" height="27" /></a> </p>
<p>Clicking and dragging the blue ball seen below will allow you to scroll the panel left or right. Clicking the left/right white arrow buttons will accomplish the same thing.</p>
<p><a href="http://www.michaelsnow.com/wp-content/uploads/2010/04/image4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.michaelsnow.com/wp-content/uploads/2010/04/image_thumb4.png" width="240" height="35" /></a> </p>
<p>Thank you,    <br />&#8211;Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelsnow.com/2010/04/23/flickrbinggoogle-high-end-image-viewer/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

