Convert WPF visuals to Windows metafile (WMF)

Feb 2, 2010

There's already a solution for this, you can convert both visual or UIElemnt to metafile... the only (and the biggest) drawback is that the metafile that you get is not vector because you are pasting an bmp inside it... here are the links:

http://www.switchonthecode.com/tutorials/wpf-tutorial-getting-from-wpf-to-a-metafile-and-onto-the-clipboard

and the visuals addon taken from the microsoft forums:

private static BitmapSource CaptureScreen(Visual target, double dpiX, double dpiY)
{
if (target == null)
{
return null;
}

Rect bounds = VisualTreeHelper.GetDescendantBounds(target);

RenderTargetBitmap rtb = new RenderTargetBitmap((int)(bounds.Width * dpiX / 96.0),
(int)(bounds.Height * dpiY / 96.0),
dpiX,
dpiY,
PixelFormats.Pbgra32);

DrawingVisual dv = new DrawingVisual();
using (DrawingContext ctx = dv.RenderOpen())
{
VisualBrush vb = new VisualBrush(target);
ctx.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
}

rtb.Render(dv);

return rtb;
}



EDIT: if your visual/UIElement has transparent background, the code supplied above will make an image with black background... the workaround is to use the PngBitmapEncoder instead of BmpBitmapEncoder

Restart Computer rule failed during MS SQL Server 2008 installation

Jan 17, 2010

If you happen to get the "Restart Computer" rule Failed while trying to install Microsoft SQL Server 2008 R2, the only thing you need to do is Clear the PendingFileRenameOperations key in your registry. You can find the key in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager. You can start the Registry Editor running the Regedit.exe

Afterwards, just rerun the test, and voila, it will pass.
Hope i saved you some time!

Cool CSS Tricks

Aug 8, 2009

1. Center verticaly using line-height


div {
height:100px;
}

div * {
margin:0;
}

div p {
line-height:100px;
}



2. Center horizontally


div {
margin:0px auto;
}

3. Reset Stylesheet

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}

/* remember to define focus styles! */
:focus {
outline: 0;
}

/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}

/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}




4. Font Sizing


body {
font-size: 62.5%;
line-height: 1.5em;
}


5. Wrap around the containing divs


#container {
overflow:auto;
}

OR

#container {
overflow:hidden;
}


6. CSS3 border-radius property

Firefox:

#container {
-moz-border-radius: 20px;
}


Safari, Chrome:

#container {
-webkit-border-radius: 20px;
}