public NamedArrowCursorControl() { this.Container = new Canvas(); this.Cursor = new ArrowCursorControl().AttachContainerTo(this.Container); var ShadowCointainer = new Canvas().AttachTo(this.Container); Func <int, Action> CreateShadow = ShadowLength => Enumerable.Range(2, ShadowLength).ToOrphanizeAction( (c, i) => new Rectangle { Fill = Brushes.Black, Width = 3, Opacity = 1.0 - (double)i / (double)ShadowLength, Height = 18 } .AttachTo(ShadowCointainer) .MoveTo(12 + i * 3, 24) ); //this.CreateShadow = CreateShadow.ToContinuation((string t) => 10 + t.Length); this.CreateShadow = t => { }; this.LabelShadow = new TextBox { IsReadOnly = true, Background = Brushes.Transparent, BorderThickness = new Thickness(0), Foreground = Brushes.Black, Width = 400, Height = 18, TextAlignment = TextAlignment.Left, FontFamily = new FontFamily("Verdana") }.AttachTo(Container).MoveTo(12 + 1, 24 + 1); this.Label = new TextBox { IsReadOnly = true, Background = Brushes.Transparent, BorderThickness = new Thickness(0), Foreground = Brushes.White, Width = 400, Height = 18, TextAlignment = TextAlignment.Left, FontFamily = new FontFamily("Verdana") }.AttachTo(Container).MoveTo(12, 24); }
public NumericTransmitterCanvas() { Width = DefaultWidth; Height = DefaultHeight; Colors.Blue.ToGradient(Colors.Red, DefaultHeight / 4).Select( (c, i) => new Rectangle { Fill = new SolidColorBrush(c), Width = DefaultWidth, Height = 4, }.MoveTo(0, i * 4).AttachTo(this) ).ToArray(); var c1 = new ArrowCursorControl { }; c1.Red.Opacity = 0.8; c1.Container.AttachTo(this); var c2 = new ArrowCursorControl { }; c2.Yellow.Opacity = 0.8; c2.Container.AttachTo(this); var c3 = new ArrowCursorControl { }; c3.Green.Opacity = 0.8; c3.Container.AttachTo(this); var Overlay = new Rectangle { Fill = Brushes.White, Width = DefaultWidth, Height = DefaultHeight, Opacity = 0, Cursor = Cursors.None }.AttachTo(this); Action <int, int> Emitter = NumericEmitter.Of( (x, y) => c3.Container.MoveTo(x, y) ); Action <int, int> Omitter = NumericOmitter.Of( (x, y) => { c2.Container.MoveTo(x, y); Emitter(x, y); } ); Overlay.MouseMove += (sender, e) => { var p = e.GetPosition(this); c1.Container.MoveTo(p.X, p.Y); //1000.AtDelay( // delegate // { // c2.Container.MoveTo(p.X, p.Y); // } //); 300.AtDelay( () => Omitter(Convert.ToInt32(p.X), Convert.ToInt32(p.Y)) ); }; }
public DynamicCursorCanvas() { Width = DefaultWidth; Height = DefaultHeight; var g = Colors.Yellow.ToGradient(Colors.Red, DefaultHeight).ToArray(); g.Select( (c, i) => new Rectangle { Fill = new SolidColorBrush(c), Width = DefaultWidth, Height = 2, }.MoveTo(0, i).AttachTo(this) ).ToArray(); var cur = new ArrowCursorControl(); cur.Cyan.Opacity = 0; cur.Magenta.Opacity = 0; cur.Yellow.Opacity = 0; new Rectangle { Fill = Brushes.Red, Width = 32, Height = 32 }.MoveTo(32, 32).AttachTo(this); new Rectangle { Fill = Brushes.Green, Width = 32, Height = 32 }.MoveTo(32 * 2, 32).AttachTo(this); new Rectangle { Fill = Brushes.Blue, Width = 32, Height = 32 }.MoveTo(32 * 3, 32).AttachTo(this); cur.Container.AttachTo(this).MoveTo(64, 64); var Overlay = new Rectangle { Fill = Brushes.White, Width = DefaultWidth, Height = DefaultHeight, Opacity = 0 }.AttachTo(this); var Overlay_Red = new Rectangle { Fill = Brushes.Red, Width = 32, Height = 32, Opacity = 0 }.MoveTo(32, 32).AttachTo(this); var Overlay_Green = new Rectangle { Fill = Brushes.Green, Width = 32, Height = 32, Opacity = 0 }.MoveTo(32 * 2, 32).AttachTo(this); var Overlay_Blue = new Rectangle { Fill = Brushes.Blue, Width = 32, Height = 32, Opacity = 0 }.MoveTo(32 * 3, 32).AttachTo(this); var Overlay_Y = new Rectangle { Fill = Brushes.Blue, Width = 32, Height = DefaultHeight, Opacity = 0 }.AttachTo(this); Overlay_Y.MouseMove += (sender, e) => { var p = e.GetPosition(this); cur.Color = g[Convert.ToInt32(p.Y)]; }; this.Cursor = Cursors.None; Overlay_Red.MouseEnter += delegate { // http://acept.asu.edu/PiN/rdg/color/composition.shtml cur.Color = Colors.Red; }; Overlay_Green.MouseEnter += delegate { // http://acept.asu.edu/PiN/rdg/color/composition.shtml cur.Color = Colors.Green; }; Overlay_Blue.MouseEnter += delegate { // http://acept.asu.edu/PiN/rdg/color/composition.shtml cur.Color = Colors.Blue; }; this.MouseMove += (sender, e) => { var p = e.GetPosition(this); cur.Container.MoveTo(p.X, p.Y); }; }