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

C# SizeF类代码示例

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

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



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

示例1: MainForm

	public MainForm ()
	{
		// 
		// _tableLayoutPanel
		// 
		_tableLayoutPanel = new TableLayoutPanel ();
		_tableLayoutPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
		_tableLayoutPanel.ColumnCount = 3;
		_tableLayoutPanel.ColumnStyles.Add (new ColumnStyle ());
		_tableLayoutPanel.ColumnStyles.Add (new ColumnStyle ());
		_tableLayoutPanel.ColumnStyles.Add (new ColumnStyle ());
		_tableLayoutPanel.Dock = DockStyle.Fill;
		_tableLayoutPanel.RowCount = 2;
		_tableLayoutPanel.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
		_tableLayoutPanel.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
		Controls.Add (_tableLayoutPanel);
		// 
		// _buttonA
		// 
		_buttonA = new Button ();
		_buttonA.TabIndex = 1;
		_buttonA.Text = "Button A";
		_buttonA.UseVisualStyleBackColor = true;
		_tableLayoutPanel.Controls.Add (_buttonA, 0, 1);
		// 
		// _buttonB
		// 
		_buttonB = new Button ();
		_buttonB.TabIndex = 4;
		_buttonB.Text = "Button B";
		_buttonB.UseVisualStyleBackColor = true;
		_tableLayoutPanel.Controls.Add (_buttonB, 2, 1);
		// 
		// _label
		// 
		_label = new Label ();
		_label.AutoSize = true;
		_label.Dock = DockStyle.Fill;
		_label.TabIndex = 6;
		_label.Text = "Label";
		_tableLayoutPanel.Controls.Add (_label, 1, 1);
		// 
		// _textBox
		// 
		_textBox = new TextBox ();
		_textBox.Dock = DockStyle.Fill;
		_textBox.Multiline = true;
		_textBox.TabIndex = 7;
		_tableLayoutPanel.Controls.Add (_textBox, 1, 0);
		// 
		// MainForm
		// 
		AutoScaleDimensions = new SizeF (6F, 13F);
		AutoScaleMode = AutoScaleMode.Font;
		ClientSize = new Size (292, 300);
		Location = new Point (250, 100);
		StartPosition = FormStartPosition.Manual;
		Text = "bug #81843";
		Load += new EventHandler (MainForm_Load);
	}
开发者ID:mono,项目名称:gert,代码行数:60,代码来源:MainForm.cs


示例2: RectangleF

 /// <summary>Initializes a new instance of the <see cref="T:System.Drawing.RectangleF"></see> class with the specified location and size.</summary>
 /// <param name="size">A <see cref="T:System.Drawing.SizeF"></see> that represents the width and height of the rectangular region. </param>
 /// <param name="location">A <see cref="T:System.Drawing.PointF"></see> that represents the upper-left corner of the rectangular region. </param>
 public RectangleF(Vector2 location, SizeF size)
 {
     this.x = location.X;
     this.y = location.Y;
     this.width = size.Width;
     this.height = size.Height;
 }
开发者ID:Gayo,项目名称:Gayo-CAROT,代码行数:10,代码来源:RectangleF.cs


示例3: SizeToSizeF

 public void SizeToSizeF()
 {
     var size = new Size(10, 15);
     var actual = size.ToSizeF();
     var expected = new SizeF(10, 15);
     Assert.AreEqual(expected, actual);
 }
开发者ID:Mirandatz,项目名称:Trauer,代码行数:7,代码来源:SizeTests.cs


