Exemple #1
0
 public MetricSetItem(MetricSet mset)
     : base(mset.Name)
 {
     _mset      = mset;
     ImageIndex = 0;
 }
Exemple #2
0
 public void RemoveMetricSet(MetricSet ms)
 {
     _sets.Remove(ms.Name);
 }
Exemple #3
0
 public void AddMetricSet(MetricSet ms)
 {
     _sets.Add(ms.Name, ms);
 }
Exemple #4
0
        private XmlDocument AppendMetricSets()
        {
            XmlNode      setsNode = null;
            XmlNode      setNode = null;
            XmlNode      metNode = null;
            XmlAttribute setName, metId, metBound;
            XmlDocument  upd     = (XmlDocument)_doc.Clone();
            Hashtable    renamed = new Hashtable();

            if (_sets.Count > 0)
            {
                setsNode = upd.CreateElement("sets");
                upd.DocumentElement.AppendChild(setsNode);
            }

            if (setsNode == null)
            {
                return(null);
            }

            IEnumerator e = _sets.Values.GetEnumerator();

            while (e.MoveNext())
            {
                MetricSet ms = (MetricSet)e.Current;
                renamed[ms.Name] = ms;
                setNode          = upd.CreateElement("set");
                setName          = upd.CreateAttribute("name");
                setName.Value    = ms.Name;
                setNode.Attributes.Append(setName);

                IEnumerator ed = ms.GetEnumerator();
                while (ed.MoveNext())
                {
                    MetricDef md = (MetricDef)ed.Current;
                    metNode     = upd.CreateElement("met");
                    metId       = upd.CreateAttribute("id");
                    metId.Value = md.Id.ToString();
                    metNode.Attributes.Append(metId);

                    if (md.LowerBound)
                    {
                        metBound       = upd.CreateAttribute("lower");
                        metBound.Value = md.LowerValue.ToString();
                        metNode.Attributes.Append(metBound);
                    }

                    if (md.UpperBound)
                    {
                        metBound       = upd.CreateAttribute("upper");
                        metBound.Value = md.UpperValue.ToString();
                        metNode.Attributes.Append(metBound);
                    }

                    setNode.AppendChild(metNode);
                }

                setsNode.AppendChild(setNode);
            }

            _sets = renamed;
            return(upd);
        }
Exemple #5
0
        public void ParseFile()
        {
            XmlTextReader txtreader = null;
            XmlReader     reader = null;
            IEnumerator   el, ef, ee = null;

            try
            {
                // Load the reader with the data file and ignore all whitespace nodes.
                txtreader = new XmlTextReader(UserConfigFile.FullName);
                txtreader.WhitespaceHandling = WhitespaceHandling.None;
                reader = XmlReader.Create(txtreader.GetRemainder());

                _doc.Load(reader);

                XmlNode          root = _doc.DocumentElement;
                XmlNode          lang;
                XmlNode          ftype;
                XmlNode          ext;
                XmlNode          a, a2, au, al;
                Hashtable        ftypes;
                Hashtable        exts;
                string           sLang, sFiletype;
                MetricCollection metrics = KrakatauSettings.Settings.Metrics;

                el = root.ChildNodes.GetEnumerator();
                while (el.MoveNext())
                {
                    lang = (XmlNode)el.Current;
                    if (lang.Name.Equals("lang"))
                    {
                        a = lang.Attributes.GetNamedItem("name");
                        if (a != null && !"".Equals(a.Value))
                        {
                            sLang  = a.Value;
                            ftypes = new Hashtable();
                            _config.Add(sLang, ftypes);

                            ef = lang.ChildNodes.GetEnumerator();
                            while (ef.MoveNext())
                            {
                                ftype = (XmlNode)ef.Current;
                                if (ftype.Name.Equals("filetype"))
                                {
                                    a = ftype.Attributes.GetNamedItem("name");
                                    if (a != null && !"".Equals(a.Value))
                                    {
                                        sFiletype = a.Value;
                                        exts      = new Hashtable();
                                        ftypes.Add(sFiletype, exts);

                                        ee = ftype.ChildNodes.GetEnumerator();
                                        while (ee.MoveNext())
                                        {
                                            ext = (XmlNode)ee.Current;
                                            a   = ext.Attributes.GetNamedItem("name");
                                            a2  = ext.Attributes.GetNamedItem("value");

                                            if (a != null && !"".Equals(a.Value) && a2 != null && !"".Equals(a2.Value))
                                            {
                                                Ext e = new Ext(a.Value, a2.Value, sFiletype, sLang);
                                                exts.Add(e.Extension, e);
                                                _list.Add(e.ToString(), e);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (lang.Name.Equals("sets"))
                    {
                        ef = lang.ChildNodes.GetEnumerator();
                        while (ef.MoveNext())
                        {
                            ftype = (XmlNode)ef.Current;
                            if (ftype.Name.Equals("set"))
                            {
                                a = ftype.Attributes.GetNamedItem("name");
                                if (a != null && !"".Equals(a.Value))
                                {
                                    MetricSet ms = new MetricSet(a.Value);
                                    _sets.Add(ms.Name, ms);
                                    ee = ftype.ChildNodes.GetEnumerator();
                                    while (ee.MoveNext())
                                    {
                                        ext = (XmlNode)ee.Current;
                                        a   = ext.Attributes.GetNamedItem("id");
                                        au  = ext.Attributes.GetNamedItem("upper");
                                        al  = ext.Attributes.GetNamedItem("lower");

                                        if (a != null && !"".Equals(a.Value))
                                        {
                                            MetricDef md = new MetricDef(metrics[long.Parse(a.Value)]);
                                            if (au != null && !"".Equals(au.Value))
                                            {
                                                md.Upper(long.Parse(au.Value));
                                            }
                                            if (al != null && !"".Equals(al.Value))
                                            {
                                                md.Lower(long.Parse(al.Value));
                                            }
                                            ms.Add(md);
                                        }
                                    }
                                }
                            }
                        }
                        // Now remove the Metric Sets as they will be rebuilt during application execution.
                        root.RemoveChild(lang);
                    }
                }
            }

            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Exemple #6
0
        public MetricDef(Metric metric, CheckBox chkMet, CheckBox chkLower, TextBox txtLower, CheckBox chkUpper, TextBox txtUpper, MetricSet ms)
        {
            this._metric   = metric;
            this._chkMet   = chkMet;
            this._chkLower = chkLower;
            this._txtLower = txtLower;
            this._chkUpper = chkUpper;
            this._txtUpper = txtUpper;

            if (ms != null)
            {
                if (ms.Contains(Metric.Id))
                {
                    MetricDef existing = ms[Metric.Id];
                    this._lowerBound = existing._lowerBound;
                    this._lowerValue = existing._lowerValue;
                    this._upperBound = existing._upperBound;
                    this._upperValue = existing._upperValue;

                    this._chkMet.Checked = true;
                    if (this._lowerBound)
                    {
                        this._chkLower.Checked = true;
                        this._txtLower.Text    = this._lowerValue.ToString();
                    }
                    if (this._upperBound)
                    {
                        this._chkUpper.Checked = true;
                        this._txtUpper.Text    = this._upperValue.ToString();
                    }
                }
            }
        }