• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Size2D类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: LabelStyle

        public LabelStyle(StyleFont font,
						  StyleBrush foreground,
						  StyleBrush background,
						  Point2D offset,
						  Size2D collisionBuffer,
						  HorizontalAlignment horizontalAlignment,
						  VerticalAlignment verticalAlignment)
            : base(font, foreground, background, offset, collisionBuffer, horizontalAlignment, verticalAlignment)
        {}
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:9,代码来源:LabelStyle.cs


示例17: GetRotatedSize

        public static Size2D GetRotatedSize(Size2D size, double angleOfRotation)
        {
            double cosOfAngleOfRotation = Math.Cos(angleOfRotation);
            double sinOfAngleOfRotation = Math.Sin(angleOfRotation);
            double rotatedWidth = Math.Abs(cosOfAngleOfRotation) * size.Width + Math.Abs(sinOfAngleOfRotation) * size.Height;
            double rotatedHeight = Math.Abs(sinOfAngleOfRotation) * size.Width + Math.Abs(cosOfAngleOfRotation) * size.Height;

            return new Size2D(rotatedWidth, rotatedHeight);
        }
开发者ID:dirk-dagger-667,项目名称:telerik-c--QoC-lectures,代码行数:9,代码来源:01.Size2D.cs


示例18: Size2D_OpInequality

        public void Size2D_OpInequality()
        {
            var size1 = new Size2D(123.45, 456.78);
            var size2 = new Size2D(123.45, 456.78);
            var size3 = new Size2D(123.45, 555.55);
            var size4 = new Size2D(222.22, 456.78);

            TheResultingValue(size1 != size2).ShouldBe(false);
            TheResultingValue(size1 != size3).ShouldBe(true);
            TheResultingValue(size1 != size4).ShouldBe(true);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:11,代码来源:Size2DTests.cs


示例19: MeasureOverride

        /// <inheritdoc/>
        protected override Size2D MeasureOverride(Size2D availableSize)
        {
            foreach (var child in Children)
                child.Measure(availableSize);

            var contentSize = (Orientation == Orientation.Vertical) ? 
                MeasureVertically(availableSize) :
                MeasureHorizontally(availableSize);

            return contentSize;
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:12,代码来源:WrapPanel.cs


示例20: Size2D_EqualsSize2D

        public void Size2D_EqualsSize2D()
        {
            var size1 = new Size2D(123.45, 456.78);
            var size2 = new Size2D(123.45, 456.78);
            var size3 = new Size2D(123.45, 555.55);
            var size4 = new Size2D(222.22, 456.78);

            TheResultingValue(size1.Equals(size2)).ShouldBe(true);
            TheResultingValue(size1.Equals(size3)).ShouldBe(false);
            TheResultingValue(size1.Equals(size4)).ShouldBe(false);
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:11,代码来源:Size2DTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SizeChangedEventHandler类代码示例发布时间:2022-05-24
下一篇:
C# Size2类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap