Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Silverlight Online Plotter

0.00/5 (No votes)
12 Apr 2013 1  
A tool that allows you to create function graphs right in the browser, compare them, export and import.

Today I'd like to tell you about one of my old projects Silverlight Online Plotter. This is a tool that allows you to create function graphs right in the browser, compare them, export and import. 

Live demo is not allow to export because I have not implemented web service that saves data. In Silverlight 3.0 there is no way to create save dialog, so I exported data with http-handler. I created web request to web-service that saved data to a file and set session variable with filename. Than I made browser redirect to http-handler that returned this file.

There is code of web-service in PHP:

<?php

session_start();

if ($_GET['file']) {
$filename = $_SERVER['DOCUMENT_ROOT'].'/files/'.$_GET['file']; 
$f = fopen($filename, 'r');

if (!$f) { 
header('HTTP/1.0 404 Not Found');
exit();
}

header('Content-type: application/xplt');
header('Content-Disposition: attachment; filename="plots.xplt"');
header('Content-Length: '.filesize($filename));
echo fread($f, filesize($filename));
fclose($f);

@unlink($filename);
exit();
} 

if ($_POST['data']) {
$f = fopen($_SERVER['DOCUMENT_ROOT'].'/files/'.session_id().'.xml', 'w');
fwrite($f, stripslashes($_POST['data']));
fclose($f);

header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="utf-8" ?><data status="0" file="'.session_id().'.xml" />';
exit();
}

header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="utf-8" ?><data status="1" />';

?>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here