{"id":913,"date":"2010-05-07T13:30:25","date_gmt":"2010-05-07T13:30:25","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=913"},"modified":"2010-05-07T14:48:46","modified_gmt":"2010-05-07T14:48:46","slug":"loading-images-on-the-fly","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2010\/05\/07\/loading-images-on-the-fly\/","title":{"rendered":"loading images on the fly"},"content":{"rendered":"<p><span id=\"zipfile\"><a href='http:\/\/www.codingfriends.com\/wp-content\/uploads\/2010\/05\/moonlighttest.zip'><\/a><\/span>To load a image from the server, local or remote depending if you are developing locally.  I have been using <a href=\"http:\/\/monodevelop.com\/\">monodevelop<\/a> with the <a href=\"http:\/\/monodevelop.com\/Download\/What%27s_new_in_MonoDevelop_2.2#Moonlight_Add-in\">moonlight<\/a> addin, this allows you to create silverlight applications with Linux :).<\/p>\n<p>To start with, if you create a new solution by going to File->New->Solution and then selecting the moonlight Application project as similar to creating any other new project within monodeveloper (or within visual studio if you are using visual studio to create this silver light loading images on the fly).<\/p>\n<p><a href=\"http:\/\/www.codingfriends.com\/wp-content\/uploads\/2010\/05\/moonlight-solution.png\"><img decoding=\"async\" src=\"http:\/\/www.codingfriends.com\/wp-content\/uploads\/2010\/05\/moonlight-solution.png\" alt=\"Moonlight mono-develop project setup\" title=\"moonlight-solution\" class=\"aligncenter size-full wp-image-915\" \/><\/a><\/p>\n<p>And then within your main page.xaml file you need to define where you want the image to be placed.<\/p>\n<pre lang=\"xml\">\r\n\t\t<Image x:Name=\"Image1\" Source=\"dot.jpeg\"><\/Image>\r\n\t\t<Button x:Name=\"Button1\" Click=\"ButtonClick\" Height=\"50\" Content=\"Click\" ><\/Button>\r\n<\/pre>\n<p>above also includes the Button that you are going to click onto to load the image, in this case it will call the ButtonClick function (from the above it is the &#8220;click&#8221; method).  The ButtonClick is behind the page.xaml within the page.xaml.cs file (the csharp file).<\/p>\n<p>So once that button has been clicked it will call this function<\/p>\n<pre lang=\"csharp\">\r\n\t\tpublic void ButtonClick(System.Object sender,System.EventArgs eventy)\r\n\t\t{\r\n\t\t\tSystem.Windows.MessageBox.Show(\"hi there\");\r\n\t\t\tImage1.Source = new BitmapImage(new Uri(\"lcd.png\", UriKind.Relative));\r\n\t\t}\r\n<\/pre>\n<p>I put a little message pop up window to say &#8220;hi there&#8221;, just so that you know it have been clicked encase the lcd.png (as taken from the open clip art website <a href=\"http:\/\/www.openclipart.org\/detail\/23901\">here<\/a>) is not in the correct place, in this case it is placed within the bin\/debug, but if you are using a release edition or using visual studio you may have somewhere else.  <\/p>\n<p>I have included the full source code and image within a zip file above, please feel free to download.<\/p>\n<p>Here is the full page.xaml if you want to look over it.<\/p>\n<pre lang=\"xml\">\r\n<UserControl xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\" \r\n             xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\" \r\n             Width=\"500\" Height=\"350\"\r\n             x:Class=\"moonlighttest.Page\"\r\n>\r\n\t<Grid x:Name=\"LayoutRoot\" Background=\"Black\">\r\n\t\t<Image x:Name=\"Image1\" Source=\"dot.jpeg\"><\/Image>\r\n\t\t<Button x:Name=\"Button1\" Click=\"ButtonClick\" Height=\"50\" Content=\"Click\" ><\/Button>\r\n\t<\/Grid>\r\n<\/UserControl>\r\n<\/pre>\n<p>and here is the full page.xaml.cs file.<\/p>\n<pre lang=\"csharp\">\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Windows;\r\nusing System.Windows.Controls;\r\nusing System.Windows.Media;\r\nusing System.Windows.Media.Imaging;\r\n\r\nnamespace moonlighttest\r\n{\r\n\r\n\tpublic partial class Page : UserControl\r\n\t{\r\n\r\n\t\tpublic Page ()\r\n\t\t{\r\n\t\t\tthis.InitializeComponent ();\r\n\t\t}\r\n\t\t\r\n\t\tpublic void ButtonClick(System.Object sender,System.EventArgs eventy)\r\n\t\t{\r\n\t\t\tSystem.Windows.MessageBox.Show(\"hi there\");\r\n\t\t\t\r\n\t\t\tImage1.Source = new BitmapImage(new Uri(\"lcd.png\", UriKind.Relative));\r\n\t\t}\r\n\t}\r\n\t\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>To load a image from the server, local or remote depending if you are developing locally. I have been using monodevelop with the moonlight addin, this allows you to create silverlight applications with Linux :). To start with, if you create a new solution by going to File->New->Solution and then selecting the moonlight Application project &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2010\/05\/07\/loading-images-on-the-fly\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">loading images on the fly<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,195],"tags":[197,196,198],"class_list":["post-913","post","type-post","status-publish","format-standard","hentry","category-c_sharp","category-silverlight-moonlight","tag-bitmapimage","tag-loading-images","tag-uri"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=913"}],"version-history":[{"count":4,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/913\/revisions"}],"predecessor-version":[{"id":922,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/913\/revisions\/922"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}