Exemplo n.º 1
0
        private void EditOrAddItem(CustomPropertySchemaItem schemaItem)
        {
            bool isNewItem = false;

            if (schemaItem == null)
            {
                schemaItem      = new CustomPropertySchemaItem();
                schemaItem.Type = CustomPropertyType.Boolean;
                isNewItem       = true;
            }
            CustomPropertySchemaItemEditor itemEditor = new CustomPropertySchemaItemEditor(schemaItem, isNewItem);

            if (itemEditor.ShowDialog() == DialogResult.OK)
            {
                if (isNewItem)
                {
                    if (!IsThereACustomPropertyWithThisName(schemaItem.Name.ToLower()))
                    {
                        _schema.PropertyDefinitions.Add(schemaItem);
                    }
                }
                RepopulateListView();
            }
            itemEditor.Dispose();
        }
Exemplo n.º 2
0
        public CustomPropertySchemaItemEditor(CustomPropertySchemaItem item, bool isNewItem)
        {
            _itemToEdit = item;
            _copyOfItem = (CustomPropertySchemaItem)item.Clone();
            InitializeComponent();

            txtName.DataBindings.Add("Text", _copyOfItem, "Name", true, DataSourceUpdateMode.OnPropertyChanged);
            txtDescription.DataBindings.Add("Text", _copyOfItem, "Description", true, DataSourceUpdateMode.OnPropertyChanged);
            txtDefaultValue.DataBindings.Add("Text", _copyOfItem, "DefaultValue", true, DataSourceUpdateMode.OnPropertyChanged);
            chkCharacters.DataBindings.Add("Checked", _copyOfItem, "AppliesToCharacters", true, DataSourceUpdateMode.OnPropertyChanged);
            chkHotspots.DataBindings.Add("Checked", _copyOfItem, "AppliesToHotspots", true, DataSourceUpdateMode.OnPropertyChanged);
            chkInventory.DataBindings.Add("Checked", _copyOfItem, "AppliesToInvItems", true, DataSourceUpdateMode.OnPropertyChanged);
            chkObjects.DataBindings.Add("Checked", _copyOfItem, "AppliesToObjects", true, DataSourceUpdateMode.OnPropertyChanged);
            chkRooms.DataBindings.Add("Checked", _copyOfItem, "AppliesToRooms", true, DataSourceUpdateMode.OnPropertyChanged);
            cmbType.SelectedIndex = ((int)_copyOfItem.Type) - 1;

            if (!isNewItem)
            {
                txtName.Enabled = false;
            }
        }
Exemplo n.º 3
0
        private void ContextMenuEventHandler(object sender, EventArgs e)
        {
            ToolStripMenuItem        menuItem   = (ToolStripMenuItem)sender;
            CustomPropertySchemaItem schemaItem = (CustomPropertySchemaItem)menuItem.Owner.Tag;

            if (menuItem.Name == MENU_ITEM_ADD)
            {
                EditOrAddItem(null);
            }
            else if (menuItem.Name == MENU_ITEM_EDIT)
            {
                EditOrAddItem(schemaItem);
            }
            else if (menuItem.Name == MENU_ITEM_DELETE)
            {
                if (MessageBox.Show("Are you sure you want to delete this entry from the schema? It will be removed from all items in the game that currently have this property set.", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    _schema.PropertyDefinitions.Remove(schemaItem);
                    RepopulateListView();
                }
            }
        }
 public CustomPropertyDescriptor(CustomPropertySchemaItem schemaItem, CustomProperties properties)
     : base(schemaItem.Name, new Attribute[] { new DescriptionAttribute(schemaItem.Description), new DefaultValueAttribute(schemaItem.GetTypedDefaultValue()) })
 {
     _properties = properties;
     _schemaItem = schemaItem;
 }