private static void xamlParseColor(
            TagFile f0,
            bool useAmbient,
            bool useDiffuse,
            bool useSpecular,
            bool useEmission,
            CadObject co)
        {
            //            f0.display();

            String output;
            const String SCOLOR = "Color";
            const String SOPAC = "Opacity";

            String matchD = "DiffuseMaterial";
            String matchS = "SpecularMaterial";
            String matchA = "AmbientMaterial";
            String matchE = "EmissionMaterial";
            String matchX = "SolidColorBrush";

            var matchD_ = f0.getMatches(ref matchD, ref matchX);
            var matchS_ = f0.getMatches(ref matchS, ref matchX);
            var matchA_ = f0.getMatches(ref matchA, ref matchX);
            var matchE_ = f0.getMatches(ref matchE, ref matchX);

            Color diffuse = Color.Black;
            Color specular = Color.Black;
            Color ambient = Color.Black;
            Color emission = Color.Black;

            if (matchD_.Count == 1 && useDiffuse)
            {
                var dict = matchD_[0]._Params;
                if (dict.TryGetValue(SCOLOR, out output))
                {
                    Int32 iColorInt = Convert.ToInt32(output.Substring(1), 16);
                    diffuse = System.Drawing.Color.FromArgb(iColorInt);
                }
                if (dict.TryGetValue(SOPAC, out output))
                {
                    Double a;
                    if (Double.TryParse(output, out a))
                    {
                        Byte alpha = (Byte)Math.Min(255, Math.Max(0, (a * 255)));
                        diffuse = Color.FromArgb(alpha, diffuse);
                    }
                }
            }

            if (matchS_.Count == 1 && useSpecular)
            {
                var dict = matchS_[0]._Params;
                if (dict.TryGetValue(SCOLOR, out output))
                {
                    Int32 iColorInt = Convert.ToInt32(output.Substring(1), 16);
                    specular = System.Drawing.Color.FromArgb(iColorInt);
                }
                if (dict.TryGetValue(SOPAC, out output))
                {
                    Double a;
                    if (Double.TryParse(output, out a))
                    {
                        Byte alpha = (Byte)Math.Min(255, Math.Max(0, (a * 255)));
                        specular = Color.FromArgb(alpha, specular);
                    }
                }
            }

            if (matchA_.Count == 1 && useAmbient)
            {
                var dict = matchA_[0]._Params;
                if (dict.TryGetValue(SCOLOR, out output))
                {
                    Int32 iColorInt = Convert.ToInt32(output.Substring(1), 16);
                    ambient = System.Drawing.Color.FromArgb(iColorInt);
                }
                if (dict.TryGetValue(SOPAC, out output))
                {
                    Double a;
                    if (Double.TryParse(output, out a))
                    {
                        Byte alpha = (Byte)Math.Min(255, Math.Max(0, (a * 255)));
                        ambient = Color.FromArgb(alpha, ambient);
                    }
                }
            }
            else if (useAmbient) ambient = specular;

            if (matchE_.Count == 1 && useEmission)
            {
                var dict = matchE_[0]._Params;
                if (dict.TryGetValue(SCOLOR, out output))
                {
                    Int32 iColorInt = Convert.ToInt32(output.Substring(1), 16);
                    emission = System.Drawing.Color.FromArgb(iColorInt);
                }
                if (dict.TryGetValue(SOPAC, out output))
                {
                    Double a;
                    if (Double.TryParse(output, out a))
                    {
                        Byte alpha = (Byte)Math.Min(255, Math.Max(0, (a * 255)));
                        emission = Color.FromArgb(alpha, emission);
                    }
                }
            }

            co._Color = new ColorGL();
            co._Color._Diffuse[0] = diffuse.R / 255.0f;
            co._Color._Diffuse[1] = diffuse.G / 255.0f;
            co._Color._Diffuse[2] = diffuse.B / 255.0f;
            co._Color._Diffuse[3] = diffuse.A / 255.0f;

            co._Color._Ambient[0] = ambient.R / 255.0f;
            co._Color._Ambient[1] = ambient.G / 255.0f;
            co._Color._Ambient[2] = ambient.B / 255.0f;
            co._Color._Ambient[3] = ambient.A / 255.0f;

            co._Color._Specular[0] = specular.R / 255.0f;
            co._Color._Specular[1] = specular.G / 255.0f;
            co._Color._Specular[2] = specular.B / 255.0f;
            co._Color._Specular[3] = specular.A / 255.0f;

            co._Color._Emission[0] = emission.R / 255.0f;
            co._Color._Emission[1] = emission.G / 255.0f;
            co._Color._Emission[2] = emission.B / 255.0f;
            co._Color._Emission[3] = emission.A / 255.0f;
        }