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

C# Rectangle2D类代码示例

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

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



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

示例1: AddDynamicWeather

		public static void AddDynamicWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, int moveSpeed, int width, int height, Rectangle2D bounds )
		{
			for ( int i = 0; i < m_Facets.Length; ++i )
			{
				Rectangle2D area = new Rectangle2D();
				bool isValid = false;

				for ( int j = 0; j < 10; ++j )
				{
					area = new Rectangle2D( bounds.X + Utility.Random( bounds.Width - width ), bounds.Y + Utility.Random( bounds.Height - height ), width, height );

					if ( !CheckWeatherConflict( m_Facets[i], null, area ) )
						isValid = true;

					if ( isValid )
						break;
				}

				if ( !isValid )
					continue;

				Weather w = new Weather( m_Facets[i], new Rectangle2D[]{ area }, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, TimeSpan.FromSeconds( 30.0 ) );

				w.m_Bounds = bounds;
				w.m_MoveSpeed = moveSpeed;
			}
		}
开发者ID:Grimoric,项目名称:RunUO.T2A,代码行数:27,代码来源:Weather.cs


示例2: 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


示例3: PresetMapEntry

		public PresetMapEntry( int name, int width, int height, int xLeft, int yTop, int xRight, int yBottom )
		{
			m_Name = name;
			m_Width = width;
			m_Height = height;
			m_Bounds = new Rectangle2D( xLeft, yTop, xRight - xLeft, yBottom - yTop );
		}
开发者ID:greeduomacro,项目名称:last-wish,代码行数:7,代码来源:PresetMap.cs


示例4: ConfirmTentPlacementGump

		public ConfirmTentPlacementGump( Mobile owner, TentAddon tent, TentFlap flap, TentBedroll roll, SecureTentChest chest, Rectangle2D bounds )
			: base( 10, 10 )
		{
			m_Owner = owner;
			m_Tent = tent;
			m_Flap = flap;
			m_Bedroll = roll;
			m_Chest = chest;
			m_RegionBounds = bounds;

			Closable = false;
			Disposable = false;
			Resizable = false;
			Dragable = true;

			AddPage( 1 );
			AddBackground( 10, 10, 325, 305, 9250 );
			AddImageTiled( 25, 25, 295, 11, 50 );
			AddLabel( 90, 35, 0, "Confirm Tent Placement" );

			AddButton( 35, 275, 4020, 4022, 0, GumpButtonType.Reply, 1 ); //Cancel
			AddButton( 280, 275, 4023, 4025, 1, GumpButtonType.Reply, 1 ); //Ok

			AddHtml( 27, 75, 290, 200, String.Format( "<center>You are about to place a travel tent.</center><br> Within, you will find a bedroll "
													 + "and a secure wooden chest.<br> To repack your tent, or to logout safely, double-click "
													 + "your bedroll. When doing so, please make sure that all items are removed from the chest."
													 + "<br> Please press okay to continue, or press cancel to stop tent placement." ), false, false );
		}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:28,代码来源:Gumps.cs


