示例#1
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     try
     {
         TagType type = TagType.EnumerateTypes()[lvwTypes.SelectedIndices[0]];
         this.Compound.AddTag(tbxName.Text, type, type.DataType.IsValueType ? Activator.CreateInstance(type.DataType) : null);
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Cannot Add Tag", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
        private void cbxTypes_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (TagType type in TagType.EnumerateTypes())
            {
                if (type.Name == cbxTypes.SelectedItem.ToString())
                {
                    this.EditTag.Type = type;

                    nupLength.Value   = this.EditTag.Length;
                    nupLength.Enabled = false;//this.EditTag.Type.Length == -1;
                    tbxValue.Text     = this.EditValue.ToString();
                    hlpData.SetValue(this.EditTag.Type.ConvertToBytes(this.EditValue));
                }
            }
        }
示例#3
0
        public frmAddTag(TagCompound compound)
        {
            InitializeComponent();

            this.Compound = compound;

            lvwTypes.SmallImageList = Functions.Icons;
            lvwTypes.View           = View.List;
            lvwTypes.MultiSelect    = false;

            foreach (TagType type in TagType.EnumerateTypes())
            {
                lvwTypes.Items.Add(type.Name, Functions.TagIcons.Keys.Contains(type) ? Functions.TagIcons[type] : 0);
            }
        }
示例#4
0
        private void btnChangeType_Click(object sender, EventArgs e)
        {
            cbxTypes.Items.Clear();

            foreach (TagType type in TagType.EnumerateTypes())
            {
                if (TagType.CanConvert(this.EditValue, type))
                {
                    cbxTypes.Items.Add(type.Name);
                }
            }

            btnChangeType.Enabled = false;
            cbxTypes.Enabled      = true;
            cbxTypes.Text         = this.EditTag.Type.Name;
        }