Exemplo n.º 1
0
 public void AddCommand <T>(ECommand command, CommandHandler <T> handler) where T : ICommand
 {
     if (!this.mCommands.ContainsKey(command))
     {
         this.mCommands.Add(command, handler);
     }
 }
Exemplo n.º 2
0
        public static void UpdateCommandState_Prefix(PlayerController __instance)
        {
            if (__instance.cmd.type != ECommand.None && __instance.cmd.type != ECommand.Follow &&
                (__instance.cmd.mode != lastCmdMode || __instance.cmd.type != lastCmdType))
            {
                ResetMultiBuild();

                if (__instance.cmd.type != ECommand.Build || __instance.cmd.mode != 0)
                {
                    BlueprintCreator.EndBpMode();
                }

                // the preivous command might force us to stau in BuildMode (Even though we were leaving)
                if (__instance.cmd.type == ECommand.Build && lastCmdMode == 1 && __instance.cmd.mode != 1)
                {
                    BlueprintManager.Reset();
                }

                if (__instance.cmd.type != ECommand.Build)
                {
                    BlueprintManager.Reset();
                }

                lastCmdMode = __instance.cmd.mode;
                lastCmdType = __instance.cmd.type;
            }
        }
Exemplo n.º 3
0
        public static void Go(ECommand command, Position position, EDirection direction)
        {
            switch (command)
            {
            case ECommand.PLACE:
                table.Place(turtle, position, direction);
                break;

            case ECommand.MOVE:
                table.Move(turtle);
                break;

            case ECommand.LEFT:
                turtle.Left();
                break;

            case ECommand.RIGHT:
                turtle.Right();
                break;

            case ECommand.REPORT:
                var output = turtle.Report();

                if (!string.IsNullOrEmpty(output))
                {
                    Console.WriteLine($"\n-- OUTPUT --\n {output} \n \n -- INPUT --");
                }

                break;

            default:
                Console.WriteLine($"{command} is not a valid Command.");
                break;
            }
        }
 private void InitCommands()
 {
     OpenCommand              = new OpenCommand(this);
     ApplyCommand             = new ApplyCommand(this);
     FlipCommand              = new FlipCommand(this);
     HistogramEqualizeCommand = new HistogramEqualizeCommand(this);
     HistogramStretchCommand  = new HistogramStretchCommand(this);
     CropCommand              = new CropCommand(this);
     InpaintCommand           = new InpaintCommand(this);
     ResizeCommand            = new ResizeCommand(this);
     RotateCommand            = new RotateCommand(this);
     SaveAsCommand            = new SaveAsCommand(this);
     SaveCommand              = new SaveCommand(this);
     ZoomCommand              = new ZoomCommand(this);
     ResetCommand             = new ResetCommand(this);
     CloseCommand             = new CloseCommand(this);
     SelectToolCommand        = new SelectToolCommand(this);
     UndoCommand              = new UndoCommand(this);
     RedoCommand              = new RedoCommand(this);
     DropboxCommand           = new DropboxCommand(this);
     DownloadCommand          = new DownloadCommand(this);
     UploadCommand            = new UploadCommand(this);
     DCommand       = new DCommand(this);
     ECommand       = new ECommand(this);
     PrewittCommand = new PrewittCommand(this);
 }
Exemplo n.º 5
0
        private static bool Compare(string input, ECommand type)
        {
            if (input == null)
            {
                return(false);
            }
            switch (type)
            {
            case ECommand.START:
            case ECommand.TURN:
            case ECommand.INFO:
                return(input.StartsWith(type + " "));

            case ECommand.BOARD:
                return(input.StartsWith(type.ToString()));

            case ECommand.END:
            case ECommand.BEGIN:
            case ECommand.ABOUT:
                return(input.Equals(type.ToString()));

            default:
                return(false);
            }
        }
