Ejemplo n.º 1
0
        public FilterDialog()
        {
            InitializeComponent();

            /* add the possbile mesage fields that cause to dump the message */
            lstExcept.Items.Add("IMEI");
            lstExcept.Items.Add("IMEISV");
            lstExcept.Items.Add("IMSI");
            lstExcept.Items.Add("TMSI/P-TMSI");
            lstExcept.Items.Add("Emergency call");


            /* add all known messages */
            foreach (L3MessageInfo info in L3Handler.L3MessagesRadio.Map.Values)
            {
                lstFiltered.Items.Add(info);
            }

            /* pre-select the already skipped messages */
            lock (L3Handler.SkipMessages)
            {
                lstFiltered.SelectedItems.Clear();
                foreach (string reference in L3Handler.SkipMessages.Keys)
                {
                    L3MessageInfo selectedItem = L3Handler.L3MessagesRadio.Get(reference);
                    if (selectedItem != null)
                    {
                        lstFiltered.SelectedItems.Add(selectedItem);
                    }
                }
            }

            /* the same for the exception fields */
            lock (L3Handler.ExceptFields)
            {
                lstExcept.SelectedItems.Clear();
                foreach (string field in L3Handler.ExceptFields.Keys)
                {
                    lstExcept.SelectedItems.Add(field);
                }
            }

            chkExcept.Checked = L3Handler.ExceptFieldsEnabled;
            lstExcept.Enabled = L3Handler.ExceptFieldsEnabled;

            Initializing = false;

            if (!AlreadyLoaded)
            {
                try
                {
                    LoadXml("default.flt.xml");
                }
                catch (Exception)
                {
                }
                AlreadyLoaded = true;
            }
        }
Ejemplo n.º 2
0
        private void LoadXml(string fileName)
        {
            XmlSerializer ser    = new XmlSerializer(typeof(FilterSettings));
            FileStream    stream = new FileStream(fileName, FileMode.Open);

            try
            {
                FilterSettings container = (FilterSettings)ser.Deserialize(stream);

                lstFiltered.SelectedItems.Clear();
                foreach (string reference in container.FilteredMessages)
                {
                    L3MessageInfo selectedItem = L3Handler.L3MessagesRadio.Get(reference);
                    for (int pos = 0; pos < lstFiltered.Items.Count; pos++)
                    {
                        if (lstFiltered.Items[pos].ToString() == selectedItem.ToString())
                        {
                            lstFiltered.SelectedItems.Add(lstFiltered.Items[pos]);
                        }
                    }
                }

                lstExcept.SelectedItems.Clear();
                foreach (string field in container.ExceptionFields)
                {
                    for (int pos = 0; pos < lstExcept.Items.Count; pos++)
                    {
                        if (lstExcept.Items[pos].ToString() == field)
                        {
                            lstExcept.SelectedItems.Add(lstExcept.Items[pos]);
                        }
                    }
                }
            }
            finally
            {
                stream.Close();
            }
        }