DeepZoom is neeeat
And neat indeed is also Scott Hanselman’s post about mouse wheel zoom handling for MultiScaleImages.
In his sample, clicking on the MultiScaleImage zooms in by a certain amount and shift-clicking zooms out. I modified the MouseLeftButtonUp handler so that instead of zooming, the point where the click occured is moved to the center.
A sample which uses Scott’s implementation(and can be adapted to center instead of zooming) is found in the Expression Blend Team Blog.
Heres the XAML:
<UserControl x:Class="MoveClickPositionToCenter.Page" xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="Black">
<Grid HorizontalAlignment="Stretch" Margin="0,0,0,50" VerticalAlignment="Stretch" x:Name="GridMain">
<MultiScaleImage Source="voodude/items.bin" x:Name="msi"/>
</Grid>
</Grid>
</UserControl>
And here the handler code:
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
this.MouseLeftButtonUp += delegate(object sender, MouseButtonEventArgs e)
{
Point newOrigin = new Point();
//width and height of the actual viewport
double viewportWidth = msi.ViewportWidth;
double viewportHeight = msi.ViewportWidth * msi.ActualHeight / msi.ActualWidth;
//the current origin
double currX = -msi.ViewportOrigin.X;
double currY = -msi.ViewportOrigin.Y;
//click position relative to the viewport
double clickX = viewportWidth * e.GetPosition(msi).X / msi.ActualWidth;
double clickY = viewportHeight * e.GetPosition(msi).Y / msi.ActualHeight;
//the center of the viewport
double centerX = viewportWidth / 2;
double centerY = viewportHeight / 2;
//calculate new origin
double newX = currX + centerX - clickX;
double newY = currY + centerY - clickY;
newOrigin.X = -newX;
newOrigin.Y = -newY;
msi.ViewportOrigin = newOrigin;
};
}
}
Fiddler is a very useful tool for capturing HTTP traffic. One can use it such as for figuring out what headers and POST-parameters are sent to a webserver when filling out a form. This information can then be used to programmatically create the same request to a webserver.
Fiddler is also able to decrypt SSL traffic. I used it recently to capture traffic over SSL sent by my browser and wanted then to use it again to check if my programmatic requests look the same as those from the browser. Because fiddler links itself as man-in-the-middle proxy between client and server, it also needs to provide a certificate for SSL requests. As this is not recognized as valid certificate, .NET throws an WebException at System.Net.HttpWebRequest.GetResponse() and no traffic shows up in fiddler.
To still be able to check accuracy of the programmatic requests with fiddler, it is possible to directly add a new delegate to ServicePointManager.ServerCertificateValidationCallback which always returns true:
//* Hack for debugging purposes to accept Fiddler certificate
ServicePointManager.ServerCertificateValidationCallback +=
delegate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors errors)
{
return true;
};
//*/
// Create request, write post parameters and so on..
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(“https://www.someurl.com”)
In the wordpress plugins directory, different source highlighting plugins are found. I tried some of them but was not happy 100% as none of them colors C#, XAML etc. source code like it is colored in Visual Studio.
Finally i found this nice website, which converts sourcecode into HTML 4.01.
http://www.manoli.net/csharpformat/
Remains including the provided csharp.css in the header.php of your current WordPress theme and off you go:
C#
public class OhHai
{
private string _msg = &quot;oh hai!&quot;;
public void SayHello()
{
Console.WriteLine(_msg);
}
}
Yay! (Almost) like in VS
Update 1.06.2009: Using SyntaxHighlighter Plus instead now.