清理代码

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

@ -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();
}
}

@ -47,7 +47,7 @@ a {
#input-hint input {
border: none;
outline: medium;
width: 80%;
width: 50%;
}
#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);
//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 (
<span key={index}
className="hint vice-hint"
onClick={this.handleClick}
onClick={this.handleClickKeyword}
>
[{item.msg}<span>({item.key})</span>]
</span>

@ -40,7 +40,8 @@ export class CommandStore
@observable searchCommand: Array<string> = []; //联想命令库
//历史命令列表
@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();

Loading…
Cancel
Save