public void ReadXml(System.Xml.XmlReader reader)
 {
     reader.MoveToContent(); 
     this.Code = reader.ReadElementContentAsInt();
     this.Message = reader.ReadElementContentAsString();
     this.DataAreaId = reader.ReadElementContentAsString();
 }
Пример #2
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {

            if (reader.LocalName != "count" && !reader.ReadToFollowing("count"))
            {
                UtilityMethods.CheckParsingException(reader);
                return;
            }

            Count = reader.ReadElementContentAsInt();

            if( reader.LocalName != "prevphotos" ) reader.ReadToFollowing("prevphotos");
            reader.ReadToDescendant("photo");
            while (reader.LocalName == "photo")
            {
                FavoriteContextPhoto photo = new FavoriteContextPhoto();
                ((IFlickrParsable)photo).Load(reader);
                PreviousPhotos.Add(photo);
            }

            if (reader.LocalName != "nextphotos") reader.ReadToFollowing("nextphotos");
            reader.ReadToDescendant("photo");
            while (reader.LocalName == "photo")
            {
                FavoriteContextPhoto photo = new FavoriteContextPhoto();
                ((IFlickrParsable)photo).Load(reader);
                NextPhotos.Add(photo);
            }
        }
Пример #3
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     m_stairMapping = new Dictionary<Guid, Point>();
     reader.ReadStartElement();
     int count = reader.ReadElementContentAsInt();
     for (int i = 0; i < count; ++i)
     {
         Guid g = new Guid(reader.ReadElementContentAsString());
         Point destination = new Point();
         destination = destination.ReadXml(reader);
         m_stairMapping[g] = destination;
     }
     reader.ReadEndElement();
 }
Пример #4
0
 internal override void ReadXml(System.Xml.XmlReader reader)
 {
     m_damagePerInterval = reader.ReadElementContentAsInt();
     m_castByPlayer = bool.Parse(reader.ReadElementContentAsString());
 }
Пример #5
0
 public static int readItemId(System.Xml.XmlReader reader)
 {
     return reader.ReadElementContentAsInt();
 }
Пример #6
0
        private void LoadElements(System.Xml.XmlReader reader)
        {
            while (reader.LocalName != "photo")
            {
                switch (reader.LocalName)
                {
                    case "owner":
                        ParseOwner(reader);
                        break;
                    case "title":
                        Title = reader.ReadElementContentAsString();
                        break;
                    case "description":
                        Description = reader.ReadElementContentAsString();
                        break;
                    case "visibility":
                        ParseVisibility(reader);
                        break;
                    case "permissions":
                        ParsePermissions(reader);
                        break;
                    case "editability":
                        ParseEditability(reader);
                        break;
                    case "publiceditability":
                        ParsePublicEditability(reader);
                        break;
                    case "dates":
                        ParseDates(reader);
                        break;
                    case "usage":
                        ParseUsage(reader);
                        break;
                    case "comments":
                        CommentsCount = reader.ReadElementContentAsInt();
                        break;
                    case "notes":
                        ParseNotes(reader);
                        break;
                    case "tags":
                        ParseTags(reader);
                        break;
                    case "urls":
                        ParseUrls(reader);
                        break;
                    case "location":
                        Location = new PlaceInfo();
                        ((IFlickrParsable)Location).Load(reader);
                        break;
                    case "people":
                        ParsePeople(reader);
                        break;
                    case "geoperms":
                        GeoPermissions = new GeoPermissions();
                        ((IFlickrParsable)GeoPermissions).Load(reader);
                        break;
                    case "video":
                        VideoInfo = new VideoInfo();
                        ((IFlickrParsable)VideoInfo).Load(reader);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        reader.Skip();
                        break;

                }
            }

            reader.Skip();
        }
Пример #7
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     //读取工位号
     reader.MoveToAttribute("Number");
     this.Number = reader.ReadContentAsInt();
     //读取铣形环绕方向
     reader.MoveToAttribute("MillDirection");
     this.MillDirection = (Direction)Enum.Parse(typeof(Direction), reader.ReadContentAsString());
     //读取切边环绕方向
     reader.MoveToAttribute("CutDirection");
     this.CutDirection = (Direction)Enum.Parse(typeof(Direction), reader.ReadContentAsString());
     //开始读取工位信息
     reader.ReadStartElement("Station");
     //读取内外侧面切换高度
     this.InOutChangeHeight = reader.ReadElementContentAsInt("InOutChangeHeight", "");
     //读取对刀点
     this.ZeroPoint.ReadXml(reader, "ZeroPoint");
     //开始读取工序列表
     reader.ReadStartElement("ProcessList");
     while (XmlNodeType.Element == reader.NodeType) {
         ProcessList.Add(new Process());
         ProcessList.Last().ReadXml(reader);
     }
     //结束读取工位列表
     reader.ReadEndElement();
     //开始读取切边点列表
     reader.ReadStartElement("CutPointList");
     while (XmlNodeType.Element == reader.NodeType) {
         CutPointList.Add(new CutPoint());
         CutPointList.Last().ReadXml(reader, "CutPoint");
     }
     //结束读取切边点列表
     reader.ReadEndElement();
     //读取工位信息结束
     reader.ReadEndElement();
 }