示例4: RectangleF

	// Constructors.
	public RectangleF(PointF location, SizeF size)
			{
				x = location.X;
				y = location.Y;
				width = size.Width;
				height = size.Height;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:RectangleF.cs


示例5: Clamp

 /// <summary>
 /// Clamps point coordinate according to the specified size (0,0, size.Width, size.Height).
 /// </summary>
 /// <param name="point">The point to clamp.</param>
 /// <param name="size">The valid region.</param>
 /// <returns>Clamped point.</returns>
 public static PointF Clamp(this PointF point, SizeF size)
 {
     return new PointF
     {
         X = System.Math.Min(System.Math.Max(0, point.X), size.Width),
         Y = System.Math.Min(System.Math.Max(0, point.Y), size.Height)
     };
 }
开发者ID:remingtonsteel,项目名称:accord-net-extensions,代码行数:14,代码来源:PointExtensions.cs


示例6: BuildLookupList

 private static void BuildLookupList(IDeviceContext g, Font font, ref SizeF[] size)
 {
     size = new SizeF[char.MaxValue];
     for (var i = (char)0; i < (char)256; i++)
     {
         size[i] = MeasureString(g, font, i.ToString());
     }
 }
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:8,代码来源:MeasureString.cs


示例7: NonDefaultConstructorTest

        public void NonDefaultConstructorTest(float x, float y, float width, float height)
        {
            RectangleF rect1 = new RectangleF(x, y, width, height);
            PointF p = new PointF(x, y);
            SizeF s = new SizeF(width, height);
            RectangleF rect2 = new RectangleF(p, s);

            Assert.Equal(rect1, rect2);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:9,代码来源:RectangleFTests.cs


示例8: MeasureString

 private static SizeF MeasureString(IDeviceContext g, IList text, Font font, FontData data)
 {
     SizeF ans = new SizeF();
         foreach (char chr in text)
         {
             SizeF temp = MeasureString(g, chr, font, data);
             ans = new SizeF(ans.Width + temp.Width, temp.Height);
         }
         return ans;
 }
开发者ID:LeoTosti,项目名称:x-drone,代码行数:10,代码来源:MeasureString.cs


示例9: ResizeFactorConstructorFromSizeFToSizeNotPreservingProportions

        public void ResizeFactorConstructorFromSizeFToSizeNotPreservingProportions()
        {
            var from = new SizeF(123, 456);
            var to = new SizeF(456, 789);
            var factor = new ResizeFactor(from, to, false);
            var expectedHorizontalFactor = to.Width / from.Width;
            var expectedVerticalFactor = to.Height / from.Height;

            Assert.AreEqual(expectedHorizontalFactor, factor.Horizontal);
            Assert.AreEqual(expectedVerticalFactor, factor.Vertical);
        }
开发者ID:Mirandatz,项目名称:Trauer,代码行数:11,代码来源:ResizeFactorTests.cs


示例10: ArithmeticTestWithSizeF

        public void ArithmeticTestWithSizeF(float x, float y)
        {
            PointF p = new PointF(x, y);
            SizeF s = new SizeF(y, x);

            PointF addExpected = new PointF(x + y, y + x);
            PointF subExpected = new PointF(x - y, y - x);
            Assert.Equal(addExpected, p + s);
            Assert.Equal(subExpected, p - s);
            Assert.Equal(addExpected, PointF.Add(p, s));
            Assert.Equal(subExpected, PointF.Subtract(p, s));
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:12,代码来源:PointFTests.cs


示例11: ArithmeticTest

        public void ArithmeticTest(float width, float height)
        {
            SizeF s1 = new SizeF(width, height);
            SizeF s2 = new SizeF(height, width);
            SizeF addExpected = new SizeF(width + height, width + height);
            SizeF subExpected = new SizeF(width - height, height - width);

            Assert.Equal(addExpected, s1 + s2);
            Assert.Equal(addExpected, SizeF.Add(s1, s2));

            Assert.Equal(subExpected, s1 - s2);
            Assert.Equal(subExpected, SizeF.Subtract(s1, s2));
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:13,代码来源:SizeFTests.cs


示例12: NonDefaultConstructorAndDimensionsTest

        public void NonDefaultConstructorAndDimensionsTest(float width, float height)
        {
            SizeF s1 = new SizeF(width, height);
            PointF p1 = new PointF(width, height);
            SizeF s2 = new SizeF(s1);

            Assert.Equal(s1, s2);
            Assert.Equal(s1, new SizeF(p1));
            Assert.Equal(s2, new SizeF(p1));

            Assert.Equal(width, s1.Width);
            Assert.Equal(height, s1.Height);
        }
开发者ID:jemmy655,项目名称:corefx,代码行数:13,代码来源:SizeFTests.cs


示例13: DimensionsTest

        public void DimensionsTest(float x, float y, float width, float height)
        {
            RectangleF rect = new RectangleF(x, y, width, height);
            PointF p = new PointF(x, y);
            SizeF s = new SizeF(width, height);

            Assert.Equal(p, rect.Location);
            Assert.Equal(s, rect.Size);
            Assert.Equal(x, rect.X);
            Assert.Equal(y, rect.Y);
            Assert.Equal(width, rect.Width);
            Assert.Equal(height, rect.Height);
            Assert.Equal(x, rect.Left);
            Assert.Equal(y, rect.Top);
            Assert.Equal(x + width, rect.Right);
            Assert.Equal(y + height, rect.Bottom);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:17,代码来源:RectangleFTests.cs


示例14: EqualityTest

        public void EqualityTest(float width, float height)
        {
            SizeF sLeft = new SizeF(width, height);
            SizeF sRight = new SizeF(height, width);

            if (width == height)
            {
                Assert.True(sLeft == sRight);
                Assert.False(sLeft != sRight);
                Assert.True(sLeft.Equals(sRight));
                Assert.Equal(sLeft.GetHashCode(), sRight.GetHashCode());
                return;
            }

            Assert.True(sLeft != sRight);
            Assert.False(sLeft == sRight);
            Assert.False(sLeft.Equals(sRight));
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:18,代码来源:SizeFTests.cs


示例15: InitCallAndSendMsgBtns

            private void InitCallAndSendMsgBtns()
            {
                var image = UIImage.FromFile ("Images/Info/button.png");

                _buttonSize = new SizeF (120, image.Size.Height);
                _btnCall = new UIButton (UIButtonType.RoundedRect);
                _btnCall.SetImage (new UIImage ("Images/Info/icon_phone.png"), UIControlState.Normal);
                _btnCall.SetStretchableImage ("Images/Info/button.png", "Images/Info/button_pressed.png");
                _btnCall.ImageEdgeInsets = new UIEdgeInsets (0, 0, 10, 0);

                _btnSendMessage = new UIButton (UIButtonType.RoundedRect);
                _btnSendMessage.SetImage (new UIImage ("Images/Info/icon_mail.png"), UIControlState.Normal);
                _btnSendMessage.SetStretchableImage ("Images/Info/button.png", "Images/Info/button_pressed.png");
                _btnSendMessage.ImageEdgeInsets = new UIEdgeInsets (0, 0, 10, 0);

                AddSubview (_btnCall);
                AddSubview (_btnSendMessage);
            }
开发者ID:RomanYemelyanenko,项目名称:hashbot,代码行数:18,代码来源:InfoSrolableResizebleView.cs


示例16: GetPreferredSize

		public static SizeF GetPreferredSize(this Control control, SizeF availableSize)
		{
			if (control == null)
				return Size.Empty;
			var mh = control.GetMacControl();
			if (mh != null)
			{
				return mh.GetPreferredSize(availableSize);
			}
			
			var c = control.ControlObject as NSControl;
			if (c != null)
			{
				c.SizeToFit();
				return c.Frame.Size.ToEto();
			}
			var child = control.ControlObject as Control;
			return child == null ? SizeF.Empty : child.GetPreferredSize(availableSize);

		}
开发者ID:gene-l-thomas,项目名称:Eto,代码行数:20,代码来源:MacControlExtensions.cs


示例17: CreateRoundedRectangle

    public static GraphicsPath CreateRoundedRectangle(SizeF size, PointF location)
    {
        int cornerSize			= (int)GraphConstants.CornerSize * 2;

        var height				= size.Height;
        var width				= size.Width;
        var left				= location.X;
        var top					= location.Y;
        var right				= location.X + width;
        var bottom				= location.Y + height;

        var path = new GraphicsPath(FillMode.Winding);
        path.AddArc(left, top, cornerSize, cornerSize, 180, 90);
        path.AddArc(right - cornerSize, top, cornerSize, cornerSize, 270, 90);

        path.AddArc(right - cornerSize, bottom - cornerSize, cornerSize, cornerSize, 0, 90);
        path.AddArc(left, bottom - cornerSize, cornerSize, cornerSize, 90, 90);
        path.CloseFigure();
        return path;
    }
开发者ID:idursun,项目名称:StateMachines,代码行数:20,代码来源:GraphUtils.cs


示例18: CreateThumbnailImage

 //生成缩略图
 public void CreateThumbnailImage(string sFileSrcPath, string sFileDstPath, int iSizeLimit)
 {
     //检测源图片是否存在
     if (File.Exists(sFileSrcPath))
     {
         //获取源图片图像
         System.Drawing.Image image = System.Drawing.Image.FromFile(sFileSrcPath);
         //定义一个大小结构
         SizeF size = new SizeF(image.Width, image.Height);
         //计算出符合要求的大小
         while (size.Width > iSizeLimit || size.Height > iSizeLimit)//51+aspx
         {
             size.Width /= 1.1F;
             size.Height /= 1.1F;
         }
         //创建缩略图图像
         Bitmap bitmap = new Bitmap(Convert.ToInt16(size.Width), Convert.ToInt16(size.Height));
         //创建缩略图绘画面
         Graphics g = Graphics.FromImage(bitmap);
         //清除整个绘画面并以透明色填充
         g.Clear(Color.Transparent);
         //定义源图像矩形区域
         Rectangle Srcrect = new Rectangle(0, 0, image.Width, image.Height);
         //定义缩略图矩形区域
         Rectangle Dstrect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
         //绘制缩略图
         g.DrawImage(bitmap, Dstrect, Srcrect, GraphicsUnit.Pixel);
         //保存为Jpeg图片
         bitmap.Save(sFileDstPath, ImageFormat.Jpeg);
         //释放对象
         g.Dispose();
         image.Dispose();
         bitmap.Dispose();
         
     }
 }
开发者ID:xueshijun,项目名称:0.Undergraduation-Design,代码行数:37,代码来源:DrawHelper.cs


示例19: SizeSetTest

 public static void SizeSetTest(float x, float y)
 {
     var size = new SizeF(x, y);
     var rect = new RectangleF(10, 10, 10, 10);
     rect.Size = size;
     Assert.Equal(size, rect.Size);
     Assert.Equal(size.Width, rect.Width);
     Assert.Equal(size.Height, rect.Height);
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:9,代码来源:RectangleFTests.cs


示例20: InflateTest

        public void InflateTest(float x, float y, float width, float height)
        {
            RectangleF rect = new RectangleF(x, y, width, height);
            RectangleF inflatedRect = new RectangleF(x - width, y - height, width + 2 * width, height + 2 * height);

            rect.Inflate(width, height);
            Assert.Equal(inflatedRect, rect);

            SizeF s = new SizeF(x, y);
            inflatedRect = RectangleF.Inflate(rect, x, y);

            rect.Inflate(s);
            Assert.Equal(inflatedRect, rect);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:14,代码来源:RectangleFTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SizeOfExpression类代码示例发布时间:2022-05-24
下一篇:
C# SizeExceededAction类代码示例发布时间: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