예제 #1
0
        // check ok
        private void AddToFile(XatXml xx)
        {
            if (!File.Exists(TidyConst.XmlPath))
            {
                WriteToFile();
                return;
            }

            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(TidyConst.XmlPath);
            XmlNode xn = xdoc.SelectSingleNode("/AnimeTidy/Settings");

            XmlElement xe = xdoc.CreateElement("Xat");

            xe.SetAttribute("Type", xx.XatType.ToString());

            XmlElement xes = xdoc.CreateElement("Name");

            xes.InnerText = xx.XatName;
            xe.AppendChild(xes);

            xes           = xdoc.CreateElement("Path");
            xes.InnerText = xx.XatPath;
            xe.AppendChild(xes);

            xn.AppendChild(xe);

            xdoc.Save(TidyConst.XmlPath);
        }
예제 #2
0
        private void InitFromFile()
        {
            if (!File.Exists(TidyConst.XmlPath))
            {
                return;
            }

            this._xatLst = new List <XatXml>();

            XPathDocument     xptdoc  = new XPathDocument(TidyConst.XmlPath);
            XPathNavigator    xptnavi = xptdoc.CreateNavigator();
            XPathNodeIterator xpnode  = xptnavi.Select("/AnimeTidy/Settings/Xat");

            if (xpnode == null)
            {
                WriteToFile();
                return;
            }

            while (xpnode.MoveNext())
            {
                XPathNavigator xpnavi = xpnode.Current;
                String         type   = xpnavi.GetAttribute("Type", String.Empty);

                if (!String.IsNullOrEmpty(type))
                {
                    XatXml txml = new XatXml();
                    txml.XatType = (TidyType)Enum.Parse(typeof(TidyType), type);
                    XPathNavigator xt = xpnavi.SelectSingleNode("Name");
                    if (xt == null)
                    {
                        continue;
                    }

                    txml.XatName = xt.Value;

                    xt = xpnavi.SelectSingleNode("Path");
                    if (xt == null)
                    {
                        continue;
                    }

                    txml.XatPath = xt.Value;

                    this._xatLst.Add(txml);
                }
            }
        }
예제 #3
0
        public void InitAnimeInfo(XatXml xml)
        {
            if (xml.XatPath.Length == 0)
            {
                return;
            }

            AnimeInfo.Name = xml.XatName.Length == 0 ?
                             xml.XatPath.Substring(xml.XatPath.LastIndexOf('\\') + 1) : xml.XatName;
            AnimeInfo.Path = xml.XatPath;

            if (AnimeInfo.AnimeList != null)
            {
                AnimeInfo.IsCreated = true;
            }
        }
예제 #4
0
        public void UpdateXmlFile(XatXml xx)
        {
            XatXml ck = this._xatLst.Find(txml => txml.XatType == xx.XatType);

            if (ck != null)
            {
                ck.XatName = xx.XatName;
                ck.XatPath = xx.XatPath;

                EditToFile(ck);
            }
            else
            {
                this._xatLst.Add(xx);

                AddToFile(xx);
            }
        }
예제 #5
0
        // check ok
        private void EditToFile(XatXml xx)
        {
            if (!File.Exists(TidyConst.XmlPath))
            {
                WriteToFile();
                return;
            }

            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(TidyConst.XmlPath);
            XmlNode     xn    = xdoc.SelectSingleNode("/AnimeTidy/Settings");
            XmlNodeList xnlst = xn.SelectNodes(String.Format("Xat[@Type='{0}']", xx.XatType));

            for (int i = 1; i < xnlst.Count; i++)
            {
                xn.RemoveChild(xnlst[i]);
            }

            xnlst[0].SelectSingleNode("Name").InnerText = xx.XatName;
            xnlst[0].SelectSingleNode("Path").InnerText = xx.XatPath;

            xdoc.Save(TidyConst.XmlPath);
        }