Пример #8
0
            private void readTrackDesignerBitmapTag(ref System.Xml.XmlReader xmlReader)
            {
                bool bitmapFound = xmlReader.ReadToDescendant("TDBitmap");
                // instanciate the list of bitmap id
                if (bitmapFound)
                    mTDRemapData.mConnexionData = new List<TDRemapData.ConnexionData>();

                while (bitmapFound)
                {
                    // instanciate a connection point for the current connexion
                    TDRemapData.ConnexionData connexionData = new TDRemapData.ConnexionData();

                    // read the first child node
                    xmlReader.Read();
                    bool continueToRead = !xmlReader.EOF;
                    while (continueToRead)
                    {
                        if (xmlReader.Name.Equals("BBConnexionPointIndex"))
                            connexionData.mBBConnexionPointIndex = xmlReader.ReadElementContentAsInt();
                        else if (xmlReader.Name.Equals("Type"))
                            connexionData.mType = xmlReader.ReadElementContentAsInt();
                        else if (xmlReader.Name.Equals("AngleBetweenTDandBB"))
                            connexionData.mDiffAngleBtwTDandBB = xmlReader.ReadElementContentAsFloat();
                        else
                            xmlReader.Read();

                        // check if we need to continue
                        continueToRead = !xmlReader.Name.Equals("TDBitmap") && !xmlReader.EOF;
                    }

                    // add the current connexion in the list
                    mTDRemapData.mConnexionData.Add(connexionData);

                    // go to next bitmap
                    bitmapFound = !xmlReader.EOF && xmlReader.ReadToNextSibling("TDBitmap");
                }

                // finish the bitmap list
                if (!xmlReader.EOF)
                    xmlReader.ReadEndElement();
            }
Пример #9
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            reader.Read();

            while (reader.LocalName != "photos")
            {
                switch (reader.LocalName)
                {
                    case "firstdatetaken":
                        FirstTakenDate = UtilityMethods.ParseDateWithGranularity(reader.ReadElementContentAsString());
                        break;
                    case "firstdate":
                        FirstDate = UtilityMethods.UnixTimestampToDate(reader.ReadElementContentAsString());
                        break;
                    case "count":
                        PhotoCount = reader.ReadElementContentAsInt();
                        break;
                    case "views":
                        Views = reader.ReadElementContentAsInt();
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        reader.Skip();
                        break;
                }
            }

            reader.Read();
        }
Пример #10
0
 public void readVersionNumber(System.Xml.XmlReader reader)
 {
     reader.ReadToDescendant("Version");
     mDataVersionOfTheFileLoaded = reader.ReadElementContentAsInt();
 }
Пример #11
0
            private void readConnexionListTag(ref System.Xml.XmlReader xmlReader, Dictionary<string, int> connectionRemapingDictionary)
            {
                if (!xmlReader.IsEmptyElement)
                {
                    // the connexion
                    bool connexionFound = xmlReader.ReadToDescendant("connexion");
                    if (connexionFound)
                    {
                        mConnectionPoints = new List<ConnectionPoint>();
                        mConnectionPositionList = new List<PointF>();
                    }

                    while (connexionFound)
                    {
                        // instanciate a connection point for the current connexion
                        ConnectionPoint connectionPoint = new ConnectionPoint();

                        // read the first child node of the connexion
                        xmlReader.Read();
                        bool continueToReadConnexion = true;
                        while (continueToReadConnexion)
                        {
                            if (xmlReader.Name.Equals("type"))
                                connectionPoint.mType = readConnectionType(ref xmlReader, connectionRemapingDictionary);
                            else if (xmlReader.Name.Equals("position"))
                                connectionPoint.mPosition = readPointTag(ref xmlReader, "position");
                            else if (xmlReader.Name.Equals("angle"))
                                connectionPoint.mAngle = xmlReader.ReadElementContentAsFloat();
                            else if (xmlReader.Name.Equals("angleToPrev"))
                                connectionPoint.mAngleToPrev = xmlReader.ReadElementContentAsFloat();
                            else if (xmlReader.Name.Equals("angleToNext"))
                                connectionPoint.mAngleToNext = xmlReader.ReadElementContentAsFloat();
                            else if (xmlReader.Name.Equals("nextConnexionPreference"))
                                connectionPoint.mNextPreferedIndex = xmlReader.ReadElementContentAsInt();
                            else if (xmlReader.Name.Equals("electricPlug"))
                                connectionPoint.mElectricPlug = xmlReader.ReadElementContentAsInt();
                            else
                                xmlReader.Read();
                            // check if we reach the end of the connexion
                            continueToReadConnexion = !xmlReader.Name.Equals("connexion") && !xmlReader.EOF;
                        }

                        // add the current connexion in the list
                        mConnectionPoints.Add(connectionPoint);
                        mConnectionPositionList.Add(connectionPoint.mPosition);

                        // go to next connexion
                        connexionFound = !xmlReader.EOF && xmlReader.ReadToNextSibling("connexion");
                    }
                    // finish the connexion
                    if (!xmlReader.EOF)
                        xmlReader.ReadEndElement();

                    // build the electric circuit if these connections are electrical
                    // to know if there's a circuit between two connections, we must find pairs like
                    // 1/-1 or 2/-2 or 3/-3, etc...
                    if (mConnectionPoints != null)
                    {
                        int nbPossibleCircuits = mConnectionPoints.Count - 1;
                        for (int i = 0; i < nbPossibleCircuits; ++i)
                            for (int j = i + 1; j < mConnectionPoints.Count; ++j)
                                if ((mConnectionPoints[i].mElectricPlug != 0) &&
                                    (mConnectionPoints[i].mElectricPlug == -mConnectionPoints[j].mElectricPlug))
                                {
                                    // we found a circuit, so create the list if not already done
                                    if (this.mElectricCircuitList == null)
                                        this.mElectricCircuitList = new List<ElectricCircuit>();
                                    // compute the distance between the two connection (length of the circuit)
                                    PointF distance = new PointF(	mConnectionPoints[i].mPosition.X - mConnectionPoints[j].mPosition.X,
                                                                    mConnectionPoints[i].mPosition.Y - mConnectionPoints[j].mPosition.Y);
                                    float length = (float)Math.Sqrt((distance.X * distance.X) + (distance.Y * distance.Y));
                                    // add the new circuit in the list
                                    this.mElectricCircuitList.Add(new ElectricCircuit(i, j, length));
                                }
                    }
                }
                else
                {
                    xmlReader.Read();
                }
            }
