예제 #1
0
        /// <summary>
        /// 设置cmbKeyword的Text
        /// </summary>
        private void SetKeywordText(KeywordStruct keyword)
        {
            //写回cmbKeyword
            string str = "";

            if (keyword.Directory != null && keyword.Directory != "")
            {
                str += "\"" + keyword.Directory + "\"" + " ";
            }

            if (this.modeStatus == ModeStatus.FILE)
            {
                if (keyword.Extension != null && keyword.Extension != "")
                {
                    str += "\"" + keyword.Extension + "\"" + " ";
                }
            }

            if (this.modeStatus == ModeStatus.MP3)
            {
                if (keyword.Artist != null && keyword.Artist != "")
                {
                    str += keyword.Artist + " ";
                }
            }

            if (keyword.Name != "")
            {
                str += keyword.Name;
            }
            this.cmbKeyword.Text = str;
        }
예제 #2
0
        /// <summary>
        /// 拖放完成
        /// </summary>
        private void FileFinder_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Effect == DragDropEffects.Link)
            {
                string        str     = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
                KeywordStruct keyword = Deal.GetKeyword(this.cmbKeyword.Text.Trim());

                if (Directory.Exists(str))
                {
                    //文件夹
                    keyword.Directory = str;
                }
                else
                {
                    //文件
                    try
                    {
                        FileInfo fileInfo = new FileInfo(str);
                        keyword.Extension = fileInfo.Extension;
                    }
                    catch
                    { }
                }

                //如果是MP3文件可以也设置音乐家(暂时不做)

                this.SetKeywordText(keyword);
            }
        }
예제 #3
0
 private void 作为搜索后缀ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.modeStatus == ModeStatus.FILE)
     {
         KeywordStruct keyword = Deal.GetKeyword(this.cmbKeyword.Text);
         string        str     = "";
         int           i;
         if (this.lvwFiles.SelectedItems[0].ImageIndex != 0)
         {
             str = this.lvwFiles.SelectedItems[0].Text;
             i   = str.LastIndexOf('.');
             keyword.Extension = str.Substring(i, str.Length - i);
             //写回cmbKeyword
             this.SetKeywordText(keyword);
         }
     }
 }
예제 #4
0
    // Adds new keywords to the _keywords HashSet by supplying a txt file
    public void AddKeywords(TextAsset txt)
    {
        //Init a KeywordStruct we can fill with data
        KeywordStruct keyword = new KeywordStruct();

        string[] kws = txt.text.Split('\n');            //Create a string array of lines

        //Extract a color from the first line in the txt file
        keyword.Color = kws[0].Trim();

        //Loop through the keywords and add them (skip the color)
        for (int i = 1; i < kws.Length; i++)
        {
            keyword.Word = kws[i].Trim();
            _keywords.Add(keyword);
        }
    }
예제 #5
0
        private void 作为搜索路径ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            KeywordStruct keyword = Deal.GetKeyword(this.cmbKeyword.Text);
            string        str     = "";

            if (this.lvStatus == ListViewStatus.File)
            {
                if (this.lvwFiles.SelectedItems[0].ImageIndex == 0)
                {
                    //文件夹的imageindex为0。
                    str = this.lvwFiles.SelectedItems[0].SubItems[1].Text
                          + this.lvwFiles.SelectedItems[0].Text;
                    keyword.Directory = str;
                    //写回cmbKeyword
                    this.SetKeywordText(keyword);
                }
                else
                {
                    //如果是文件,则将文件所在的目录作为搜索目录
                    str = this.lvwFiles.SelectedItems[0].SubItems[1].Text;
                    keyword.Directory = str;
                    //写回cmbKeyword
                    this.SetKeywordText(keyword);
                }
            }
            else if (this.lvStatus == ListViewStatus.MP3)
            {
                if (this.lvwFiles.SelectedItems[0].ImageIndex != 0)
                {
                    //如果是文件,则将文件所在的目录作为搜索目录
                    str = this.lvwFiles.SelectedItems[0].SubItems[8].Text;
                    keyword.Directory = str;
                    //写回cmbKeyword
                    this.SetKeywordText(keyword);
                }
            }
        }
예제 #6
0
    // Adds new keywords to the _keywords HashSet by supplying a txt file
    public void AddKeywords(TextAsset txt)
    {
        //Init a KeywordStruct we can fill with data
        KeywordStruct keyword = new KeywordStruct();

        string[] kws = txt.text.Split( '\n' );	//Create a string array of lines

        //Extract a color from the first line in the txt file
        keyword.Color = kws[0].Trim();

        //Loop through the keywords and add them (skip the color)
        for (int i = 1; i < kws.Length; i++) {
            keyword.Word = kws[i].Trim();
            _keywords.Add (keyword);
        }
    }