private static Bitmap DrawToIcon(IPresentationImage image, int width, int height) { //We just hide the text overlay and application graphics because it creates ugly icons. var textOverlayHider = new TextOverlayVisibilityHelper(image); var applicationGraphicsHider = GraphicsVisibilityHelper.CreateForApplicationGraphics(image); textOverlayHider.Hide(); applicationGraphicsHider.HideAll(); try { return(image.DrawToBitmap(width, height)); } catch (Exception ex) { // rendering the error text to a 100x100 icon is useless, so we'll just paint a placeholder error icon and log the icon error Platform.Log(LogLevel.Warn, ex, "Failed to render icon with dimensions {0}x{1}", width, height); var bitmap = new Bitmap(width, height); using (var graphics = System.Drawing.Graphics.FromImage(bitmap)) { graphics.FillRectangle(Brushes.Black, 0, 0, width, height); graphics.DrawLine(Pens.WhiteSmoke, 0, 0, width, height); graphics.DrawLine(Pens.WhiteSmoke, 0, height, width, 0); } return(bitmap); } finally { textOverlayHider.Restore(); applicationGraphicsHider.RestoreAll(); } }
public void TestRestoreVisible() { var layout = CreateLayout(true); var helper = new TextOverlayVisibilityHelper(layout); Assert.IsTrue(layout.Visible); helper.Hide(); Assert.IsFalse(layout.Visible); helper.Restore(); Assert.IsTrue(layout.Visible); }
public void TestRestoreVisible() { var layout = CreateLayout(true); var helper = new TextOverlayVisibilityHelper(layout); Assert.IsTrue(layout.Visible); helper.Hide(); Assert.IsFalse(layout.Visible); helper.Restore(); Assert.IsTrue(layout.Visible); }
public static Bitmap CreateThumbnail(IPresentationImage image, int width, int height) { var visibilityHelper = new TextOverlayVisibilityHelper(image); visibilityHelper.Hide(); var bitmap = CreateThumbnailImage(image, width, height); using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap)) DrawBorder(graphics, width, height); visibilityHelper.Restore(); return(bitmap); }