DeserializeFromXML() public method

public DeserializeFromXML ( XmlNode node ) : void
node System.Xml.XmlNode
return void
Ejemplo n.º 1
0
        public override void DeserializeFromXML(XmlNode node)
        {
            base.DeserializeFromXML(node);
            foreach (XmlNode xn in node.ChildNodes)
            {
                if (xn.Name == "Point" &&
                    (xn.Attributes["Name"] != null) &&
                    (xn.Attributes["Name"].Value == "Center")
                    )
                {
                    mCenter.DeserializeFromXML(xn);
                }
            }

            double res = 0;

            if (node.Attributes["Angle"] != null)
            {
                if (double.TryParse(node.Attributes["Angle"].Value, NumberStyles.Float, nfi, out res))
                {
                    mAngle = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse Angle value");
                }
            }
            if (node.Attributes["CropWidth"] != null)
            {
                if (double.TryParse(node.Attributes["CropWidth"].Value, NumberStyles.Float, nfi, out res))
                {
                    mCropWidth = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse CropWidth value");
                }
            }
            if (node.Attributes["CropHeight"] != null)
            {
                if (double.TryParse(node.Attributes["CropHeight"].Value, NumberStyles.Float, nfi, out res))
                {
                    mCropHeight = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse CropHeight value");
                }
            }
            if (node.Attributes["AspectRatio"] != null)
            {
                if (double.TryParse(node.Attributes["AspectRatio"].Value, NumberStyles.Float, nfi, out res))
                {
                    mAspectRatio = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AspectRatio value");
                }
            }

            int ires;

            if (node.Attributes["AspectRatioPreset"] != null)
            {
                if (int.TryParse(node.Attributes["AspectRatioPreset"].Value, out ires))
                {
                    mAspectRatioPreset = ires;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AspectRatioPreset value");
                }
            }
            if (node.Attributes["Mode"] != null)
            {
                if (int.TryParse(node.Attributes["Mode"].Value, out ires))
                {
                    mMode = (CrotateStageOperation.Mode)ires;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse Mode value");
                }
            }

            bool bres;

            if (node.Attributes["AspectRatioCustom"] != null)
            {
                if (bool.TryParse(node.Attributes["AspectRatioCustom"].Value, out bres))
                {
                    mAspectRatioCustom = bres;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AspectRatioCustom value");
                }
            }
            OnChanged();
        }
Ejemplo n.º 2
0
        public override void DeserializeFromXML(XmlNode node)
        {
            base.DeserializeFromXML(node);
            foreach (XmlNode xn in node.ChildNodes)
            {
                if (xn.Name == "Tone" &&
                    xn.Attributes["Name"] != null &&
                    xn.Attributes["Name"].Value == "DarkTone")
                {
                    mDarkTone.DeserializeFromXML(xn);
                }
                if (xn.Name == "Tone" &&
                    xn.Attributes["Name"] != null &&
                    xn.Attributes["Name"].Value == "LightTone")
                {
                    mLightTone.DeserializeFromXML(xn);
                }
                if (xn.Name == "Point" &&
                    xn.Attributes["Name"] != null &&
                    xn.Attributes["Name"].Value == "AutoDarkCenter")
                {
                    mAutoDarkCenter.DeserializeFromXML(xn);
                }
                if (xn.Name == "Point" &&
                    xn.Attributes["Name"] != null &&
                    xn.Attributes["Name"].Value == "AutoLightCenter")
                {
                    mAutoLightCenter.DeserializeFromXML(xn);
                }
            }

            double res = 0;

            if (node.Attributes["Edge"] != null)
            {
                if (double.TryParse(node.Attributes["Edge"].Value, NumberStyles.Float, nfi, out res))
                {
                    mEdge = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse Edge value");
                }
            }

            res = 0;
            if (node.Attributes["Softness"] != null)
            {
                if (double.TryParse(node.Attributes["Softness"].Value, NumberStyles.Float, nfi, out res))
                {
                    mSoftness = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse Softness value");
                }
            }

            res = 0;
            if (node.Attributes["AutoDarkRadius"] != null)
            {
                if (double.TryParse(node.Attributes["AutoDarkRadius"].Value, NumberStyles.Float, nfi, out res))
                {
                    mAutoDarkRadius = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AutoDarkRadius value");
                }
            }

            res = 0;
            if (node.Attributes["AutoLightRadius"] != null)
            {
                if (double.TryParse(node.Attributes["AutoLightRadius"].Value, NumberStyles.Float, nfi, out res))
                {
                    mAutoLightRadius = res;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AutoLightRadius value");
                }
            }

            bool bres = false;

            if (node.Attributes["AutoDarkTone"] != null)
            {
                if (bool.TryParse(node.Attributes["AutoDarkTone"].Value, out bres))
                {
                    mAutoDarkTone = bres;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AutoDarkTone value");
                }
            }

            bres = false;
            if (node.Attributes["AutoLightTone"] != null)
            {
                if (bool.TryParse(node.Attributes["AutoLightTone"].Value, out bres))
                {
                    mAutoLightTone = bres;
                }
                else
                {
                    throw new IncorrectNodeValueException("Can't parse AutoLightTone value");
                }
            }

            OnChanged();
        }