Exemplo n.º 6
0
        Vector3 pos;    // NPOBJECT

        // 在此初始化参数
        protected override void OnCreate()
        {
            obj  = Utility.ToObject(parameters["object"]);
            cmd  = (ECommand)Utility.ToEnumInt(parameters["command"]);
            func = Utility.ToFunc(parameters["func"]);
            pos  = Utility.ToVector(missionVars, parameters["vector"]);
        }
Exemplo n.º 7
0
    void _OnHandleReceivedPacket(Transmitter transmitter, int idCommand, byte[] aPacketBuffer, int iPos)
    {
        ECommand eCommand = (ECommand)idCommand;

        if (eCommand == ECommand.LOGIN)
        {
            LoginMessage msg = new LoginMessage();
            msg.UnSealPacketBuffer(aPacketBuffer, iPos);
            msg.Unserialize();

            OnLoginMessage(transmitter, msg);
        }
        else if (eCommand == ECommand.EXIT)
        {
            ExitMessage msg = new ExitMessage();
            msg.UnSealPacketBuffer(aPacketBuffer, iPos);
            msg.Unserialize();

            OnExitMessage(transmitter, msg);
        }
        else if (eCommand == ECommand.MOVEMENT)
        {
            MovementMessage msg = new MovementMessage();
            msg.UnSealPacketBuffer(aPacketBuffer, iPos);
            msg.Unserialize();

            OnMovementMessage(transmitter, msg);
        }
    }
Exemplo n.º 8
0
        /// <summary>
        /// Get the command class.
        /// </summary>
        /// <param name="command">Command enum.<see cref="ECommand"/>.</param>
        /// <returns>return the type.</returns>
        public static Type GetCommandClass(ECommand command)
        {
            ITypeFinder typeFinder = new TypeFinder();

            var types = typeFinder.FindAll().Where(zw => zw.Name == command.ToString() + "Command");

            return(types.FirstOrDefault());
        }
Exemplo n.º 9
0
        public static void Command(ECommand command, ICollection <File> files)
        {
            string fileList = "";

            foreach (File file in files)
            {
                fileList += file.GetPaths() + " ";
            }
            CommandExplicit(CommandList[(int)command] + " " + fileList);
        }
Exemplo n.º 10
0
    public bool GetButtonDown(ECommand eCommand)
    {
        Command command = Commands.Find(x => x.ECommand == eCommand);

        if (command != null)
        {
            return(Input.GetKeyDown(command.KeyCode));
        }
        return(false);
    }
        public byte[] CreateCommand(ECommand command)
        {
            var ms = new MemoryStream(new byte[20]);

            using (var w = new BinaryWriter(ms)) {
                w.Write((int)command);
            }

            return(ms.ToArray());
        }
Exemplo n.º 12
0
 public static Command create(ECommand command)
 {
     Command c = new Command (command);
       switch (command) {
       case ECommand.NOP:
     return c;
       case ECommand.END_STAGE:
     return c;
       default:
     Logger.putError ("Unknown command");
     return null;
       }
 }
Exemplo n.º 13
0
        public bool Receive(ArraySegment <byte> rawData)
        {
            ByteReader reader = new ByteReader(rawData);
            ECommand   eData  = (ECommand)reader.Binary.ReadInt32();

            switch (eData)
            {
            case ECommand.InitialWorldState:
                return(ReceiveWorldState(rawData));

            default:
                return(false);
            }
        }
