<?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>Silverlike &#187; C#</title>
	<atom:link href="http://silverlike.net/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://silverlike.net</link>
	<description>We Like Silverlight</description>
	<lastBuildDate>Mon, 07 Dec 2009 06:34:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple File Upload Solution</title>
		<link>http://silverlike.net/simple-file-upload-solution/</link>
		<comments>http://silverlike.net/simple-file-upload-solution/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 12:18:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[UploadFile]]></category>

		<guid isPermaLink="false">http://silverlike.net/simple-file-upload-solution/</guid>
		<description><![CDATA[Gergely Orosz target to implement a simple solution in uploading file using Silverlight. The upload control contains a progress indicator where you can keep track of the upload progress. The sample also showed you how you can collect the uploaded file using PHP or C#.]]></description>
			<content:encoded><![CDATA[<p><a href="http://gregdoesit.com/2009/10/file-upload-in-silverlight-a-simple-solution/" target="_blank">Gergely Orosz</a> target to implement a simple solution in uploading file using Silverlight. The upload control contains a progress indicator where you can keep track of the upload progress. The sample also showed you how you can collect the uploaded file using PHP or C#.</p>
<p class="image"><a href="http://gregdoesit.com/2009/10/file-upload-in-silverlight-a-simple-solution/" target="_blank"><img style="display: inline" title="Simple File Upload Solution" alt="Simple File Upload Solution" src="http://silverlike.net/wp-content/uploads/2009/11/SimpleFileUploadSolution.jpg" width="400" height="250" /></a> </p>
<div class="reference-info"><strong>Website:</strong> <a href="http://silverlike.net/simple-file-upload-solution/" title="http://silverlike.net/simple-file-upload-solution/" target="_blank">Click here</a></div>
<div class="reference-info"><strong>Download:</strong> <a href="http://silverlike.net/simple-file-upload-solution/" title="http://silverlike.net/simple-file-upload-solution/" target="_blank">Click here</a></div>
<img src="http://silverlike.net/?ak_action=api_record_view&id=832&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://silverlike.net/simple-file-upload-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strip HTML Tags</title>
		<link>http://silverlike.net/strip-html-tags/</link>
		<comments>http://silverlike.net/strip-html-tags/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 22:15:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://silverlike.net/strip-html-tags/</guid>
		<description><![CDATA[Corey referred a very useful code snippet provided by John which helps you to strip HTML Tags.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.85turns.com/2009/09/29/silverlight-tip-managing-html/" target="_blank">Corey</a> referred a very useful code snippet provided by <a href="http://books.google.com/books?id=o92WkIjDpAUC&amp;pg=PP1&amp;dq=john+papa+silverlight&amp;ei=kQ2uSqSkDYnOzQTHqK2ABQ#v=onepage&amp;q=html%20regex&amp;f=false" target="_blank">John</a> which helps you to strip HTML Tags.</p>
<p class="image"><a href="http://www.85turns.com/2009/09/29/silverlight-tip-managing-html/" target="_blank"><img style="display: inline" title="Strip HTML Tags" alt="Strip HTML Tags" src="http://silverlike.net/wp-content/uploads/2009/10/StripHTMLTags.jpg" width="450" height="250" /></a> </p>
<div class="demo-area">Silverlight Demo: <a class="new-window" href="http://silverlike.net/silverlight/index.php?xap=%2Fwp-content%2Fuploads%2Fxap%2FStripHtmlTags.xap&TB_iframe=true&caption=Strip+HTML+Tags&height=400&width=650" target="_blank">Click here to view</a></div>
<div class="csharp-area">csharp title: </div>
<pre class="brush: c-sharp;">
private string StripHtmlTags(string value){
    int length = 0;
    int.TryParse(value, out length);

    // Remove HTML tags and empty newlines and spaces and leading spaces
    string formattedValue = Regex.Replace(value as string, &quot;&lt;.*?&gt;&quot;, &quot;&quot;);
    formattedValue = Regex.Replace(formattedValue, @&quot;\n+\s+&quot;, &quot;\n\n&quot;);
    formattedValue = formattedValue.TrimStart(' ');
    formattedValue = HttpUtility.HtmlDecode(formattedValue);
    if(length &gt; 0 &amp;&amp; formattedValue.Length &gt;= length)
        formattedValue = formattedValue.Substring(0, length - 1);
    return formattedValue;
}</pre>
<div class="reference-info"><strong>Website:</strong> <a href="http://silverlike.net/strip-html-tags/" title="http://silverlike.net/strip-html-tags/" target="_blank">Click here</a></div>
<div class="reference-info"><strong>Data Driven Services with Silverlight 2:</strong> <a href="http://silverlike.net/strip-html-tags/" title="http://silverlike.net/strip-html-tags/" target="_blank">Click here</a></div>
<img src="http://silverlike.net/?ak_action=api_record_view&id=697&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://silverlike.net/strip-html-tags/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Checking Image Download Progress</title>
		<link>http://silverlike.net/checking-image-download-progress/</link>
		<comments>http://silverlike.net/checking-image-download-progress/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 06:02:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://silverlike.net/checking-image-download-progress/</guid>
		<description><![CDATA[This application demonstrated how we may check the download progress of an image. The progress is visualized with a Progress Bar.]]></description>
			<content:encoded><![CDATA[<p>This application demonstrated how we may check the download progress of an image. The progress is visualized with a Progress Bar.</p>
<p class="image"><a class="thickbox" href="http://www.shinedraw.com/data-handling/flash-vs-silverlight-loading-external-image/" target="_blank"><img style="display: inline" title="Checking Image Download Progress" alt="Checking Image Download Progress" src="http://silverlike.net/wp-content/uploads/2009/09/CheckingImageDownloadProgress.jpg" width="400" height="250" /></a></p>
<div class="demo-area">Silverlight Demo: <a class="new-window" href="http://silverlike.net/silverlight/index.php?xap=%2Fwp-content%2Fuploads%2Fxap%2FLoadingExternalImage.xap&TB_iframe=true&caption=Checking+Image+Download+Progress&height=400&width=650" target="_blank">Click here to view</a></div>
<div class="csharp-area">Check the download progress: </div>
<pre class="brush: c-sharp;">// C#
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.DownloadProgress += new EventHandler&lt;downloadprogresseventargs&gt;(bitmapImage_DownloadProgress);
bitmapImage.UriSource = new Uri(URL, UriKind.Absolute);
Image newImage = new Image() { Source = _bitmapImage };  

void bitmapImage_DownloadProgress(object sender, DownloadProgressEventArgs e)
{
    int progress = e.Progress; // 0 = 100  

    if (e.Progress == 100)
    {
        // finish
    }
}</pre>
<div class="reference-info"><strong>Website:</strong> <a href="http://silverlike.net/checking-image-download-progress/" title="http://silverlike.net/checking-image-download-progress/" target="_blank">Click here</a></div>
<div class="reference-info"><strong>Download:</strong> <a href="http://silverlike.net/checking-image-download-progress/" title="http://silverlike.net/checking-image-download-progress/" target="_blank">Click here</a></div>
<img src="http://silverlike.net/?ak_action=api_record_view&id=571&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://silverlike.net/checking-image-download-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Path in C# and XAML</title>
		<link>http://silverlike.net/create-path-in-csharp-xaml/</link>
		<comments>http://silverlike.net/create-path-in-csharp-xaml/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 10:40:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Geometry]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://silverlike.net/create-path-in-c/</guid>
		<description><![CDATA[Matthias Shapiro demonstrated how you create a geometry object using C# and XAML.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.veracitysolutions.com/creating-a-programmatic-path-in-silverlight-or-wpf/" target="_blank">Matthias Shapiro</a> demonstrated how you create a geometry object using C# and XAML.</p>
<p class="image"><a class="thickbox" href="http://silverlike.net/wp-content/uploads/2009/09/CreatePathinC_.jpg"><img style="display: inline" title="Create-Path-in-C#" alt="Create-Path-in-C#" src="http://silverlike.net/wp-content/uploads/2009/09/CreatePathinC__thumb.jpg" width="400" height="250" /></a></p>
<div class="reference-info"><strong>View:</strong> <a href="http://silverlike.net/create-path-in-csharp-xaml/" title="http://silverlike.net/create-path-in-csharp-xaml/" target="_blank">Click here</a></div>
<div class="reference-info"><strong>Download:</strong> <a href="http://silverlike.net/create-path-in-csharp-xaml/" title="http://silverlike.net/create-path-in-csharp-xaml/" target="_blank">Click here</a></div>
<img src="http://silverlike.net/?ak_action=api_record_view&id=269&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://silverlike.net/create-path-in-csharp-xaml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Gradient Background</title>
		<link>http://silverlike.net/create-gradient-background/</link>
		<comments>http://silverlike.net/create-gradient-background/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 06:50:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://silverlike.net/create-gradient-background-in-xaml/</guid>
		<description><![CDATA[Most of the time when you are using Visual Studio and you don't' want to open Blend for just setting a very Gradient Background! The below code can surely help you.]]></description>
			<content:encoded><![CDATA[<p>Most of the time when you are using Visual Studio and you don&#8217;t&#8217; want to open Blend for just setting a very Gradient Background! The below code can surely help you.</p>
<p class="image"><a class="thickbox" href="http://silverlike.net/wp-content/uploads/2009/09/CreateGradientBackgroundinXAML.jpg"><img style="display: inline" title="Create Gradient Background in XAML" alt="Create Gradient Background in XAML" src="http://silverlike.net/wp-content/uploads/2009/09/CreateGradientBackgroundinXAML_thumb.jpg" width="400" height="250" /></a></p>
<div class="csharp-area">Creat gradient background in c#: </div>
<pre class="brush: c-sharp;">
LinearGradientBrush linear = new LinearGradientBrush();
linear.StartPoint = new Point(0.5, 0);
linear.EndPoint = new Point(0.5, 1);

GradientStop g1 = new GradientStop();
g1.Color = _backgroundColor1;
g1.Offset = 0;

GradientStop g2 = new GradientStop();
g2.Color = _backgroundColor2;
g1.Offset = 1;

linear.GradientStops.Add(g2);
linear.GradientStops.Add(g1);

Border border = new Border();
border.Background = linear;</pre>
<div class="xaml-area">Creating gradient background in xaml: </div>
<pre class="brush: xml;">&lt;UserControl x:Class=&quot;GradientBackground.Page&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    Width=&quot;600&quot; Height=&quot;400&quot;&gt;
    &lt;Grid x:Name=&quot;LayoutRoot&quot; Background=&quot;White&quot;&gt;
        &lt;Rectangle Stroke=&quot;Black&quot; Height=&quot;180&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;10,10,0,0&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;285&quot;&gt;
            &lt;Rectangle.Fill&gt;
                &lt;LinearGradientBrush EndPoint=&quot;0.5,1&quot; StartPoint=&quot;0.5,0&quot;&gt;
                    &lt;GradientStop Color=&quot;Black&quot; Offset=&quot;0&quot;/&gt;
                    &lt;GradientStop Color=&quot;White&quot; Offset=&quot;1&quot;/&gt;
                &lt;/LinearGradientBrush&gt;
            &lt;/Rectangle.Fill&gt;
        &lt;/Rectangle&gt;
        &lt;Rectangle Stroke=&quot;Black&quot; Height=&quot;190&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;10,0,0,10&quot; VerticalAlignment=&quot;Bottom&quot; Width=&quot;285&quot;&gt;
            &lt;Rectangle.Fill&gt;
                &lt;LinearGradientBrush EndPoint=&quot;0,0&quot; StartPoint=&quot;0,1&quot;&gt;
                    &lt;GradientStop Color=&quot;Black&quot; Offset=&quot;0&quot;/&gt;
                    &lt;GradientStop Color=&quot;White&quot; Offset=&quot;0.1&quot;/&gt;
                    &lt;GradientStop Color=&quot;Black&quot; Offset=&quot;0.2&quot;/&gt;
                    &lt;GradientStop Color=&quot;White&quot; Offset=&quot;0.3&quot;/&gt;
                    &lt;GradientStop Color=&quot;Black&quot; Offset=&quot;0.4&quot;/&gt;
                    &lt;GradientStop Color=&quot;White&quot; Offset=&quot;0.5&quot;/&gt;
                    &lt;GradientStop Color=&quot;Black&quot; Offset=&quot;0.6&quot;/&gt;
                    &lt;GradientStop Color=&quot;White&quot; Offset=&quot;0.7&quot;/&gt;
                    &lt;GradientStop Color=&quot;Black&quot; Offset=&quot;0.8&quot;/&gt;
                    &lt;GradientStop Color=&quot;White&quot; Offset=&quot;0.9&quot;/&gt;
                    &lt;GradientStop Color=&quot;Black&quot; Offset=&quot;1&quot;/&gt;
                &lt;/LinearGradientBrush&gt;
            &lt;/Rectangle.Fill&gt;
        &lt;/Rectangle&gt;
        &lt;Rectangle Stroke=&quot;Black&quot; Height=&quot;180&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,10,10,0&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;285&quot;&gt;
            &lt;Rectangle.Fill&gt;
                &lt;LinearGradientBrush EndPoint=&quot;0,0&quot; StartPoint=&quot;1,1&quot;&gt;
                    &lt;GradientStop Color=&quot;Black&quot; Offset=&quot;0&quot;/&gt;
                    &lt;GradientStop Color=&quot;Red&quot; Offset=&quot;1&quot;/&gt;
                &lt;/LinearGradientBrush&gt;
            &lt;/Rectangle.Fill&gt;
        &lt;/Rectangle&gt;
        &lt;Rectangle Stroke=&quot;Black&quot; Height=&quot;190&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,0,10,10&quot; VerticalAlignment=&quot;Bottom&quot; Width=&quot;285&quot;&gt;
            &lt;Rectangle.Fill&gt;
                &lt;RadialGradientBrush&gt;
                    &lt;GradientStop Color=&quot;White&quot; Offset=&quot;0&quot;/&gt;
                    &lt;GradientStop Color=&quot;Black&quot; Offset=&quot;1&quot;/&gt;
                &lt;/RadialGradientBrush&gt;
            &lt;/Rectangle.Fill&gt;
        &lt;/Rectangle&gt;
    &lt;/Grid&gt;
&lt;/UserControl&gt;</pre>
<div class="demo-area">Silverlight Demo: <a class="new-window" href="http://silverlike.net/silverlight/index.php?xap=%2Fwp-content%2Fuploads%2Fxap%2FGradientBackground.xap&TB_iframe=true&caption=Create+Gradient+Background&height=400&width=650" target="_blank">Click here to view</a></div>
<div class="reference-info"><strong>Website:</strong> <a href="http://silverlike.net/create-gradient-background/" title="http://silverlike.net/create-gradient-background/" target="_blank">Click here</a></div>
<img src="http://silverlike.net/?ak_action=api_record_view&id=450&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://silverlike.net/create-gradient-background/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upload file using File Dialog</title>
		<link>http://silverlike.net/upload-file-using-file-dialog/</link>
		<comments>http://silverlike.net/upload-file-using-file-dialog/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 06:52:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[UploadFile]]></category>

		<guid isPermaLink="false">http://silverlike.net/upload-file-using-file-dialog/</guid>
		<description><![CDATA[The coding below demonstrating how you might utilize your FileDialog to upload files from your local disk to server.]]></description>
			<content:encoded><![CDATA[<p>The coding below demonstrating how you might utilize your FileDialog to upload files from your local disk to server. </p>
<p>The code demonstrated the following: </p>
<ol>
<li>Limited the selection of JPG and PNG files only </li>
<li>Only 1 file can be selected </li>
<li>Upload the file with the corresponding file name </li>
<li>How to get the file data inside PHP </li>
</ol>
<p class="image"><a class="thickbox" href="http://www.shinedraw.com"><img style="display: inline" title="Upload file using File Dialog" alt="Upload file using File Dialog" src="http://silverlike.net/wp-content/uploads/2009/09/UploadfileusingFileDialog_thumb.jpg" width="400" height="250" /></a>&#160;</p>
<div class="csharp-area">Select and upload file in c#: </div>
<pre class="brush: c-sharp;">OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = &quot;Image Files (.jpg,.png)|*.JPG;*.jpg;*.PNG;*.png&quot;;
dialog.FilterIndex = 1;
bool? userClickedOK = _imageDialog.ShowDialog();

// Process input if the user clicked OK.
if (userClickedOK == true)
{
    UploadFile(dialog.File.Name, dialog.File.OpenRead());
}

private void UploadFile(string filename, Stream data)
{
    UriBuilder ub = new UriBuilder(UPLOAD_PATH);
    ub.Query = string.Format(&quot;filename={0}&quot;, filename);

    WebClient c = new WebClient();
    c.OpenWriteCompleted += (sender, e) =&gt;
    {
        PushData(data, e.Result);
        e.Result.Close();
        data.Close();
    };
    c.OpenWriteAsync(ub.Uri, &quot;Post&quot;);
}

private void PushData(Stream input, Stream output)
{
    byte[] buffer = new byte[4096];
    int bytesRead;

    while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)
    {
        output.Write(buffer, 0, bytesRead);
    }
}</pre>
<div class="xaml-area">Get and save file in PHP: </div>
<pre class="brush: c-sharp;">
$filepath = $_REQUEST['filename'];
$handle = fopen(&quot;php://input&quot;, &quot;r&quot;);
$file = fopen($filepath,&quot;w&quot;);

if($file != null &amp;&amp; $handle != null)
{
        while ($data = fread($handle, 8192)) fwrite($file, $data);
        fclose($handle);
        fclose($file);
}</pre>
<div class="reference-info"><strong>Website:</strong> <a href="http://silverlike.net/upload-file-using-file-dialog/" title="http://silverlike.net/upload-file-using-file-dialog/" target="_blank">Click here</a></div>
<img src="http://silverlike.net/?ak_action=api_record_view&id=454&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://silverlike.net/upload-file-using-file-dialog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading external assembly</title>
		<link>http://silverlike.net/loading-external-assembly/</link>
		<comments>http://silverlike.net/loading-external-assembly/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 06:46:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Reflection]]></category>

		<guid isPermaLink="false">http://silverlike.net/loading-external-assembly/</guid>
		<description><![CDATA[Terence Tsang demonstrated how to load an external assembly library (Usually a dll or xap file) into your own Silverlight application.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shinedraw.com/data-handling/flash-vs-silverlight-loading-external-assemblylibrary-dynamically/" target="_blank">Terence Tsang</a> demonstrated how to load an external assembly library (Usually a dll or xap file) into your own Silverlight application. This is a very effective method to minimize the application file size.</p>
<p class="image"><a class="thickbox" href=" http://www.shinedraw.com/data-handling/flash-vs-silverlight-loading-external-assemblylibrary-dynamically/" target="_blank"><img style="display: inline" title="Loading external assembly" alt="Loading external assembly" src="http://silverlike.net/wp-content/uploads/2009/09/Loadingexternalassembly.jpg" width="400" height="250" /></a></p>
<div class="csharp-area">Loading external library in C#: </div>
<pre class="brush: c-sharp;">WebClient downloader = new WebClient();
downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(onDownloadCompleted);
downloader.OpenReadAsync(new Uri(DLL_PATH, UriKind.Absolute));  

// Once the assembly is downloaded
private void onDownloadCompleted(object o, OpenReadCompletedEventArgs args)
{
    try
    {
        AssemblyPart ap = new AssemblyPart();
        Assembly assembly = ap.Load(args.Result);
        Object control = assembly.CreateInstance(CLASS_NAME);
    }
    catch (Exception e){}
}</pre>
<div class="reference-info"><strong>Website:</strong> <a href="http://silverlike.net/loading-external-assembly/" title="http://silverlike.net/loading-external-assembly/" target="_blank">Click here</a></div>
<div class="reference-info"><strong>Download:</strong> <a href="http://silverlike.net/loading-external-assembly/" title="http://silverlike.net/loading-external-assembly/" target="_blank">Click here</a></div>
<img src="http://silverlike.net/?ak_action=api_record_view&id=443&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://silverlike.net/loading-external-assembly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Load &amp; Save File from Isolated Storage</title>
		<link>http://silverlike.net/load-save-file-from-isolated-storage/</link>
		<comments>http://silverlike.net/load-save-file-from-isolated-storage/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 09:36:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Data]]></category>

		<guid isPermaLink="false">http://silverlike.net/load-save-file-from-isolated-storage/</guid>
		<description><![CDATA[Mike Snow demonstrated how to read file and load file from local storage. Please read the C# for details.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.silverlight.net/blogs/msnow/archive/2008/07/16/tip-of-the-day-19-using-isolated-storage.aspx" target="_blank">Mike Snow</a> demonstrated how to read file and load file from local storage. Please read the C# for details.</p>
<p class="image"><a class="thickbox" href="http://blogs.silverlight.net/blogs/msnow/archive/2008/07/16/tip-of-the-day-19-using-isolated-storage.aspx" target="_blank"><img style="display: inline" title="Load &amp; Save File from Isolated Storage" alt="Load &amp; Save File from Isolated Storage" src="http://silverlike.net/wp-content/uploads/2009/09/LoadSaveFilefromIsolatedStorage.jpg" width="400" height="250" /></a></p>
<div class="csharp-area">Save and read file from local storage: </div>
<pre class="brush: c-sharp;">using System;
using System.Windows.Controls;
using System.IO.IsolatedStorage;
using System.IO;

namespace SilverlightApplication10
{
    public class Page : UserControl
    {
        public Page()
        {
            SaveData(&quot;Hello There&quot;, &quot;MyData.txt&quot;);
            if (HasFile(&quot;MyData.txt&quot;))
            {
                string test = LoadData(&quot;MyData.txt&quot;);
            }
        }

        private void SaveData(string data, string fileName)
        {
            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
            IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.Create, isf);
            using (StreamWriter sw = new StreamWriter(isfs))
            {
                sw.Write(data);
                sw.Close();
            }
        }

        private bool HasFile(string fileName)
        {
            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
            return isf.FileExists(fileName);
        }

        private string LoadData(string fileName)
        {
            string data = String.Empty;
            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
            IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.Open, isf);
            using (StreamReader sr = new StreamReader(isfs))
            {
                string lineOfData = String.Empty;
                while ((lineOfData = sr.ReadLine()) != null) data += lineOfData;
            }
            return data;
        }
    }
}</pre>
<div class="reference-info"><strong>Website:</strong> <a href="http://silverlike.net/load-save-file-from-isolated-storage/" title="http://silverlike.net/load-save-file-from-isolated-storage/" target="_blank">Click here</a></div>
<img src="http://silverlike.net/?ak_action=api_record_view&id=498&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://silverlike.net/load-save-file-from-isolated-storage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clip/Mask To Actual Size</title>
		<link>http://silverlike.net/clipmask-to-actual-size/</link>
		<comments>http://silverlike.net/clipmask-to-actual-size/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 09:30:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[Behavior]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://silverlike.net/clip-to-bounds-actual-size/</guid>
		<description><![CDATA[Colin Eberhardt created a very useful Clipping behavior class which helps you do clipping easily. The behavior can detect the ActualHeight and ActualWidth at run time and create a RectangleGeometry() to Clip your Grid.]]></description>
			<content:encoded><![CDATA[<p><b><a href="http://www.codeproject.com/Articles/36495/Silverlight-ClipToBounds-Can-I-Clip-It-Yes-You-Can.aspx" target="_blank">Colin Eberhardt</a></b> created a very useful Clipping behavior class which helps you do clipping easily. The behavior can detect the ActualHeight and ActualWidth at run time and create a RectangleGeometry() to Clip your Grid. </p>
<p class="image"><a class="thickbox" href="http://www.codeproject.com/Articles/36495/Silverlight-ClipToBounds-Can-I-Clip-It-Yes-You-Can.aspx" target="_blank"><img style="display: inline" title="Clip To Bounds" alt="Clip To Bounds" src="http://silverlike.net/wp-content/uploads/2009/09/ClipToBounds.png" width="400" height="250" /></a></p>
<div class="csharp-area">c# implementation of the behavior: </div>
<pre class="brush: c-sharp;">using System;
using System.Windows;

namespace Namespace
{

    public class Clip
    {
        public static bool GetToBounds(DependencyObject depObj)
        {
            return (bool)depObj.GetValue(ToBoundsProperty);
        }

        public static void SetToBounds(DependencyObject depObj, bool clipToBounds)
        {
            depObj.SetValue(ToBoundsProperty, clipToBounds);
        }

        /// &lt;summary&gt;
        /// Identifies the ToBounds Dependency Property.
        /// &lt;summary&gt;
        public static readonly DependencyProperty ToBoundsProperty =
        DependencyProperty.RegisterAttached(&quot;ToBounds&quot;, typeof(bool),
        typeof(Clip), new PropertyMetadata(false, OnToBoundsPropertyChanged));

        private static void OnToBoundsPropertyChanged(DependencyObject d,
        DependencyPropertyChangedEventArgs e)
        {
        FrameworkElement fe = d as FrameworkElement;
        if (fe != null)
        {
            ClipToBounds(fe);

            // whenever the element which this property is attached to is loaded
            // or re-sizes, we need to update its clipping geometry
            fe.Loaded += new RoutedEventHandler(fe_Loaded);
            fe.SizeChanged += new SizeChangedEventHandler(fe_SizeChanged);

        }
        }

        /// &lt;summary&gt;
        /// Creates a rectangular clipping geometry which matches the geometry of the
        /// passed element
        /// &lt;/summary&gt;
        private static void ClipToBounds(FrameworkElement fe)
        {
        if (GetToBounds(fe))
        {
            fe.Clip = new RectangleGeometry()
            {
            Rect = new Rect(0, 0, fe.ActualWidth, fe.ActualHeight)
            };
        }
        else
        {
            fe.Clip = null;
        }
        }

        static void fe_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            ClipToBounds(sender as FrameworkElement);
        }

        static void fe_Loaded(object sender, RoutedEventArgs e)
        {
            ClipToBounds(sender as FrameworkElement);
        }
    }
}</pre>
<div class="xaml-area">sample usage in XAML: </div>
<pre class="brush: xml;">&lt;UserControl x:Class=&quot;Namespace.MainPage&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:this=&quot;clr-namespace:Namespace;assembly=Namespace&quot;
    &gt;
    &lt;Grid x:Name=&quot;LayoutRoot&quot;  this:Clip.ToBounds=&quot;True&quot; &gt;

    &lt;/Grid&gt;
&lt;/UserControl&gt;</pre>
<div class="reference-info"><strong>Website:</strong> <a href="http://silverlike.net/clipmask-to-actual-size/" title="http://silverlike.net/clipmask-to-actual-size/" target="_blank">Click here</a></div>
<div class="reference-info"><strong>Download:</strong> <a href="http://silverlike.net/clipmask-to-actual-size/" title="http://silverlike.net/clipmask-to-actual-size/" target="_blank">Click here</a></div>
<img src="http://silverlike.net/?ak_action=api_record_view&id=494&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://silverlike.net/clipmask-to-actual-size/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hit Test (Get all objects in a specific point)</title>
		<link>http://silverlike.net/hit-test-get-all-objects-in-a-specific-point/</link>
		<comments>http://silverlike.net/hit-test-get-all-objects-in-a-specific-point/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 10:55:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Hittest]]></category>
		<category><![CDATA[Interaction]]></category>

		<guid isPermaLink="false">http://silverlike.net/hit-test-get-all-objects-in-a-specific-point/</guid>
		<description><![CDATA[Most of the time, when you are creating games, you will have to find out all the UIElemetn in a specific coordinate. (Or we can this hittest). In such circumstance, you will need to use the method VisualTreeHelper.FindElementsInHostCoordinates. Please view the C# coding for more details.]]></description>
			<content:encoded><![CDATA[<p>Most of the time, when you are creating games, you will have to find out all the UIElemetn in a specific coordinate. (Or we can this hittest). In such circumstance, you will need to use the method VisualTreeHelper.FindElementsInHostCoordinates. Please view the C# coding for more details.</p>
<p class="image"><a class="thickbox" href=" http://www.shinedraw.com" target="_blank"><img style="display: inline" title="Hit-Test" alt="Hit-Test" src="http://silverlike.net/wp-content/uploads/2009/09/HitTest.jpg" width="400" height="250" /></a></p>
<div class="csharp-area">Get all the UIElement in a specific coordinate: </div>
<pre class="brush: c-sharp;">

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;

namespace HitTest
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

            Loaded += new RoutedEventHandler(MainPage_Loaded);
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            App.Current.RootVisual.MouseLeftButtonDown += new MouseButtonEventHandler(RootVisual_MouseLeftButtonDown);
        }

        void RootVisual_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            List&lt;uielement&gt; list = VisualTreeHelper.FindElementsInHostCoordinates
            (e.GetPosition(null), LayoutRoot as UIElement) as List&lt;uielement&gt;;

            var selectedControls = from control in list
                                   where control is Rectangle
                                   select control as Rectangle;

            if (selectedControls.Count() &amp;gt; 0)
            {
                foreach (var selectedControl in selectedControls)
                {
                    // do your opreation here
                }
            }
        }
    }
}
</pre>
<div class="reference-info"><strong>Website:</strong> <a href="http://silverlike.net/hit-test-get-all-objects-in-a-specific-point/" title="http://silverlike.net/hit-test-get-all-objects-in-a-specific-point/" target="_blank">Click here</a></div>
<img src="http://silverlike.net/?ak_action=api_record_view&id=273&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://silverlike.net/hit-test-get-all-objects-in-a-specific-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!--
This site's performance optimized by W3 Total Cache:

W3 Total Cache improves the user experience of your blog by caching
frequent operations, reducing the weight of various files and providing
transparent content delivery network integration.

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk

Served from: shareelements.silverlighteffect.com @ 2010-07-29 22:57:32 -->