private static PromptEntityResult PromptSourceEntity(Document doc, ref bool deleteSource)
        {
            // Выберите объект-исходник (текст, выноска, таблица или размер):
            var peo = new PromptEntityOptions($"\n{Language.GetItem(LangItem, "msg1")}");

            peo.SetMessageAndKeywords($"\n{Language.GetItem(LangItem, "msg2")}", "Delete");
            peo.AppendKeywordsToMessage = true;
            peo.SetRejectMessage($"\n{Language.GetItem(LangItem, "msg3")}");
            peo.AddAllowedClass(typeof(DBText), false);
            peo.AddAllowedClass(typeof(MText), false);
            peo.AddAllowedClass(typeof(MLeader), false);
            peo.AddAllowedClass(typeof(Table), false);
            peo.AddAllowedClass(typeof(Dimension), false);
            peo.AllowNone = true;
            var per = doc.Editor.GetEntity(peo);

            if (per.Status == PromptStatus.Keyword)
            {
                // Удалять объект-исходник (для таблиц - содержимое ячейки)?
                deleteSource = MessageBox.ShowYesNo(Language.GetItem(LangItem, "msg4"), MessageBoxIcon.Question);

                // Сохраняем текущее значение как значение по умолчанию
                ModPlus.Helpers.XDataHelpers.SetStringXData("mpTxtCopyPaste", deleteSource.ToString());
                return(PromptSourceEntity(doc, ref deleteSource));
            }

            if (per.Status == PromptStatus.OK)
            {
                return(per);
            }

            throw new OperationCanceledException();
        }
Esempio n. 2
0
        /// <summary> 在界面中选择一个对象 </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ed"></param>
        /// <returns></returns>
        private static bool ReadEntityAnnot(Editor ed, out bool clearAnnots, out bool editInForm, out bool setNewValue, out Entity ent)
        {
            clearAnnots = false;
            editInForm  = false;
            setNewValue = false;
            ent         = null;
            var op = new PromptEntityOptions("查看任意一个元素的注释")
            {
                AllowNone = true,
            };

            //op.SetRejectMessage($"请选择一个 {typeof(T).FullName} 对象");
            //op.AddAllowedClass(typeof(T), exactMatch: false);
            op.SetMessageAndKeywords(messageAndKeywords: "\n[清除注释(C) / 窗口编辑(F) / 设置新值(S)]:",
                                     globalKeywords: "K清除注释 K窗口编辑 K设置新值"); // 默认值写在前面

            var res = ed.GetEntity(op);

            if (res.Status == PromptStatus.OK)
            {
                ent = res.ObjectId.GetObject(OpenMode.ForRead) as Entity;
                // 继续读取下一个元素注释
                return(true);
            }
            else if (res.Status == PromptStatus.Keyword)
            {
                var key = res.StringResult;
                if (key == "K清除注释")
                {
                    clearAnnots = true;
                }
                else if (key == "K窗口编辑")
                {
                    editInForm = true;
                }
                else if (key == "K设置新值")
                {
                    setNewValue = true;
                }
                else
                {
                    // 输入的为一般字符,可以直接作为属性值
                    return(true);
                }
                return(true);
            }
            else if (res.Status == PromptStatus.None)
            {
                // 直接按下了 右键 或 Enter
                return(false);
            }
            return(false);
        }