Пример #12
0
 public override void ReadXml(System.Xml.XmlReader reader)
 {
     base.ReadXml(reader);
     GridColor = XmlReadWrite.readColor(reader);
     GridThickness = reader.ReadElementContentAsFloat();
     SubGridColor = XmlReadWrite.readColor(reader);
     SubGridThickness = reader.ReadElementContentAsFloat();
     mGridSizeInStud = reader.ReadElementContentAsInt();
     mSubDivisionNumber = Math.Max(reader.ReadElementContentAsInt(), 2);
     if (reader.Name.Equals("DisplayGrid"))
         mDisplayGrid = reader.ReadElementContentAsBoolean();
     mDisplaySubGrid = reader.ReadElementContentAsBoolean();
     mDisplayCellIndex = reader.ReadElementContentAsBoolean();
     mCellIndexFont = XmlReadWrite.readFont(reader);
     CellIndexColor = XmlReadWrite.readColor(reader);
     mCellIndexColumnType = (CellIndexType)reader.ReadElementContentAsInt();
     mCellIndexRowType = (CellIndexType)reader.ReadElementContentAsInt();
     mCellIndexCorner = XmlReadWrite.readPoint(reader);
     // step the progress bar for the grid
     MainForm.Instance.stepProgressBar();
 }
Пример #13
0
        public virtual void ReadXml(System.Xml.XmlReader reader)
        {
            // The budget is already cleared cause a new instance of Budget is created for serialization

            // set the existing flag to false before reading. If the reading goes well (no exception thrown) we will set it to true
            mIsExisting = false;

            // version
            reader.ReadToDescendant("Version");
            mDataVersionOfTheFileLoaded = reader.ReadElementContentAsInt();

            // read the parts
            bool partFound = reader.ReadToDescendant("Part");
            while (partFound)
            {
                // read the part name and value (get the new value if it was renamed)
                string partId = BrickLibrary.Instance.getActualPartNumber(reader.GetAttribute("id"));
                int budget = reader.ReadElementContentAsInt();
                // and set the budget
                mBudget.Add(partId, budget);
                // read the next part
                partFound = reader.Name.Equals("Part");
            }
            // read the PartList tag, to finish the list of parts
            reader.Read();

            // after that the reading went well (no exception thrown)
            // set the flag to tell that the budget now exists
            mIsExisting = true;
            // reset the was modified flag cause we just load a new budget
            this.WasModified = false;
        }
