I was just searching for something and accidentlly got into this site which gives presentations, articles, explanations..blah blah blah abt .Net
Here is something ABOUT the site
DEVHOOD: "DevHood was created by six students at MIT who had nothing better to do than to create a developer's community using .NET. Actually it was really more of a proof of concept for the 2001 MIT $50K Entrepreneurial Competition. They actually got into the semifinals with their alpha version of the site which was pretty exciting.
Sunday, October 15, 2006
Wednesday, October 11, 2006
Annotations in WPF, Post-it notes using WPF, and more ...
code that'll be useful
Lester's Blog..........
Lester's Blog..........
Code for getting screen relative Position in WPF
One of the common customer queries that we see on the forums is to get the screen relative position of a point. Currently we do not provide an API which allows this functionality. However, Nick Kramer came up with this code on the forum and it works great for LTR (left to right) systems. Following is the code for getting the screen relative position :
static Point TransformToScreen(Point point, Visual relativeTo)
{
HwndSource hwndSource = PresentationSource.FromVisual(relativeTo) as HwndSource;
Visual root = hwndSource.RootVisual;
// Translate the point from the visual to the root.
GeneralTransform transformToRoot = relativeTo.TransformToAncestor(root);
Point pointRoot = transformToRoot.Transform(point);
// Transform the point from the root to client coordinates.
Matrix m = Matrix.Identity;
Transform transform = VisualTreeHelper.GetTransform(root);
if (transform != null)
{
m = Matrix.Multiply(m, transform.Value);
}
Vector offset = VisualTreeHelper.GetOffset(root);
m.Translate(offset.X, offset.Y);
Point pointClient = m.Transform(pointRoot);
// Convert from “device-independent pixels” into pixels.
pointClient = hwndSource.CompositionTarget.TransformToDevice.Transform(pointClient);
POINT pointClientPixels = new POINT();
pointClientPixels.x = (0 < pointClient.X) ? (int)(pointClient.X + 0.5) : (int)(pointClient.X - 0.5);
pointClientPixels.y = (0 < pointClient.Y) ? (int)(pointClient.Y + 0.5) : (int)(pointClient.Y - 0.5);
// Transform the point into screen coordinates.
POINT pointScreenPixels = pointClientPixels;
ClientToScreen(hwndSource.Handle, pointScreenPixels);
return new Point(pointScreenPixels.x, pointScreenPixels.y);
}
[StructLayout(LayoutKind.Sequential)]
public class POINT
{
public int x = 0;
public int y = 0;
}
[DllImport("User32", EntryPoint = "ClientToScreen", SetLastError = true,
ExactSpelling = true, CharSet = CharSet.Auto)]
private static extern int ClientToScreen(IntPtr hWnd, [In, Out] POINT pt);
static Point TransformToScreen(Point point, Visual relativeTo)
{
HwndSource hwndSource = PresentationSource.FromVisual(relativeTo) as HwndSource;
Visual root = hwndSource.RootVisual;
// Translate the point from the visual to the root.
GeneralTransform transformToRoot = relativeTo.TransformToAncestor(root);
Point pointRoot = transformToRoot.Transform(point);
// Transform the point from the root to client coordinates.
Matrix m = Matrix.Identity;
Transform transform = VisualTreeHelper.GetTransform(root);
if (transform != null)
{
m = Matrix.Multiply(m, transform.Value);
}
Vector offset = VisualTreeHelper.GetOffset(root);
m.Translate(offset.X, offset.Y);
Point pointClient = m.Transform(pointRoot);
// Convert from “device-independent pixels” into pixels.
pointClient = hwndSource.CompositionTarget.TransformToDevice.Transform(pointClient);
POINT pointClientPixels = new POINT();
pointClientPixels.x = (0 < pointClient.X) ? (int)(pointClient.X + 0.5) : (int)(pointClient.X - 0.5);
pointClientPixels.y = (0 < pointClient.Y) ? (int)(pointClient.Y + 0.5) : (int)(pointClient.Y - 0.5);
// Transform the point into screen coordinates.
POINT pointScreenPixels = pointClientPixels;
ClientToScreen(hwndSource.Handle, pointScreenPixels);
return new Point(pointScreenPixels.x, pointScreenPixels.y);
}
[StructLayout(LayoutKind.Sequential)]
public class POINT
{
public int x = 0;
public int y = 0;
}
[DllImport("User32", EntryPoint = "ClientToScreen", SetLastError = true,
ExactSpelling = true, CharSet = CharSet.Auto)]
private static extern int ClientToScreen(IntPtr hWnd, [In, Out] POINT pt);
Tuesday, October 10, 2006
AnimationBehaviors
AnimationBehaviors is a library (dll) built for Windows Presentation Foundation (WPF) that makes it easy to add common animations to elements in XAML with little effort. Adding animations becomes as easy as adding an attribute to an element in XAML. AnimationBehaviors simplifies the process of creating page transitions, layout animations, and other common types of animations in WPF.
AnimationBehaviors
AnimationBehaviors
Wow---printing 3D graphics
Here is what he writes about the wonder of WPF Printing the 3D Graphics with just 5lines of code
From Eric's Blog:Eric Writes......
The last time I worked on an app which used 3D graphics, printing was fairly simple. OpenGL was brand new and DirectX didn't exist yet, so we had to do all the projection math anyway. Adapting the code from screen to paper wasn't a big deal.
Modern graphics APIs are great, but they don't help with printing. Since I started my woodworking app using C# and Direct3D, I always figured it would be a huge task to implement printing. More to the point, since this app is a hobby project and the implementation of printing would probably be like real work, I figured this app would never be able to print.
Recently I switched everything over to WPF. Here is my printing code:
PrintDialog dlg = new PrintDialog();
if ((bool)dlg.ShowDialog().GetValueOrDefault())
{
dlg.PrintVisual(myViewport, "sawdust");
}
Five lines. Were it not for my pathological need to use braces on every if statement, it would be three lines.
Yes, yes I know -- a useful real-world printing feature would require more work. I'm just saying: I added these five lines to my app and a color picture of my bookshelf model emerged out of the printer down the hall. That's excellent.
Wow.
Sunday, October 08, 2006
Subscribe to:
Comments (Atom)