Exemple #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();
        }
        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();
        }