Пример #14
0
            public override void ReadXml(System.Xml.XmlReader reader)
            {
                // read the id of the brick, then add this brick in the hashtable
                if (Map.DataVersionOfTheFileLoaded >= 7)
                {
                    int brickId = int.Parse(reader.GetAttribute(0));
                    Id = brickId.ToString();
                    Map.sHashtableForRulerAttachementRebuilding.Add(brickId, this);
                }
                // read the base class
                base.ReadXml(reader);
                // avoid using the accessor to reduce the number of call of updateBitmap
                mPartNumber = BrickLibrary.Instance.getActualPartNumber(reader.ReadElementContentAsString().ToUpperInvariant());
                // but then update its electric list
                mElectricCircuitIndexList = BrickLibrary.Instance.getElectricCircuitList(mPartNumber);
                mOrientation = reader.ReadElementContentAsFloat();
                mActiveConnectionPointIndex = reader.ReadElementContentAsInt();
                // the altitude
                if (Map.DataVersionOfTheFileLoaded >= 3)
                    mAltitude = reader.ReadElementContentAsFloat();
                // update the bitmap
                updateImage();
                updateSnapMargin();
                // read the connexion points if any
                reader.ReadAttributeValue();
                int count = int.Parse(reader.GetAttribute(0));

                // check the number of connection is the same in the Brick library and in the loading file.
                // They can be different if the file was saved with an old part library and then one part
                // was updated to add or remove connection. So there is 3 different cases:
                // - if they are the same: no problems.
                // - if there is more connections in the part lib than in the file: we reserve enough space in the list,
                // based on the library value, and then we will add empty connections instances to fullfill the list
                // after finishing reading the connection tag.
                // - if there is more parts in the file than in the list, we need to discard some connection,
                // so we add a check in the parsing to create the last connections as default one (of type brick).
                // This will ensure that the link will be broken (because all connections or type BRICK are
                // broken after the loading of the file is finished) and then the GC will destroy these connections.
                // And of course the list is reserved based on the library value.

                // So first, we ask the number of connection to the part lib then allocate
                // the list of connection based on the number set in the library and not the number
                // read in the file, because finally the number of connection must be like the part lib says
                int connectionCountInBrickLibrary = BrickLibrary.Instance.getConnectionCount(mPartNumber);
                if (connectionCountInBrickLibrary > 0)
                    mConnectionPoints = new List<ConnectionPoint>(connectionCountInBrickLibrary);

                // now check if we need to parse some connection in the file
                if (count > 0)
                {
                    // declare a counter for the connections
                    int connexionIndex = 0;
                    bool connexionFound = reader.ReadToDescendant("Connexion");
                    while (connexionFound)
                    {
                        // a boolean saying if the current connection is valid or will be destroyed later
                        // because it is over the number indicated by the part library
                        // be careful mConnectionPoints can be null, so use the int var instead
                        bool isConnectionValid = (connexionIndex < connectionCountInBrickLibrary);

                        // read the id (hashcode key) of the connexion
                        reader.ReadAttributeValue();
                        String id = reader.GetAttribute(0);
                        int hashCode = int.Parse(id.Substring(1));

                        // look in the hastable if this connexion alread exists, else create it
                        ConnectionPoint connexion = ConnectionPoint.sHashtableForLinkRebuilding[hashCode] as ConnectionPoint;
                        if (connexion == null)
                        {
                            // instanciate a ConnectionPoint, and add it in the hash table
                            if (isConnectionValid)
                                connexion = new ConnectionPoint(this, connexionIndex);
                            else
                                connexion = new ConnectionPoint();
                            ConnectionPoint.sHashtableForLinkRebuilding.Add(hashCode, connexion);
                        }
                        else
                        {
                            // set the connexion type, if not set during the above creation
                            if (isConnectionValid)
                                connexion.Type = BrickLibrary.Instance.getConnexionType(this.PartNumber, connexionIndex);
                        }

                        //read the connexion data and add it in the Connection list
                        connexion.mMyBrick = this;
                        connexion.ReadXml(reader);

                        // during the reading of the connection list in the file, we check if
                        // we didn't reached the limit of the part library. If there is more connection
                        // in the file than in the part lib, we continue to read the connections,
                        // but we don't add them in the connection list.
                        if (isConnectionValid)
                            mConnectionPoints.Add(connexion);

                        // increment the connexion index
                        connexionIndex++;

                        // read the next brick
                        connexionFound = reader.ReadToNextSibling("Connexion");
                    }
                    reader.ReadEndElement();

                    // check if we read all the connections in the file, if not we have to instanciate
                    // empty connection to fullfill the list
                    if (mConnectionPoints != null)
                        for (int i = mConnectionPoints.Count; i < mConnectionPoints.Capacity; ++i)
                        {
                            ConnectionPoint connexion = new ConnectionPoint(this, i);
                            mConnectionPoints.Add(connexion);
                            // we don't need to add this connection in the hastable since we know this
                            // connection doesn't exist in the file, so there is no link attached to it
                        }

                    // update the connexion position which is not stored in the bbm file
                    // in file version before 3 it was stored, but I removed it because the connexion
                    // point can move in different part libraries
                    updateConnectionPosition();
                }
                else
                {
                    reader.Read();
                }
                // read the end element of the brick
                reader.ReadEndElement();
            }
Пример #15
0
            private void readTrackDesignerTag(ref System.Xml.XmlReader xmlReader)
            {
                // check if the track designer is not empty
                if (!xmlReader.IsEmptyElement)
                {
                    // the Track designer tag is not empty, instanciate the class that will hold the data
                    mTDRemapData = new TDRemapData();

                    // read the first child node
                    xmlReader.Read();
                    bool continueToRead = !xmlReader.EOF;
                    while (continueToRead)
                    {
                        if (xmlReader.Name.Equals("ID"))
                            readTrackDesignerIDTag(ref xmlReader);
                        else if (xmlReader.Name.Equals("IDList"))
                            readTrackDesignerIDListTag(ref xmlReader);
                        else if (xmlReader.Name.Equals("Flag"))
                            mTDRemapData.mFlags = xmlReader.ReadElementContentAsInt();
                        else if (xmlReader.Name.Equals("HasSeveralGeometries"))
                            mTDRemapData.mHasSeveralPort = xmlReader.ReadElementContentAsBoolean();
                        else if (xmlReader.Name.Equals("TDBitmapList"))
                            readTrackDesignerBitmapTag(ref xmlReader);
                        else
                            xmlReader.Read();

                        // check if we need to continue
                        continueToRead = !xmlReader.Name.Equals("TrackDesigner") && !xmlReader.EOF;
                    }

                    // finish the track designer tag
                    if (!xmlReader.EOF)
                        xmlReader.ReadEndElement();
                }
                else
                {
                    xmlReader.Read();
                }
            }
Пример #16
0
 private void readTrackDesignerIDTag(ref System.Xml.XmlReader xmlReader)
 {
     // check if the id list is not empty
     if (!xmlReader.IsEmptyElement)
     {
         // get the registry attribute if any
         string registry = "default";
         if (xmlReader.HasAttributes)
             registry = xmlReader.GetAttribute("registry");
         // read the int id
         int id = xmlReader.ReadElementContentAsInt();
         // add it to the id class (that can maintain several ids)
         mTDRemapData.mTDId.addId(registry, id);
     }
     else
     {
         xmlReader.Read();
     }
 }
