示例#1
0
 public static void GraspProgress(string word)
 {
     if (GetProgress(word) < AppInfoHelper.GetReciteNumber())
     {
         int newprogress = AppInfoHelper.GetReciteNumber();
         SetProgress(word, newprogress);
         StatisticsHelper.AddWordLog(word, StatisticsHelper.WordLogType.grasp);
     }
 }
示例#2
0
        /// <summary>
        /// 由AppInfo生成包含网络词典在内的词典列表
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static List <string> GenerateDictList()
        {
            List <string> result = new List <string>();
            List <string> l      = new List <string>();

            l = AppInfoHelper.GetDictList();
            for (int i = 0; i < l.Count; i++)
            {
                result.Add(l[i]);
            }
            return(result);
        }
示例#3
0
        // 新建笔记,新建单词本,打开单词本,打开笔记,删除笔记,删除单词本
        // 记录构想:

        /**<type class="En">
         *    <element>
         *       <word />--item--trans...
         *       <phrase />
         *       <sentence />
         *
         *
         *
         *
         */

        /// <summary>
        /// 如果不存在单词本,则自动创建。
        /// </summary>
        public static void CreateMyWordbook(string name)
        {
            string path = AppInfoHelper.GetMyWordBookFolder() + "\\" + name;

            if (File.Exists(path))
            {
            }
            else
            {
                XmlHelper.CreateXml(path, "wordbook");
            }
        }
示例#4
0
        /// <summary>
        /// 将单词添加到单词本
        /// </summary>
        /// <param name="name"></param>
        /// <param name="word"></param>
        /// <param name="type"></param>
        public static void AddWord(string name, string word, WordType type)
        {
            string      path = AppInfoHelper.GetMyWordBookFolder() + "\\" + name + ".xml";
            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(path);
            XmlElement root = xdoc.DocumentElement;
            XmlElement node = xdoc.CreateElement("item");

            node.InnerText = word;
            node.SetAttribute("wordtype", type.ToString());
            xdoc.Save(path);
        }
示例#5
0
        public static List <string> ReadMyWordbookList()
        {
            List <string> list = new List <string>();

            string[] files = Directory.GetFiles(AppInfoHelper.GetMyWordBookFolder());
            foreach (string f in files)
            {
                if (Path.GetExtension(f) == ".xml")
                {
                    list.Add(Path.GetFileNameWithoutExtension(f));
                }
            }
            return(list);
        }
示例#6
0
        /// <summary>
        /// 删除单词本,成功删除返回true
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private static bool DeleteMyWordbook(string name)
        {
            string path = AppInfoHelper.GetMyWordBookFolder() + "\\" + name;

            if (!File.Exists(path))
            {
                return(false);
            }
            else
            {
                File.Delete(path);
                return(true);
            }
        }
示例#7
0
        /// <summary>
        /// 将单词从单词本中删除
        /// </summary>
        /// <param name="name"></param>
        /// <param name="word"></param>
        /// <param name="type"></param>
        public static void DeleteWord(string name, string word)
        {
            string      path = AppInfoHelper.GetMyWordBookFolder() + "\\" + name + ".xml";
            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(path);
            XmlElement root = xdoc.DocumentElement;

            foreach (XmlElement node in root.ChildNodes)
            {
                if (node.InnerText == word)
                {
                    node.RemoveAll();
                }
            }
            xdoc.Save(path);
        }
示例#8
0
        public static List <string> ReadWordbookList()
        {
            List <string> result = new List <string>();

            //Console.WriteLine(AppInfoHelper.GetMyWordBookFolder());
            if (Directory.Exists(AppInfoHelper.GetMyWordBookFolder()))
            {
                string[] files = Directory.GetFiles(AppInfoHelper.GetMyWordBookFolder());
                foreach (string f in files)
                {
                    if (Path.GetExtension(f) == ".xml")
                    {
                        result.Add(Path.GetFileNameWithoutExtension(f));
                    }
                }
            }
            return(result);
        }
