清理代码

pull/7/head
zoe 7 years ago
parent 0ae7eaf65e
commit b9ee0e8d44

@ -10,20 +10,31 @@ export class DrawLine implements Command
{ {
async exec() async exec()
{ {
app.m_Editor.m_CommandStore.commandPrompt = "请输入一个点:"; 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(); let ptRes = await app.m_Editor.GetPoint();
if (ptRes.Status != PromptStatus.OK) if (ptRes.Status != PromptStatus.OK)
{ {
return; return;
} }
let i = 1;
let i = 0;
let p1 = ptRes.Value; let p1 = ptRes.Value;
let p2 = p1; let p2 = p1;
while (true) while (true)
{ {
app.m_Editor.m_CommandStore.Prompt("请输入点2:"); 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 }); ptRes = await app.m_Editor.GetPoint({ BasePoint: p1, AllowDrawRubberBand: true });
if (ptRes.Status != PromptStatus.OK) if (ptRes.Status != PromptStatus.OK)
{ {
return; return;
@ -170,13 +181,23 @@ export class DrawCircle implements Command
async exec() async exec()
{ {
let cir = new Circle(app.m_Editor.m_MouseCtrl.m_CurMousePointWCS.clone(), 10); 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(); app.m_Editor.UpdateScreen();
let ptRes = await app.m_Editor.GetPoint({ let ptRes = await app.m_Editor.GetPoint({
Callback: (p) => Callback: (p) =>
{ {
cir.m_Center.copy(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) if (ptRes.Status != PromptStatus.OK)
{ {
return; return;
@ -195,6 +216,8 @@ export class DrawCircle implements Command
AllowDrawRubberBand: true AllowDrawRubberBand: true
} }
); );
app.m_Editor.m_CommandStore.EndCommand();
} }
} }

@ -47,7 +47,7 @@ a {
#input-hint input { #input-hint input {
border: none; border: none;
outline: medium; outline: medium;
width: 80%; width: 50%;
} }
#input-hint .input, #input-hint .input,

@ -171,16 +171,13 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore },
} }
} }
// 点击确认命令 // 点击关键词
public handleClick = (e: React.MouseEvent<HTMLElement>) => public handleClickKeyword = (e: React.MouseEvent<HTMLElement>) =>
{ {
let { viceCommand } = this.props.commandStore; const store = this.props.commandStore;
//获取点击的关键词
let m_key = e.currentTarget.firstElementChild.innerHTML.slice(1, 2); let m_key = e.currentTarget.firstElementChild.innerHTML.slice(1, 2);
//TODO: 删除该代码 store.m_getKeyword = m_key;
if (m_key === 'U')
{
viceCommand.length = 0;
}
} }
//鼠标选择命令 //鼠标选择命令
@ -207,7 +204,7 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore },
&& this.props.commandStore.searchCommand.length > 0) && this.props.commandStore.searchCommand.length > 0)
{ {
this.m_liHover = this.m_recommendUl.firstElementChild; this.m_liHover = this.m_recommendUl.firstElementChild;
console.log('this.m_liHover: ', this.m_liHover);
if (this.m_liHover) if (this.m_liHover)
{ {
this.m_liHover.className = 'hover'; this.m_liHover.className = 'hover';
@ -246,7 +243,7 @@ export class InputHint extends React.Component<{ commandStore?: CommandStore },
return ( return (
<span key={index} <span key={index}
className="hint vice-hint" className="hint vice-hint"
onClick={this.handleClick} onClick={this.handleClickKeyword}
> >
[{item.msg}<span>({item.key})</span>] [{item.msg}<span>({item.key})</span>]
</span> </span>

@ -40,7 +40,8 @@ export class CommandStore
@observable searchCommand: Array<string> = []; //联想命令库 @observable searchCommand: Array<string> = []; //联想命令库
//历史命令列表 //历史命令列表
@observable historyCommands: string[] = []; @observable historyCommands: string[] = [];
//获取关键词命令
m_getKeyword: string;
//提示字符串 当前: //提示字符串 当前:
@observable commandPrompt: string = ''; @observable commandPrompt: string = '';
Prompt(msg: string) Prompt(msg: string)
@ -74,6 +75,22 @@ export class CommandStore
} }
this.historyCommands.unshift(cmd); 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) => keyDownHandle = (keyCode: number) =>
{ {
let inpValue: string = this.m_commandInput.value.toUpperCase().trim(); let inpValue: string = this.m_commandInput.value.toUpperCase().trim();
@ -86,19 +103,18 @@ export class CommandStore
} }
case KeyBoard.Space: case KeyBoard.Space:
case KeyBoard.Enter: 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; let cmdName: string;
if (this.m_HoverLi) if (this.m_HoverLi)
{ {
@ -118,6 +134,15 @@ export class CommandStore
} }
else else
{ {
if (inpValue == "")
{
this.viceCommand.length = 0;
this.commandPrompt = '';
}
else
{
}
// // 已经有首条命令了,直接执行后续命名 // // 已经有首条命令了,直接执行后续命名
// if (inpValue === 'U') // if (inpValue === 'U')
// { // {
@ -128,9 +153,7 @@ export class CommandStore
} }
break; break;
case KeyBoard.Escape://esc case KeyBoard.Escape://esc
this.searchCommand.length = 0; this.EndCommand();
this.viceCommand.length = 0;
this.commandPrompt = '';
if (!commandMachine.m_CommandIng) if (!commandMachine.m_CommandIng)
{ {
app.m_Editor.m_SelectCtrl.Cancel(); app.m_Editor.m_SelectCtrl.Cancel();

Loading…
Cancel
Save