// 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>Select the record corresponding to the specified id.</para> /// </summary> /// <param name="selectId">The id to select</param> public Boolean selectRecord(String selectId) { TableHandler primaryTableHandler = listTableHandler[0]; ItemRecordManager itemRecordManager = (ItemRecordManager)primaryTableHandler.getTableIO().getRecordManager(); frmItems gui = (frmItems)itemRecordManager.getGui(); frmItems.EditorType previousEditorType = gui.getCurrentEditorType(); String selectCommand = primaryTableHandler.getTableIO().getRecordManager().selectDataRowFromId(selectId); String currentId = getPrimaryId(); Boolean foundRecord = primaryTableHandler.getTableIO().recordSearch(selectCommand); if (!foundRecord) { // Remain with this current editor selectCommand = primaryTableHandler.getTableIO().getRecordManager().selectDataRowFromId(currentId); primaryTableHandler.getTableIO().recordSearch(selectCommand); return(false); } primaryTableHandler.getTableIO().viewRecord(); // A new type of editor may have been activated frmItems.EditorType currentEditorType = gui.getCurrentEditorType(); if (!currentEditorType.Equals(previousEditorType)) { // Let that new editor handle the record // Note that this call is recursive since it calls this same // function. An infinite loop is avoided as long as the previous // and current editor types are different return(gui.getCurrentEditor().selectRecord(selectId)); } Boolean skippedFirstTable = false; foreach (TableHandler tableHandler in listTableHandler) { if (!skippedFirstTable) { skippedFirstTable = true; } else { selectCommand = tableHandler.getTableIO().getRecordManager().selectDataRowFromId(selectId); tableHandler.getTableIO().recordSearch(selectCommand); tableHandler.getTableIO().viewRecord(); } } return(foundRecord); }
private void onItemValidationReport(object sender, EventArgs e) { if (m_itemValidationReport == null) { IEditor itemEditor = (IEditor)getEditor(EditorType.Items); ItemRecordManager itemRecordManager = (ItemRecordManager)itemEditor.getTableIO(tabBase).getRecordManager(); m_itemValidationReport = new Gui.FrmItemValidationReport(itemRecordManager, this); } m_itemValidationReport.ShowDialog(); // TODO: Item Validation Report should not change the TabControl getTabControl().SelectedTab = getTabControl().TabPages[0]; // Temporary fix // TODO: ItemValidationReport as a search dialog // Call an internal show and pass whether the Editor is Items // If it is then allow a Select button such that the report acts as a Search dialog }
/// <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); }