Esempio n. 1
0
        /// <summary>Get the data size associated with a command.</summary>
        /// <param name="command">Command</param>
        /// <returns>int</returns>
        public static int GetCommandDataSize(CommandEnum command)
        {
            FieldInfo fi   = typeof(CommandEnum).GetRuntimeField(command.ToString());
            Attribute attr = fi.GetCustomAttribute(typeof(CommandDataSize));

            return(((CommandDataSize)attr).DataSize);
        }
        /// <summary>
        /// The function sends commands (messages)
        /// from the GUI to the server
        /// </summary>
        public void SendCommandToServer(CommandEnum commandID, string[] args,
                                        string message = null,
                                        bool status    = true)
        {
            if (!Connected)
            {
                return;
            }
            if (message == null)
            {
                message = "Command to server - " + commandID.ToString();
            }
            CommandMessage cmd = new CommandMessage
            {
                Status  = status,
                Type    = commandID,
                Message = message,
                Args    = args
            };

            m_client.Write(cmd.ToJSONString());
        }
Esempio n. 3
0
 private string CommandReplyValidate(CommandDefinition.CommandFormat? reply, CommandEnum expectedCommand)
 {
     string result = /*OK*/ string.Empty;
     if (/*fail?*/ reply == null)
         result = "null reply";
     else if (/*fail?*/ !reply.HasValue)
         result = "reply has no value (!.HasValue)";
     else if (/*fail?*/ reply.Value.CommandAck.Command != expectedCommand)
         result = ".Value.CommandAck.Command(" + reply.Value.CommandAck.Command.ToString() + ") != " + expectedCommand.ToString();
     else if (/*fail?*/ reply.Value.Action.Action != ActionEnum.Response)
         result = ".Value.Action.Action(" + reply.Value.Action.Action.ToString() + ") != " + ActionEnum.Response.ToString();
     return result;
 }
Esempio n. 4
0
 public DelegateCommand(CommandEnum command, Action <T> execute)
 {
     this._name    = command.ToString();
     this._execute = execute;
 }
Esempio n. 5
0
        /**
         * <summary>
         * Creates a radio button for creating something and places it accordingly
         * </summary>
         */
        private RadioButton CreateCreationButton(CommandEnum woName, int position)
        {
            RadioButton b = new RadioButton {
                BorderColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Right, Foreground = Color.Black, GroupName = "Creator", Text = woName.ToString(), Margin = new Thickness(0, 50 * position, 0, 0)
            };

            Owner.Scene.EntityManager.Add(b);
            b.Checked += AddWO;
            b.Entity.AddComponent(new MouseEnterBehavior());
            return(b);
        }