/// <inheritdoc />
        public override void OnGripStatusChanged(ObjectId entityId, Status newStatus)
        {
            try
            {
                // При начале перемещения запоминаем первоначальное положение ручки
                // Запоминаем начальные значения
                if (newStatus == Status.GripStart)
                {
                    _gripTmp = GripPoint;
                }

                // При удачном перемещении ручки записываем новые значения в расширенные данные
                // По этим данным я потом получаю экземпляр класса section
                if (newStatus == Status.GripEnd)
                {
                    using (var tr = AcadUtils.Database.TransactionManager.StartOpenCloseTransaction())
                    {
                        var blkRef = tr.GetObject(Section.BlockId, OpenMode.ForWrite, true, true);
                        using (var resBuf = Section.GetDataForXData())
                        {
                            blkRef.XData = resBuf;
                        }

                        tr.Commit();
                    }

                    Section.Dispose();
                }

                // При отмене перемещения возвращаем временные значения
                if (newStatus == Status.GripAbort)
                {
                    if (_gripTmp != null)
                    {
                        if (GripIndex == 0)
                        {
                            Section.InsertionPoint = _gripTmp;
                        }
                        else if (GripIndex == Section.MiddlePoints.Count + 1)
                        {
                            Section.EndPoint = _gripTmp;
                        }
                        else
                        {
                            Section.MiddlePoints[GripIndex - 1] = _gripTmp;
                        }
                    }
                }

                base.OnGripStatusChanged(entityId, newStatus);
            }
            catch (Exception exception)
            {
                if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy)
                {
                    ExceptionBox.Show(exception);
                }
            }
        }
 public SectionAddVertexGrip(Section section, Point3d?leftPoint, Point3d?rightPoint)
 {
     Section                = section;
     GripLeftPoint          = leftPoint;
     GripRightPoint         = rightPoint;
     GripType               = GripType.Plus;
     RubberBandLineDisabled = true;
 }
Beispiel #3
0
 public SectionTextGrip(Section section)
 {
     Section  = section;
     GripType = GripType.Point;
     CachedAlongTopShelfTextOffset     = section.AlongTopShelfTextOffset;
     CachedAcrossTopShelfTextOffset    = section.AcrossTopShelfTextOffset;
     CachedAlongBottomShelfTextOffset  = section.AlongBottomShelfTextOffset;
     CachedAcrossBottomShelfTextOffset = section.AcrossBottomShelfTextOffset;
 }
        /// <summary>
        /// Singleton instance
        /// </summary>
        public static SectionGripPointOverrule Instance()
        {
            if (_instance != null)
            {
                return(_instance);
            }

            _instance = new SectionGripPointOverrule();

            // Фильтр "отлова" примитива по расширенным данным. Работает лучше, чем проверка вручную!
            _instance.SetXDataFilter(Section.GetDescriptor().Name);
            return(_instance);
        }