示例5: Rectangle2DEqualityTests

        public void Rectangle2DEqualityTests()
        {
            Rectangle2D r1 = new Rectangle2D();
            Rectangle2D r2 = Rectangle2D.Empty;
            Rectangle2D r3 = Rectangle2D.Zero;
            Rectangle2D r4 = new Rectangle2D(0, 0, 0, 0);
            Rectangle2D r5 = new Rectangle2D(9, 10, -5, -6);
            Rectangle2D r6 = new Rectangle2D(0, 0, 10, 10);
            Rectangle2D r7 = new Rectangle2D(new Point2D(0, 0), new Size2D(10, 10));

            Assert.Equal(r1, r2);
            Assert.NotEqual(r1, r3);
            Assert.Equal(r3, r4);
            Assert.NotEqual(r1, r5);
            Assert.NotEqual(r3, r5);
            Assert.Equal(r6, r7);

            IMatrixD v1 = r1;
            IMatrixD v2 = r2;
            IMatrixD v3 = r3;
            IMatrixD v4 = r4;
            IMatrixD v5 = r5;

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

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


示例6: Create2DElement

        public static void Create2DElement(String name, String texture, Vector2 TopLeft, Vector2 BottomRight)
        {
            MaterialPtr material = MaterialManager.Singleton.Create(name, "General");
                material.GetTechnique(0).GetPass(0).CreateTextureUnitState(texture);
                material.GetTechnique(0).GetPass(0).DepthCheckEnabled = false;
                material.GetTechnique(0).GetPass(0).DepthWriteEnabled = false;
                material.GetTechnique(0).GetPass(0).LightingEnabled = false;
                // Create background rectangle covering the whole screen
                Rectangle2D rect = new Rectangle2D(true);
                rect.SetCorners(TopLeft.x * 2 - 1, 1 - TopLeft.y * 2, BottomRight.x * 2 - 1, 1 - BottomRight.y * 2);
                //rect.SetCorners(-1.0f, 1.0f, 1.0f, -1.0f);
                rect.SetMaterial(name);

                // Render the background before everything else
                rect.RenderQueueGroup = (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY;

                // Use infinite AAB to always stay visible
                AxisAlignedBox aab = new AxisAlignedBox();
                aab.SetInfinite();
                rect.BoundingBox = aab;

                // Attach background to the scene
                SceneNode node = _OgreEngine.mMgr.RootSceneNode.CreateChildSceneNode("2D__" + name);
                node.AttachObject(rect);
        }
开发者ID:Serebriakov,项目名称:rybrcoul-games,代码行数:25,代码来源:Drawing2D.cs


示例7: StrongholdDefinition

		public StrongholdDefinition( Rectangle2D[] area, Point3D joinStone, Point3D factionStone, Point3D[] monoliths )
		{
			m_Area = area;
			m_JoinStone = joinStone;
			m_FactionStone = factionStone;
			m_Monoliths = monoliths;
		}
开发者ID:greeduomacro,项目名称:last-wish,代码行数:7,代码来源:StrongholdDefintion.cs


示例8: SerpentPillar

		public SerpentPillar( string word, Rectangle2D destination, bool active ) : base( 0x233F )
		{
			Movable = false;

			m_Active = active;
			m_Word = word;
			m_Destination = destination;
		}
开发者ID:greeduomacro,项目名称:last-wish,代码行数:8,代码来源:SerpentPillar.cs


示例9: SafeZone

		/*public override bool AllowReds{ get{ return true; } }*/

		public SafeZone( Rectangle2D area, Point3D goloc, Map map, bool isGuarded ) : base( null, map, SafeZonePriority, area )
		{
			GoLocation = goloc;

			this.Disabled = !isGuarded;

			Register();
		}
开发者ID:greeduomacro,项目名称:last-wish,代码行数:10,代码来源:SafeZone.cs


示例10: RandomPointIn

		private static Point3D RandomPointIn( Rectangle2D rect, Map map )
		{
			int x = Utility.Random( rect.X, rect.Width );
			int y = Utility.Random( rect.Y, rect.Height );
			int z = map.GetAverageZ( x, y );

			return new Point3D( x, y, z );
		}
开发者ID:greeduomacro,项目名称:last-wish,代码行数:8,代码来源:PumpkinPatch.cs


示例11: transform

 /**
  * Auto-shapes are defined in the [0,21600] coordinate system.
  * We need to transform it into normal slide coordinates
  *
 */
 public static java.awt.Shape transform(java.awt.Shape outline, Rectangle2D anchor){
     AffineTransform at = new AffineTransform();
     at.translate(anchor.GetX(), anchor.GetY());
     at.scale(
             1.0f/21600*anchor.Width,
             1.0f/21600*anchor.Height
     );
     return at.CreateTransformedShape(outline);
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:14,代码来源:AutoShapes.cs


示例12: PolygonElementClip

 internal PolygonElementClip(Rectangle2D clipBox)
 {
     this.boundary = clipBox;
     this.Edges = new Edge[]
     {
         new Edge { IsHorisontal = false, IsLeft = true, Value = this.boundary.Left },
         new Edge { IsHorisontal = false, IsLeft = false, Value = this.boundary.Right },
         new Edge { IsHorisontal = true, IsLeft = true, Value = this.boundary.Bottom },
         new Edge { IsHorisontal = true, IsLeft = false, Value = this.boundary.Top }
     };
 }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:11,代码来源:PolygonElementClip.cs


示例13: ViewBoundsChanedEventArgs

 public ViewBoundsChanedEventArgs(Rectangle2D oldViewBounds, Rectangle2D newViewBounds)
 {
     if (oldViewBounds != null)
     {
         _oldViewBounds = new Rectangle2D(oldViewBounds);
     }
     if (_newViewBounds != null)
     {
         _newViewBounds = new Rectangle2D(newViewBounds);
     }
 }
开发者ID:SuperMap,项目名称:iClient-for-DotNet,代码行数:11,代码来源:ViewBoundsChanedEventArgs.cs


示例14: TentValidator

		public TentValidator( Mobile owner, TentAddon tent, TentBedroll bedroll, SecureTentChest chest, TravelTentRegion region, Rectangle2D bounds )
			: base( 0x12B3 )
		{
			Name = "travel tent validator";
			Movable = false;
			Visible = false;

			m_Owner = owner;
			m_Tent = tent;
			m_Bedroll = bedroll;
			m_Chest = chest;
			m_Region = region;
			m_Bounds = bounds;
		}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:14,代码来源:TentValidator.cs


示例15: OnTarget

		public void OnTarget( Mobile from, Map map, Point3D start, Point3D end, object state )
		{
			try
			{
				object[] states = (object[])state;
				BaseCommand command = (BaseCommand)states[0];
				string[] args = (string[])states[1];

				Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );

				Extensions ext = Extensions.Parse( from, ref args );

				bool items, mobiles;

				if ( !CheckObjectTypes( command, ext, out items, out mobiles ) )
					return;

				IPooledEnumerable eable;

				if ( items && mobiles )
					eable = map.GetObjectsInBounds( rect );
				else if ( items )
					eable = map.GetItemsInBounds( rect );
				else if ( mobiles )
					eable = map.GetMobilesInBounds( rect );
				else
					return;

				ArrayList objs = new ArrayList();

				foreach ( object obj in eable )
				{
					if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) )
						continue;

					if ( ext.IsValid( obj ) )
						objs.Add( obj );
				}

				eable.Free();

				ext.Filter( objs );

				RunCommand( from, objs, command, args );
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
开发者ID:FreeReign,项目名称:imaginenation,代码行数:50,代码来源:AreaCommandImplementor.cs


示例16: IntersectsTest

        public void IntersectsTest()
        {
            Rectangle2D r1 = Rectangle2D.Empty;
            Rectangle2D r2 = Rectangle2D.Zero;
            Rectangle2D r3 = new Rectangle2D(0, 0, 10, 10);
            Rectangle2D r4 = new Rectangle2D(new Point2D(5, 5), new Size2D(10, 10));

            Assert.False(r1.Intersects(Rectangle2D.Empty));
            Assert.False(r1.Intersects(r2));
            Assert.False(r2.Intersects(r1));
            Assert.True(r2.Intersects(r3));
            Assert.True(r3.Intersects(r4));
            Assert.True(r4.Intersects(r4));
        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:14,代码来源:Rectangle2DTests.cs


示例17: Weather

        public Weather(Map facet, Rectangle2D[] area, int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, TimeSpan interval)
        {
            this.m_Facet = facet;
            this.m_Area = area;
            this.m_Temperature = temperature;
            this.m_ChanceOfPercipitation = chanceOfPercipitation;
            this.m_ChanceOfExtremeTemperature = chanceOfExtremeTemperature;

            List<Weather> list = GetWeatherList(facet);

            if (list != null)
                list.Add(this);

            Timer.DelayCall(TimeSpan.FromSeconds((0.2 + (Utility.RandomDouble() * 0.8)) * interval.TotalSeconds), interval, new TimerCallback(OnTick));
        }
开发者ID:Crome696,项目名称:ServUO,代码行数:15,代码来源:Weather.cs


示例18: OnDoubleClick

		public override void OnDoubleClick( Mobile from )
		{
			Point2D start = new Point2D( from.X - 3, from.Y - 3 );
			Point2D end = new Point2D( from.X + 3, from.Y + 3 );

			m_Bounds = new Rectangle2D( start, end );

			if( !IsChildOf( from.Backpack ) )
			{
				from.SendLocalizedMessage( 1042001 ); //That must be in your pack to use it.
			}
			else if( AlreadyOwnTent( from ) )
			{
				from.SendMessage( "You already have a tent established." );
			}
			else if( from.HasGump( typeof( ConfirmTentPlacementGump ) ) )
			{
				from.CloseGump( typeof( ConfirmTentPlacementGump ) );
			}
			else if( from.Combatant != null )
			{
				from.SendMessage( "You can't place a tent while fighting!" );
			}
			else if( VerifyPlacement( from, m_Bounds ) )
			{
				TentAddon tent = new TentAddon();
				tent.MoveToWorld( new Point3D( from.X, from.Y, from.Z ), from.Map );

				TentFlap flap = new TentFlap( from, this );
				flap.MoveToWorld( new Point3D( from.X + 2, from.Y, from.Z ), from.Map );

				SecureTentChest chest = new SecureTentChest( from );
				chest.MoveToWorld( new Point3D( from.X - 1, from.Y - 2, from.Z ), from.Map );

				TentBedroll roll = new TentBedroll( from, tent, flap, chest );
				roll.MoveToWorld( new Point3D( from.X, from.Y + 1, from.Z ), from.Map );

				from.SendGump( new ConfirmTentPlacementGump( from, tent, flap, roll, chest, m_Bounds ) );

				this.Delete();
			}
			else
			{
				from.SendMessage( "You cannot place a tent in this area." );
			}
		}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:46,代码来源:TravelTent.cs


示例19: BoundingBox_Callback

		private void BoundingBox_Callback( Mobile from, Map map, Point3D start, Point3D end, object state )
		{
			Utility.FixPoints( ref start, ref end );
			Rectangle2D rect = new Rectangle2D(start, end);
			_map = map;
		
			_rects.Add(new Rect2D(rect.Start.X, rect.Start.Y, rect.Width, rect.Height));

			if(_args.MultipleRects)
			{
				_picker.Begin( this.Mobile, new BoundingBoxCallback( BoundingBox_Callback ), null );
			}
			else
			{
				ExtractItems();
			}
		}
开发者ID:greeduomacro,项目名称:cov-shard-svn-1,代码行数:17,代码来源:ExtractItemsRequest.cs


示例20: CompareTest

        public void CompareTest()
        {
            Rectangle2D r1 = Rectangle2D.Empty;
            Rectangle2D r2 = Rectangle2D.Zero;
            Rectangle2D r3 = new Rectangle2D(0, 0, 10, 10);
            Rectangle2D r4 = new Rectangle2D(new Point2D(11, -11), new Size2D(10, 10));
            Rectangle2D r5 = new Rectangle2D(new Point2D(-11, -11), new Size2D(10, 10));
            Rectangle2D r6 = new Rectangle2D(new Point2D(11, 11), new Size2D(10, 10));

            Assert.Equal(0, r1.CompareTo(Rectangle2D.Empty));
            Assert.Equal(-1, r1.CompareTo(r2));
            Assert.Equal(1, r2.CompareTo(r1));
            Assert.Equal(0, r3.CompareTo(r3));
            Assert.Equal(0, r3.CompareTo(r2));
            Assert.Equal(-1, r4.CompareTo(r3));
            Assert.Equal(-1, r5.CompareTo(r3));
            Assert.Equal(1, r6.CompareTo(r3));
        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:18,代码来源:Rectangle2DTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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