コード例 #1
0
ファイル: UIComponent.cs プロジェクト: jensj12/MeesGame
        protected virtual void InterpretInput(InputHelper inputHelper)
        {
            bool mouseHovering = false;
            bool mouseDown     = false;
            bool mouseClicked  = false;

            if (AbsoluteRectangle.Contains(inputHelper.MousePosition))
            {
                mouseHovering = true;
                if (inputHelper.MouseLeftButtonDown())
                {
                    mouseDown = true;
                }
                if (inputHelper.MouseLeftButtonPressed())
                {
                    mouseClicked = true;
                    InputUser    = this;
                    InvokeClickEvent();
                }
            }

            MouseHovering = mouseHovering;
            MouseDown     = mouseDown;
            MouseClicked  = mouseClicked;
        }
コード例 #2
0
        public void DrawRectangle(AbsoluteRectangle rectangle, IBrush fill)
        {
            canvas.Save();
            var paint = fill.ToSKPaint();

            canvas.DrawRect(new SKRect(rectangle.X, rectangle.Y, rectangle.Right, rectangle.Bottom), paint);
            canvas.Restore();
        }
コード例 #3
0
ファイル: SortedList.cs プロジェクト: jensj12/MeesGame
        public override void HandleInput(InputHelper inputHelper)
        {
            //Because the scrollbar is drawn first it needs to be the first object to have its input checked
            scrollBar.HandleInput(inputHelper);

            if (AbsoluteRectangle.Contains(inputHelper.MousePosition))
            {
                ChildOffset = ChildOffset - inputHelper.ScrollDelta;
            }

            base.HandleInput(inputHelper);
        }
コード例 #4
0
        public void DrawMultilineText(AbsoluteRectangle box, Typeface typeface, string text, IBrush brush, float lineHeight = 1.2f)
        {
            var paint = typeface.ToSKPaint(brush);

            canvas.Save();
            canvas.ClipRect(box.ToSKRect());
            var lines = splitLines(text, paint, box.Width);

            for (var i = 0; i < lines.Length; i++)
            {
                DrawText(new AbsolutePoint(box.Location.X, box.Location.Y + (i + 1) * typeface.Size * lineHeight), typeface, lines[i].text, brush);
            }
            canvas.Restore();
        }
コード例 #5
0
 public static SKRect ToSKRect(this AbsoluteRectangle rectangle)
 {
     return(new SKRect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom));
 }