public void FillDataRowFromObject(Object mob) { if (mob != null) { DataRow row = DB.NPCTable.NewRow(); foreach (DataColumn column in DB.NPCTable.Columns) { try { String dolColumn = QuestDesignerMain.DatabaseAdapter.ConvertXMLColumnToDOLColumn(column.ColumnName); PropertyInfo field = mob.GetType().GetProperty(dolColumn); if (field != null) { row[column.ColumnName] = field.GetValue(mob, null); } else { if (dolColumn == DB.COL_NPC_OBJECTNAME || dolColumn == "AddToWorld") { //skipping ObjectName since it a QuestDesigner internal value. } else { throw new DOLConfigurationException("No Property found in DOL Mob object for column: " + column.ColumnName); } } } catch (DOLConfigurationException ex) { QuestDesignerMain.HandleException(ex); } // generate objectname since it doesn't exists in the dol world. row[DB.COL_NPC_OBJECTNAME] = Utils.ConvertToObjectName(Convert.ToString(row[DB.COL_NPC_NAME])); } DB.NPCTable.Rows.Add(row); } }
private void B_SearchItem_Click(object sender, EventArgs e) { DialogResult result = QuestDesignerMain.ItemLookupForm.ShowDialog(); if (result == DialogResult.OK) { Object item = QuestDesignerMain.ItemLookupForm.SelectedItem; if (item != null) { DataRow row = DB.ItemTemplateTable.NewRow(); foreach (DataColumn column in DB.ItemTemplateTable.Columns) { try { String dolColumn = QuestDesignerMain.DatabaseAdapter.ConvertXMLColumnToDOLColumn(column.ColumnName); PropertyInfo field = item.GetType().GetProperty(dolColumn); if (field != null) { row[column.ColumnName] = field.GetValue(item, null); } else { throw new DOLConfigurationException("No property found in DOL item object for column :" + column.ColumnName); } } catch (DOLConfigurationException ex) { QuestDesignerMain.HandleException(ex); } } //row["ObjectName"] = Utils.ConvertToObjectName(Convert.ToString(row["Name"])); DB.ItemTemplateTable.Rows.Add(row); } } }
public QuestDesignerForm() { InitializeComponent(); DB.DatabaseLoaded += new DB.DatabaseLoadedEventHandler(DB_DatabaseLoaded); QuestDesignerMain.InitDB(); }