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


C# RectangleF.Equals方法代码示例

本文整理汇总了C#中System.Drawing.RectangleF.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# RectangleF.Equals方法的具体用法?C# RectangleF.Equals怎么用?C# RectangleF.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.RectangleF的用法示例。


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

示例1: GetImageDim

		/// <summary>
		/// Returns new dimensions of the image's bounding rect according to its parameters
		/// </summary>
		/// <param name="pict">Image reference</param>
		/// <param name="rect">Image bounding rect</param>
		/// <param name="ppos">Image alignment</param>
		/// <param name="picw">New image's width value</param>
		/// <param name="pich">New image's height value</param>
		/// <param name="xoff">Image's X offset</param>
		/// <param name="yoff">Image's Y offset</param>
		/// <returns>true if successfull otherwise false</returns>
		public bool GetImageDim(Image pict, RectangleF rect, ImageAlign ppos, ref float  picw, ref float pich , ref float xoff , ref float yoff)
		{
			bool bOk = false;
			int xc = 0, yc = 0;

			try
			{
			
				if ( rect.Equals(RectangleF.Empty))
					return false;

				picw = 0;
				pich = 0;
				xoff =0;
				yoff =0;

				Graphics g = System.Drawing.Graphics.FromHwnd(GetActiveWindow());
				setTransforms(g);

				// get image logical size in document coordinates
				RectangleF sizeDev = RectangleF.FromLTRB(0, 0,
					(float)pict.Size.Width / pict.HorizontalResolution * g.DpiX * g.PageScale,
					(float)pict.Size.Height / pict.VerticalResolution * g.DpiY * g.PageScale);
				RectangleF sizeDoc = deviceToDoc(g, sizeDev);
				picw = sizeDoc.Width;
				pich = sizeDoc.Height;

				
				switch (ppos)
				{
					case ImageAlign.TopLeft:
						xoff = rect.Left;
						yoff = rect.Top;
						break;
					case ImageAlign.BottomLeft:
						xoff = rect.Left;
						yoff = rect.Bottom - pich;
						break;
					case ImageAlign.TopRight:
						xoff = rect.Right - picw;
						yoff = rect.Top;
						break;
					case ImageAlign.BottomRight:
						xoff = rect.Right - picw;
						yoff = rect.Bottom - pich;
						break;
					case ImageAlign.Center:
						xoff = (rect.Right + rect.Left - picw) / 2;
						yoff = (rect.Bottom + rect.Top - pich) / 2;
						break;
					case ImageAlign.TopCenter:
						xoff = rect.X + rect.Width / 2 - picw / 2;
						yoff = rect.Y;
						break;
					case ImageAlign.BottomCenter:
						xoff = rect.X + rect.Width / 2 - picw / 2;
						yoff = rect.Bottom - pich;
						break;
					case ImageAlign.MiddleLeft:
						xoff = rect.X;
						yoff = rect.Y + rect.Height / 2 - pich / 2;
						break;
					case ImageAlign.MiddleRight:
						xoff = rect.Right - picw;
						yoff = rect.Y + rect.Height / 2 - pich / 2;
						break;
					case ImageAlign.Fit:
					{
						float h = rect.Bottom - rect.Top;
						float w = rect.Right - rect.Left;
						if (h == 0) break;

						float ratioCtrl = w / h;
						float ratioPic = picw / pich;

						if (ratioCtrl > ratioPic)
						{
							//stretch vertically
							pich = (int)h;
							picw = (int)(ratioPic * pich);
							yoff = rect.Top;
							xoff = (rect.Right + rect.Left - picw) / 2;
						}
						else
						{
							//stretch horizontally
							picw = (int)w;
							if (ratioPic == 0) break;
							pich = (int)(picw / ratioPic);
//.........这里部分代码省略.........
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:101,代码来源:DxfHelper.cs

示例2: ClipBoundsTest

		public void ClipBoundsTest() {
			Region r = new Region();
			Assert.IsTrue(t.Graphics.ClipBounds.Equals(r.GetBounds(t.Graphics)));

			RectangleF rf = new RectangleF(10, 10, 60, 60);
			r = new Region(rf);
			t.Graphics.Clip = r;
			Assert.IsTrue(rf.Equals(t.Graphics.ClipBounds));
		}
开发者ID:kumpera,项目名称:mono,代码行数:9,代码来源:Graphics.cs

示例3: drawingCanvas_MouseMove

 internal void drawingCanvas_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         Visible = false;
     }
     else
     {
         PointF[] ptArr = { new PointF(e.X, e.Y) };
         canvas.CreateGraphicsWithWorldTransform().TransformPoints(CoordinateSpace.World, CoordinateSpace.Page, ptArr);
         //canvas.MouseLocation = ptArr[0];
         float gridSize = grid.GridSize;
         PointF pos = new PointF((float)Math.Floor(ptArr[0].X / gridSize) * gridSize, (float)Math.Floor(ptArr[0].Y / gridSize) * gridSize);
         RectangleF newMouseRectangle = new RectangleF(pos, new SizeF(gridSize, gridSize));
         if (!newMouseRectangle.Equals(HighlightRectangle))
         {
             HighlightRectangle = newMouseRectangle;
             ((PictureBox)sender).Invalidate();
         }
     }
 }
开发者ID:Echo343,项目名称:Cartographer,代码行数:21,代码来源:MouseHighlight.cs

示例4: GetRegionScans

        /// <summary>
        /// Compares the imput rectangles and caculates the portion of the new rctangle not included in the old.
        /// </summary>
        /// <param name="current"> The current rectangle</param>
        /// <param name="previous">The previous rectangle</param>
        /// <returns>An array of rectangles describing the difference between the input rectangles.</returns>
        /// <remarks>
        /// This funtion is a liner exclusive OR on 2 rectangles. It is catagorized by specifying the order of the 
        /// rectangles in a linear fashion so that the xor'd intersection is directional. A natural XOR intersection
        /// would include the portions of both rectangles not found the intersction of the two. A Linear XOR includes 
        /// only the portion of the current rectangle not found in the intersection of the two.
        /// </remarks>
        public static RectangleF[] GetRegionScans(RectangleF current, RectangleF previous)
        {
            // If the extents are equal, or one contains the other, or they're not intersecting there's nothing
            // to do. Return the current rectangle. 
            if (
                !current.Equals(previous) &&
                !Contains(current, previous) &&
                !Contains(previous, current) &&
                IntersectsWith(current, previous))
            {
                // Get the horizontal rectangle, uncovered from a north or south pan 
                RectangleF h = RectangleFHelper.FromLTRB(
                    current.Left, //current.Left < previous.Left ? current.Left : previous.Left,
                    current.Top < previous.Top ? current.Top : previous.Bottom,
                    current.Right, //current.Left < previous.Left ? previous.Right : current.Right,
                    current.Top < previous.Top ? previous.Top : current.Bottom
                    );

                // Get the vertical rectangle, uncovered from an east or west pan 
                RectangleF v = RectangleFHelper.FromLTRB(
                    current.Left < previous.Left ? current.Left : previous.Right,
                    current.Top < previous.Top ? previous.Top : current.Top,
                    current.Left < previous.Left ? previous.Left : current.Right,
                    current.Top < previous.Top ? current.Bottom : previous.Bottom
                    );

                // Retangles with no width or height are excluded
                if ((h.Height <= 0 || h.Width <= 0) && (v.Height <= 0 || v.Width <= 0))
                    return new RectangleF[] { current };

                // Retangles with no width or height are excluded
                if (h.Height <= 0 || h.Width <= 0)
                    return new RectangleF[] { v };
                if (v.Height <= 0 || v.Width <= 0)
                    return new RectangleF[] { h };

                return new RectangleF[] { h, v };
            }

            return new RectangleF[] { current };
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:53,代码来源:RectangleFHelper.cs

示例5: ButtonImage

        public static UIImage ButtonImage(UIColor color, float cornerRadius, UIColor shadowColor, UIEdgeInsets shadowInsets)
        {
            UIImage topImage = FlatUI.Image(color, cornerRadius);
            UIImage bottomImage = FlatUI.Image(shadowColor, cornerRadius);
            float totalHeight = FlatUI.EdgeSize(cornerRadius) + shadowInsets.Top + shadowInsets.Bottom;
            float totalWidth = FlatUI.EdgeSize(cornerRadius) + shadowInsets.Left + shadowInsets.Right;
            float topWidth = FlatUI.EdgeSize(cornerRadius);
            float topHeight = FlatUI.EdgeSize(cornerRadius);
            RectangleF topRect = new RectangleF(shadowInsets.Left, shadowInsets.Top, topWidth, topHeight);
            RectangleF bottomRect = new RectangleF(0, 0, totalWidth, totalHeight);

            UIGraphics.BeginImageContextWithOptions(new SizeF(totalWidth, totalHeight), false, 0f);
            if (!bottomRect.Equals(topRect))
                bottomImage.Draw(bottomRect);
            topImage.Draw(topRect);
            UIImage buttonImage = UIGraphics.GetImageFromCurrentImageContext();
            UIEdgeInsets resizeableInsets = new UIEdgeInsets(cornerRadius + shadowInsets.Top,
                                                             cornerRadius + shadowInsets.Left,
                                                             cornerRadius + shadowInsets.Bottom,
                                                             cornerRadius + shadowInsets.Right);
            UIGraphics.EndImageContext();
            return buttonImage.CreateResizableImage(resizeableInsets);
        }
开发者ID:natecook1000,项目名称:FlatUIKit.Xamarin,代码行数:23,代码来源:FlatUI.cs

示例6: RelayoutItemsAnimated

        private void RelayoutItemsAnimated(bool animated)
        {
            //Console.WriteLine ("Relayout animated " + animated);

            RelayoutBlock layoutBlock = delegate
            {
                ItemSubviews.EnumerateGridCells(delegate(GridViewCell view,out bool stop)
                {
                    stop=false;
                    if (view != sortMovingItem && view != transformingItem)
                    {
                        int index = view.Tag - kTagOffset;
                        PointF origin = layoutStrategy.OriginForItemAtPosition(index);
                        RectangleF newFrame = new RectangleF(origin.X, origin.Y, itemSize.Width, itemSize.Height);

                        // IF statement added for performance reasons (Time Profiling in instruments)
                        if (!newFrame.Equals(view.Frame))
                        {
                            view.Frame = newFrame;
                        }
                    }
                });
            };

            if (animated)
            {
                UIView.Animate(kDefaultAnimationDuration,0,kDefaultAnimationOptions,
                delegate
                {
                    layoutBlock();
                },
                delegate
                {

                });
            }
            else
            {
                layoutBlock();
            }
        }
开发者ID:skela,项目名称:GMGridView,代码行数:41,代码来源:GridView.cs


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