Beispiel #5
0
        public override void OnGripStatusChanged(ObjectId entityId, Status newStatus)
        {
            try
            {
                // При удачном перемещении ручки записываем новые значения в расширенные данные
                // По этим данным я потом получаю экземпляр класса section
                if (newStatus == Status.GripEnd)
                {
                    using (var tr = AcadUtils.Database.TransactionManager.StartOpenCloseTransaction())
                    {
                        var blkRef = tr.GetObject(Section.BlockId, OpenMode.ForWrite, true, true);
                        using (var resBuf = Section.GetDataForXData())
                        {
                            blkRef.XData = resBuf;
                        }

                        tr.Commit();
                    }

                    Section.Dispose();
                }

                // При отмене перемещения возвращаем временные значения
                if (newStatus == Status.GripAbort)
                {
                    if (Name == TextGripName.TopText)
                    {
                        Section.AlongTopShelfTextOffset  = CachedAlongTopShelfTextOffset;
                        Section.AcrossTopShelfTextOffset = CachedAcrossTopShelfTextOffset;
                    }

                    if (Name == TextGripName.BottomText)
                    {
                        Section.AlongBottomShelfTextOffset  = CachedAlongBottomShelfTextOffset;
                        Section.AcrossBottomShelfTextOffset = CachedAcrossBottomShelfTextOffset;
                    }
                }

                base.OnGripStatusChanged(entityId, newStatus);
            }
            catch (Exception exception)
            {
                if (exception.ErrorStatus != ErrorStatus.NotAllowedForThisProxy)
                {
                    ExceptionBox.Show(exception);
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SectionVertexGrip"/> class.
        /// </summary>
        /// <param name="section">Экземпляр класса <see cref="mpSection.Section"/></param>
        /// <param name="index">Индекс ручки</param>
        public SectionVertexGrip(Section section, int index)
        {
            Section   = section;
            GripIndex = index;
            GripType  = GripType.Point;

            /* При инициализации ручки нужно собрать все точки разреза и поместить их в поле _points.
             * Это создаст кэш точек разреза. Если в методе WorldDraw брать точки из самого разреза (Section),
             * то вспомогательные линии будут меняться при зуммировании. Это связано с тем, что в методе
             * MoveGripPointsAt происходит вызов метода UpdateEntities */
            _points = new List <Point3d> {
                Section.InsertionPoint
            };
            _points.AddRange(Section.MiddlePoints);
            _points.Add(Section.EndPoint);
        }
        /// <inheritdoc />
        public override ReturnValue OnHotGrip(ObjectId entityId, Context contextFlags)
        {
            using (Section)
            {
                Point3d?newInsertionPoint = null;

                if (GripIndex == 0)
                {
                    Section.InsertionPoint = Section.MiddlePoints[0];
                    newInsertionPoint      = Section.MiddlePoints[0];
                    Section.MiddlePoints.RemoveAt(0);
                }
                else if (GripIndex == Section.MiddlePoints.Count + 1)
                {
                    Section.EndPoint = Section.MiddlePoints.Last();
                    Section.MiddlePoints.RemoveAt(Section.MiddlePoints.Count - 1);
                }
                else
                {
                    Section.MiddlePoints.RemoveAt(GripIndex - 1);
                }

                Section.UpdateEntities();
                Section.BlockRecord.UpdateAnonymousBlocks();
                using (var tr = AcadUtils.Database.TransactionManager.StartOpenCloseTransaction())
                {
                    var blkRef = tr.GetObject(Section.BlockId, OpenMode.ForWrite, true, true);
                    if (newInsertionPoint.HasValue)
                    {
                        ((BlockReference)blkRef).Position = newInsertionPoint.Value;
                    }

                    using (var resBuf = Section.GetDataForXData())
                    {
                        blkRef.XData = resBuf;
                    }

                    tr.Commit();
                }
            }

            return(ReturnValue.GetNewGripPoints);
        }
        /// <inheritdoc />
        public override void OnGripStatusChanged(ObjectId entityId, Status newStatus)
        {
            if (newStatus == Status.GripStart)
            {
                AcadUtils.Editor.TurnForcedPickOn();
                AcadUtils.Editor.PointMonitor += AddNewVertex_EdOnPointMonitor;
            }

            if (newStatus == Status.GripEnd)
            {
                AcadUtils.Editor.TurnForcedPickOff();
                AcadUtils.Editor.PointMonitor -= AddNewVertex_EdOnPointMonitor;
                using (Section)
                {
                    Point3d?newInsertionPoint = null;

                    if (GripLeftPoint == Section.InsertionPoint)
                    {
                        Section.MiddlePoints.Insert(0, NewPoint);
                    }
                    else if (GripLeftPoint == null)
                    {
                        Section.MiddlePoints.Insert(0, Section.InsertionPoint);
                        Section.InsertionPoint = NewPoint;
                        newInsertionPoint      = NewPoint;
                    }
                    else if (GripRightPoint == null)
                    {
                        Section.MiddlePoints.Add(Section.EndPoint);
                        Section.EndPoint = NewPoint;
                    }
                    else
                    {
                        Section.MiddlePoints.Insert(Section.MiddlePoints.IndexOf(GripLeftPoint.Value) + 1, NewPoint);
                    }

                    Section.UpdateEntities();
                    Section.BlockRecord.UpdateAnonymousBlocks();
                    using (var tr = AcadUtils.Database.TransactionManager.StartOpenCloseTransaction())
                    {
                        var blkRef = tr.GetObject(Section.BlockId, OpenMode.ForWrite, true, true);
                        if (newInsertionPoint.HasValue)
                        {
                            ((BlockReference)blkRef).Position = newInsertionPoint.Value;
                        }

                        using (var resBuf = Section.GetDataForXData())
                        {
                            blkRef.XData = resBuf;
                        }

                        tr.Commit();
                    }
                }
            }

            if (newStatus == Status.GripAbort)
            {
                AcadUtils.Editor.TurnForcedPickOff();
                AcadUtils.Editor.PointMonitor -= AddNewVertex_EdOnPointMonitor;
            }

            base.OnGripStatusChanged(entityId, newStatus);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SectionRemoveVertexGrip"/> class.
 /// </summary>
 /// <param name="section">Экземпляр класса <see cref="mpSection.Section"/></param>
 /// <param name="index">Индекс ручки</param>
 public SectionRemoveVertexGrip(Section section, int index)
 {
     Section   = section;
     GripIndex = index;
     GripType  = GripType.Minus;
 }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SectionReverseGrip"/> class.
 /// </summary>
 /// <param name="section">Экземпляр класса <see cref="mpSection.Section"/></param>
 public SectionReverseGrip(Section section)
 {
     Section  = section;
     GripType = GripType.TwoArrowsUpDown;
 }
 public SectionReverseGrip(Section section)
 {
     Section  = section;
     GripType = GripType.Mirror;
 }