Пример #1
0
        public static IControl Debug(this IControl ctrl, string name, [CallerFilePath] string filepath = "", [CallerLineNumber] int lineNumber = 0)
        {
#if DEBUG
            var location = new ReplaySubject <IMountLocation>(1);
            ctrl = ctrl.WithMountLocation(
                oldLocation =>
            {
                location.OnNext(oldLocation);
                return(oldLocation);
            });

            var debugCtrl = new DebugControl(
                name,
                ctrl,
                location.Select(l => l.NativeFrame).Switch(),
                location.Select(l => l.AvailableSize).Switch(),
                AbsoluteFilePath.Parse(filepath),
                lineNumber);

            DebugControls.OnNext(DebugControls.Value.SetItem(debugCtrl.Name, debugCtrl));

            var selected = Command.Enabled(action: () => SelectedControl.OnNext(name));

            return(ctrl.WithOverlay(
                       SelectedControl.StartWithNone()
                       .Select(selCtrl => selCtrl.MatchWith(n => n == name, () => false))
                       .Select(isSelected => isSelected
                                                ? Shapes.Rectangle(stroke: Stroke.Create(2, Color.FromBytes(0x6d, 0xc0, 0xd2)), fill: Color.FromBytes(0x6d, 0xc0, 0xd2, 50))
                                                : Shapes.Rectangle().OnMouse(pressed: selected))
                       .Switch()
                       ));
#else
            return(ctrl);
#endif
        }
Пример #2
0
        static IControl CreateInfoPanel(DebugControl selCtrl)
        {
            var rooted        = selCtrl.Control.IsRooted;
            var desiredSize   = selCtrl.Control.DesiredSize.Transpose();
            var nativeFrame   = selCtrl.Frame.Transpose();
            var availableSize = selCtrl.AvailableSize.Transpose();
            var actualSize    = nativeFrame.Size();

            return(Layout.StackFromTop(
                       CreateProperty("IsRooted", rooted, r => r.ToString()),
                       CreateProperty("Desired Size", desiredSize, d => d.Format()),
                       CreateProperty("Actual Size", actualSize, a => a.Format()),
                       CreateProperty("Available Size", availableSize, a => a.Format()),
                       CreateProperty("Native Frame", nativeFrame, f => f.Format()).WithPadding(new Thickness <Points>(0, 20, 0, 0))
                       )
                   .WithPadding(new Thickness <Points>(0, 5, 0, 0)));
        }