예제 #1
0
        public virtual Type CommandType(ComEnum en)
        {
            switch (en)
            {
            case ComEnum.Connect:
                return(typeof(ConnectCommand <MT, T>));

            case ComEnum.Disconnect:
                return(typeof(DisconnectCommand <MT, T>));

            case ComEnum.Kill:
                return(typeof(KillCommand <MT, T>));

            case ComEnum.General:
                return(typeof(GeneralCommand <MT, T>));

            case ComEnum.Main:
                return(typeof(MainCommand <MT, T>));

            case ComEnum.Broadcast:
                return(typeof(BroadcastCommand <MT, T>));

            case ComEnum.Settings:
                return(typeof(SettingsCommand <MT, T>));

            case ComEnum.Users:
                return(typeof(UsersCommand <MT, T>));

            case ComEnum.Time:
                return(typeof(TimeGetSetCommand <MT, T>));
            }
            return(null);
        }
예제 #2
0
        public override Type CommandType(ComEnum en)
        {
            var res = base.CommandType(en);

            if (res == null)
            {
                switch (en)
                {
                case ComEnum.CreateRoom:
                    return(typeof(CreateRoomCommand <MT, T>));

                case ComEnum.StartChat:
                    return(typeof(StartChatCommand <MT, T>));

                case ComEnum.ChangeStatus:
                    return(typeof(ChangeStatusCommand <MT, T>));

                case ComEnum.JoinRoom:
                    return(typeof(JoinRoomCommand <MT, T>));

                case ComEnum.LeaveRoom:
                    return(typeof(LeaveRoomCommand <MT, T>));

                case ComEnum.SendMessage:
                    return(typeof(SendMessageCommand <MT, T>));

                case ComEnum.ManageChat:
                    return(typeof(ManageChatCommand <MT, T>));
                }
            }
            return(res);
        }
예제 #3
0
        public FrmLightCrlManager()
        {
            InitializeComponent();
            string[]       serialPorts = SerialPort.GetPortNames(); //获取所有串口打开光源
            List <ComEnum> ComList     = new List <ComEnum>();

            ComEnum[] ComS = new ComEnum[ComList.Count()];
            if (serialPorts.Length > 2)
            {
                foreach (string item in serialPorts)
                {
                    ComEnum NowEnum = (ComEnum)Enum.Parse(typeof(ComEnum), item, true);
                    ComList.Add(NowEnum);
                }
                ComS = new ComEnum[ComList.Count()];
                for (int i = 0; i < ComList.Count(); i++)
                {
                    ComS[i] = ComList[i];
                }
            }
            else
            {
                ComS = new ComEnum[] { ComEnum.COM0, ComEnum.COM1, ComEnum.COM2, ComEnum.COM3, ComEnum.COM4, ComEnum.COM5 };
            }
            this.portNameDataGridViewTextBoxColumn.DataSource = ComS;
            this.portNameDataGridViewTextBoxColumn.ValueType  = typeof(ComEnum);
            //this.portNameDataGridViewTextBoxColumn.DataPropertyName = "EventSeverity";
            this.stopBitsDataGridViewTextBoxColumn.Items.Clear();
            foreach (StopBits temp in Enum.GetValues(typeof(StopBits)))
            {
                this.stopBitsDataGridViewTextBoxColumn.Items.Add(temp);
            }
            //this.stopBitsDataGridViewTextBoxColumn.DataPropertyName = "EventSeverity";
            this.parityDataGridViewTextBoxColumn.Items.Clear();
            foreach (Parity temp in Enum.GetValues(typeof(Parity)))
            {
                this.parityDataGridViewTextBoxColumn.Items.Add(temp);
            }
            this.parityDataGridViewTextBoxColumn.ValueType = typeof(Parity);
            //this.parityDataGridViewTextBoxColumn.DataPropertyName = "EventSeverity";
            this.lightCtrlTypeDataGridViewTextBoxColumn.Items.Clear();
            foreach (LightCtrlTypeEnum temp in Enum.GetValues(typeof(LightCtrlTypeEnum)))
            {
                this.lightCtrlTypeDataGridViewTextBoxColumn.Items.Add(temp);
            }
            this.lightCtrlTypeDataGridViewTextBoxColumn.ValueType = typeof(LightCtrlTypeEnum);
            //this.lightCtrlTypeDataGridViewTextBoxColumn.DataPropertyName = "EventSeverity";
            this.lightCtrlNameDataGridViewTextBoxColumn.Items.Clear();
            foreach (LightCtrlEmun temp in Enum.GetValues(typeof(LightCtrlEmun)))
            {
                this.lightCtrlNameDataGridViewTextBoxColumn.Items.Add(temp);
            }
            this.lightCtrlNameDataGridViewTextBoxColumn.ValueType = typeof(LightCtrlEmun);
            // this.lightCtrlNameDataGridViewTextBoxColumn.DataPropertyName = "EventSeverity";
        }
예제 #4
0
 public ClientCommand <MT, T> this[ComEnum en]
 {
     get
     {
         if (!comms.ContainsKey(en))
         {
             comms.Add(en, commandsManager.Command(en, false));
         }
         return(comms[en]);
     }
 }
예제 #5
0
        public ClientCommand <MT, T> Command(ComEnum en, bool noNewBinding)
        {
            Type t = CommandType(en);

            if (t != null)
            {
                var com = Activator.CreateInstance(t, new object[] { noNewBinding }) as ClientCommand <MT, T>;
                return(com);
            }
            return(null);
        }
예제 #6
0
 public object ExecuteAsync(ComEnum en, object key)
 {
     return(ExecuteAsync(commandsManager.CommandType(en), key));
 }
예제 #7
0
 public object Execute(ComEnum en, object par)
 {
     return(Execute(CommandType(en), par));
 }
예제 #8
0
 public object Execute(ComEnum en)
 {
     return(Execute(CommandType(en)));
 }