Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rect"/> structure.
 /// </summary>
 /// <param name="size">The size of the rectangle.</param>
 public Rect(Size size)
 {
     this.x = 0;
     this.y = 0;
     this.width = size.Width;
     this.height = size.Height;
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rect"/> structure.
 /// </summary>
 /// <param name="position">The position of the rectangle.</param>
 /// <param name="size">The size of the rectangle.</param>
 public Rect(Point position, Size size)
 {
     this.x = position.X;
     this.y = position.Y;
     this.width = size.Width;
     this.height = size.Height;
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rect"/> structure.
 /// </summary>
 /// <param name="size">The size of the rectangle.</param>
 public Rect(Size size)
 {
     _x = 0;
     _y = 0;
     _width = size.Width;
     _height = size.Height;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rect"/> structure.
 /// </summary>
 /// <param name="position">The position of the rectangle.</param>
 /// <param name="size">The size of the rectangle.</param>
 public Rect(Point position, Size size)
 {
     _x = position.X;
     _y = position.Y;
     _width = size.Width;
     _height = size.Height;
 }
Пример #5
0
 protected override Size ArrangeOverride(Size finalSize)
 {
     _viewport = new Size(finalSize.Width, finalSize.Height / _lineSize.Height);
     _extent = new Size(_lineSize.Width, itemCount + 1);
     InvalidateScroll?.Invoke();
     return finalSize;
 }
Пример #6
0
 protected override Size MeasureOverride(Size availableSize)
 {
     using (var line = new FormattedText(
         "Item 100",
         TextBlock.GetFontFamily(this),
         TextBlock.GetFontSize(this),
         TextBlock.GetFontStyle(this),
         TextAlignment.Left,
         TextBlock.GetFontWeight(this)))
     {
         line.Constraint = availableSize;
         _lineSize = line.Measure();
         return new Size(_lineSize.Width, _lineSize.Height * itemCount);
     }
 }
Пример #7
0
        public ArcSegmentGeometry(Point startPoint, Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection,bool isClosed,bool isStroked)
        {
            _startPoint = startPoint;
            _point = point;
            _size = size;
            _rotationAngle = rotationAngle;
            _isLargeArc = isLargeArc;
            _sweepDirection = sweepDirection;
            _isClosed = isClosed;
            _isStroked = isStroked;
            IPlatformRenderInterface factory = PerspexLocator.Current.GetService<IPlatformRenderInterface>();
            IStreamGeometryImpl impl = factory.CreateStreamGeometry();

            using (IStreamGeometryContextImpl context = impl.Open())
            {
                context.BeginFigure(startPoint, isStroked);
                context.ArcTo(point, size, rotationAngle,isLargeArc, sweepDirection);
                context.EndFigure(isClosed);
            }

            PlatformImpl = impl;
        }
Пример #8
0
 /// <summary>
 /// Constrains the size.
 /// </summary>
 /// <param name="constraint">The size to constrain to.</param>
 /// <returns>The constrained size.</returns>
 public Size Constrain(Size constraint)
 {
     return new Size(
         Math.Min(_width, constraint._width),
         Math.Min(_height, constraint._height));
 }
Пример #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="style"></param>
        /// <param name="rect"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        private Point GetTextOrigin(ShapeStyle style, ref Rect2 rect, ref Size size)
        {
            double ox, oy;

            switch (style.TextStyle.TextHAlignment)
            {
                case TextHAlignment.Left:
                    ox = rect.X;
                    break;
                case TextHAlignment.Right:
                    ox = rect.Right - size.Width;
                    break;
                case TextHAlignment.Center:
                default:
                    ox = (rect.Left + rect.Width / 2.0) - (size.Width / 2.0);
                    break;
            }

            switch (style.TextStyle.TextVAlignment)
            {
                case TextVAlignment.Top:
                    oy = rect.Y;
                    break;
                case TextVAlignment.Bottom:
                    oy = rect.Bottom - size.Height;
                    break;
                case TextVAlignment.Center:
                default:
                    oy = (rect.Bottom - rect.Height / 2f) - (size.Height / 2f);
                    break;
            }

            return new Point(ox, oy);
        }
Пример #10
0
 public Point ToPixels(Size size)
 {
     return this.unit == OriginUnit.Pixels ?
         this.point :
         new Point(this.point.X * size.Width, this.point.Y * size.Height);
 }
Пример #11
0
 /// <summary>
 /// Constrains the size.
 /// </summary>
 /// <param name="constraint">The size to constrain to.</param>
 /// <returns>The constrained size.</returns>
 public Size Constrain(Size constraint)
 {
     return new Size(
         Math.Min(this.width, constraint.width),
         Math.Min(this.height, constraint.height));
 }
Пример #12
0
 /// <summary>
 /// Convert from WPF size to core size.
 /// </summary>
 public static RSize Convert(Size s)
 {
     return new RSize(s.Width, s.Height);
 }
Пример #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="finalSize"></param>
        /// <returns></returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            var context = this.DataContext as EditorContext;
            if (context != null
                && context.Editor != null
                && context.Editor.Project != null)
            {
                if (context.Renderers[0].State.EnableAutofit)
                {
                    AutoFit(finalSize.Width, finalSize.Height);
                }
            }

            return base.ArrangeOverride(finalSize);
        }