private ListViewItem RetrieveVirtualItem(int index) { if (this.itemCache != null && index >= this.cacheOffset && index < this.cacheOffset + (int)this.itemCache.Length) { return(this.itemCache[index - this.cacheOffset]); } if (this.mappedNodes[index] is ChangeListTree.RootNode) { GameData.Item item = (this.mappedNodes[index] as ChangeListTree.RootNode).Item; ListViewItem listViewItem = new ListViewItem(item.Name); ListViewItem.ListViewSubItemCollection subItems = listViewItem.SubItems; itemType _itemType = item.type; subItems.Add(_itemType.ToString(), listViewItem.ForeColor, listViewItem.BackColor, listViewItem.Font); listViewItem.SubItems.Add(""); listViewItem.Checked = this.mappedNodes[index].Checked; listViewItem.ForeColor = StateColours.GetStateColor(item.getState()); listViewItem.Tag = this.mappedNodes[index]; return(listViewItem); } if (!(this.mappedNodes[index] is ChangeListTree.ChangeData)) { return(null); } ChangeListTree.ChangeData changeDatum = this.mappedNodes[index] as ChangeListTree.ChangeData; ListViewItem @checked = new ListViewItem(changeDatum.Text ?? changeDatum.Key); ListViewItem.ListViewSubItemCollection listViewSubItemCollections = @checked.SubItems; ChangeListTree.ChangeType type = changeDatum.Type; listViewSubItemCollections.Add(type.ToString(), @checked.ForeColor, @checked.BackColor, @checked.Font); @checked.SubItems.Add(changeDatum.ToString(), @checked.ForeColor, @checked.BackColor, @checked.Font); @checked.Checked = changeDatum.Checked; @checked.ForeColor = changeDatum.Colour; @checked.Tag = changeDatum; return(@checked); }
public void RefreshList() { ChangeListTree.ChangeData changeDatum; this.Cursor = Cursors.WaitCursor; this.Nodes = new List <ChangeListTree.RootNode>(); foreach (GameData.Item value in this.GameData.items.Values) { if (value.getState() == GameData.State.ORIGINAL || this.Filter != null && !this.Filter.Test(value) || value.getState() == GameData.State.OWNED && !this.ShowNew || value.getState() == GameData.State.MODIFIED && !this.ShowChanged || value.getState() == GameData.State.REMOVED && !this.ShowDeleted || value.getState() == GameData.State.LOCKED || value.getState() == GameData.State.LOCKED_REMOVED || value.getState() == GameData.State.REMOVED && value.OriginalName == null) { continue; } this.Nodes.Add(new ChangeListTree.RootNode(value)); } this.Nodes = ( from o in this.Nodes orderby o.Item.type, o.Item.Name select o).ToList <ChangeListTree.RootNode>(); foreach (ChangeListTree.RootNode node in this.Nodes) { GameData.Item item = node.Item; GameData.State state = item.getState(); if (state == GameData.State.OWNED) { continue; } if (item.Name != item.OriginalName) { ChangeListTree.ChangeData changeDatum1 = new ChangeListTree.ChangeData(ChangeListTree.ChangeType.NAME, item.OriginalName, item.Name, state) { Text = "Name" }; node.Add(changeDatum1); } foreach (KeyValuePair <string, object> keyValuePair in item) { GameData.State state1 = item.getState(keyValuePair.Key); if (state1 == GameData.State.ORIGINAL || state1 == GameData.State.LOCKED) { continue; } node.Add(new ChangeListTree.ChangeData(ChangeListTree.ChangeType.VALUE, keyValuePair.Key, item.OriginalValue(keyValuePair.Key), item[keyValuePair.Key], state1)); } foreach (string str in item.referenceLists()) { GameData.Desc desc = GameData.getDesc(item.type, str); if (!(desc.defaultValue is GameData.TripleInt)) { desc = null; } foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair1 in item.referenceData(str, true)) { GameData.State state2 = item.getState(str, keyValuePair1.Key); if (state2 == GameData.State.ORIGINAL || state2 == GameData.State.LOCKED || state2 == GameData.State.LOCKED_REMOVED) { continue; } ChangeListTree.ChangeData changeDatum2 = null; GameData.Item item1 = this.GameData.getItem(keyValuePair1.Key); if (state2 == GameData.State.REMOVED) { changeDatum2 = new ChangeListTree.ChangeData(ChangeListTree.ChangeType.DELREF, str, keyValuePair1.Key, null, null, state2); } else if (state2 == GameData.State.MODIFIED) { changeDatum2 = new ChangeListTree.ChangeData(ChangeListTree.ChangeType.MODREF, str, keyValuePair1.Key, this.FormatTripleInt(item.OriginalValue(str, keyValuePair1.Key), desc), this.FormatTripleInt(keyValuePair1.Value, desc), state2); } else if (state2 != GameData.State.OWNED) { if (state2 != GameData.State.INVALID) { continue; } changeDatum2 = new ChangeListTree.ChangeData(ChangeListTree.ChangeType.INVALIDREF, str, keyValuePair1.Key, null, this.FormatTripleInt(keyValuePair1.Value, desc), state2); } else { changeDatum2 = new ChangeListTree.ChangeData(ChangeListTree.ChangeType.NEWREF, str, keyValuePair1.Key, null, this.FormatTripleInt(keyValuePair1.Value, desc), state2); } changeDatum2.Text = string.Concat(str, " : ", (item1 == null ? keyValuePair1.Key : item1.Name)); node.Add(changeDatum2); } } foreach (KeyValuePair <string, GameData.Instance> keyValuePair2 in item.instanceData()) { GameData.State state3 = keyValuePair2.Value.getState(); if (state3 == GameData.State.ORIGINAL || state3 == GameData.State.LOCKED || state3 == GameData.State.LOCKED_REMOVED) { continue; } changeDatum = (state3 != GameData.State.OWNED ? new ChangeListTree.ChangeData(ChangeListTree.ChangeType.MODINST, keyValuePair2.Key, state3) : new ChangeListTree.ChangeData(ChangeListTree.ChangeType.NEWINST, keyValuePair2.Key, state3)); changeDatum.Text = string.Concat("Instance : ", keyValuePair2.Key); node.Add(changeDatum); if (state3 != GameData.State.MODIFIED) { continue; } foreach (KeyValuePair <string, object> value1 in keyValuePair2.Value) { if (keyValuePair2.Value.getState(value1.Key) != GameData.State.MODIFIED) { continue; } changeDatum.Add(new ChangeListTree.ChangeData(ChangeListTree.ChangeType.INSTVALUE, keyValuePair2.Key, value1.Key, keyValuePair2.Value.OriginalValue(value1.Key), keyValuePair2.Value[value1.Key], state3)); } } } this.initialiseMap(); this.Cursor = Cursors.Default; }