Пример #17
0
 public static Point readPoint(System.Xml.XmlReader reader)
 {
     reader.ReadToDescendant("X");
     int x = reader.ReadElementContentAsInt();
     int y = reader.ReadElementContentAsInt();
     reader.ReadEndElement();
     return new Point(x, y);
 }
Пример #18
0
	/// <summary>
	/// Loads the inventory from XML.
	/// </summary>
	/// <param name="reader">Reader.</param>
	public void LoadInventory(System.Xml.XmlReader reader) {
		int itemCount = 0;
		reader.ReadToFollowing ("Inventory");
		reader.ReadToDescendant ("Item");
		do {
			string id = reader.GetAttribute ("ID");
			inventory [itemCount] = database [int.Parse (id)].Clone ();
			reader.ReadToDescendant ("Quantity");
			inventory [itemCount].stackSize = reader.ReadElementContentAsInt();
			Debug.Log ("Just parsed " + inventory [itemCount]);
			itemCount++;
			reader.ReadEndElement();
		} while(reader.ReadToNextSibling("Item"));
		reader.ReadEndElement ();
	}
Пример #19
0
        public void ReadXml(System.Xml.XmlReader r)
        {
            bool wasEmpty = r.IsEmptyElement;
            if (wasEmpty)
                return;
            _variable = r.GetAttribute("Map");
            r.Read();							//<AddressInstance>
            _startAddress = Convert.ToUInt32(r.ReadElementContentAsString(), 16);
            _X = r.ReadElementContentAsInt();
            _Y = r.ReadElementContentAsInt();
            _mapSize = r.ReadElementContentAsInt();
            _value = r.ReadElementContentAsInt();
            _byteOnCell = r.ReadElementContentAsInt();
            _mapName = r.ReadElementContentAsString();
            _comment = r.ReadElementContentAsString();

            r.Read();
            {									//<FRom>
                _sizeOfCellX = r.ReadElementContentAsInt();
                _sizeOfCellY = r.ReadElementContentAsInt();
                _loColor = (int)Convert.ToUInt32(r.ReadElementContentAsString(), 16);
                _hiColor = (int)Convert.ToUInt32(r.ReadElementContentAsString(), 16);
                _xSatteliteConstName = r.ReadElementContentAsString();
                _ySatteliteConstName = r.ReadElementContentAsString();
                _hide = r.ReadElementContentAsBoolean();
                _flip = r.ReadElementContentAsBoolean();
                _mask = (byte)r.ReadElementContentAsInt();
                _mapView = (ViewEnum)r.ReadElementContentAsInt();
            } r.ReadEndElement();				//</FRom>
            r.ReadEndElement();					//</AddressInstance>
        }
Пример #20
0
 internal override void ReadXml(System.Xml.XmlReader reader)
 {
     m_level = reader.ReadElementContentAsInt();
 }
