public void AddColumn(string name, GameDataList.ColumnInfo info) { ColumnHeader columnHeader = new ColumnHeader() { Text = name, Tag = info }; columnHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); base.Columns.Add(columnHeader); this.itemCache = null; }
public GameDataList.ColumnInfo AddReferenceColumn(string name, string key, bool names, bool values) { GameDataList.ColumnInfo columnInfo = new GameDataList.ColumnInfo(); ColumnHeader columnHeader = new ColumnHeader() { Text = name, Tag = columnInfo }; columnHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); columnInfo.list = name; columnInfo.showNames = names; columnInfo.showValues = values; base.Columns.Add(columnHeader); this.itemCache = null; return(columnInfo); }
private ListViewItem createItem(GameData.Item item) { ListViewItem listViewItem = new ListViewItem(item.Name) { ForeColor = StateColours.GetStateColor(item.getState()) }; foreach (ColumnHeader column in base.Columns) { if (column.Index == 0) { continue; } if (column.Tag == null) { column.Tag = "Name"; } string str = column.Tag.ToString(); if (str == "Name") { listViewItem.SubItems.Add(item.Name); } else if (str == "StringID") { listViewItem.SubItems.Add(item.stringID); } else if (str == "Type") { listViewItem.SubItems.Add(item.type.ToString()); } else if (str == "Ref") { listViewItem.SubItems.Add(item.refCount.ToString()); } else if (column.Tag is GameDataList.ColumnInfo && item.hasReference(str)) { GameDataList.ColumnInfo tag = column.Tag as GameDataList.ColumnInfo; string str1 = ""; if (tag.showNames || tag.showValues) { GameData.Desc desc = GameData.getDesc(item.type, str); foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair in item.referenceData(str, false)) { GameData.Item item1 = this.Source.getItem(keyValuePair.Key); if (tag.showNames) { str1 = string.Concat(str1, (item1 == null ? keyValuePair.Key : item1.Name)); } if (!tag.showValues) { if (!tag.showNames) { continue; } str1 = string.Concat(str1, "; "); } else { if (desc.flags == 1) { str1 = string.Concat(new object[] { str1, " ", keyValuePair.Value.v0, "; " }); } if (desc.flags == 2) { str1 = string.Concat(new object[] { str1, " ", keyValuePair.Value.v0, " ", keyValuePair.Value.v1, "; " }); } if (desc.flags != 3) { continue; } str1 = string.Concat(new object[] { str1, " ", keyValuePair.Value.v0, " ", keyValuePair.Value.v1, " ", keyValuePair.Value.v2, "; " }); } } } else { str1 = string.Concat("Size: ", item.getReferenceCount(str)); } listViewItem.SubItems.Add(str1); } else if (str == "Data") { int referenceValue = 0; if (item.hasReference("cost")) { referenceValue = item.getReferenceValue("cost", 0).v0; } listViewItem.SubItems.Add(referenceValue.ToString()); } else if (!item.ContainsKey(str)) { listViewItem.SubItems.Add("-"); } else { object bah = item[str]; if (bah is int) { GameData.Desc desc1 = GameData.getDesc(item.type, str); if (desc1 != GameData.nullDesc && desc1.defaultValue.GetType().IsEnum) { if (desc1.flags != 256) { string name = Enum.GetName(desc1.defaultValue.GetType(), bah); if (name != null) { bah = name; } } else { bah = (new BitSetProperty(desc1.defaultValue.GetType(), false)).getAsString(bah); } } } listViewItem.SubItems.Add(bah.ToString()); } } return(listViewItem); }
private void addRefColumn_Click(object sender, EventArgs e) { System.Drawing.Size size = new System.Drawing.Size(200, 84); Form form = new Form() { FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog, MinimizeBox = false, MaximizeBox = false, ClientSize = size, Text = "添加列表列" }; ComboBox comboBox = new ComboBox() { Size = new System.Drawing.Size(size.Width - 10, 23), Location = new Point(5, 5), Text = "", AutoCompleteMode = AutoCompleteMode.SuggestAppend, AutoCompleteSource = AutoCompleteSource.ListItems }; foreach (KeyValuePair <string, GameData.Desc> currentFilterDescList in this.getCurrentFilterDescList()) { if (!(currentFilterDescList.Value.defaultValue is GameData.TripleInt)) { continue; } comboBox.Items.Add(currentFilterDescList.Key); } form.Controls.Add(comboBox); CheckBox checkBox = new CheckBox() { Text = "项目", Checked = false, Size = new System.Drawing.Size((size.Width - 10) / 2, 23), Location = new Point(5, 30) }; form.Controls.Add(checkBox); CheckBox checkBox1 = new CheckBox() { Text = "值", Checked = false, Size = new System.Drawing.Size((size.Width - 10) / 2, 23), Location = new Point(size.Width / 2, 30) }; form.Controls.Add(checkBox1); Button button = new Button() { DialogResult = System.Windows.Forms.DialogResult.OK, Name = "okButton", Size = new System.Drawing.Size(75, 23), Text = "(&A)添加", Location = new Point(size.Width - 80 - 80, 56) }; form.Controls.Add(button); Button button1 = new Button() { DialogResult = System.Windows.Forms.DialogResult.Cancel, Name = "cancelButton", Size = new System.Drawing.Size(75, 23), Text = "(&C)取消", Location = new Point(size.Width - 80, 56) }; form.Controls.Add(button1); form.AcceptButton = button; form.CancelButton = button1; if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK && comboBox.Text.Trim() != "") { string str = comboBox.Text.Trim(); ToolStripMenuItem toolStripMenuItem = null; foreach (ToolStripItem dropDownItem in this.columnsMenu.DropDownItems) { if (dropDownItem.Tag == null || !(dropDownItem.Tag.ToString() == str)) { continue; } toolStripMenuItem = dropDownItem as ToolStripMenuItem; goto Label0; } Label0: if (toolStripMenuItem == null) { GameDataList.ColumnInfo columnInfo = this.listView1.AddReferenceColumn(str, str, checkBox.Checked, checkBox1.Checked); toolStripMenuItem = new ToolStripMenuItem(str, null, new EventHandler(this.showColumn_Click)) { Tag = columnInfo, CheckOnClick = true, CheckState = CheckState.Checked }; this.columnsMenu.DropDownItems.Insert(this.columnsMenu.DropDownItems.Count - 3, toolStripMenuItem); return; } if (toolStripMenuItem.CheckState == CheckState.Checked) { this.listView1.RemoveColumn(str); } toolStripMenuItem.Tag = this.listView1.AddReferenceColumn(str, str, checkBox.Checked, checkBox1.Checked); toolStripMenuItem.CheckState = CheckState.Checked; } }