예제 #1
0
        private void compareRefreshLists(RenderableObjectList newList, RenderableObjectList curList)
        {
            ArrayList addList = new ArrayList();
            ArrayList delList = new ArrayList();

            foreach (RenderableObject newObject in newList.ChildObjects)
            {
                bool foundObject = false;
                foreach (RenderableObject curObject in curList.ChildObjects)
                {
                    string xmlSource = curObject.MetaData["XmlSource"] as string;

                    if (xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name)
                    {
                        foundObject = true;
                        UpdateRenderable(curObject, newObject);
                        break;
                    }
                }

                if (!foundObject)
                {
                    addList.Add(newObject);
                }
            }

            foreach (RenderableObject curObject in curList.ChildObjects)
            {
                bool foundObject = false;
                foreach (RenderableObject newObject in newList.ChildObjects)
                {
                    string xmlSource = newObject.MetaData["XmlSource"] as string;
                    if (xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name)
                    {
                        foundObject = true;
                        break;
                    }
                }

                if (!foundObject)
                {
                    string src = (string)curObject.MetaData["XmlSource"];

                    if (src != null || src == m_DataSource)
                    {
                        delList.Add(curObject);
                    }
                }
            }

            foreach (RenderableObject o in addList)
            {
                curList.Add(o);
            }

            foreach (RenderableObject o in delList)
            {
                curList.Remove(o);
            }
        }
예제 #2
0
        /// <summary>
        /// Permanently delete the layer
        /// </summary>
        public virtual void Delete()
        {
            string namestring = name;
            //TODO: Make the string absolute from the XML root so that we don't delete stuff we aren't supposed to...
            string xmlConfigFile = (string)MetaData["XML Configuration File"];

            if (xmlConfigFile == null)
            {
                xmlConfigFile = (string)ParentList.MetaData["XML Configuration File"];
            }

            if (xmlConfigFile == null ||
                !File.Exists(xmlConfigFile))
            {
                throw new ApplicationException("Error deleting layer.");
            }

            XmlDocument doc = new XmlDocument();

            doc.Load(xmlConfigFile);

            XmlNodeList list;
            XmlElement  root = doc.DocumentElement;

            list = root.SelectNodes("//*[Name='" + namestring + "']");

            ParentList.Remove(Name);

            list[0].ParentNode.RemoveChild(list[0]);
            if (File.Exists(xmlConfigFile.Replace(".xml", ".bak")))
            {
                File.Delete(xmlConfigFile.Replace(".xml", ".bak"));
            }
            File.Move(xmlConfigFile, xmlConfigFile.Replace(".xml", ".bak"));
            doc.Save(xmlConfigFile);
        }
예제 #3
0
		private void compareRefreshLists(RenderableObjectList newList, RenderableObjectList curList)
		{
			ArrayList addList = new ArrayList();
			ArrayList delList = new ArrayList();

			foreach(RenderableObject newObject in newList.ChildObjects)
			{
				bool foundObject = false;
				foreach(RenderableObject curObject in curList.ChildObjects)
				{
					string xmlSource = curObject.MetaData["XmlSource"] as string;
						
					if(xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name)
					{
						foundObject = true;
						UpdateRenderable(curObject, newObject);
						break;
					}
				}

				if(!foundObject)
				{
					addList.Add(newObject);
				}
			}

			foreach(RenderableObject curObject in curList.ChildObjects)
			{
				bool foundObject = false;
				foreach(RenderableObject newObject in newList.ChildObjects)
				{
					string xmlSource = newObject.MetaData["XmlSource"] as string;
					if(xmlSource != null && xmlSource == m_DataSource && newObject.Name == curObject.Name)
					{
						foundObject = true;
						break;
					}
				}

				if(!foundObject)
				{
					string src = (string)curObject.MetaData["XmlSource"];

					if(src != null || src == m_DataSource)
						delList.Add(curObject);
				}
			}

			foreach(RenderableObject o in addList)
			{
				curList.Add(o);
			}

			foreach(RenderableObject o in delList)
			{
				curList.Remove(o);
			}
		}