Пример #21
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            // reset the counter of modifications because we just load the map (no modification done)
            mNumberOfModificationSinceLastSave = 0;
            // version
            readVersionNumber(reader);
            // check if the BlueBrick program is not too old, that
            // means the user try to load a file generated with
            /// a earlier version of BlueBrick
            if (mDataVersionOfTheFileLoaded > CURRENT_DATA_VERSION)
            {
                MessageBox.Show(null, Properties.Resources.ErrorMsgProgramObsolete,
                    Properties.Resources.ErrorMsgTitleError, MessageBoxButtons.OK,
                    MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }
            // get the number of layer for the progressbar
            if (mDataVersionOfTheFileLoaded >= 3)
            {
                int nbItems = reader.ReadElementContentAsInt();
                // init the progress bar with the real number of layer items (+1 for the header +1 for the link rebuilding)
                MainForm.Instance.resetProgressBar(nbItems + 2);
            }
            // check is there is a background color
            if (reader.Name.Equals("BackgroundColor"))
                mBackgroundColor = XmlReadWrite.readColor(reader);
            // data of the map
            mAuthor = reader.ReadElementContentAsString();
            mLUG = reader.ReadElementContentAsString();
            mShow = reader.ReadElementContentAsString();
            reader.ReadToDescendant("Day");
            int day = reader.ReadElementContentAsInt();
            int month = reader.ReadElementContentAsInt();
            int year = reader.ReadElementContentAsInt();
            mDate = new DateTime(year, month, day);
            // read the comment if the version is greater than 0
            if (mDataVersionOfTheFileLoaded > 0)
            {
                reader.ReadToFollowing("Comment");
                mComment = reader.ReadElementContentAsString().Replace("\n", Environment.NewLine);
            }
            else
            {
                reader.ReadToFollowing("CurrentSnapGridSize");
            }
            if (mDataVersionOfTheFileLoaded < 2)
            {
                // skip the static data of layers that before we were saving
                // but now I think it is stupid, since we don't have action to change that
                // and we don't have way to update the enabled of the buttons
                reader.ReadElementContentAsFloat(); // CurrentSnapGridSize
                reader.ReadElementContentAsBoolean(); // SnapGridEnabled
                reader.ReadElementContentAsFloat(); // CurrentRotationStep
            }

            // read the export data if the version is 5 or higher
            if (mDataVersionOfTheFileLoaded > 4)
            {
                reader.ReadToDescendant("ExportPath");
                // read the relative export path and store it temporarly in the absolute path variable
                // the absolute path will be computed after the xml serialization is finished
                mExportAbsoluteFileName = reader.ReadElementContentAsString();
                // read the other export info
                mExportFileTypeIndex = reader.ReadElementContentAsInt();
                mExportArea = XmlReadWrite.readRectangleF(reader);
                mExportScale = reader.ReadElementContentAsFloat();
                // read even more info from version 8
                if (mDataVersionOfTheFileLoaded > 7)
                {
                    mExportWatermark = XmlReadWrite.readBoolean(reader);
                    mExportBrickHull = XmlReadWrite.readBoolean(reader);
                    mExportElectricCircuit = XmlReadWrite.readBoolean(reader);
                    mExportConnectionPoints = XmlReadWrite.readBoolean(reader);
                }
                reader.ReadEndElement();
            }

            // selected layer
            int selectedLayerIndex = reader.ReadElementContentAsInt();
            // step the progress bar after the read of the header
            MainForm.Instance.stepProgressBar();

            // layers
            // first clear the hashtable that contains all the bricks
            Map.sHashtableForRulerAttachementRebuilding.Clear();
            // then load all the layers
            bool layerFound = reader.ReadToDescendant("Layer");
            while (layerFound)
            {
                // get the 'type' attribute of the layer
                reader.ReadAttributeValue();
                string layerType = reader.GetAttribute(0);

                // instantiate the right layer according to the type
                Layer layer = null;
                if (layerType.Equals("grid"))
                    layer = new LayerGrid();
                else if (layerType.Equals("brick"))
                    layer = new LayerBrick();
                else if (layerType.Equals("text"))
                    layer = new LayerText();
                else if (layerType.Equals("area"))
                    layer = new LayerArea();
                else if (layerType.Equals("ruler"))
                    layer = new LayerRuler();

                // read and add the new layer
                if (layer != null)
                {
                    layer.ReadXml(reader);
                    mLayers.Add(layer);
                }

                // read the next layer
                layerFound = reader.ReadToNextSibling("Layer");
            }
            reader.ReadEndElement(); // end of Layers

            // once we have finished to read all the layers thus all the items, we need to recreate all the links they have between them
            foreach (Layer layer in mLayers)
                layer.recreateLinksAfterLoading();
            // then clear again the hash table to free the memory
            Map.sHashtableForRulerAttachementRebuilding.Clear();

            // step the progress bar after the rebuilding of links
            MainForm.Instance.stepProgressBar();

            // if the selected index is valid, reset the selected layer
            // use the setter in order to enable the toolbar buttons
            if ((selectedLayerIndex >= 0) && (selectedLayerIndex < mLayers.Count))
                SelectedLayer = mLayers[selectedLayerIndex];
            else
                SelectedLayer = null;

            // DO NOT READ YET THE BRICK URL LIST, BECAUSE THE BRICK DOWNLOAD FEATURE IS NOT READY
            if (false)
            {
                // read the url of all the parts for version 5 or later
                if ((mDataVersionOfTheFileLoaded > 5) && !reader.IsEmptyElement)
                {
                    bool urlFound = reader.ReadToDescendant("BrickUrl");
                    while (urlFound)
                    {
                        // read the next url
                        urlFound = reader.ReadToNextSibling("BrickUrl");
                    }
                    reader.ReadEndElement();
                }
            }

            // construct the watermark
            computeGeneralInfoWatermark();
            // for old version, make disapear the progress bar, since it was just an estimation
            MainForm.Instance.finishProgressBar();
        }
Пример #22
0
            private void readGroupConnectionPreferenceListTag(ref System.Xml.XmlReader xmlReader)
            {
                if (!xmlReader.IsEmptyElement)
                {
                    // start to read the subpart
                    bool entryFound = xmlReader.ReadToDescendant("nextIndex");
                    if (entryFound)
                    {
                        if (mGroupInfo == null)
                            mGroupInfo = new GroupInfo();
                        mGroupInfo.mGroupNextPreferedConnection = new Dictionary<int, int>();
                    }

                    while (entryFound)
                    {
                        // read the "from" connection index
                        int from = int.Parse(xmlReader.GetAttribute("from"));
                        int to = xmlReader.ReadElementContentAsInt();

                        // store the prefered connection couple
                        mGroupInfo.mGroupNextPreferedConnection.Add(from, to);

                        // go to next index
                        entryFound = !xmlReader.EOF && xmlReader.ReadToNextSibling("nextIndex");
                    }
                    // finish the connexion
                    if (!xmlReader.EOF)
                        xmlReader.ReadEndElement();
                }
                else
                {
                    xmlReader.Read();
                }
            }
