public MouseMazeCanvas() { Width = DefaultWidth; Height = DefaultHeight; #region Gradient for (int i = 0; i < DefaultHeight; i += 4) { new Rectangle { Fill = ((uint)(0xff00007F + (int)(128 * i / DefaultHeight))).ToSolidColorBrush(), Width = DefaultWidth, Height = 4, }.MoveTo(0, i).AttachTo(this); } #endregion var img = new Avalon.Images.jsc { }.MoveTo(DefaultWidth - 128, DefaultHeight - 128).AttachTo(this); var mouse = new Avalon.Images.mouse { }.MoveTo(0, 0).AttachTo(this); var container = new Canvas { Width = DefaultWidth, Height = DefaultHeight }.AttachTo(this); var mousehollow = new Avalon.Images.mouse_hollow { }.MoveTo(0, 0).AttachTo(this); var canvasdrawing = new Canvas { Width = DefaultWidth, Height = DefaultHeight }.AttachTo(container); InitializeCanvasDrawing(canvasdrawing); var canvas = new Rectangle { Fill = Brushes.Red, Width = DefaultWidth, Height = DefaultHeight, Opacity = 0 }.MoveTo(0, 0).AttachTo(this); canvas.MouseLeftButtonUp += delegate { canvasdrawing.Visibility = Visibility.Hidden; canvasdrawing = new Canvas { Width = DefaultWidth, Height = DefaultHeight }.AttachTo(container); maze = new MazeGenerator(maze.Width, maze.Height, null); InitializeCanvasDrawing(canvasdrawing); }; this.Cursor = Cursors.None; canvas.MouseEnter += delegate { mouse.Visibility = Visibility.Visible; }; canvas.MouseLeave += delegate { mouse.Visibility = Visibility.Hidden; }; canvas.MouseMove += (s, ev) => { var p = ev.GetPosition(canvas); mouse.MoveTo(p.X - 8, p.Y - 8); mousehollow.MoveTo(p.X - 8, p.Y - 8); }; }