private static Animator<Tuple<int, Rect>> MakePointerAnimator(string name) { return (value, visible, topLeft) => { var brush = value.Select(e => e == null ? (Brush)Brushes.Red : e.Item1 == 0 ? Brushes.DarkGray : Brushes.Black); var rx = MakeTextAnimator(brush, fontWeight: value.Select(e => e != null && e.Item1 != 0 ? FontWeights.Normal : FontWeights.Bold))( value.Select(e => e == null ? "???" : e.Item1 == 0 ? "null" : "0x" + e.Item1.ToString("x")), visible, topLeft.Select(e => new Point(e.X + 5, e.Y + 5))); var size = rx.Item2.Select(e => new Size(e.Width.Max(50), e.Height + 8)); var box = size.WithTopLeft(topLeft); var boxAnim = new RectDesc( box, stroke: visible.Select(e => e ? (Brush)Brushes.Black : Brushes.Transparent), strokeThickness: 1); return Tuple.Create( new Animation { new TextDesc(name, topLeft, new Point(0, 1)), rx.Item1, boxAnim, MakeLinkAnimation(box, value.Select(e => e == null || e.Item1 == 0 ? (Rect?)null : e.Item2)) }, size); }; }
private static Animator<MemoryPoint> MakePointMemoryAnimator(int address) { return (value, visible, topLeft) => { var rx = MakeTextAnimator(value.Select(e => e.X.HasValue ? (Brush)Brushes.Black : Brushes.Red), fontWeight: value.Select(e => e.X.HasValue ? FontWeights.Normal : FontWeights.Bold))( value.Select(e => e.X.Select(f => "X = " + f).Else("X = ???")), visible, topLeft.Select(e => new Point(e.X + 5, e.Y + 5))); var ry = MakeTextAnimator(value.Select(e => e.Y.HasValue ? (Brush)Brushes.Black : Brushes.Red), fontWeight: value.Select(e => e.Y.HasValue ? FontWeights.Normal : FontWeights.Bold))( value.Select(e => e.Y.Select(f => "Y = " + f).Else("Y = ???")), visible, topLeft.Combine(rx.Item2, (p, s) => new Point(p.X + 5, p.Y + s.Height + 5))); var box = rx.Item2.Combine(ry.Item2, (xx, yy) => new Size(xx.Width.Max(yy.Width).Max(50), xx.Height + yy.Height + 8)); var boxAnim = new RectDesc( box.WithTopLeft(topLeft), stroke: visible.Select(e => e ? (Brush)Brushes.Black : Brushes.Transparent), strokeThickness: 1); return Tuple.Create( new Animation { new TextDesc("0x" + address.ToString("x"), topLeft, new Point(0, 1)), rx.Item1, ry.Item1, boxAnim }, box); }; }
private static Animator<string> MakeBoxValueAnimator(string name) { return (value, visible, topLeft) => { var brush = value.Select(e => e == null ? (Brush)Brushes.Red : Brushes.Black); var rx = MakeTextAnimator(brush, fontWeight: value.Select(e => e != null ? FontWeights.Normal : FontWeights.Bold))( value.Select(e => e ?? "???"), visible, topLeft.Select(e => new Point(e.X + 5, e.Y + 5))); var size = rx.Item2.Select(e => new Size(e.Width.Max(50), e.Height + 8)); var box = size.WithTopLeft(topLeft); var boxAnim = new RectDesc( box, stroke: visible.Select(e => e ? (Brush)Brushes.Black : Brushes.Transparent), strokeThickness: 1); return Tuple.Create( new Animation { new TextDesc(name, topLeft, new Point(0, 1)), rx.Item1, boxAnim, }, size); }; }