Пример #1
0
        public void ExecuteCommand()
        {
            string elementType;
            string floorNumber;
            int currentNumber;
            StopStatus stopStatus = new StopStatus();

            PromptResult elementPromptResult = GetElementTypeToSign();
            if (elementPromptResult.Status != PromptStatus.OK)
                return;
            elementType = elementPromptResult.StringResult;

            PromptResult floorNumberPromptResult = GetFloorNumber();
            if (floorNumberPromptResult.Status != PromptStatus.OK)
                return;
            floorNumber = floorNumberPromptResult.StringResult;

            PromptIntegerResult startingNumberPromptResult = GetStartingNumber();
            if (startingNumberPromptResult.Status != PromptStatus.OK)
                return;
            currentNumber = startingNumberPromptResult.Value;

            while (!stopStatus.IsStopped())
            {
                Transaction trans = db.TransactionManager.StartTransaction();

                MText signText = new MText();
                SignWallColumnJig signTextJig = new SignWallColumnJig(signText, stopStatus);

                signText.Contents = GetText(elementType, currentNumber, floorNumber);
                currentNumber++;
                try
                {
                    BlockTableRecord blockTableRecord = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;

                    blockTableRecord.AppendEntity(signText);
                    trans.AddNewlyCreatedDBObject(signText, true);

                    PromptStatus promptStatus = PromptStatus.Keyword;
                    while (promptStatus == PromptStatus.Keyword && !stopStatus.IsStopped())
                    {
                        PromptResult promptResult = editor.Drag(signTextJig);
                        promptStatus = promptResult.Status;
                        if (promptStatus != PromptStatus.OK && promptStatus != PromptStatus.Keyword)
                            return;
                    }

                    if (stopStatus.IsStopped())
                        trans.Abort();
                    else
                        trans.Commit();
                }
                catch (System.Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message, "error");
                }
                finally
                {
                    trans.Dispose();
                }
            }
        }
Пример #2
0
 internal SignWallColumnJig(Entity entity, StopStatus stopStatus):base(entity)
 {
     this.stopStatus = stopStatus;
 }