From b9ee0e8d440934694630da5dad74be55d2b65c1f Mon Sep 17 00:00:00 2001 From: zoe Date: Tue, 12 Dec 2017 10:43:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/DrawLine.ts | 27 +++++++++- .../Components/commandLineInput/InputHint.css | 2 +- .../Components/commandLineInput/InputHint.tsx | 17 +++--- src/UI/Store/CommandStore.ts | 53 +++++++++++++------ 4 files changed, 71 insertions(+), 28 deletions(-) diff --git a/src/Add-on/DrawLine.ts b/src/Add-on/DrawLine.ts index f01f06411..239f0a8de 100644 --- a/src/Add-on/DrawLine.ts +++ b/src/Add-on/DrawLine.ts @@ -10,20 +10,31 @@ export class DrawLine implements Command { async exec() { + app.m_Editor.m_CommandStore.commandPrompt = "请输入一个点:"; - app.m_Editor.m_CommandStore.viceCommand.push({ key: "U", msg: "放弃" }); + app.m_Editor.m_CommandStore.Prompt("请输入一个点:"); let ptRes = await app.m_Editor.GetPoint(); if (ptRes.Status != PromptStatus.OK) { return; } - let i = 1; + + let i = 0; let p1 = ptRes.Value; let p2 = p1; + while (true) { app.m_Editor.m_CommandStore.Prompt("请输入点2:"); + app.m_Editor.m_CommandStore.commandPrompt = "请输入点2:"; + i++; + if (i === 1) + app.m_Editor.m_CommandStore.viceCommand.push({ key: "U", msg: "放弃" }); + else if (i == 3) + app.m_Editor.m_CommandStore.viceCommand.push({ key: "C", msg: "闭合" }); + ptRes = await app.m_Editor.GetPoint({ BasePoint: p1, AllowDrawRubberBand: true }); + if (ptRes.Status != PromptStatus.OK) { return; @@ -170,13 +181,23 @@ export class DrawCircle implements Command async exec() { let cir = new Circle(app.m_Editor.m_MouseCtrl.m_CurMousePointWCS.clone(), 10); + app.m_Editor.m_CommandStore.Prompt("指定圆的圆心:"); + app.m_Editor.m_CommandStore.commandPrompt = "指定圆的圆心"; + app.m_Editor.m_CommandStore.viceCommand.push( + { key: "3P", msg: "三点" }, { key: "2P", msg: "二点" }, { key: "T", msg: "切点、切点、半径" } + ) app.m_Editor.UpdateScreen(); let ptRes = await app.m_Editor.GetPoint({ Callback: (p) => { cir.m_Center.copy(p); + } }); + app.m_Editor.m_CommandStore.Prompt("指定圆的半径:"); + app.m_Editor.m_CommandStore.commandPrompt = "指定圆的半径:"; + app.m_Editor.m_CommandStore.viceCommand.length = 0; + app.m_Editor.m_CommandStore.viceCommand.push({ key: "D", msg: "直径" }) if (ptRes.Status != PromptStatus.OK) { return; @@ -195,6 +216,8 @@ export class DrawCircle implements Command AllowDrawRubberBand: true } ); + + app.m_Editor.m_CommandStore.EndCommand(); } } diff --git a/src/UI/Components/commandLineInput/InputHint.css b/src/UI/Components/commandLineInput/InputHint.css index 39cd95473..190bd02be 100644 --- a/src/UI/Components/commandLineInput/InputHint.css +++ b/src/UI/Components/commandLineInput/InputHint.css @@ -47,7 +47,7 @@ a { #input-hint input { border: none; outline: medium; - width: 80%; + width: 50%; } #input-hint .input, diff --git a/src/UI/Components/commandLineInput/InputHint.tsx b/src/UI/Components/commandLineInput/InputHint.tsx index a0d40f659..e2eaee156 100644 --- a/src/UI/Components/commandLineInput/InputHint.tsx +++ b/src/UI/Components/commandLineInput/InputHint.tsx @@ -171,16 +171,13 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore }, } } - // 点击确认命令 - public handleClick = (e: React.MouseEvent) => + // 点击关键词 + public handleClickKeyword = (e: React.MouseEvent) => { - let { viceCommand } = this.props.commandStore; + const store = this.props.commandStore; + //获取点击的关键词 let m_key = e.currentTarget.firstElementChild.innerHTML.slice(1, 2); - //TODO: 删除该代码 - if (m_key === 'U') - { - viceCommand.length = 0; - } + store.m_getKeyword = m_key; } //鼠标选择命令 @@ -207,7 +204,7 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore }, && this.props.commandStore.searchCommand.length > 0) { this.m_liHover = this.m_recommendUl.firstElementChild; - console.log('this.m_liHover: ', this.m_liHover); + if (this.m_liHover) { this.m_liHover.className = 'hover'; @@ -246,7 +243,7 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore }, return ( [{item.msg}({item.key})] diff --git a/src/UI/Store/CommandStore.ts b/src/UI/Store/CommandStore.ts index 8c72972da..97f6682af 100644 --- a/src/UI/Store/CommandStore.ts +++ b/src/UI/Store/CommandStore.ts @@ -40,7 +40,8 @@ export class CommandStore @observable searchCommand: Array = []; //联想命令库 //历史命令列表 @observable historyCommands: string[] = []; - + //获取关键词命令 + m_getKeyword: string; //提示字符串 当前: @observable commandPrompt: string = ''; Prompt(msg: string) @@ -74,6 +75,22 @@ export class CommandStore } this.historyCommands.unshift(cmd); } + //结束命令 + EndCommand() + { + this.m_commandInput.value = ""; + this.searchCommand.length = 0; + this.viceCommand.length = 0; + this.commandPrompt = ''; + } + ExecKeyword(key: string) + { + switch (key) + { + case 'U': + + } + } keyDownHandle = (keyCode: number) => { let inpValue: string = this.m_commandInput.value.toUpperCase().trim(); @@ -86,19 +103,18 @@ export class CommandStore } case KeyBoard.Space: case KeyBoard.Enter: - //如果没输入命令,空格键为上一次输入命令 - if (inpValue == "" && this.historyCommands.length > 0) - { - - this.ExecCommand(this.historyCommands[0]); - this.Prompt(this.historyCommands[0]); - this.m_commandInput.value = ""; - - break; - } //如果没有确认执行命令,运行当前输入的命令,并将命令添加到历史 - if (!this.commandPrompt) + if (!commandMachine.m_CommandIng) { + //如果没输入命令,空格键为上一次输入命令 + if (inpValue == "" && this.historyCommands.length > 0) + { + + this.ExecCommand(this.historyCommands[0]); + this.Prompt(this.historyCommands[0]); + this.m_commandInput.value = ""; + break; + } let cmdName: string; if (this.m_HoverLi) { @@ -118,6 +134,15 @@ export class CommandStore } else { + if (inpValue == "") + { + this.viceCommand.length = 0; + this.commandPrompt = ''; + } + else + { + + } // // 已经有首条命令了,直接执行后续命名 // if (inpValue === 'U') // { @@ -128,9 +153,7 @@ export class CommandStore } break; case KeyBoard.Escape://esc - this.searchCommand.length = 0; - this.viceCommand.length = 0; - this.commandPrompt = ''; + this.EndCommand(); if (!commandMachine.m_CommandIng) { app.m_Editor.m_SelectCtrl.Cancel();