コード例 #1
0
        //add a new vedio into the list

        public void add(String path)
        {
            video_info tmp = null;

            char[]   separatingChars1 = { '\\', '/' };
            string[] Names            = path.Split(separatingChars1, StringSplitOptions.RemoveEmptyEntries);
            string   fileName         = Names[Names.Length - 1];

            //deduplication goes first
            foreach (video_info myvideo in name_to_list.Values)
            {
                if (myvideo.fileName == fileName)
                {
                    tmp = myvideo;
                    break;
                }
            }
            //may be a real new one
            if (tmp == null)
            {
                tmp = new video_info();
            }
            tmp.readFromAddr(path);
            name_to_list.Add(tmp.fileName, tmp);
        }
コード例 #2
0
        /// <summary>
        /// add result to list
        /// </summary>
        /// <param name="item">single item. May iterate through the whole result set</param>
        /// <param name="mediaInfo">mediaInfo object</param>
        /// <param name="mybox">the ListBox component. In our program, pass in "selector in MainWindow class"</param>
        static void update_search_result(video_info item, media_info mediaInfo, ListBox mybox)
        {
            mediaInfo.name_to_list.Add(item.fileName, item);
            mybox.Items.Clear();
            HashSet <String> play_list = mediaInfo.print();

            general_add(play_list, mybox);
        }
コード例 #3
0
        public void delete(string filename)
        {
            video_info to_delete_vid = name_to_list[filename];
            //remove from document
            XmlNode to_delete = doc.SelectSingleNode(String.Format("/Karaoke/video[@id='{0}']", to_delete_vid.id), man);

            to_delete.ParentNode.RemoveChild(to_delete);
            //remove from list
            name_to_list.Remove(to_delete_vid.fileName);
        }
コード例 #4
0
        //load the initial input video list...
        public void load()
        {
            doc = new XmlDocument();
            doc.Load(inputList);
            man = new XmlNamespaceManager(doc.NameTable);
            man.AddNamespace("kara", "list");
            XmlElement  root   = doc.DocumentElement;
            XmlNodeList videos = root.SelectNodes("/Karaoke/video", man);

            foreach (XmlNode video in videos)
            {
                video_info tmp = new video_info();
                tmp.load(video);
                name_to_list.Add(tmp.fileName, tmp);
            }
        }
コード例 #5
0
        /// <summary>
        /// return the truth value
        /// search music title and singer name and album
        /// </summary>
        /// <param name="key">the string user type in search window</param>
        /// <param name="item">a video_info. You may use iteration to traverse all video_infos</param>
        /// <returns></returns>
        public static bool search(string key, video_info item)
        {
            //split keys into multiple key, since we support multikeyword search
            string[] keys   = key.Split(null);
            bool     result = false;

            //while result
            foreach (string mykey in keys)
            {
                Regex regex = new Regex(mykey, RegexOptions.IgnoreCase);

                result = result || regex.IsMatch(item.album) || regex.IsMatch(item.author) || regex.IsMatch(item.title) || regex.IsMatch(item.fileName);
                //return true when result becomes true
                if (result)
                {
                    return(result);
                }
            }
            return(result);
        }