Wednesday, May 15, 2013

Precise moving and resizing using Visio without snapping

Visio 2013 improves a bit on some of the move and resize features.  Below is a quick summary of moving and resizing images related to grid/snapping.

To gain more precise control over a moving or resizing a shape, hold down the Alt key while dragging the shape to move, rotate, or resize; this will suspend all forms of snapping.

Alt + Drag applies to 1D and 2D shapes, as well as multi-shape selections. It also applies to connectors, but they will still snap to glue targets.

Alt + Drag also works in combination with Ctrl and Shift modifier keys for drag actions.

Move
Alt + Shift + Drag: non-snapping move in one direction Alt + Ctrl + Drag: non-snapping copy

Resize
Alt + Shift + Drag side handle: non-snapping "resize from center"
Alt + Shift + Drag corner handle: non-snapping "resize in both dimensions"

Thursday, May 9, 2013

Call stored procedure with parameters using Entity Framework 5 and return scalar

Entity Framework 5 using a DbContext
bool result = myDbContext.Database.SqlQuery<bool>(
   "myProc @param1, @param2",
   new SqlParameter("param1", id),
   new SqlParameter("param2", name))
   .First();

Monday, May 6, 2013

ASP.NET dynamic images without a separate aspx file

In the past, when I wanted to display a dynamically generated image in ASP.NET, I would have a standalone aspx page that would stream back the image bytes using a image ContentType.

I recently found out that you can also stream images by setting the src attribute of the image with encoded bytes. This can be easily done using the ASP.NET Image control. Assume you have "myobject" that contains an image byte[] property called "imagebytes":

image1.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(myobject.imagebytes);

This will increase the size of your HTML since the image bytes are encoded directly into the HTML source. But hey, you don't need a separate aspx file.

Yippie.

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...