Esempio n. 1
0
    private ThresholdHSVPreset loadPreset(string inPath)
    {
        //init values
        ThresholdHSVPreset loadedPreset = new ThresholdHSVPreset(new ColorHSV(-1, -1, -1), new ColorHSV(-1, -1, -1));

        error = false;

        //open XML file
        doc = new XmlDocument();
        try {
            using (StreamReader sr = new StreamReader(inPath)) {
                doc.LoadXml(sr.ReadToEnd());
            }
        } catch {
            error = true;
        }

        if (!error)
        {
            ColorHSV colorLow  = new ColorHSV();
            ColorHSV colorHigh = new ColorHSV();
            XmlNode  tempNode;

            try {
                //read low bound
                tempNode            = doc.SelectSingleNode("/colortracking/values/colorlow");
                tempNode            = tempNode.FirstChild;
                colorLow.hue        = Convert.ToInt32(tempNode.InnerText);
                tempNode            = tempNode.NextSibling;
                colorLow.saturation = Convert.ToInt32(tempNode.InnerText);
                tempNode            = tempNode.NextSibling;
                colorLow.value      = Convert.ToInt32(tempNode.InnerText);

                //read low bound
                tempNode             = doc.SelectSingleNode("/colortracking/values/colorhigh");
                tempNode             = tempNode.FirstChild;
                colorHigh.hue        = Convert.ToInt32(tempNode.InnerText);
                tempNode             = tempNode.NextSibling;
                colorHigh.saturation = Convert.ToInt32(tempNode.InnerText);
                tempNode             = tempNode.NextSibling;
                colorHigh.value      = Convert.ToInt32(tempNode.InnerText);
            } catch {
                error = true;
            }

            if (!error)
            {
                loadedPreset.lowBound  = colorLow;
                loadedPreset.highBound = colorHigh;
            }
        }

        return(loadedPreset);
    }
Esempio n. 2
0
 public void savePreset(ThresholdHSVPreset inPreset)
 {
     //TODO
 }