当前位置: 首页>>代码示例>>C#>>正文


C# Size2D类代码示例

本文整理汇总了C#中Size2D的典型用法代码示例。如果您正苦于以下问题:C# Size2D类的具体用法?C# Size2D怎么用?C# Size2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Size2D类属于命名空间,在下文中一共展示了Size2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MeasureOverride

        /// <inheritdoc/>
        protected override Size2D MeasureOverride(Size2D availableSize)
        {
            var sizeLeft   = 0.0;
            var sizeTop    = 0.0;
            var sizeRight  = 0.0;
            var sizeBottom = 0.0;

            foreach (var child in Children)
            {
                var availableSizeForChild = new Size2D(
                    availableSize.Width - (sizeLeft + sizeRight),
                    availableSize.Height - (sizeTop + sizeBottom));

                child.Measure(availableSizeForChild);

                switch (GetDock(child))
                {
                    case Dock.Left:
                        sizeLeft += child.DesiredSize.Width;
                        break;
                    case Dock.Top:
                        sizeTop += child.DesiredSize.Height;
                        break;
                    case Dock.Right:
                        sizeRight += child.DesiredSize.Width;
                        break;
                    case Dock.Bottom:
                        sizeBottom += child.DesiredSize.Height;
                        break;
                }
            }

            return new Size2D(sizeLeft + sizeRight, sizeTop + sizeBottom);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:35,代码来源:DockPanel.cs

示例2: Size2DEqualityTests

        public void Size2DEqualityTests()
        {
            Size2D s1 = new Size2D();
            Size2D s2 = Size2D.Empty;
            Size2D s3 = Size2D.Zero;
            Size2D s4 = new Size2D(0, 0);
            Size2D s5 = new Size2D(9, 10);

            Assert.Equal(s1, s2);
            Assert.NotEqual(s1, s3);
            Assert.Equal(s3, s4);
            Assert.NotEqual(s1, s5);
            Assert.NotEqual(s3, s5);

            IVectorD v1 = s1;
            IVectorD v2 = s2;
            IVectorD v3 = s3;
            IVectorD v4 = s4;
            IVectorD v5 = s5;

            Assert.Equal(v1, v2);
            Assert.NotEqual(v1, v3);
            Assert.Equal(v3, v4);
            Assert.NotEqual(v1, v5);
            Assert.NotEqual(v3, v5);

            Assert.Equal(v5, s5);
        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:28,代码来源:Size2DTests.cs

示例3: Size2D_IsConstructedProperly

        public void Size2D_IsConstructedProperly()
        {
            var result = new Size2D(123.45, 456.78);

            TheResultingValue(result)
                .ShouldBe(123.45, 456.78);
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:7,代码来源:Size2DTests.cs

示例4: MeasureOverride

        /// <inheritdoc/>
        protected override Size2D MeasureOverride(Size2D availableSize)
        {
            var contentWidth  = 0.0;
            var contentHeight = 0.0;

            if (Orientation == Orientation.Vertical)
            {
                foreach (var child in Children)
                {
                    child.Measure(new Size2D(availableSize.Width, Double.PositiveInfinity));

                    contentWidth  = Math.Max(contentWidth, child.DesiredSize.Width);
                    contentHeight = contentHeight + child.DesiredSize.Height;
                }
            }
            else
            {
                foreach (var child in Children)
                {
                    child.Measure(new Size2D(Double.PositiveInfinity, availableSize.Height));

                    contentWidth  = contentWidth + child.DesiredSize.Width;
                    contentHeight = Math.Max(contentHeight, child.DesiredSize.Height);
                }
            }

            return new Size2D(contentWidth, contentHeight);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:29,代码来源:StackPanel.cs

示例5: SimpleCollisionTest

		/// <summary>
		/// Test whether label collides.
		/// </summary>
		/// <param name="newLabel"></param>
		/// <returns>true if label collided with another (more important or earlier) label</returns>
		public Boolean SimpleCollisionTest(Label2D newLabel)
		{
			if (labelList.Contains(newLabel))
			{
				return false;
			}

			Size2D newSize = TextRenderer.MeasureString(newLabel.Text, newLabel.Font);
			newSize = new Size2D(newSize.Width + 2 * newLabel.CollisionBuffer.Width, newSize.Height + 2 * newLabel.CollisionBuffer.Height);
			Rectangle2D newRect = new Rectangle2D(new Point2D(newLabel.Location.X - newLabel.CollisionBuffer.Width, newLabel.Location.Y - newLabel.CollisionBuffer.Height), newSize);

			foreach (Label2D label in labelList)
			{
				Size2D size = TextRenderer.MeasureString(label.Text, label.Font);
				size = new Size2D(size.Width + 2*label.CollisionBuffer.Width, size.Height + 2*label.CollisionBuffer.Height);
				Rectangle2D rect =
					new Rectangle2D(
						new Point2D(label.Location.X - newLabel.CollisionBuffer.Width, label.Location.Y - label.CollisionBuffer.Height),
						size);

				if (newRect.Intersects(rect))
				{
					return true;
				}
			}

			labelList.Add(newLabel);

			return false;
		}
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:35,代码来源:LabelCollisionDetection2D.cs

示例6: VirtualButton

        public VirtualButton(Size2D<int> CustomHitbox, bool Animate = false)
        {
            this.CustomHitbox = CustomHitbox;
            this.Animate = Animate;

            PressedAnimation = "Pressed";
            ReleasedAnimation = "Released";
        }
开发者ID:iLambda,项目名称:Freemwork,代码行数:8,代码来源:VirtualButton.cs

示例7: Size2D_EqualsObject

        public void Size2D_EqualsObject()
        {
            var size1 = new Size2D(123.45, 456.78);
            var size2 = new Size2D(123.45, 456.78);

            TheResultingValue(size1.Equals((Object)size2)).ShouldBe(true);
            TheResultingValue(size1.Equals("This is a test")).ShouldBe(false);
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:8,代码来源:Size2DTests.cs

示例8: Size2D_Area_IsCalculatedCorrectly

        public void Size2D_Area_IsCalculatedCorrectly()
        {
            var size1 = new Size2D(123.45, 456.78);
            TheResultingValue(size1.Area).ShouldBe(123.45 * 456.78);

            var size2 = new Size2D(222.22, 55555.55);
            TheResultingValue(size2.Area).ShouldBe(222.22 * 55555.55);
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:8,代码来源:Size2DTests.cs

示例9: ArrangeOverride

 /// <inheritdoc/>
 protected override Size2D ArrangeOverride(Size2D finalSize, ArrangeOptions options)
 {
     if (child != null)
     {
         child.Arrange(new RectangleD(Point2D.Zero, finalSize), options);
     }
     return finalSize;
 }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:9,代码来源:Decorator.cs

示例10: SpriteOscillator

 public SpriteOscillator(Size2D<int> MinSize, Size2D<int> MaxSize, float Frequency, Size2D<int>? IdleSize = null, bool Oscillate = true)
 {
     this.MinSize = MinSize;
     this.MaxSize = MaxSize;
     this.IdleSize = IdleSize;
     this.Frequency = Frequency;
     this.Oscillate = Oscillate;
 }
开发者ID:iLambda,项目名称:Freemwork,代码行数:8,代码来源:SpriteOscillator.cs

示例11: StyleFont

        public StyleFont(StyleFontFamily family, Size2D emSize, StyleFontStyle style)
        {
            if (family == null) throw new ArgumentNullException("family");

            _fontFamily = family;
            _size = emSize;
            _style = style;
        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:8,代码来源:StyleFont.cs

示例12: MeasureOverride

 /// <inheritdoc/>
 protected override Size2D MeasureOverride(Size2D availableSize)
 {
     if (Track != null)
     {
         Track.InvalidateMeasure();
     }
     return base.MeasureOverride(availableSize);
 }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:9,代码来源:VSlider.cs

示例13: MeasureOverride

 /// <inheritdoc/>
 protected override Size2D MeasureOverride(Size2D availableSize)
 {
     if (child != null)
     {
         child.Measure(availableSize);
         return child.DesiredSize;
     }
     return Size2D.Zero;
 }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:10,代码来源:Decorator.cs

示例14: ArrangeOverride

 /// <inheritdoc/>
 protected override Size2D ArrangeOverride(Size2D finalSize, ArrangeOptions options)
 {
     var arrangedSize = base.ArrangeOverride(finalSize, options);
     if (VisualTreeHelper.GetParent(adornerLayer) == this)
     {
         adornerLayer.Arrange(new RectangleD(Point2D.Zero, finalSize));
     }
     return arrangedSize;
 }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:10,代码来源:AdornerDecorator.cs

示例15: MeasureOverride

 /// <inheritdoc/>
 protected override Size2D MeasureOverride(Size2D availableSize)
 {
     var desiredSize = base.MeasureOverride(availableSize);
     if (VisualTreeHelper.GetParent(adornerLayer) == this)
     {
         adornerLayer.Measure(availableSize);
     }
     return desiredSize;
 }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:10,代码来源:AdornerDecorator.cs


注:本文中的Size2D类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。