Exemple #1
0
 internal void Remove(GRange range)
 {
     if (ranges != null)
     {
         ranges.Remove(range); Lib.Unregister(range);
     }
 }
Exemple #2
0
        public void Load(Context context)
        {
            if (ranges != null)
            {
                throw new Exception("Ranges already loaded.");
            }
            GmCommand cmd = context.Conn.CreateCommandById("selectCountFromGisRangesWhereTypeId");

            cmd.AddInt("TypeId", id);
            int count = (int)cmd.ExecuteScalar();

            ranges = new List <GRange>(count);
            if (count > 0)
            {
                cmd = context.Conn.CreateCommandById("selectAllFromGisRangesWhereTypeId");
                cmd.AddInt("TypeId", id);
                using (IDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        GRange range = new GRange(context, this, dr);
                    }
                }
            }
        }
Exemple #3
0
 internal void Register(GRange range)
 {
     if (allRanges == null)
     {
         allRanges = new Dictionary <int, GRange>(1 << 16);
     }
     allRanges.Add(range.Id, range);
 }
Exemple #4
0
        internal static GObject Create(Context context, BinaryReader br)
        {
            GRange  range = context.Lib.GetRange(br.ReadInt32());
            GObject gobj  = Create(range);

            gobj.Read(context, br);
            return(gobj);
        }
Exemple #5
0
 internal void Add(GRange range)
 {
     if (ranges == null)
     {
         ranges = new List <GRange>();
     }
     ranges.Add(range);
     UpdateBounds(range.Bounds);
 }
Exemple #6
0
/*		void AssignId()
 *              {
 *                      id=Lib.GenerateId(this,ref updateAttr);
 *              }*/
        void CheckRange()
        {
            GRange range = Type.GetRangeStrong(this);

            if (this.range != range)
            {
                this.range.Remove(this);
                this.range = range;
                range.Add(this);
            }
        }
Exemple #7
0
        internal static GObject Create(Context context, GRange range, IDataReader dr, bool updateRange)
        {
            if (range == null)
            {
                int rangeId = dr.GetInt32((int)ObjectField.RangeId);
                range = context.Lib.GetRange(rangeId);
            }
            GObject gobj = Create(range);

            gobj.Init(context, dr);
            if (updateRange)
            {
                range.Add(gobj);
            }
            return(gobj);
        }
Exemple #8
0
        static GObject Create(GRange range)
        {
            GObject gobj;

            switch (range.Type.GeomType)
            {
            case GeomType.Point: gobj = new GPoint(); break;

            case GeomType.Polyline: gobj = new GPolyline(); break;

            case GeomType.Polygon: gobj = new GPolygon(); break;

            case GeomType.Caption: gobj = new GCaption(); break;

            default: throw new Exception("Unknown GeomType: " + range.Type.GeomType);
            }
            gobj.range = range;
//			gobj.AssignId();
            return(gobj);
        }
Exemple #9
0
        void LoadRanges(Context context)
        {
            if (allTypes == null)
            {
                throw new Exception("Types not loaded.");
            }
//      DZ      16.01.09
//			int count=(int)context.Conn.ExecuteScalarById("selectCountFromGisRanges");
            int count = Convert.ToInt32(context.Conn.ExecuteScalarById("selectCountFromGisRanges"));

            if (allRanges == null)
            {
                allRanges = new Dictionary <int, GRange>(count);
            }
            using (IDataReader dr = context.Conn.ExecuteReaderById("selectAllFromGisRanges"))
            {
                while (dr.Read())
                {
                    GRange range = new GRange(context, dr);
                }
            }
        }
Exemple #10
0
 internal GRange GetRangeStrong(GObject obj)
 {
     lock (getRangeStrongLock)
     {
         Rect rangeBounds = lib.Indexer.GetIndex(obj.Bounds);
         if (ranges == null)
         {
             ranges = new List <GRange>();
         }
         else
         {
             foreach (GRange range in ranges)
             {
                 if (range.Equals(rangeBounds))
                 {
                     return(range);
                 }
             }
         }
         GRange rng = new GRange(this, rangeBounds);
         return(rng);
     }
 }
Exemple #11
0
 public GObject GetObject(int objectId, int rangeId)
 {
     GRange range = GetRange(rangeId); return(range == null ? null : range.GetObject(objectId));
 }
Exemple #12
0
 internal void Unregister(GRange range)
 {
     allRanges.Remove(range.Id); SetChanged(); SetStateAttr(LibStateAttr.AllObjectsLoaded, false);
 }