コード例 #1
0
        public CanvasLayer(UGContext context, float alpha, UGRect clipRect) : this(context, 2)
        {
            _context.Native.PushOpacity(alpha);
            var geometry = new RectangleGeometry(clipRect.ToWPFRect());

            _context.Native.PushClip(geometry);
        }
コード例 #2
0
        public void OnDraw(IUGContext context)
        {
            var rect = new UGRect(10, 20, 100, 200);

            context.FillRoundedRectangle(rect, 40, 80, RED);
            context.DrawRoundedRectangle(rect, 40, 80, BLUE);

            var rect2 = new UGRect();

            rect2.X      = 4;
            rect2.Y      = 131;
            rect2.Width  = 10;
            rect2.Height = 40;
            context.DrawRectangle(rect2, BLUE, 2, STYLE);

            var points = new[]
            {
                new Vector2()
                {
                    X = 10F, Y = 20F
                },
                new Vector2()
                {
                    X = 20F, Y = 10F
                },
                new Vector2()
                {
                    X = 30F, Y = 20F
                },
                new Vector2()
                {
                    X = 40F, Y = 10F
                },
                new Vector2()
                {
                    X = 50F, Y = 20F
                },
                new Vector2()
                {
                    X = 60F, Y = 10F
                },
            };

            context.DrawLines(points, BLUE);

            var points2 = points.Select(p => { p.Y += 30F; return(p); }).ToArray();

            context.DrawLines(points2, BLUE, 2F);

            var points3 = points2.Select(p => { p.Y += 30F; return(p); }).ToArray();

            context.DrawLines(points3, BLUE, 3F, STYLE);
        }
コード例 #3
0
        private void ComputeBounds()
        {
#if __MACOS__
            var attributes = new NSStringAttributes()
            {
                Font = _textFormat.Native,
            };

            var size = _native.StringSize(attributes);
#else
            var attributes = new UIStringAttributes()
            {
                Font = _textFormat.Native,
            };

            var size = _native.GetSizeUsingAttributes(attributes);
#endif
            _LayoutBounds = new UGRect(
                0F,
                0F,
                (float)size.Width,
                (float)size.Height);
            if (HorizontalAlignment != UGHorizontalAlignment.Left)
            {
                if (HorizontalAlignment == UGHorizontalAlignment.Right)
                {
                    _LayoutBounds.X = Math.Max(0F, _requestedSize.Width - _LayoutBounds.Width);
                }
                else if (HorizontalAlignment == UGHorizontalAlignment.Center)
                {
                    _LayoutBounds.X = Math.Max(0F, (_requestedSize.Width - _LayoutBounds.Width) / 2F);
                }
            }
            if (VerticalAlignment != UGVerticalAlignment.Top)
            {
                if (VerticalAlignment == UGVerticalAlignment.Bottom)
                {
                    _LayoutBounds.Y = Math.Max(0F, _requestedSize.Height - _LayoutBounds.Height);
                }
                else if (VerticalAlignment == UGVerticalAlignment.Center)
                {
                    _LayoutBounds.Y = Math.Max(0F, (_requestedSize.Height - _LayoutBounds.Height) / 2F);
                }
            }
        }
コード例 #4
0
        private void ComputeBounds()
        {
            var layout = GetLayout();

            _LayoutBounds = new UGRect(
                0F,
                0F,
                layout.Width,
                layout.Height);
            if (VerticalAlignment != UGVerticalAlignment.Top)
            {
                if (VerticalAlignment == UGVerticalAlignment.Bottom)
                {
                    _LayoutBounds.Y = Math.Max(0F, _requestedSize.Height - _LayoutBounds.Height);
                }
                else if (VerticalAlignment == UGVerticalAlignment.Center)
                {
                    _LayoutBounds.Y = Math.Max(0F, (_requestedSize.Height - _LayoutBounds.Height) / 2F);
                }
            }
        }
コード例 #5
0
        public CanvasLayer(UGContext context, UGRect clipRect) : this(context, 1)
        {
            var geometry = new RectangleGeometry(clipRect.ToWPFRect());

            _context.Native.PushClip(geometry);
        }
コード例 #6
0
 public static CGRect ToCGRect(this UGRect rect)
 => new CGRect(rect.X, rect.Y, rect.Width, rect.Height);
コード例 #7
0
 public static Rect ToWinRTRect(this UGRect rect)
 => new Rect(rect.X, rect.Y, rect.Width, rect.Height);
コード例 #8
0
 public static RectangleF ToGDIRect(this UGRect rect)
 => new RectangleF(rect.X, rect.Y, rect.Width, rect.Height);
コード例 #9
0
 public static RectF ToAGRectF(this UGRect rect)
 => new RectF(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
コード例 #10
0
 public static Rect ToAGRect(this UGRect rect)
 => new Rect(
     (int)(rect.X + 0.5F),
     (int)(rect.Y + 0.5F),
     (int)(rect.X + rect.Width + 0.5F),
     (int)(rect.Y + rect.Height + 0.5F));