//---------------------------------------------------------------------- // InkDropShadow.cs (c) 2005 by Charles Petzold, www.charlespetzold.com //---------------------------------------------------------------------- using System; using System.Drawing; using System.Windows.Forms; using Microsoft.Ink; class InkDropShadow: Form { InkOverlay inkov; public static void Main() { Application.Run(new InkDropShadow()); } public InkDropShadow() { Text = "Ink Drop Shadow"; BackColor = Color.White; Size = new Size(640, 480); // Create the Menu Menu = new MainMenu(); Menu.MenuItems.Add("&Shadow!", new EventHandler(MenuShadowOnClick)); Menu.MenuItems.Add("&Clear!", new EventHandler(MenuClearOnClick)); // Create InkOverlay object attached to form inkov = new InkOverlay(this); inkov.DefaultDrawingAttributes.Width = 1000; // = 1 centimeter inkov.DefaultDrawingAttributes.IgnorePressure = true; inkov.Enabled = true; } void MenuShadowOnClick(object objSrc, EventArgs args) { Ink ink = inkov.Ink; Strokes stks = ink.Strokes; // Shadows first foreach (Stroke stk in stks) { Stroke stkShadow = ink.CreateStroke(stk.GetPoints()); stkShadow.DrawingAttributes = stk.DrawingAttributes.Clone(); stkShadow.DrawingAttributes.Color = Color.Gray; stkShadow.Move(250, 250); } // Then the foreground text foreach (Stroke stk in stks) { Stroke stkText = ink.CreateStroke(stk.GetPoints()); stkText.DrawingAttributes = stk.DrawingAttributes.Clone(); } // Delete the original stroke from the Ink object foreach (Stroke stk in stks) ink.DeleteStroke(stk); Invalidate(); } void MenuClearOnClick(object objSrc, EventArgs args) { inkov.Ink.DeleteStrokes(); Refresh(); } }