Esempio n. 1
0
        public bool ModifySize(Bound bound, double cx1, double cy1, double sx2, double sy2)
        {
            if (bound.Points == null || bound.Points.Count != 4)
            {
                return(false);
            }
            var points = db.Points.FindAll(i => i.BoundId == bound.Id);

            db.Points.RemoveList(points);

            bound.Points.Clear();

            float x1 = (float)(cx1 - sx2 / 2);
            float y1 = (float)(cy1 - sy2 / 2);
            float x2 = (float)(cx1 + sx2 / 2);
            float y2 = (float)(cy1 + sy2 / 2);

            var pointsNew   = bound.SetInitBound(x1, y1, x2, y2);
            var dbPointsNew = pointsNew.ToDbModel();

            db.Points.AddRange(dbPointsNew);
            for (int i = 0; i < dbPointsNew.Count; i++)
            {
                pointsNew[i].Id = dbPointsNew[i].Id;
            }
            return(true);
        }
Esempio n. 2
0
 private Location.TModel.Location.AreaAndDev.Bound NewBound(PhysicalTopology pt)
 {
     try
     {
         var bound = new Location.TModel.Location.AreaAndDev.Bound();
         bound.IsRelative = pt.IsRelative;
         bound.SetInitBound(pt.Transfrom);
         return(bound);
     }
     catch (System.Exception ex)
     {
         Log.Error(tag, "NewBound", ex.ToString());
         return(null);
     }
 }
Esempio n. 3
0
        public bool ModifySize(Bound bound, double cx1, double cy1, double sx2, double sy2)
        {
            try
            {
                if (bound.Points != null && bound.Points.Count != 4)
                {
                    return(false);
                }
                if (bound.Points != null)
                {
                    var points = db.Points.FindAll(i => i.BoundId == bound.Id);
                    db.Points.RemoveList(points);
                    bound.Points.Clear();
                }

                float x1 = (float)(cx1 - sx2 / 2);
                float y1 = (float)(cy1 - sy2 / 2);
                float x2 = (float)(cx1 + sx2 / 2);
                float y2 = (float)(cy1 + sy2 / 2);

                var pointsNew = bound.SetInitBound(x1, y1, x2, y2);

                var  dbPointsNew = pointsNew.ToDbModel();
                bool r1          = db.Points.AddRange(dbPointsNew);
                for (int i = 0; i < dbPointsNew.Count; i++)
                {
                    pointsNew[i].Id = dbPointsNew[i].Id;
                }

                var  dbBound = bound.ToDbModel();
                bool r2      = db.Bounds.Edit(dbBound);

                return(r1 && r2);
            }
            catch (System.Exception ex)
            {
                Log.Error(tag, "ModifySize", ex.ToString());
                return(false);
            }
        }