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#.
Nov
ADO.NET Data Services
A Game catalog which demonstrated how to use ADO.NET Data Services. You are able to witch between NHibernate and Entity Framework as well.
Oct
Getting Twitter Updates
A Twitter updates collection tool created by pay4foss. The app will collect the updates from http://twitter.com/statuses/public_timeline.xml and display the messages with some interesting arm circles. The app also demonstrated how to get a cross domain XML file using web services.
Oct
Datagrid Activity Control
David Poll shared a comprehensive business application on presenting customer data. A very good sample to take reference to start your own business app.
Sep
Checking Image Download Progress
This application demonstrated how we may check the download progress of an image. The progress is visualized with a Progress Bar.
// C#
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.DownloadProgress += new EventHandler<downloadprogresseventargs>(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
}
}
Sep
Connecting Drupal and Silverlight
Mattserbinski attempted to integrate Silverlight with Drupal. He created a module in Drupal which makes use of XML PRC functionalities to check login credential via Silverlight.
The Drupal module provides the following features:
- Check if user is signed in
- Create User
- Sign out user
- Check the login Credentials In Silverlight
Sep
Upload file using File Dialog
The coding below demonstrating how you might utilize your FileDialog to upload files from your local disk to server.
The code demonstrated the following:
- Limited the selection of JPG and PNG files only
- Only 1 file can be selected
- Upload the file with the corresponding file name
- How to get the file data inside PHP
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "Image Files (.jpg,.png)|*.JPG;*.jpg;*.PNG;*.png";
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("filename={0}", filename);
WebClient c = new WebClient();
c.OpenWriteCompleted += (sender, e) =>
{
PushData(data, e.Result);
e.Result.Close();
data.Close();
};
c.OpenWriteAsync(ub.Uri, "Post");
}
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);
}
}
$filepath = $_REQUEST['filename'];
$handle = fopen("php://input", "r");
$file = fopen($filepath,"w");
if($file != null && $handle != null)
{
while ($data = fread($handle, 8192)) fwrite($file, $data);
fclose($handle);
fclose($file);
}
Sep
Loading external assembly
Terence Tsang 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.
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){}
}
Sep
HTTP Post Request
This coding below demonstrated how you can POST data to the target remote server. Terence Tsang also provided a simple sample letting you to search the feed items of your blog (Only works for Wordpress).
If you are new to Silverlight networking, remember to check out Network Security Access Restrictions in Silverlight.
// Create a request object
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(POST_ADDRESS, UriKind.Absolute));
request.Method = "POST";
// don't miss out this
request.ContentType = "application/x-www-form-urlencoded";
request.BeginGetRequestStream(new AsyncCallback(RequestReady), request);
// Sumbit the Post Data
void RequestReady(IAsyncResult asyncResult)
{
HttpWebRequest request = asyncResult.AsyncState as HttpWebRequest;
Stream stream = request.EndGetRequestStream(asyncResult);
// Hack for solving multi-threading problem
this.Dispatcher.BeginInvoke(delegate()
{
// Send the post variables
StreamWriter writer = new StreamWriter(stream);
writer.WriteLine("key1=value1");
writer.WriteLine("key2=value2");
writer.Flush();
writer.Close();
request.BeginGetResponse(new AsyncCallback(ResponseReady), request);
});
}
// Get the result from the server
void ResponseReady(IAsyncResult asyncResult)
{
HttpWebRequest request = asyncResult.AsyncState as HttpWebRequest;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asyncResult);
this.Dispatcher.BeginInvoke(delegate()
{
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
// get the result text
string result = reader.ReadToEnd();
});
}
Sep
Silverlight Multiple File Upload
Darick shared a very nice application which enables you to upload multiple files concurrently.It has a rich user interface with a lot of configurable options.









