// Multi-threaded form with delegate // http://msdn.microsoft.com/en-us/library/ms171728.aspx public FrmItemValidationReport(ItemRecordManager itemRecordManager, frmItems gui) { InitializeComponent(); m_itemRecordManager = itemRecordManager; m_gui = gui; }
/// <summary> /// <para>Initialize the item page</para> /// </summary> /// <remarks>There's a lot of cross-reference among the classes</remarks> private TableIO initializeItems() { ItemRecordManager itemRecordManager = new ItemRecordManager(this, cboCategory, cboSubCategory, baseTypeCbo, base2DAssetTxt, base3DAssetTxt, baseBaseItemTxt, baseBaseItemBtn, baseManufacturingBtn, guiEquipVisualEffectTxt); TableIO tableIO = new TableIO(this, itemRecordManager); DataBinding dataBinding; dataBinding = tableIO.bind(txtId, Net7.Table_item_base._id, "ID"); tableIO.addFieldNeverEnabled(txtId); dataBinding = tableIO.bind(baseStatusCbo, Net7.Table_item_base._status, "Status"); dataBinding = tableIO.bind(txtDescription, Net7.Table_item_base._description, "Description"); //dataBinding.addValidation(new ValidateNonEmpty()); tableIO.bind(cboCategory, Net7.Table_item_base._category, "Category"); //tableIO.addFieldEnabledOnlyOnAdd(cboCategory); tableIO.bind(cboSubCategory, Net7.Table_item_base._sub_category, "Sub-Category"); //tableIO.addFieldEnabledOnlyOnAdd(cboSubCategory); dataBinding = tableIO.bind(baseTypeCbo, Net7.Table_item_base._type, "Type"); baseTypeCbo.Items.Clear(); baseTypeCbo.Items.AddRange(Database.Database.getItemTypes()); tableIO.bind(cboManufacturer, Net7.Table_item_base._manufacturer, "Manufacturer"); dataBinding = tableIO.bind(txtPrice, Net7.Table_item_base._price, "Price"); dataBinding.addValidation(new ValidateNumericGreaterEqual(0)); tableIO.bind(cboLevel, Net7.Table_item_base._level, "Level"); // This value is self-validated dataBinding = tableIO.bind(txtStackSize, Net7.Table_item_base._max_stack, "Stack Size"); dataBinding.addValidation(new ValidateInteger()); dataBinding.addValidation(new ValidateNumericGreater(0)); dataBinding.addValidation(new ValidateNumericLesserEqual(60000)); dataBinding = tableIO.bind(txtName, Net7.Table_item_base._name, "Name"); dataBinding.addValidation(new ValidateNonEmpty()); dataBinding = tableIO.bind(base2DAssetTxt, Net7.Table_item_base._2d_asset, "2D Asset"); dataBinding.addValidation(new ValidateInteger()); dataBinding.addValidation(new ValidateNumericGreaterEqual(0)); base2DAssetBtn.Click += new EventHandler(itemRecordManager.base2DAssetBtn_Click); new AssetToolip(base2DAssetBtn, base2DAssetTxt); dataBinding = tableIO.bind(base3DAssetTxt, Net7.Table_item_base._3d_asset, "3D Asset"); dataBinding.addValidation(new ValidateInteger()); dataBinding.addValidation(new ValidateNumericGreaterEqual(0)); base3DAssetBtn.Click += new EventHandler(itemRecordManager.base3DAssetBtn_Click); new AssetToolip(base3DAssetBtn, base3DAssetTxt); tableIO.addFieldEnabledOnlyOnView(baseManufacturingBtn); tableIO.bind(baseManufacturingBtn, null, ""); baseManufacturingBtn.Click += new EventHandler(itemRecordManager.baseManufacturingBtn_Click); dataBinding = tableIO.bind(baseCustom, Net7.Table_item_base._custom_flag, "Custom item"); baseCustom.CheckedChanged += new System.EventHandler(itemRecordManager.onCustomItem); tableIO.bind(baseBaseItemTxt, Net7.Table_item_base._item_base_id, "Item base ID"); baseBaseItemTxt.EnabledChanged += new EventHandler(itemRecordManager.onBaseItemEnabledChanged); new AssetToolip(baseBaseItemBtn, baseBaseItemTxt); baseBaseItemBtn.Click += new EventHandler(itemRecordManager.baseItemBtn_Click); dataBinding = tableIO.bind(guiEquipVisualEffectTxt, Net7.Table_item_base._effect_id, "Effect ID"); dataBinding.addValidation(new ValidateInteger()); dataBinding.addValidation(new ValidateNumericGreaterEqual(0)); guiEquipVisualEffectBtn.Click += new EventHandler(itemRecordManager.equipVisualEffectBtn_Click); // These values are self-validated tableIO.bind(chkNoTrade, Net7.Table_item_base._no_trade, "No Tradable"); tableIO.bind(chkNoStore, Net7.Table_item_base._no_store, "No Storable"); tableIO.bind(chkNoDestroy, Net7.Table_item_base._no_destroy, "No Destroyable"); tableIO.bind(chkNoManu, Net7.Table_item_base._no_manu, "Not manufacturable"); tableIO.bind(chkUnique, Net7.Table_item_base._unique, "Unique"); // Initialize the item status baseStatusCbo.Items.Clear(); baseStatusCbo.Items.AddRange(Database.Database.getItemStatus()); // Initialize the item levels cboLevel.Items.Clear(); cboLevel.Items.AddRange(ItemRecordManager.getLevels()); // Initialize the list of manufacturers cboManufacturer.Items.Clear(); cboManufacturer.Items.AddRange(Database.Database.getManufacturers()); // Initialize the list of categories cboCategory.Items.Clear(); cboCategory.Items.AddRange(Database.Database.getItemCategories()); cboCategory.SelectionChangeCommitted += new EventHandler(itemRecordManager.onCategorySelectionChanged); // Initialize the sub-categories cboSubCategory.SelectionChangeCommitted += new EventHandler(itemRecordManager.onSubCategorySelectionChanged); tableIO.initialize(Net7.Tables.item_base.ToString(), Net7.Table_item_base._id, Database.Database.getQueryItem()); itemRecordManager.setTabPages(Items.ItemSubCategory.Ammo, new TabPage[] { tabBase, tabAmmo }); itemRecordManager.setTabPages(Items.ItemSubCategory.Beam_Weapon, new TabPage[] { tabBase, tabBeam }); itemRecordManager.setTabPages(Items.ItemSubCategory.Projectile_Launcher, new TabPage[] { tabBase, tabProjectile }); itemRecordManager.setTabPages(Items.ItemSubCategory.Missile_Launcher, new TabPage[] { tabBase, tabMissile }); itemRecordManager.setTabPages(Items.ItemSubCategory.Device, new TabPage[] { tabBase, tabDevice }); itemRecordManager.setTabPages(Items.ItemSubCategory.Engine, new TabPage[] { tabBase, tabEngine }); itemRecordManager.setTabPages(Items.ItemSubCategory.Reactor, new TabPage[] { tabBase, tabRS }); itemRecordManager.setTabPages(Items.ItemSubCategory.Shield, new TabPage[] { tabBase, tabRS }); itemRecordManager.setTabPages(Items.ItemSubCategory.Other, new TabPage[] { tabBase }); /*itemRecordManager.setTabPages(Items.ItemCategory.Consumable, new TabPage[] { tabBase }); itemRecordManager.setTabPages(Items.ItemCategory.Electronic_Item, new TabPage[] { tabBase }); itemRecordManager.setTabPages(Items.ItemCategory.Reactor_Component, new TabPage[] { tabBase }); itemRecordManager.setTabPages(Items.ItemCategory.Fabricated_Item, new TabPage[] { tabBase }); itemRecordManager.setTabPages(Items.ItemCategory.Weapon_Component, new TabPage[] { tabBase }); itemRecordManager.setTabPages(Items.ItemCategory.Ammo_Component, new TabPage[] { tabBase }); itemRecordManager.setTabPages(Items.ItemCategory.Refined_Resource, new TabPage[] { tabBase }); itemRecordManager.setTabPages(Items.ItemCategory.Raw_Resource, new TabPage[] { tabBase }); itemRecordManager.setTabPages(Items.ItemCategory.Trade_Good, new TabPage[] { tabBase });*/ return tableIO; }