示例#9
0
        /// <summary>
        /// 生成包含网络词典的“词典-路径”字典
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, string> ReadDictDict()
        {
            Dictionary <string, string> dictDict = new Dictionary <string, string>();
            List <string> dictList = AppInfoHelper.GetDictList();

            for (int i = 0; i < dictList.Count; i++)
            {
                if (dictList[i] == "有道词典")
                {
                    dictDict.Add("有道词典", @"http://dict.youdao.com/search?q=");
                }
                else
                {
                    dictDict.Add(dictList[i], String.Format("{0}\\{1}.xml", AppInfoHelper.GetDictionaryFolder(), dictList[i]));
                }
            }
            return(dictDict);
        }
示例#10
0
        private static void DeleteWordLog(int limit)
        {
            List <string> loglist = new List <string>();
            DirectoryInfo root    = new DirectoryInfo(AppInfoHelper.GetStatisticsFolder());

            FileInfo[] files = root.GetFiles();
            for (int i = 0; i < files.Length; i++)
            {
                if (Path.GetExtension(files[i].Name) == ".log")
                {
                    string   file = Path.GetFileNameWithoutExtension(files[i].Name);
                    DateTime t    = DateTime.ParseExact(file, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                    if ((DateTime.Now.Date - t).Days > limit)
                    {
                        File.Delete(files[i].FullName);
                    }
                }
            }
        }
示例#11
0
        public static string GetWordLogPath(DateTime dtime)
        {
            string wordLogDirePath = AppInfoHelper.GetStatisticsFolder();
            string month = "", day = "";

            if (dtime.Month < 10)
            {
                month = "0";
            }
            month += dtime.Month.ToString();
            if (dtime.Day < 10)
            {
                day = "0";
            }
            day += dtime.Day.ToString();
            string wordLogFileName = dtime.Year.ToString() + month + day + ".log";
            string wordLogPath     = wordLogDirePath + "\\" + wordLogFileName;

            return(wordLogPath);
        }
示例#12
0
        /// <summary>
        /// 如果不存在当天的日志,则自动创建,同时删除n天之前的日志。
        /// </summary>
        public static void GenerateWordLog()
        {
            string wordLogPath = GetWordLogPath(DateTime.Now);

            if (File.Exists(wordLogPath))
            {
            }
            else
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.AppendChild(xdoc.CreateXmlDeclaration("1.0", "UTF-8", null));
                XmlElement root = xdoc.CreateElement("wordlog");
                xdoc.AppendChild(root);
                XmlNode grasp   = xdoc.CreateElement("grasp");
                XmlNode ungrasp = xdoc.CreateElement("ungrasp");
                root.AppendChild(grasp);
                root.AppendChild(ungrasp);
                xdoc.Save(wordLogPath);
            }
            DeleteWordLog(AppInfoHelper.GetWordLogSaveLimit());
        }
示例#13
0
        public static void UpdateDict()
        {
            List <string> list = new List <string>();

            list = DictHelper.ReadDictList();
            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(Environment.CurrentDirectory + "\\WordData.xml");
            XmlNode root = xdoc.DocumentElement;

            foreach (XmlNode node in root.ChildNodes)
            {
                if (node["update"].InnerText == true.ToString())
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        DictHelper.SetDictProgress(AppInfoHelper.GetDictionaryFolder() + "\\" + list[i] + ".xml", node["word"].InnerText, node["progress"].InnerText);
                    }
                    node["update"].InnerText = false.ToString();
                }
            }
            xdoc.Save(Environment.CurrentDirectory + "\\WordData.xml");
        }
示例#14
0
 public static void SetProgress(string word, int progress)
 {
     if (IsWordIn(word))
     {
     }
     else
     {
         AddWordData(word, 0);
     }
     if (StatisticsHelper.IsWordInLog(word))
     {
     }
     else
     {
         if (progress >= -2 && progress <= AppInfoHelper.GetReciteNumber())
         {
             XmlDocument xdoc = new XmlDocument();
             xdoc.Load(Environment.CurrentDirectory + "\\WordData.xml");
             XmlNode root = xdoc.DocumentElement;
             foreach (XmlNode node in root.ChildNodes)
             {
                 if ("item" == node.Name)
                 {
                     foreach (XmlNode node2 in node.ChildNodes)
                     {
                         if (node2.InnerText == word)
                         {
                             node["progress"].InnerText = progress.ToString();
                             node["update"].InnerText   = true.ToString();
                         }
                     }
                 }
             }
             xdoc.Save(Environment.CurrentDirectory + "\\WordData.xml");
         }
     }
 }