public CommandResolver() { m_CommandList = new FRList<PtCommand>(); m_SelectCmd = PtApp.Get().GetCommand("SelectCmd"); if (m_SelectCmd != null) m_SelectCmd.OnCommand(); }
// There are two kinds of command // 1. Database command, It will change the database. Such as create line, circle. // 2. Non-database command, It won¡¯t change the database. Such as view commands. // // Currently, we only support 2-depth command nested. It means there are // two commands in the stack at most. Their combination is [db cmd, non-db cmd]. // // The following work flow is used to process the nested commands. // 1. If the command stack isn¡¯t empty. // A) If the new command is database command, terminate all the commands, // including all the database command and non-database command, in the stack. // Such as [Line (, Pan)] ->Circle => [Circle]. // B) If the new command is non-database command, terminate all the // non-database commands in the stack if there is. The database command will be left // if there is. Such as [(Line ,) Pan] ->Zoom =>[(Line,) Zoom]. // // 2. Active this command and add it to the stack. // // // The entry of all the commands public void OnCommand(PtCommand Command) { if(!m_CommandList.Empty()) { if (Command.IsDatabaseCommand) TerminateAllStackCommands(); else TerminateNonDatabaseCommands(); } // Start the command bool bSuc = Command.OnCommand(); if (!bSuc) Command.Terminate(); else m_CommandList.Add(Command); }