Пример #1
0
        /// <summary>
        /// Read the attribute values of this class from XML.
        /// </summary>
        /// <param name="readerName"></param>
        /// <param name="readerValue"></param>
        /// <returns></returns>
        private bool ReadAttributes(string readerName, string readerValue)
        {
            switch (readerName)
            {
            case "Name":
                this.Name = readerValue;
                return(true);

            case "ID":
                this.ID = readerValue;
                return(true);

            case "Position":
                double[] size = FrameworkUtilities.GetDoubleAttributes(readerValue, 2, new double[] { 100, 100 });
                this.Position = new Point(size[0], size[1]);
                return(true);

            case "xmlns":
                if (readerValue != NameSpace)
                {
                    throw new ArgumentException("XML namespace:'" + readerValue + "' is not supported.");
                }
                return(true);

            default:
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// Read an attribute value from the given string and return true if it was successful,
        /// otherwise, return false.
        /// </summary>
        /// <param name="readerName"></param>
        /// <param name="readerValue"></param>
        /// <returns></returns>
        public bool ReadAttribute(string readerName, string readerValue)
        {
            switch (readerName)
            {
            case "Size":
                double[] size = FrameworkUtilities.GetDoubleAttributes(readerValue, 2,
                                                                       new double[] { DefaultXSize, DefaultYSize });
                this.prop_PageSize = new Size(size[0], size[1]);
                return(true);

            case "xmlns":
                if (readerValue != PageViewModelBase.NameSpace)
                {
                    throw new ArgumentException("XML namespace:'" + readerValue + "' is not supported.");
                }

                return(true);

            default:
                if (readerName.Trim().Length > 0 && readerName != PageViewModelBase.XmlComment)
                {
                    throw new ArgumentException("XML node:'" + readerName + "' as child of '" + PageViewModel.XmlElementName + "' is not supported.");
                }
                break;
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Read the attribute values of this class from XML.
        /// </summary>
        /// <param name="readerName"></param>
        /// <param name="readerValue"></param>
        /// <returns></returns>
        protected virtual bool ReadAttributes(string readerName, string readerValue)
        {
            switch (readerName)
            {
            case "Position":
                double[] size = FrameworkUtilities.GetDoubleAttributes(readerValue, 4,
                                                                       new double[] { 100, 100, 200, 200 });
                this.Position = new System.Windows.Point(size[0], size[1]);
                this.Width    = size[2];
                this.Height   = size[3];
                return(true);

            case "ID":
                this.ID = readerValue;
                return(true);

            case "Name":
                this.Name = readerValue;
                return(true);

            case "xmlns":
                if (readerValue != NameSpace)
                {
                    throw new ArgumentException("XML namespace:'" + readerValue + "' is not supported.");
                }
                return(true);

            default:
                return(false);
            }
        }