Exemple #1
0
        private void mappingAddButton_Click(object sender, EventArgs e)
        {
            String reg    = mappingFilter.Text;
            String pref   = mappingPrefix.Text;
            String local  = localLog.Text;
            String fac    = syslogFacility.Text;
            int    selind = syslogFacility.SelectedIndex;
            bool   trim   = mappingTrim.Checked;

            if (selectedMapping == -1)
            {
                // this next link is a bit of a copout and i should do it better
                Console.WriteLine("stuff is " + reg + " and " + pref + " and " + trim.ToString() + " and " + local + " and " + fac + " which is " + selind);

                singleMapping sm = new singleMapping();

                sm.setFilter(reg);
                sm.setPrefix(pref);
                sm.setTrim(trim);
                sm.setFacility(selind);
                sm.setLocalLog(local);
                mData.addMapping(sm);
            }
            else
            {
                // we're modifying an existing mapping... what could possiblie go wrong?
                mData.getMap(selectedMapping).setFacility(selind);
                mData.getMap(selectedMapping).setFilter(reg);
                mData.getMap(selectedMapping).setPrefix(pref);
                mData.getMap(selectedMapping).setLocalLog(local);
                mData.getMap(selectedMapping).setTrim(trim);
            }
            redrawMappingList();
        }
Exemple #2
0
        public int addMapping(singleMapping sm)
        {
            int i = 0;

            // find the next key
            while (mappings.ContainsKey(i))
            {
                i++;
            }

            mappings.Add(i, sm);

            return(i);
        }
Exemple #3
0
        public bool removeMapping(int map)
        {
            if (!mappings.ContainsKey(map))
            {
                return(false);
            }

            mappings.Remove(map);

            int sval = map + 1;

            while (mappings.ContainsKey(sval))
            {
                singleMapping sm = mappings[sval];
                mappings.Remove(sval);
                mappings[sval - 1] = sm;
                sval++;
            }
            return(true);
        }
Exemple #4
0
        private void mappingListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            int nselectm = mappingListView.SelectedIndex;

            //if (nselectm == -1) return;

            if (nselectm == selectedMapping || nselectm == -1)
            {
                // if we select someting twice, we deselect all.

                // nothing selected, revert forms to default value... perhaps we shouldnt do this?
                // you could select an item like what you want, deselect it and use it to add a new one
                mappingListView.SelectedIndex = -1;
                selectedMapping             = -1;
                mappingRemoveButton.Enabled = false;
                //mappingFilter.Text = "";
                //mappingPrefix.Text = "";
                //localLog.SelectedIndex = 0;
                //syslogFacility.SelectedIndex = 0;
                mappingAddButton.Text = "Add";
                //mappingTrim.Checked = false;
            }
            else
            {
                // somthing is selected, load its data into the form so we can edit it
                selectedMapping             = nselectm;
                mappingRemoveButton.Enabled = true;
                singleMapping sm = mData.getMap(nselectm);

                // supprised this works, but kewl!
                localLog.SelectedIndex       = localLog.FindString(mData.getMap(nselectm).getLocalLog());
                syslogFacility.SelectedIndex = sm.getFacility();
                mappingFilter.Text           = sm.getFilter();
                mappingPrefix.Text           = sm.getPrefix();
                mappingTrim.Checked          = sm.getTrim();

                // change Add to Save
                mappingAddButton.Text = "Modify";
            }
            Console.WriteLine("select changed to " + selectedMapping.ToString());
        }
Exemple #5
0
        public bool fromString(String load)
        {
            String[] sep = { "\r" };
            String[] av  = load.Split(sep, StringSplitOptions.None);

            for (int i = 0; i < av.Length; i++)
            {
                singleMapping ism = new singleMapping();
                Trace.WriteLine("line is " + av[i]);
                if (ism.fromString(av[i]))
                {
                    Trace.WriteLine("added");
                    addMapping(ism);
                }
                else
                {
                    Trace.WriteLine("not added");
                }
            }

            return(true);
        }