Пример #23
0
 internal override void ReadXml(System.Xml.XmlReader reader)
 {
     m_visionBoost = reader.ReadElementContentAsInt();
 }
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the object is deserialized.</param>
        /// <remarks>Documented by Dev05, 2008-11-27</remarks>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.Read();

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.Name)
                {
                    case "Name":
                        name = reader.ReadElementContentAsString().Trim();
                        break;
                    case "Server":
                        server = reader.ReadElementContentAsString().Trim();
                        break;
                    case "Port":
                        port = reader.ReadElementContentAsInt();
                        break;
                    case "UserId":
                        userId = reader.ReadElementContentAsString().Trim();
                        break;
                    case "Password":
                        password = reader.ReadElementContentAsString().Trim();
                        break;
                    case "Ssl":
                        ssl = reader.ReadElementContentAsBoolean();
                        break;
                    case "Database":
                        database = reader.ReadElementContentAsString().Trim();
                        break;
                    case "SyncType":
                        SyncType = (SyncType)Enum.Parse(typeof(SyncType), reader.ReadElementContentAsString().Trim());

                        // [ML-2349]  Deactivate HalfSynchronizedWithDbAccess sync mode
                        if (SyncType == SyncType.HalfSynchronizedWithDbAccess)
                            SyncType = SyncType.HalfSynchronizedWithoutDbAccess;

                        break;
                    case "SyncURI":
                        SyncURI = reader.ReadElementContentAsString().Trim();
                        break;
                    case "MediaURI":
                        MediaURI = reader.ReadElementContentAsString().Trim() + Resources.MediaURI_Suffix;
                        break;
                    case "ExtensionURI":
                        ExtensionURI = reader.ReadElementContentAsString().Trim() + Resources.ExtensionURI_Suffix;
                        break;
                    case "OtherProperties":
                        otherProperties = otherPropertiesSerializer.Deserialize(reader) as SerializableDictionary<string, object>;
                        break;
                    default:
            #if debug_output
                        Trace.WriteLine("Unknow Connection-Property: " + reader.Name);
            #endif
                        reader.Read();
                        break;
                }
            }

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(server))
                throw new Exception("Invalid connection name or path.");

            reader.ReadEndElement();
        }
Пример #25
0
 public override void ReadXml(System.Xml.XmlReader reader)
 {
     base.ReadXml(reader);
     // read the data of the ruler (don't use accessor to avoid multiple call to the update functions
     mControlPoint[0].mPoint = XmlReadWrite.readPointF(reader);
     mControlPoint[1].mPoint = XmlReadWrite.readPointF(reader);
     // read the id of the attached brick (if any)
     mControlPoint[0].mAttachedBrickHashCodeUsedDuringLoading = reader.ReadElementContentAsInt();
     mControlPoint[1].mAttachedBrickHashCodeUsedDuringLoading = reader.ReadElementContentAsInt();
     mOffsetDistance = reader.ReadElementContentAsFloat();
     mAllowOffset = reader.ReadElementContentAsBoolean();
     // read the end element of the ruler
     reader.ReadEndElement();
     // update the computing data after reading the 2 points and offset
     updateDisplayDataAndMesurementImage();
 }
Пример #26
0
 public void ReadXml(System.Xml.XmlReader r)
 {
     if (r.IsEmptyElement)
         return;
     if (r.Read())
     {
         this.TyreWidth = (TyreWidth)r.ReadElementContentAsInt();
         this.TyreProfile = (TyreProfile)r.ReadElementContentAsInt();
         this.TyreRadius = (TyreRadius)r.ReadElementContentAsInt();
     }
 }
Пример #27
0
 //=========================================================================
 ///	<summary>
 ///		XML����ǂݍ���
 ///	</summary>
 /// <remarks>
 /// </remarks>
 /// <history>2006/XX/XX �V�K�쐬</history>
 //=========================================================================
 public void Read(System.Xml.XmlReader xr)
 {
     while (xr.Read())
     {
         if (xr.NodeType == System.Xml.XmlNodeType.Element)
         {
             if (xr.LocalName.Equals("StoryNumber"))
                 mStoryNumber = xr.ReadElementContentAsInt();
             else if (xr.LocalName.Equals("FilePath"))
                 mFilePath = xr.ReadElementContentAsString();
             // Ver1.9.18�ȑO����̈ȍ~
             else if (xr.LocalName.Equals("State"))
                 MigrationState( (State)xr.ReadElementContentAsInt() );
             else if (xr.LocalName.Equals("SubTitle"))
                 mSubTitle = xr.ReadElementContentAsString();
             else if (xr.LocalName.Equals("Unread"))
                 mIsUnread = xr.ReadElementContentAsInt() == 1 ? true : false;
             else if (xr.LocalName.Equals("ThumbnailMaked"))
                 mThumbnailMaked = xr.ReadElementContentAsInt() == 1 ? true : false;
             else if (xr.LocalName.Equals("DateTime"))
             {
                 string strDateTime = xr.ReadElementContentAsString();
                 mStartTime = new DateTime(Convert.ToInt64(strDateTime));
             }
             else if (xr.LocalName.Equals("HasPlan"))
                 mHasPlan			= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("IsReserved"))
                 mIsReserved			= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("ReserveStartTime"))
                 mReserveStartTime	= new DateTime( Convert.ToInt64( xr.ReadElementContentAsString() ) );
             else if (xr.LocalName.Equals("HasFile"))
                 mHasFile			= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("IsReserveError"))
                 mIsReserveError		= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("IsEncoded"))
                 mIsEncoded			= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("IsStored"))
                 mIsStored			= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("Length"))
                 mLength				= xr.ReadElementContentAsInt();
             else if (xr.LocalName.Equals("RepeatNumber"))
                 mRepeatNumber		= xr.ReadElementContentAsInt();
             else if (xr.LocalName.Equals("PlanError"))
                 PlanError			= bool.Parse( xr.ReadElementContentAsString() );
         }
         else if (xr.NodeType == System.Xml.XmlNodeType.EndElement)
             if (xr.LocalName.Equals("Records"))
                 break;
     }
 }
        protected void readGenerationConstraints(System.Xml.XmlTextReader xr)
        {
            do
            {
                xr.Read();
                if ((xr.NodeType == XmlNodeType.Element))
                {
                    if (xr.Name == "MinStarsPerConstellation")
                        this.generationConstraints.minStarsPerConstellation = xr.ReadElementContentAsInt();
                    else if (xr.Name == "MinStarDistance")
                        this.generationConstraints.minStarDistance = xr.ReadElementContentAsDouble();
                    else if (xr.Name == "MinEmpireDistance")
                        this.generationConstraints.minEmpireDistance = xr.ReadElementContentAsDouble();
            //                    else if (xr.Name == "MaxWormholesConnections")
            //                        this.generationConstraints.maxWormholesConnections = xr.ReadElementContentAsInt();
                }
            }
            while (!((xr.NodeType == XmlNodeType.EndElement) && (xr.Name == "GenerationConstraints")));

            System.Diagnostics.Trace.WriteLine("cross-checking constraints...");
            System.Diagnostics.Trace.WriteLine("Min stars per constellation : " + this.generationConstraints.minStarsPerConstellation.ToString());
            System.Diagnostics.Trace.WriteLine("Min distance between stars : " + this.generationConstraints.minStarDistance.ToString());
            System.Diagnostics.Trace.WriteLine("Min distance between home systems : " + this.generationConstraints.minEmpireDistance.ToString());
            System.Diagnostics.Trace.WriteLine("...end of cross-checking constraints");
        }
