From bbf648947d2741dcc698e78dd8ba94ee1ee99781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=89?= <940119273@qq.com> Date: Wed, 9 Jun 2021 17:07:38 +0800 Subject: [PATCH] =?UTF-8?q?!1538=20=E5=A2=9E=E5=BC=BA=EF=BC=9A=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E8=96=84=E8=83=8C=E6=9D=BF=E5=8F=AF=E4=BB=A5=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=8E=9A=E5=BA=A6,=E5=8E=9A=E5=BA=A6=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=9C=A8=E4=BA=91=E7=AB=AF=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BoardEditor/SelectThinBehindBoard.ts | 91 ++++++++++++++++--- src/UI/Components/Board/BoardModal.tsx | 1 + 2 files changed, 81 insertions(+), 11 deletions(-) diff --git a/src/Add-on/BoardEditor/SelectThinBehindBoard.ts b/src/Add-on/BoardEditor/SelectThinBehindBoard.ts index 8221bf4fc..3f2fd441c 100644 --- a/src/Add-on/BoardEditor/SelectThinBehindBoard.ts +++ b/src/Add-on/BoardEditor/SelectThinBehindBoard.ts @@ -1,25 +1,94 @@ import { app } from "../../ApplicationServices/Application"; +import { FixedNotZero } from "../../Common/Utils"; import { Board } from "../../DatabaseServices/Entity/Board"; import { Command } from "../../Editor/CommandMachine"; import { PromptStatus } from "../../Editor/PromptResult"; +import { BoardModalType } from "../../UI/Components/Board/BoardModal"; +import { IConfigOption } from "../../UI/Components/Board/UserConfig"; import { BoardType } from "../../UI/Store/BoardInterface"; +import { IConfigStore } from "../../UI/Store/BoardStore"; +import { userConfigStore } from "../../UI/Store/UserConfigStore"; export class SelectThinBehindBoard implements Command { + store: SelectThinBehindBoardStore; async exec() { - let ssRes = await app.Editor.GetSelection({ - Msg: "选择薄背板", - AllowNone: true, - UseSelect: true, - Filter: { - filterFunction: (obj, ent) => - { - return (ent instanceof Board) && (ent.BoardType === BoardType.Behind) && (ent.Thickness < 15); + if (!this.store) + { + this.store = new SelectThinBehindBoardStore; + await userConfigStore.UpdateBoardOption(this.store.configName, BoardModalType.SelectThinBehindBoard, this.store); + } + + while (true) + { + let ssRes = await app.Editor.GetSelection({ + Msg: `当前规定薄背板厚度为小于:${FixedNotZero(this.store.config.option.thickness)}`, + AllowNone: true, + KeyWordList: [{ msg: "重新设置厚度输入:", key: "S" }], + Filter: { + filterFunction: (obj, ent) => + { + return (ent instanceof Board) && (ent.BoardType === BoardType.Behind) && (ent.Thickness < this.store.config.option.thickness); + } } + }); + switch (ssRes.Status) + { + case PromptStatus.OK: + app.Editor.SetSelection(ssRes.SelectSet.SelectEntityList); + return; + case PromptStatus.Cancel: + return; + case PromptStatus.Keyword: + if (ssRes.StringResult === "S") + { + let ret = await app.Editor.GetDistance({ Msg: "当前规定薄背板厚度为小于:", Default: this.store.config.option.thickness }); + if (ret.Status === PromptStatus.OK) + { + if (ret.Distance <= 0 || isNaN(ret.Distance)) + { + app.Editor.Prompt("请输入为正数的厚度!"); + return; + } + this.store.config.option.thickness = Math.abs(ret.Distance); + userConfigStore.SaveConfig(BoardModalType.SelectThinBehindBoard, this.store, { toaster: false }); + } + else if (ret.Status === PromptStatus.Cancel) + return; + break; + } + default: + return; } - }); - if (ssRes.Status === PromptStatus.OK) - app.Editor.SetSelection(ssRes.SelectSet.SelectEntityList); + } + } +} + +//只是用来保存配置 +class SelectThinBehindBoardStore implements IConfigStore +{ + configName = "默认"; + configsNames = ['默认']; + config = { + option: { + thickness: 15 + } + }; + InitOption() + { + this.config = { + option: { + thickness: 15 + } + }; + } + SaveConfig() + { + return this.config; + } + UpdateOption(conf: IConfigOption) + { + Object.assign(this.config, conf); } } diff --git a/src/UI/Components/Board/BoardModal.tsx b/src/UI/Components/Board/BoardModal.tsx index 8065f521d..8188839c6 100644 --- a/src/UI/Components/Board/BoardModal.tsx +++ b/src/UI/Components/Board/BoardModal.tsx @@ -53,6 +53,7 @@ export enum BoardModalType HS = "hideSelect",//隐藏-选中 ParseBrName = "ParseBrName",//分析板件名 AutoDimBrs = "AutoDimBrs",//自动标注 + SelectThinBehindBoard = "SelectThinBehindBoard",//选择薄背板 ChangeColorByMaterial = "ChangeColorByMaterial", ModifyTexts = "ModifyTexts",//批量修改文本 }