private void SaveAllSettings(string fileName) { Store.MessageSessions.Clear(); Store.PacketSessions.Clear(); foreach (ListViewItem item in listViewPacketFilters.Items) { FilterEntry entry = new FilterEntry(); entry.Checked = item.Checked; entry.pType = item.SubItems[1].Text; if(!Store.PacketSessions.ContainsKey(item.Text)) Store.PacketSessions.Add(item.Text, entry); } foreach (ListViewItem item in listViewMessageFilters.Items) { FilterEntry entry = new FilterEntry(); entry.Checked = item.Checked; entry.pType = item.SubItems[1].Text; if(!Store.MessageSessions.ContainsKey(item.Text)) Store.MessageSessions.Add(item.Text, entry); } Store.StatisticsEnabled = enableStatisticsToolStripMenuItem.Checked; Store.AutoScrollEnabled = autoScrollSessionsToolStripMenuItem.Checked; Store.SaveSessionOnExit = saveOptionsOnExitToolStripMenuItem.Checked; Store.AutoCheckNewCaps = autoAddNewDiscoveredMessagesToolStripMenuItem.Checked; Store.SerializeToFile(fileName); }
public void Deserialize(OSDMap map) { if (map.ContainsKey("message_sessions")) { AutoScrollEnabled = map["AutoScrollSessions"].AsBoolean(); StatisticsEnabled = map["CaptureStatistics"].AsBoolean(); SaveSessionOnExit = map["SaveProfileOnExit"].AsBoolean(); AutoCheckNewCaps = map["AutoCheckNewCaps"].AsBoolean(); OSDArray messageArray = (OSDArray)map["message_sessions"]; MessageSessions = new Dictionary<string, FilterEntry>(messageArray.Count); for (int i = 0; i < messageArray.Count; i++) { OSDMap m = (OSDMap)messageArray[i]; FilterEntry entry = new FilterEntry(); entry.Checked = m["Capture"].AsBoolean(); entry.pType = m["Type"].AsString(); MessageSessions.Add(m["Capability"].AsString(), entry); } } else { //MessageSessions = new Dictionary<string, bool>(); } if (map.ContainsKey("packet_sessions")) { OSDArray packetArray = (OSDArray)map["packet_sessions"]; PacketSessions = new Dictionary<string, FilterEntry>(packetArray.Count); for (int i = 0; i < packetArray.Count; i++) { OSDMap packetMap = (OSDMap)packetArray[i]; FilterEntry entry = new FilterEntry(); entry.Checked = packetMap["Capture"].AsBoolean(); entry.pType = packetMap["Type"].AsString(); PacketSessions.Add(packetMap["PacketName"].AsString(), entry); } } else { //PacketSessions = new Dictionary<string, bool>(); } }