Пример #29
0
        protected override void ReadXmlBase(System.Xml.XmlReader reader)
        {
            base.ReadXmlBase(reader);

            if (reader.LocalName == "alternate_text")
                this.alternateText = reader.ReadElementString("alternate_text", RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            if (reader.LocalName == "uri")
            {
                string uriType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace);
                if (uriType != null)
                {
                    Check.Assert(uriType.IndexOf("DV_EHR_URI")>0, "uriType must be DV_EHR_URI, but it is "+uriType);
                    this.uri = new OpenEhr.RM.DataTypes.Uri.DvEhrUri();
                }
                this.uri = new OpenEhr.RM.DataTypes.Uri.DvUri();
                this.uri.ReadXml(reader);
            }

            if (reader.LocalName == "data")
            {
                reader.MoveToContent();
                reader.ReadStartElement();
                byte[] buffer = new byte[1024];
                System.IO.MemoryStream stream = new System.IO.MemoryStream();
                System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
                int bytesRead = reader.ReadContentAsBase64(buffer, 0, 1024);
                while (bytesRead > 0)
                {
                    writer.Write(buffer, 0, bytesRead);
                    bytesRead = reader.ReadContentAsBase64(buffer, 0, 1024);
                }
                writer.Close();
                reader.MoveToContent();
                reader.ReadEndElement();
                this.data = stream.ToArray();
            }
            reader.MoveToContent();

            if (reader.LocalName == "media_type")
            {
                this.mediaType = new OpenEhr.RM.DataTypes.Text.CodePhrase();
                this.mediaType.ReadXml(reader);
            }

            if (reader.LocalName == "compression_algorithm")
            {
                this.compressionAlgorithm = new OpenEhr.RM.DataTypes.Text.CodePhrase();
                this.compressionAlgorithm.ReadXml(reader);
            }

            if (reader.LocalName == "integrity_check")
            {
                reader.ReadElementContentAsBase64(this.integrityCheck, 0, this.integrityCheck.Length);
            }
            reader.MoveToContent();

            if (reader.LocalName == "integrity_check_algorithm")
            {
                this.integrityCheckAlgorithm = new OpenEhr.RM.DataTypes.Text.CodePhrase();
                this.integrityCheckAlgorithm.ReadXml(reader);
            }

            Check.Assert(reader.LocalName=="size", "Expected LocalName is 'size', not " + reader.LocalName);
            this.size = reader.ReadElementContentAsInt("size", RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            if (reader.LocalName == "thumbnail")
            {
                this.thumbnail = new DvMultimedia();
                this.thumbnail.ReadXml(reader);
            }
        }
Пример #30
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            base.ReadXml(reader);
            // before version 5, the transparency was only in the area layer, after it is read in the base class
            if (Map.DataVersionOfTheFileLoaded < 5)
                mTransparency = reader.ReadElementContentAsInt();
            // read the cell size
            mAreaCellSizeInStud = reader.ReadElementContentAsInt();
            // the areas list
            int currentLineIndex = int.MaxValue;
            bool areaFound = reader.ReadToDescendant("Area");
            while (areaFound)
            {
                // read all the data of the area
                reader.ReadToDescendant("x");
                int x = reader.ReadElementContentAsInt();
                int y = reader.ReadElementContentAsInt();
                string stringColor = reader.ReadElementContentAsString();
                Color color = Color.FromArgb(int.Parse(stringColor, System.Globalization.NumberStyles.HexNumber));
                // and paint the appropriate cell
                paintCell(x, y, color);

                // read the next area
                areaFound = reader.ReadToNextSibling("Area");

                // step the progress bar for each line
                if (x != currentLineIndex)
                {
                    MainForm.Instance.stepProgressBar();
                    currentLineIndex = x;
                }
            }
            // read the Areas tag, to finish the list of area
            reader.Read();
        }