예제 #1
0
        private void cbxOps_SelectedValueChanged(object sender, EventArgs e)
        {
            pnlFields.Visible = false;
            _controls.Clear();
            pnlFields.Controls.Clear();
            PacketReflectionInfo info = PacketController.Client.Processor.Serializer.Info[cbxOps.Text];

            foreach (FieldInfo field in info.Fields)
            {
                Type        type      = field.FieldType;
                TypeCode    fTypeCode = Type.GetTypeCode(type);
                UserControl ctrl      = null;
                if (type.IsEnum)
                {
                    ctrl = new ExEnum(field);
                }
                else
                {
                    switch (fTypeCode)
                    {
                    case TypeCode.Object:
                        if (type == typeof(Vector3))
                        {
                            ctrl = new ExVector3(field);
                        }
                        if (type == typeof(Angle))
                        {
                            ctrl = new ExAngle(field);
                        }
                        break;

                    case TypeCode.Boolean: break;

                    case TypeCode.SByte:
                    case TypeCode.Byte:
                    case TypeCode.Int16:
                    case TypeCode.UInt16:
                    case TypeCode.Int32:
                    case TypeCode.UInt32:
                    case TypeCode.Int64:
                    case TypeCode.UInt64:
                    case TypeCode.Single:
                    case TypeCode.Double: ctrl = new ExUpDown(field); break;

                    case TypeCode.String: ctrl = new ExTextBox(field); break;
                    }
                }
                if (ctrl != null)
                {
                    AddControl(GetPanel()); AddControl(ctrl); _controls.Add((ExControl)ctrl);
                }
            }
            if (_controls.Count != info.Fields.Length)
            {
                throw new Exception("Not enough controls.");
            }
            pnlFields.Visible = true;
        }
예제 #2
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            PacketReflectionInfo info = PacketController.Client.Processor.Serializer.Info[cbxOps.Text];
            Object pObject            = Activator.CreateInstance(info.Type);
            int    length             = info.Fields.Length;

            for (int i = 0; i < length; i++)
            {
                FieldInfo field = info.Fields[i];
                field.SetValue(pObject, _controls[i].FieldValue);
            }
            PacketController.Send((Packet)pObject);
        }