Gyrolabs

Random tools to make your life easier

Saving Silverlight Ink

July 19th, 2007 by admin

Recently I was doing a project that required a signature applet. Since silverlight has ink support it was the logical choice. However, after many hours of searching around, I couldn’t seem to figure out how to save the ink without programming in C#. So here’s a solution that can turn the ink from an InkPresenter into XAML and back into ink again.

getStrokesAsString = function(inkpresenter) {
var strokes = inkpresenter.strokes;
var buffer = "<inkpresenter .Strokes>";

for (x = 0; x < strokes.Count; x++) {
buffer += "<Stroke>" +
"<stroke .DrawingAttributes>" +
"<drawingattributes Color='#FF000000' Height='1.75' Width='1.75'/>" +
"</stroke>" +
"<stroke .StylusPoints>";
var curstroke = strokes.getItem(x);
if (curstroke) {
var sps = curstroke.StylusPoints;
for (y = 0; y < sps.Count; y++) {
buffer += "<StylusPoint X='" + sps.getItem(y).X + "' Y='" + sps.getItem(y).Y + "' />";
}
}
buffer += "</stroke>";
buffer += "";
}
buffer += "</inkpresenter>";
return buffer;
}
setStrokesFromString = function(inkpresenter, silverlightobj, strokestring) {
inkpresenter.strokes.Clear();
var allstrokes = "allstrokes";
var allstrokes = silverlightobj.content.createFromXAML(strokestring);
inkpresenter.strokes = allstrokes;
}

Sorry it’t not formatted nicely — wordpress stripped all that out.

Use the getStrokesAsString method to get a XAML string representing all the strokes; just pass it the inkpresenter element.

Use the setStrokesFromString method to transfer a XAML string representing the strokes into actual strokes on the canvas. Pass it the inkpresenter element, the silverlight object (usually window.silverLight), and the XAML stroke string.

Posted in Articles, C#/.NET, Quick Tips | 1125 Comments »

Summer Plans

April 15th, 2007 by admin

I know summer doesn’t start until the end of June, but I’m starting earlier. I’ll be spending May working at Microsoft, so updates will be limited or nonexistent.

Once I get back from the internship, I’ll be redesigning this site to be more friendly to tracking downloads and keeping them separate from blog posts. If I end up writing a custom program for this, I’ll make it available for download.

In addition to the new site, I’ll be writing a system (in collaboration with Blueshift Labs) called CompactIS which is too complicated to explain on here. The spec on the protocol will be made available as soon as possible.

Posted in Articles | 2656 Comments »

Verizon LG Phone Hack

March 4th, 2007 by admin

This has been around for awhile and a lot of people know about it, but heres a little trick to confuse your friends. This ONLY works on VERIZON LG PHONES.

  1. Go into the phone’s menu
  2. Type 0 (zero) seven times
  3. Hit #
  4. Go to ‘Motor Test’
  5. Turn it on

Then the phone will vibrate until you go back in and turn it off.

Posted in Articles, Quick Tips | 604 Comments »

Traits of a Good Programmer

August 22nd, 2006 by admin

Here’s 4 traits of some of the best programmers. Click Here to Read the Full Article

Posted in Articles | 108 Comments »