Exemplo n.º 14
0
        public bool ExecuteCommand(ECommand eCommand)
        {
            var data = _CommandData[(int)eCommand];

            _UsbApi.Write(data);
            var dataR = _UsbApi.Read();

            if (dataR[1] == 0x06)
            {
                _UsbApi.Write(ConfirmData);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 15
0
        private static bool StartEditFile(string[] arrCommandLine, ECommand eCommand, string strCurrentDirectory, ref int i)
        {
            if (i + 1 >= arrCommandLine.Length)
            {
                Console.WriteLine($"Run Error, {eCommand} is require more argument");
                return(false);
            }

            string strConfigFilePath       = $"{strCurrentDirectory}/{arrCommandLine[++i]}";
            string strFileContents         = File.ReadAllText(strConfigFilePath);
            SearchFileEditorConfig pConfig = JsonConvert.DeserializeObject <SearchFileEditorConfig>(strFileContents);

            var arrFileInfo = pConfig.arrEditFile;

            for (int j = 0; j < arrFileInfo.Length; j++)
            {
                var    pFileInfo   = arrFileInfo[j];
                string strFilePath = $"{strCurrentDirectory}/{pFileInfo.File_RelativePath}";
                if (File.Exists(strFilePath) == false)
                {
                    Console.WriteLine($"Not Found File {strFilePath}");
                    continue;
                }

                string strFileText = File.ReadAllText(strFilePath);
                switch (pFileInfo.FileType)
                {
                case SearchFileEditorConfig.EditFileInfo.EFileType.yaml:
                    EditYAML(strFilePath, strFileText, pFileInfo);
                    break;

                case SearchFileEditorConfig.EditFileInfo.EFileType.json:
                    if (EditJson(strFileText, pFileInfo, out string strNewJson))
                    {
                        File.WriteAllText(strFilePath, strNewJson);
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            Console.WriteLine($"Run strConfigFilePath : {strConfigFilePath}, strFileContents : {strFileContents}");
            return(true);
        }
Exemplo n.º 16
0
        public static EScope GetMessageScope(this ECommand act)
        {
            var ChannelFlags = ECommand.PRIVMSG | ECommand.USERSTATE | ECommand.ROOMSTATE | ECommand.CLEARCHAT | ECommand.NOTICE;


            if (act.HasFlag(ECommand.WHISPER))
            {
                return(EScope.USER);
            }
            else if (act.HasFlag(ChannelFlags))
            {
                return(EScope.CHANNEL);
            }
            else
            {
                return(EScope.GLOBAL);
            }
        }
Exemplo n.º 17
0
        private void ExecuteAction(ECommand cmd)
        {
            switch (cmd)
            {
            case ECommand.MOVE:
                this.Move();
                break;

            case ECommand.LEFT:
                this.Left();
                break;

            case ECommand.RIGHT:
                this.Right();
                break;

            default:
                logger.LogError("Command was not found " + cmd);
                break;
            }
        }
Exemplo n.º 18
0
        public void command(params String[] arg)
        {
            if (arg.Length == 0)
            {
                Debug.Assert(false);
                return;
            }
            String cmd = arg[0];

            try
            {
                ECommand key = (ECommand)Enum.Parse(typeof(ECommand), cmd);
                switch (key)
                {
                case ECommand.showAbout:

                    this.showAbout();

                    break;

                case ECommand.showMessage:

                    this.ShowMessage(arg[1]);

                    break;

                default:

                    MessageBox.Show("Not implemented cmd: " + cmd);

                    break;
                }
            }
            catch
            {
                MessageBox.Show("Not known cmd: " + cmd);

                Debug.Assert(false);
            }
        }
Exemplo n.º 19
0
        private OperationResult ValidateArguments(ECommand command, string[] arguments)
        {
            OperationResult result = new OperationResult();
            Dictionary<string, string> argumentsDict;
            try
            {
                argumentsDict = (from arg in arguments
                                 let splittedArg = arg.Split(new char[] { ':' }, 2)
                                 select splittedArg)
                                 .ToDictionary(x => x[0], x => x[1]);
            }
            catch (IndexOutOfRangeException)
            {
                result.Successful = false;
                result.Description = "Some argument has wrong format.";
                return result;
            }

            var unknownArguments = argumentsDict
                .Keys
                .Where(x => !_availableArgumentsKeys.Contains(x));

            if (unknownArguments.Any())
            {
                result.Description = String.Format("Unknown arguments: {0}",
                    String.Join(", ", unknownArguments));
                result.Successful = false;
                return result;
            }

            if (command == ECommand.check && !argumentsDict.ContainsKey("expected"))
            {
                result.Description = "Check query must contains 'expected'";
                result.Successful = false;
                return result;
            }

            return result;
        }
Exemplo n.º 20
0
 private int GetReceivedBytesThreshold(byte[] btaBuf, int iStartPosData)
 {
     if (PreviousComm == ECommand.Begin)
     {
         if (btaBuf[iStartPosData] == 'S' && btaBuf[1 + iStartPosData] == 'Y' && btaBuf[2 + iStartPosData] == 'S')
         {
             PreviousComm = ECommand.SYS;                           // Чтение архивов, времени
             return(17);
         }
         if (btaBuf[iStartPosData] == (byte)ESymComm.ФХП)                        // ФХП
         {
             PreviousComm = ECommand.ФХП;
             return(1);
         }
     }
     else
     {
         if (PreviousComm == ECommand.SYS || PreviousComm == ECommand.Arch_Date)
         {
             PreviousComm = ECommand.Arch_Date;
             return(254);
         }
         if (btaBuf[iStartPosData] == (byte)ESymComm.ФХП)
         {
             if (PreviousComm == ECommand.ФХП)
             {
                 if (btaBuf[iStartPosData] == 'R')
                 {
                     return(25);
                 }
                 else
                 {
                     return(35);
                 }
             }
         }
     }
     return(1);
 }
Exemplo n.º 21
0
        private void _FrameProcessor(CConnectionFrames.CFrame frame)
        {
            ECommand _command = (ECommand)frame.Command; byte[] _bytes_buffer = frame.BytesFrame; int _buffer_length = _bytes_buffer.Length;

            Console.WriteLine(BitConverter.ToString(_bytes_buffer));
            if (_command == ECommand.DEBUG_STRING)
            {
                Console.Write(Encoding.GetEncoding(1251).GetString(_bytes_buffer));
            }
            else if (_command == ECommand.SETTINGS_DATA && _buffer_length == (2 + 2 + 1 + (2 * 2)))
            {
                int    _offset = 0;
                ushort _delay = BitConverter.ToUInt16(_bytes_buffer, _offset); _offset += 2;
                ushort _period_offset = BitConverter.ToUInt16(_bytes_buffer, _offset); _offset += 2;
                byte   _duty_cycle1 = _bytes_buffer[_offset++];
                byte   _duty_cycle2 = _bytes_buffer[_offset++], _phase2 = _bytes_buffer[_offset++];
                byte   _duty_cycle3 = _bytes_buffer[_offset++], _phase3 = _bytes_buffer[_offset++];
                _settings.SetParams(_delay, _period_offset, _duty_cycle1, _duty_cycle2, _phase2, _duty_cycle3, _phase3);
            }
            else if (_command == ECommand.SETTINGS_SAVE && _buffer_length == 0)
            {
            }
        }
Exemplo n.º 22
0
 public static Command create(ECommand command, File file, File file2 = null)
 {
     Command c = new Command (command);
       switch (command) {
       case ECommand.SAME_MD5:
     c.file = file;
     return c;
       case ECommand.COPY_FILE:
     c.file = file;
     c.file2 = file2;
     return c;
       case ECommand.COPY_FOLDER:
     c.file = file;
     c.file2 = file2;
     return c;
       case ECommand.GET_MD5:
     c.file = file;
     c.file2 = file2;
     return c;
       default:
     Logger.putError ("Unknown command");
     return null;
       }
 }
Exemplo n.º 23
0
 public static void putDoneCommand(ECommand cmd, string param, ulong size = 0)
 {
     //lock (command_lock) {
       switch (cmd) {
       case ECommand.BEGIN_FOLDER:
     cwd = param;
     break;
       case ECommand.END_STAGE:
     sender_stage_done = true;
     lock (log_strings) {
       log_strings.Add (new LogRecord ("Source parsed:", ""));
     }
     break;
       case ECommand.ITEM_DONE:
     items_done++;
     checkIfDone ();
     break;
       case ECommand.GET_MD5:
     items_md5_done++;
     break;
       case ECommand.SAME_MD5:
     items_copied++;
     lock (log_strings) {
       log_strings.Add (new LogRecord ("File attrs copied:", param));
     }
     break;
       case ECommand.COPY_FILE:
     items_copied++;
     items_done++;
     items_size_done += size;
     lock (log_strings) {
       log_strings.Add (new LogRecord ("File copied:", param));
     }
     checkIfDone ();
     break;
       case ECommand.COPY_FOLDER:
     items_copied++;
     items_done++;
     lock (log_strings) {
       log_strings.Add (new LogRecord ("Folder copied:", param));
     }
     checkIfDone ();
     break;
       case ECommand.COPY_FOLDER_ATTRS:
     items_done++;
     lock (log_strings) {
       log_strings.Add (new LogRecord ("Folder attrs copy:", param));
     }
     checkIfDone ();
     break;
       case ECommand.FIX_FOLDER_ATTRS:
     lock (log_strings) {
       log_strings.Add (new LogRecord ("Fixed folder attrs:", param));
     }
     break;
       case ECommand.CHECK_FILE:
       case ECommand.CHECK_FOLDER:
     items_checked++;
     break;
       case ECommand.REMOVE_ITEM:
     items_removed++;
     lock (log_strings) {
       log_strings.Add (new LogRecord ("Item removed:", param));
     }
     break;
       default:
     lock (error_strings) {
       error_strings.Add ("Wrong record in DoneCommand");
     }
     break;
       }
       //}
 }
Exemplo n.º 24
0
 public Command(ECommand cmd, uint param0, uint param1, EDataType type) : this(cmd, param0, param1)
 {
     this.type0 = type;
 }
Exemplo n.º 25
0
 public Command(ECommand command)
 {
     this.command = command;
 }
Exemplo n.º 26
0
        OBJECT tar;     // ENTITY

        // 在此初始化参数
        protected override void OnCreate()
        {
            obj = Utility.ToObject(parameters["object"]);
            cmd = (ECommand)Utility.ToEnumInt(parameters["command"]);
            tar = Utility.ToObject(parameters["target"]);
        }
Exemplo n.º 27
0
 public Command(ECommand cmd, uint param0, uint param1, EDataType type0, EDataType type1) : this(cmd, param0, param1, type0)
 {
     this.type1 = type1;
 }
Exemplo n.º 28
0
 public void Start(ECommand command = ECommand.DoNothing)
 {
     this.Command = command;
     IsDone       = false;
 }
Exemplo n.º 29
0
 public Command(ECommand cmd, uint param0, uint param1) : this(cmd, param0)
 {
     this.param1 = param1;
 }
Exemplo n.º 30
0
 public Command(ECommand cmd, uint param0, Varbit varbit0) : this(cmd, param0)
 {
     this.varbit0 = varbit0;
 }
Exemplo n.º 31
0
        public void ExecuteCommand(ECommand command)
        {
            switch (command)
            {
            case ECommand.Speak:
                Speak();
                break;

            case ECommand.SysShutdown:
                Shutdown();
                break;

            case ECommand.SysRestart:
                Restart();
                break;

            case ECommand.SysLogoff:
                Logoff();
                break;

            case ECommand.SysLock:
                LockComputer();
                break;

            case ECommand.SysHibernate:
                LockComputer();
                break;

            case ECommand.SysSleep:
                LockComputer();
                break;

            case ECommand.Portscan:
                UploadPortscan();
                break;

            case ECommand.GetGateways:
                UploadGatewayInfo();
                break;

            case ECommand.GetLanComputers:
                UploadLANComputers();
                break;

            case ECommand.GetShares:
                UploadShares();
                break;

            case ECommand.SetTransmissionInterval:
                SetTransmissionInterval();
                break;

            case ECommand.GetDesktop:
                UploadDesktopImage();
                break;

            case ECommand.RunCommand:
                ExecuteCommand();
                break;

            case ECommand.GetClipboardData:
                UploadClipboardData();
                break;

            case ECommand.GetWebcam:
                UploadWebcamImage();
                break;

            case ECommand.GetPorts:
                UploadPortInfo();
                break;

            case ECommand.GetProcesses:
                UploadProcessInfo();
                break;

            case ECommand.GetChromeData:
                UploadBrowserData();
                break;

            case ECommand.GetFileEvents:
                UploadFileEvents();
                break;

            case ECommand.UploadFile:
                // File retreived from C&C server
                DownloadFile();
                break;

            case ECommand.GetFile:
                // File transmitted to C&C server
                UploadFile();
                break;

            case ECommand.StreamDesktop:
                StreamDesktop();
                break;

            case ECommand.StopStreamDesktop:
                StopStreamDesktop();
                break;

            //case ECommand.MOVE_CURSOR:
            //    CursorInteract();
            //    break;
            case ECommand.KillProcess:
                KillProcess();
                break;

            case ECommand.StartPlugin:
                ExecutePlugin();
                break;

            case ECommand.KillPlugin:
                RemovePlugin();
                break;

            case ECommand.UploadPlugin:
                UploadPlugin();
                break;

            case ECommand.RunCode:
                ExecuteCode();
                break;
            }
        }
Exemplo n.º 32
0
 public static void Command(ECommand command, File file)
 {
     CommandExplicit(CommandList[(int)command] + " " + file.GetPaths());
 }
Exemplo n.º 33
0
 public static void putPendingCommand(ECommand cmd, string param, ulong size = 0)
 {
     //lock (command_lock) {
       switch (cmd) {
       case ECommand.BEGIN_MD5:
     item_md5_file = param;
     break;
       case ECommand.GET_MD5:
     items_for_md5++;
     break;
       case ECommand.SAME_MD5:
     items_for_copy++;
     lock (log_strings) {
       log_strings.Add (new LogRecord ("File for copy attrs:", param));
     }
     break;
       case ECommand.COPY_FILE:
     items_for_copy++;
     items_size_total += size;
     lock (log_strings) {
       log_strings.Add (new LogRecord ("File for copy:", param));
     }
     break;
       case ECommand.COPY_FOLDER:
     items_for_copy++;
     lock (log_strings) {
       log_strings.Add (new LogRecord ("Folder for copy:", param));
     }
     break;
       case ECommand.CHECK_FILE:
       case ECommand.CHECK_FOLDER:
     items_found++;
     break;
       case ECommand.REMOVE_ITEM:
     items_for_removal++;
     lock (log_strings) {
       log_strings.Add (new LogRecord ("Item for remove:", param));
     }
     break;
       default:
     lock (error_strings) {
       error_strings.Add ("Wrong record in PendingCommand");
     }
     break;
       }
       //}
 }
Exemplo n.º 34
0
 public static void Command(ECommand command)
 {
     CommandExplicit(CommandList[(int)command] + " .");
 }
Exemplo n.º 35
0
 public Command(ECommand cmd, uint param0, byte threebit0) : this(cmd, param0)
 {
     command        = cmd;
     this.threebit0 = threebit0;
 }
Exemplo n.º 36
0
 public Command(ECommand cmd, uint param0, long number0) : this(cmd, param0)
 {
     this.number0 = number0;
 }
Exemplo n.º 37
0
 public static Command create(ECommand command, string path, string root = null)
 {
     Command c = new Command (command);
       switch (command) {
       case ECommand.BEGIN_FOLDER:
     c.file = new File ();
     c.file.path = File.removeParent (path, root);
     c.file.root = root;
     return c;
       case ECommand.NOCOMPARE_FOLDER:
     c.file = new File ();
     c.file.path = File.removeParent (path, root);
     c.file.root = root;
     return c;
       case ECommand.END_FOLDER:
     c.file = new File ();
     c.file.path = path;
     return c;
       case ECommand.CHECK_FILE:
     c.file = new File (path, root);
     return c;
       case ECommand.CHECK_FOLDER:
     c.file = new File (path, root);
     return c;
       case ECommand.REMOVE_ITEM:
     c.file = new File (path, root);
     return c;
       default:
     Logger.putError ("Unknown command");
     return null;
       }
 }