コード例 #1
0
        //determines the next background image number
        private int GetNextBackgroundImgNumber(int lastBackgroundImgNumber)
        {
            int nextBackgroundImgNumber;

            nextBackgroundImgNumber = LastBackgroundImgNumber + 1;
            if (!BackgroundImgList.ContainsKey(nextBackgroundImgNumber))
            {
                nextBackgroundImgNumber = BackgroundImgList.First().Key;
            }

            return(nextBackgroundImgNumber);
        }
コード例 #2
0
        //loads the configuration file
        public bool Load(string configurationFile)
        {
            XmlDocument docConfig = new XmlDocument();
            XmlNode     xmlNode;

            try
            {
                docConfig.Load(configurationFile);

                //read server path
                xmlNode    = docConfig.GetElementsByTagName("server")[0];
                ServerPath = xmlNode.Attributes["path"].Value;
                if (ServerPath != "" && !ServerPath.EndsWith("/"))
                {
                    ServerPath += "/";
                }

                //read game path
                xmlNode  = docConfig.GetElementsByTagName("game")[0];
                GamePath = xmlNode.Attributes["path"].Value;
                if (GamePath != "" && !GamePath.EndsWith("/"))
                {
                    GamePath += "/";
                }
                GameConfigurationFile = xmlNode.Attributes["configFile"].Value;

                //read relative server path of the Updater
                xmlNode = docConfig.GetElementsByTagName("updater")[0];
                RelUpdaterPathOnServer = xmlNode.Attributes["serverpath"].Value;
                if (RelUpdaterPathOnServer != "" && !RelUpdaterPathOnServer.EndsWith("/"))
                {
                    RelUpdaterPathOnServer += "/";
                }

                //set absolute server path of the Updater
                AbsUpdaterPathOnServer = ServerPath + RelUpdaterPathOnServer;

                //read name of the administrated versions configuration file
                xmlNode = docConfig.GetElementsByTagName("versionsFile")[0];
                VersionsConfigurationFile = xmlNode.Attributes["name"].Value;

                //read name of a update configuration file
                xmlNode = docConfig.GetElementsByTagName("updateConfig")[0];
                UpdateConfigurationFile = xmlNode.Attributes["name"].Value;

                //read name of a full version configuration file
                xmlNode = docConfig.GetElementsByTagName("fullVersionConfig")[0];
                FullVersionConfigurationFile = xmlNode.Attributes["name"].Value;

                //read name of the temporary download folder
                xmlNode    = docConfig.GetElementsByTagName("temp")[0];
                TempFolder = xmlNode.Attributes["path"].Value;

                //read name of the Udater executeable
                xmlNode    = docConfig.GetElementsByTagName("updaterExe")[0];
                UpdaterExe = xmlNode.Attributes["name"].Value;

                //read name of the Installer executeable
                xmlNode      = docConfig.GetElementsByTagName("installerExe")[0];
                InstallerExe = xmlNode.Attributes["name"].Value;

                //read version of the Updater
                xmlNode       = docConfig.GetElementsByTagName("version")[0];
                VersionNumber = xmlNode.Attributes["name"].Value;

                //check version syntax
                if (!Version.CheckVersionSyntax(VersionNumber))
                {
                    return(false);
                }

                //read number of last background image and image-update flag
                xmlNode = docConfig.GetElementsByTagName("pictures")[0];
                LastBackgroundImgNumber = int.Parse(xmlNode.Attributes["lastNumber"].Value);
                UpdatePictures          = bool.Parse(xmlNode.Attributes["update"].Value);

                //read all background images
                foreach (XmlNode pictureNode in xmlNode.ChildNodes)
                {
                    BackgroundImgList.Add(int.Parse(pictureNode.Attributes["number"].Value),
                                          pictureNode.Attributes["path"].Value);
                }

                //set next background image number
                NextBackgroundImgNumber = GetNextBackgroundImgNumber(LastBackgroundImgNumber);
            }
            catch (Exception e)
            {
                ErrorLog.Add(this, e.Message);
                return(false);
            }

            return(true);
        }