Exemplo n.º 1
0
        public ProvinceBoundBox[] IntersectingWith( Rectangle rect )
        {
            ArrayList resultList = new ArrayList();
            IEnumerator boxEnum = this.GetEnumerator();

            for ( boxEnum.Reset(), boxEnum.MoveNext(); boxEnum.MoveNext(); ) {
                ProvinceBoundBox box = (ProvinceBoundBox)(boxEnum.Current);
                if ( rect.IntersectsWith( box.Box ) )
                    resultList.Add( box );
            }

            ProvinceBoundBox[] result = new ProvinceBoundBox[resultList.Count];
            resultList.CopyTo( result );
            return result;
        }
Exemplo n.º 2
0
        public ProvinceBoundBox this[int id]
        {
            get {
                if ( id == 0 ) {
                    Size sz = install.Map.MapSize;
                    return new ProvinceBoundBox( 0, new Rectangle( 0, 0, sz.Width, sz.Height ) );
                }

                if ( id < 1 || (id+2)*BLOCKSIZE > stream.Length ) throw new ArgumentOutOfRangeException( "id", id, "The id parameter is out of the acceptable range." );

                if ( !cache.Contains( id ) ) {
                    OpenStream();
                    stream.Seek( id*BLOCKSIZE, SeekOrigin.Begin );
                    BinaryReader reader = new BinaryReader( stream );

                    cache[id] = new ProvinceBoundBox( id, ReadRectangle( reader ) );
                }

                return (ProvinceBoundBox)(cache[id]);
            }
        }
Exemplo n.º 3
0
        public ProvinceBoundBox[] ContainedIn( Rectangle rect )
        {
            ArrayList resultList = new ArrayList();
            IEnumerator boxEnum = this.GetEnumerator();

            for ( boxEnum.Reset(), boxEnum.MoveNext(); boxEnum.MoveNext(); ) {
                ProvinceBoundBox box = (ProvinceBoundBox)boxEnum.Current;
                if ( rect.Contains( box.Box ) )
                    resultList.Add( box );
            }

            ProvinceBoundBox[] result = new ProvinceBoundBox[resultList.Count];
            resultList.CopyTo( result );
            return result;
        }