コード例 #1
0
 public void SetLocation(UI.Point location, UI.Size size)
 {
     Canvas.SetLeft(this, location.X);
     Canvas.SetTop(this, location.Y);
     Width  = size.Width;
     Height = size.Height;
 }
コード例 #2
0
        public UI.Size Measure(UI.Size constraints)
        {
            var dimensions = Dimensions;

            if (dimensions == UI.Size.Empty)
            {
                return(UI.Size.Empty);
            }

            var    stretch = Stretch;
            double scale   = 1;

            if (constraints.Width < dimensions.Width || stretch != ContentStretch.None)
            {
                scale = constraints.Width / dimensions.Width;
            }
            if (constraints.Height < dimensions.Height || stretch != ContentStretch.None)
            {
                scale = Math.Min(scale, constraints.Height / dimensions.Height);
            }

            return(dimensions * scale);
        }