示例#1
0
    public override void Tick()
    {
        base.Tick();

        var root = FindRootPanel();

        if (root?.Style != null)
        {
            var panel = InspectorUtils.GetHoveredPanel(root, root.MousePos) ?? root;

            string classList;
            if (panel.Class.Any())
            {
                classList = string.Join(".", panel.Class);
            }
            else
            {
                classList = "";
            }

            _infoPanel.Text = $"{panel.ElementName} {Math.Round( panel.Box.Rect.width*ScaleFromScreen, 1 )}x{Math.Round( panel.Box.Rect.height*ScaleFromScreen, 1 )} {classList}";

            var left   = panel.Box.Left;
            var top    = panel.Box.Top;
            var width  = panel.Box.Rect.width;
            var height = panel.Box.Rect.height;

            this.Style.Left   = Length.Pixels(ScaleFromScreen * left);
            this.Style.Top    = Length.Pixels(ScaleFromScreen * top);
            this.Style.Width  = Length.Pixels(ScaleFromScreen * width);
            this.Style.Height = Length.Pixels(ScaleFromScreen * height);
            this.Style.Dirty();

            // Place info panel inside or left of component if too close to top/left of screen.
            var right = Screen.Width - left - height;
            _infoPanel.SetClass("move_down", top <= 18);
            _infoPanel.SetClass("move_left", right < 64);
        }
    }